Changeset 225820 in webkit
- Timestamp:
- Dec 12, 2017 4:31:15 PM (6 years ago)
- Location:
- trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r225814 r225820 1 2017-12-12 Brian Burg <bburg@apple.com> 2 3 Web Inspector: support async setup() and async teardown() in AsyncTestSuite 4 https://bugs.webkit.org/show_bug.cgi?id=180626 5 6 Reviewed by Timothy Hatcher. 7 8 Update tests to cover async setup() and async teardown() in the case 9 of success, runtime failure, and explicit failure. 10 11 * inspector/unit-tests/async-test-suite-expected.txt: 12 * inspector/unit-tests/async-test-suite.html: 13 1 14 2017-12-12 Brian Burg <bburg@apple.com> 2 15 -
trunk/LayoutTests/inspector/unit-tests/async-test-suite-expected.txt
r223809 r225820 106 106 PASS: Rejected value should be a runtime exception. 107 107 108 == Running test suite: AsyncTestSuite.AsyncSetupAndAsyncTeardown 109 -- Running test setup. 110 -- Running test case: TestWithSetupAndTeardown 111 PASS: Test should see side effects of running setup() action. 112 -- Running test teardown. 113 PASS: Teardown should see side effects of running setup() action. 114 115 -- Running test case: TestRunningAfterTeardown 116 PASS: Test should see side effects of previous test's teardown() action. 117 PASS: Promise from asyncSetupAndAsyncTeardownTestSuite.runTestCases() should resolve. 118 119 == Running test suite: AsyncTestSuite.AsyncSetupExplicitFailure 120 -- Running test case: AsyncFunctionFailure 121 !! EXCEPTION: AsyncFunctionFailure Exception Message 122 Stack Trace: (suppressed) 123 PASS: Promise from asyncSetupExplicitFailureTestSuite.runTestCases() should reject. 124 PASS: Promise did evaluate the async setup function. 125 PASS: Rejected value should be thrown exception. 126 127 == Running test suite: AsyncTestSuite.AsyncSetupRuntimeFailure 128 -- Running test setup. 129 !! EXCEPTION: undefined is not an object (evaluating '({}).x.x') 130 Stack Trace: (suppressed) 131 PASS: Promise from asyncSetupRuntimeFailureTestSuite.runTestCases() should reject. 132 PASS: Promise did evaluate the async setup function. 133 PASS: Rejected value should be a runtime exception. 134 135 == Running test suite: AsyncTestSuite.AsyncTeardownExplicitFailure 136 -- Running test case: AsyncFunctionFailure 137 -- Running test teardown. 138 !! EXCEPTION: AsyncFunctionFailure Exception Message 139 Stack Trace: (suppressed) 140 PASS: Promise from asyncTeardownExplicitFailureTestSuite.runTestCases() should reject. 141 PASS: Promise did evaluate the async teardown function. 142 PASS: Rejected value should be thrown exception. 143 144 == Running test suite: AsyncTestSuite.AsyncTeardownRuntimeFailure 145 -- Running test case: AsyncFunctionFailure 146 -- Running test teardown. 147 !! EXCEPTION: undefined is not an object (evaluating '({}).x.x') 148 Stack Trace: (suppressed) 149 PASS: Promise from asyncTeardownRuntimeFailureTestSuite.runTestCases() should reject. 150 PASS: Promise did evaluate the async teardown function. 151 PASS: Rejected value should be a runtime exception. 152 -
trunk/LayoutTests/inspector/unit-tests/async-test-suite.html
r223809 r225820 291 291 teardown: (resolve, reject) => { 292 292 ProtocolTest.assert(false, "Teardown action should not execute if its setup action threw an exception."); 293 reject(); 293 reject(); 294 294 } 295 295 }); … … 390 390 }); 391 391 392 392 // Async test functions. 393 393 let asyncFunctionSuccessTestSuiteDidEvaluate = false; 394 394 let asyncFunctionSuccessTestSuite = ProtocolTest.createAsyncSuite("AsyncTestSuite.AsyncFunctionSuccess"); … … 414 414 }); 415 415 416 417 416 let asyncFunctionExplicitFailureTestSuiteDidEvaluate = false; 418 417 let asyncFunctionExplicitFailureTestSuite = ProtocolTest.createAsyncSuite("AsyncTestSuite.AsyncFunctionExplicitFailure"); … … 438 437 }); 439 438 440 441 439 let asyncFunctionRuntimeFailureTestSuiteDidEvaluate = false; 442 440 let asyncFunctionRuntimeFailureTestSuite = ProtocolTest.createAsyncSuite("AsyncTestSuite.AsyncFunctionRuntimeFailure"); … … 462 460 }); 463 461 462 // Async setup() and teardown() success test cases. 463 const asyncSetupAndTeardownSymbol = Symbol("async-suite-async-setup-and-teardown-token"); 464 window[asyncSetupAndTeardownSymbol] = 0; 465 466 let asyncSetupAndAsyncTeardownTestSuite = ProtocolTest.createAsyncSuite("AsyncTestSuite.AsyncSetupAndAsyncTeardown"); 467 asyncSetupAndAsyncTeardownTestSuite.addTestCase({ 468 name: "TestWithSetupAndTeardown", 469 description: "Check execution order for setup and teardown actions.", 470 async setup() { 471 window[asyncSetupAndTeardownSymbol] = 1; 472 }, 473 async test() { 474 ProtocolTest.expectThat(window[asyncSetupAndTeardownSymbol] === 1, "Test should see side effects of running setup() action."); 475 window[asyncSetupAndTeardownSymbol] = 2; 476 }, 477 async teardown() { 478 ProtocolTest.expectThat(window[asyncSetupAndTeardownSymbol] === 2, "Teardown should see side effects of running setup() action."); 479 window[asyncSetupAndTeardownSymbol] = 3; 480 } 481 }); 482 asyncSetupAndAsyncTeardownTestSuite.addTestCase({ 483 name: "TestRunningAfterTeardown", 484 description: "Check execution order for test after a teardown action.", 485 test(resolve, reject) { 486 ProtocolTest.expectThat(window[asyncSetupAndTeardownSymbol] === 3, "Test should see side effects of previous test's teardown() action."); 487 resolve(); 488 }, 489 }); 490 491 result = result.then(() => { 492 return asyncSetupAndAsyncTeardownTestSuite.runTestCases(); 493 }).then(function resolved() { 494 ProtocolTest.pass("Promise from asyncSetupAndAsyncTeardownTestSuite.runTestCases() should resolve."); 495 return Promise.resolve(); // Continue this test. 496 }, function rejected(e) { 497 ProtocolTest.fail("Promise from asyncSetupAndAsyncTeardownTestSuite.runTestCases() should resolve."); 498 return Promise.resolve(); // Continue this test. 499 }); 500 501 // Async setup() failure test cases. 502 let asyncSetupExplicitFailureTestSuiteDidEvaluate = false; 503 let asyncSetupExplicitFailureTestSuite = ProtocolTest.createAsyncSuite("AsyncTestSuite.AsyncSetupExplicitFailure"); 504 asyncSetupExplicitFailureTestSuite.addTestCase({ 505 name: "AsyncFunctionFailure", 506 description: "Check that an async suite with async test functions that throws will reject", 507 async test() { 508 asyncSetupExplicitFailureTestSuiteDidEvaluate = true; 509 throw "AsyncFunctionFailure Exception Message"; 510 } 511 }); 512 513 result = result.then(() => { 514 return asyncSetupExplicitFailureTestSuite.runTestCases(); 515 }).then(function resolve() { 516 ProtocolTest.fail("Promise from asyncSetupExplicitFailureTestSuite.runTestCases() should reject."); 517 return Promise.resolve(); // Continue this test. 518 }, function rejected(e) { 519 ProtocolTest.pass("Promise from asyncSetupExplicitFailureTestSuite.runTestCases() should reject."); 520 ProtocolTest.expectThat(asyncSetupExplicitFailureTestSuiteDidEvaluate, "Promise did evaluate the async setup function."); 521 ProtocolTest.expectEqual(e, "AsyncFunctionFailure Exception Message", "Rejected value should be thrown exception."); 522 return Promise.resolve(); // Continue this test. 523 }); 524 525 let asyncSetupRuntimeFailureTestSuiteDidEvaluate = false; 526 let asyncSetupRuntimeFailureTestSuite = ProtocolTest.createAsyncSuite("AsyncTestSuite.AsyncSetupRuntimeFailure"); 527 asyncSetupRuntimeFailureTestSuite.addTestCase({ 528 name: "AsyncFunctionFailure", 529 description: "Check that an async suite with an async setup function that throws with a runtime error will reject", 530 async setup() { 531 asyncSetupRuntimeFailureTestSuiteDidEvaluate = true; 532 ({}).x.x.x; 533 }, 534 async test() { return true; }, 535 }); 536 537 result = result.then(() => { 538 return asyncSetupRuntimeFailureTestSuite.runTestCases(); 539 }).then(function resolve() { 540 ProtocolTest.fail("Promise from asyncSetupRuntimeFailureTestSuite.runTestCases() should reject."); 541 return Promise.resolve(); // Continue this test. 542 }, function rejected(e) { 543 ProtocolTest.pass("Promise from asyncSetupRuntimeFailureTestSuite.runTestCases() should reject."); 544 ProtocolTest.expectThat(asyncSetupRuntimeFailureTestSuiteDidEvaluate, "Promise did evaluate the async setup function."); 545 ProtocolTest.expectThat(e instanceof TypeError, "Rejected value should be a runtime exception."); 546 return Promise.resolve(); // Continue this test. 547 }); 548 549 // Async teardown() failure test cases. 550 let asyncTeardownExplicitFailureTestSuiteDidEvaluate = false; 551 let asyncTeardownExplicitFailureTestSuite = ProtocolTest.createAsyncSuite("AsyncTestSuite.AsyncTeardownExplicitFailure"); 552 asyncTeardownExplicitFailureTestSuite.addTestCase({ 553 name: "AsyncFunctionFailure", 554 description: "Check that an async suite with async test functions that throws will reject", 555 async test() { return true; }, 556 async teardown() { 557 asyncTeardownExplicitFailureTestSuiteDidEvaluate = true; 558 throw "AsyncFunctionFailure Exception Message"; 559 }, 560 }); 561 562 result = result.then(() => { 563 return asyncTeardownExplicitFailureTestSuite.runTestCases(); 564 }).then(function resolve() { 565 ProtocolTest.fail("Promise from asyncTeardownExplicitFailureTestSuite.runTestCases() should reject."); 566 return Promise.resolve(); // Continue this test. 567 }, function rejected(e) { 568 ProtocolTest.pass("Promise from asyncTeardownExplicitFailureTestSuite.runTestCases() should reject."); 569 ProtocolTest.expectThat(asyncTeardownExplicitFailureTestSuiteDidEvaluate, "Promise did evaluate the async teardown function."); 570 ProtocolTest.expectEqual(e, "AsyncFunctionFailure Exception Message", "Rejected value should be thrown exception."); 571 return Promise.resolve(); // Continue this test. 572 }); 573 574 let asyncTeardownRuntimeFailureTestSuiteDidEvaluate = false; 575 let asyncTeardownRuntimeFailureTestSuite = ProtocolTest.createAsyncSuite("AsyncTestSuite.AsyncTeardownRuntimeFailure"); 576 asyncTeardownRuntimeFailureTestSuite.addTestCase({ 577 name: "AsyncFunctionFailure", 578 description: "Check that an async suite with an async teardown function that throws with a runtime error will reject", 579 async test() { return true; }, 580 async teardown() { 581 asyncTeardownRuntimeFailureTestSuiteDidEvaluate = true; 582 ({}).x.x.x; 583 }, 584 }); 585 586 result = result.then(() => { 587 return asyncTeardownRuntimeFailureTestSuite.runTestCases(); 588 }).then(function resolve() { 589 ProtocolTest.fail("Promise from asyncTeardownRuntimeFailureTestSuite.runTestCases() should reject."); 590 return Promise.resolve(); // Continue this test. 591 }, function rejected(e) { 592 ProtocolTest.pass("Promise from asyncTeardownRuntimeFailureTestSuite.runTestCases() should reject."); 593 ProtocolTest.expectThat(asyncTeardownRuntimeFailureTestSuiteDidEvaluate, "Promise did evaluate the async teardown function."); 594 ProtocolTest.expectThat(e instanceof TypeError, "Rejected value should be a runtime exception."); 595 return Promise.resolve(); // Continue this test. 596 }); 597 464 598 // This will finish the test whether the chain was resolved or rejected. 465 599 result = result.then(() => { ProtocolTest.completeTest(); }); -
trunk/Source/WebInspectorUI/ChangeLog
r225814 r225820 1 2017-12-12 Brian Burg <bburg@apple.com> 2 3 Web Inspector: support async setup() and async teardown() in AsyncTestSuite 4 https://bugs.webkit.org/show_bug.cgi?id=180626 5 6 Reviewed by Timothy Hatcher. 7 8 This can make some code simpler by removing Promise-related boilerplate. I'm splitting 9 this patch from the new use-site in the interest of making it easier to review. 10 11 * UserInterface/Test/TestSuite.js: 12 (AsyncTestSuite.prototype.runTestCases): 13 (AsyncTestSuite): 14 1 15 2017-12-12 Brian Burg <bburg@apple.com> 2 16 -
trunk/Source/WebInspectorUI/UserInterface/Test/TestSuite.js
r225814 r225820 140 140 chain = chain.then(() => { 141 141 this._harness.log("-- Running test setup."); 142 if (testcase.setup[Symbol.toStringTag] === "AsyncFunction") 143 return testcase.setup(); 142 144 return new Promise(testcase.setup); 143 145 }); … … 159 161 chain = chain.then(() => { 160 162 this._harness.log("-- Running test teardown."); 163 if (testcase.teardown[Symbol.toStringTag] === "AsyncFunction") 164 return testcase.teardown(); 161 165 return new Promise(testcase.teardown); 162 166 });
Note: See TracChangeset
for help on using the changeset viewer.