blob: 5a03db7005b57592b850bde93f8592ef34e5c5a2 [file] [log] [blame]
<!DOCTYPE html>
<html>
<head>
<script src="../../http/tests/inspector/resources/protocol-test.js"></script>
<script>
function test()
{
ProtocolTest.suppressStackTraces = true;
ProtocolTest.expectException(() => {
new AsyncTestSuite(this);
});
ProtocolTest.expectException(() => {
new AsyncTestSuite(this, {});
});
ProtocolTest.expectException(() => {
new AsyncTestSuite(this, " ");
});
ProtocolTest.expectException(() => {
new AsyncTestSuite("something", {});
});
let badArgsSuite = ProtocolTest.createAsyncSuite("dummy");
ProtocolTest.expectException(() => {
badArgsSuite.addTestCase();
});
ProtocolTest.expectException(() => {
badArgsSuite.addTestCase("string");
});
ProtocolTest.expectException(() => {
badArgsSuite.addTestCase({
name: {},
test() {
},
});
});
ProtocolTest.expectException(() => {
badArgsSuite.addTestCase({
name: " ",
test() {
},
});
});
ProtocolTest.expectException(() => {
badArgsSuite.addTestCase({
name: "foo",
test: null,
});
});
ProtocolTest.expectException(() => {
badArgsSuite.addTestCase({
name: "foo",
test() {
},
setup: "astd",
});
});
ProtocolTest.expectException(() => {
badArgsSuite.addTestCase({
name: "foo",
test() {
},
setup: 123,
});
});
ProtocolTest.expectException(() => {
badArgsSuite.addTestCase({
name: "foo",
test() {
},
setup: {},
});
});
ProtocolTest.expectException(() => {
badArgsSuite.addTestCase({
name: "foo",
test() {
},
teardown: "astd",
});
});
ProtocolTest.expectException(() => {
badArgsSuite.addTestCase({
name: "foo",
test() {
},
teardown: 123,
});
});
ProtocolTest.expectException(() => {
badArgsSuite.addTestCase({
name: "foo",
test() {
},
teardown: {},
});
});
let runEmptySuite = ProtocolTest.createAsyncSuite("AsyncTestSuite.RunEmptySuite");
try {
runEmptySuite.runTestCases();
ProtocolTest.fail("should not be able to run empty test suite.");
} catch (e) {
ProtocolTest.pass("should not be able to run empty test suite.");
}
let runTwiceSuiteRunCount = 0;
let runTwiceSuite = ProtocolTest.createAsyncSuite("AsyncTestSuite.RunTwiceSuite");
runTwiceSuite.addTestCase({
name: "DummyTest0",
test(resolve, reject) {
ProtocolTest.expectEqual(++runTwiceSuiteRunCount, 1, "DummyTest0 should only run once.");
resolve();
},
});
let result = runTwiceSuite.runTestCases();
ProtocolTest.expectException(() => {
// Test cases won't run in this event loop; this call should still throw.
// Later tests are chained to this suite to avoid nondeterminism.
runTwiceSuite.runTestCases();
});
function checkResult(suite, expectedCounts) {
result = result.then(() => suite.runTestCases());
let message = `Promise from ${suite.name}.runTestCases() should resolve even if a test case fails.`;
result = result.then(function resolved() {
ProtocolTest.log("");
ProtocolTest.pass(message);
ProtocolTest.expectEqual(expectedCounts.runCount, suite.runCount, `${suite.name} should have executed ${expectedCounts.runCount} tests.`);
ProtocolTest.expectEqual(expectedCounts.passCount, suite.passCount, `${suite.name} should have passed ${expectedCounts.passCount} tests.`);
ProtocolTest.expectEqual(expectedCounts.failCount, suite.failCount, `${suite.name} should have failed ${expectedCounts.failCount} tests.`);
ProtocolTest.expectEqual(expectedCounts.skipCount, suite.skipCount, `${suite.name} should have skipped ${expectedCounts.skipCount} tests.`);
}, function rejected(e) {
ProtocolTest.log("");
ProtocolTest.fail(message);
ProtocolTest.log(e.message);
});
}
// Promise test functions.
let promiseFunctionSuccessSuite = ProtocolTest.createAsyncSuite("AsyncTestSuite.PromiseFunctionSuccess");
promiseFunctionSuccessSuite.addTestCase({
name: "PromiseFunctionSuccess",
test(resolve, reject) {
resolve();
},
});
checkResult(promiseFunctionSuccessSuite, {
runCount: 1,
passCount: 1,
failCount: 0,
skipCount: 0,
});
let promiseFunctionExceptionSuite = ProtocolTest.createAsyncSuite("PromiseTestSuite.PromiseFunctionException");
promiseFunctionExceptionSuite.addTestCase({
name: "PromiseFunctionException",
test(resolve, reject) {
ProtocolTest.log("Throwing...");
throw "PromiseFunctionException throw";
},
});
checkResult(promiseFunctionExceptionSuite, {
runCount: 1,
passCount: 0,
failCount: 1,
skipCount: 0,
});
let promiseFunctionFailureSuite = ProtocolTest.createAsyncSuite("PromiseTestSuite.PromiseFunctionFailure");
promiseFunctionFailureSuite.addTestCase({
name: "PromiseFunctionFailure",
test(resolve, reject) {
ProtocolTest.log("Rejecting...");
reject("PromiseFunctionFailure reject");
},
});
checkResult(promiseFunctionFailureSuite, {
runCount: 1,
passCount: 0,
failCount: 1,
skipCount: 0,
});
let promiseSequentialExecutionPhase = 0;
let promiseSequentialExecutionSuite = ProtocolTest.createAsyncSuite("AsyncTestSuite.PromiseSequentialExecution");
promiseSequentialExecutionSuite.addTestCase({
name: "1 (Pass)",
test(resolve, reject) {
ProtocolTest.assert(promiseSequentialExecutionPhase === 0);
promiseSequentialExecutionPhase = 1;
resolve();
},
});
promiseSequentialExecutionSuite.addTestCase({
name: "2 (Pass)",
test(resolve, reject) {
ProtocolTest.assert(promiseSequentialExecutionPhase === 1);
promiseSequentialExecutionPhase = 2;
resolve();
},
});
promiseSequentialExecutionSuite.addTestCase({
name: "3 (Pass)",
test(resolve, reject) {
ProtocolTest.assert(promiseSequentialExecutionPhase === 2);
promiseSequentialExecutionPhase = 3;
resolve();
},
});
promiseSequentialExecutionSuite.addTestCase({
name: "4 (Pass)",
test(resolve, reject) {
ProtocolTest.assert(promiseSequentialExecutionPhase === 3);
promiseSequentialExecutionPhase = 4;
resolve();
},
});
checkResult(promiseSequentialExecutionSuite, {
runCount: 4,
passCount: 4,
failCount: 0,
skipCount: 0,
});
result = result.then(() => {
ProtocolTest.assert(promiseSequentialExecutionPhase === 4);
});
let promiseContinueOnFailureSuite = ProtocolTest.createAsyncSuite("AsyncTestSuite.PromiseContinueOnFailure");
promiseContinueOnFailureSuite.addTestCase({
name: "1 (Pass)",
test(resolve, reject) {
resolve();
},
});
promiseContinueOnFailureSuite.addTestCase({
name: "2 (Fail)",
test(resolve, reject) {
ProtocolTest.log("Throwing...");
throw {x: "PromiseContinueOnFailure throw"};
},
});
promiseContinueOnFailureSuite.addTestCase({
name: "3 (Pass)",
test(resolve, reject) {
resolve();
},
});
promiseContinueOnFailureSuite.addTestCase({
name: "4 (Fail)",
test(resolve, reject) {
ProtocolTest.log("Rejecting...");
reject({x: "PromiseContinueOnFailure reject"});
},
});
checkResult(promiseContinueOnFailureSuite, {
runCount: 4,
passCount: 2,
failCount: 2,
skipCount: 0,
});
let promiseSetupAndTeardownPhase = 0;
let promiseSetupAndTeardownSuite = ProtocolTest.createAsyncSuite("AsyncTestSuite.PromiseSetupAndTeardown");
promiseSetupAndTeardownSuite.addTestCase({
name: "TestWithSetupAndTeardown",
setup(resolve, reject) {
ProtocolTest.assert(promiseSetupAndTeardownPhase === 0);
promiseSetupAndTeardownPhase = 1;
resolve();
},
test(resolve, reject) {
ProtocolTest.assert(promiseSetupAndTeardownPhase === 1);
promiseSetupAndTeardownPhase = 2;
resolve();
},
teardown(resolve, reject) {
ProtocolTest.assert(promiseSetupAndTeardownPhase === 2);
promiseSetupAndTeardownPhase = 3;
resolve();
},
});
promiseSetupAndTeardownSuite.addTestCase({
name: "TestRunningAfterTeardown",
test(resolve, reject) {
ProtocolTest.assert(promiseSetupAndTeardownPhase === 3);
resolve();
},
});
checkResult(promiseSetupAndTeardownSuite, {
runCount: 2,
passCount: 2,
failCount: 0,
skipCount: 0,
});
let promiseSetupExceptionSuite = ProtocolTest.createAsyncSuite("AsyncTestSuite.PromiseSetupException");
promiseSetupExceptionSuite.addTestCase({
name: "TestWithExceptionDuringSetup",
setup(resolve, reject) {
ProtocolTest.log("Throwing...");
throw "PromiseSetupException throw";
},
test(resolve, reject) {
ProtocolTest.fail("Test should not execute if its setup action threw an exception.");
reject();
},
teardown(resolve, reject) {
ProtocolTest.fail("Teardown action should not execute if its setup action threw an exception.");
reject();
},
});
promiseSetupExceptionSuite.addTestCase({
name: "TestAfterSetupException",
setup(resolve, reject) {
ProtocolTest.pass("Setup action should still execute if previous test's setup action threw an exception.");
resolve();
},
test(resolve, reject) {
ProtocolTest.pass("Test should still execute if previous test's setup action threw an exception.");
resolve();
},
teardown(resolve, reject) {
ProtocolTest.pass("Teardown action should still execute if previous test's setup action threw an exception.");
resolve();
},
});
checkResult(promiseSetupExceptionSuite, {
runCount: 1,
passCount: 1,
failCount: 1,
skipCount: 1,
});
let promiseSetupFailureSuite = ProtocolTest.createAsyncSuite("AsyncTestSuite.PromiseSetupFailure");
promiseSetupFailureSuite.addTestCase({
name: "TestWithFailureDuringSetup",
setup(resolve, reject) {
ProtocolTest.log("Rejecting...");
reject("PromiseSetupFailure reject");
},
test(resolve, reject) {
ProtocolTest.fail("Test should not execute if its setup action failed.");
reject();
},
teardown(resolve, reject) {
ProtocolTest.fail("Teardown action should not execute if its setup action failed.");
reject();
},
});
promiseSetupFailureSuite.addTestCase({
name: "TestAfterSetupException",
setup(resolve, reject) {
ProtocolTest.pass("Setup action should still execute if previous test's setup action failed.");
resolve();
},
test(resolve, reject) {
ProtocolTest.pass("Test should still execute if previous test's setup action failed.");
resolve();
},
teardown(resolve, reject) {
ProtocolTest.pass("Teardown action should still execute if previous test's setup action failed.");
resolve();
},
});
checkResult(promiseSetupFailureSuite, {
runCount: 1,
passCount: 1,
failCount: 1,
skipCount: 1,
});
let promiseTeardownExceptionSuite = ProtocolTest.createAsyncSuite("AsyncTestSuite.PromiseTeardownException");
promiseTeardownExceptionSuite.addTestCase({
name: "TestWithExceptionDuringTeardown",
test(resolve, reject) {
resolve();
},
teardown(resolve, reject) {
ProtocolTest.log("Throwing...");
throw "PromiseTeardownException throw";
},
});
promiseTeardownExceptionSuite.addTestCase({
name: "TestAfterTeardownException",
setup(resolve, reject) {
ProtocolTest.pass("Setup action should still execute if previous test's teardown action threw an exception.");
resolve();
},
test(resolve, reject) {
ProtocolTest.pass("Test should still execute if previous test's teardown action threw an exception.");
resolve();
},
teardown(resolve, reject) {
ProtocolTest.pass("Teardown action should still execute if previous test's teardown action threw an exception.");
resolve();
},
});
checkResult(promiseTeardownExceptionSuite, {
runCount: 2,
passCount: 1,
failCount: 1,
skipCount: 0,
});
let promiseTeardownFailureSuite = ProtocolTest.createAsyncSuite("AsyncTestSuite.PromiseTeardownFailure");
promiseTeardownFailureSuite.addTestCase({
name: "TestWithExceptionDuringTeardown",
test(resolve, reject) {
resolve();
},
teardown(resolve, reject) {
ProtocolTest.log("Rejecting...");
reject("PromiseTeardownFailure reject");
},
});
promiseTeardownFailureSuite.addTestCase({
name: "TestAfterTeardownException",
setup(resolve, reject) {
ProtocolTest.pass("Setup action should still execute if previous test's teardown action failed.");
resolve();
},
test(resolve, reject) {
ProtocolTest.pass("Test should still execute if previous test's teardown action failed.");
resolve();
},
teardown(resolve, reject) {
ProtocolTest.pass("Teardown action should still execute if previous test's teardown action failed.");
resolve();
},
});
checkResult(promiseTeardownFailureSuite, {
runCount: 2,
passCount: 1,
failCount: 1,
skipCount: 0,
});
let promiseTimeoutSuite = ProtocolTest.createAsyncSuite("AsyncTestSuite.PromiseTimeout");
promiseTimeoutSuite.addTestCase({
name: "PromiseTestWithTimeout",
test(resolve, reject) {
ProtocolTest.log("Timeout...");
setTimeout(() => {
resolve();
}, 50);
},
timeout: 5,
});
promiseTimeoutSuite.addTestCase({
name: "PromiseTestAfterTimeout",
setup(resolve, reject) {
ProtocolTest.pass("Setup action should still execute if previous test timed out.");
resolve();
},
test(resolve, reject) {
ProtocolTest.pass("Test should still execute if previous test timed out.");
resolve();
},
teardown(resolve, reject) {
ProtocolTest.pass("Teardown action should still execute if previous test timed out.");
resolve();
},
});
checkResult(promiseTimeoutSuite, {
runCount: 2,
passCount: 1,
failCount: 1,
skipCount: 0,
});
// Async test functions.
let asyncFunctionSuccessSuite = ProtocolTest.createAsyncSuite("AsyncTestSuite.AsyncFunctionSuccess");
asyncFunctionSuccessSuite.addTestCase({
name: "AsyncFunctionSuccess",
async test() {
},
});
checkResult(asyncFunctionSuccessSuite, {
runCount: 1,
passCount: 1,
failCount: 0,
skipCount: 0,
});
let asyncFunctionExplicitExceptionSuite = ProtocolTest.createAsyncSuite("AsyncTestSuite.AsyncFunctionExplicitException");
asyncFunctionExplicitExceptionSuite.addTestCase({
name: "AsyncFunctionExplicitException",
async test() {
ProtocolTest.log("Throwing...");
throw "AsyncFunctionExplicitException throw";
},
});
checkResult(asyncFunctionExplicitExceptionSuite, {
runCount: 1,
passCount: 0,
failCount: 1,
skipCount: 0,
});
let asyncFunctionRuntimeExceptionSuite = ProtocolTest.createAsyncSuite("AsyncTestSuite.AsyncFunctionRuntimeException");
asyncFunctionRuntimeExceptionSuite.addTestCase({
name: "AsyncFunctionRuntimeException",
async test() {
ProtocolTest.log("Throwing...");
({}).x.x.x;
},
});
checkResult(asyncFunctionRuntimeExceptionSuite, {
runCount: 1,
passCount: 0,
failCount: 1,
skipCount: 0,
});
let asyncFunctionFailureSuite = ProtocolTest.createAsyncSuite("AsyncTestSuite.AsyncFunctionFailure");
asyncFunctionFailureSuite.addTestCase({
name: "AsyncFunctionException",
async test() {
ProtocolTest.log("Rejecting...");
return Promise.reject("AsyncFunctionFailure reject");
},
});
checkResult(asyncFunctionFailureSuite, {
runCount: 1,
passCount: 0,
failCount: 1,
skipCount: 0,
});
let asyncSequentialExecutionPhase = 0;
let asyncSequentialExecutionSuite = ProtocolTest.createAsyncSuite("AsyncTestSuite.AsyncSequentialExecution");
asyncSequentialExecutionSuite.addTestCase({
name: "1 (Pass)",
async test() {
ProtocolTest.assert(asyncSequentialExecutionPhase === 0);
asyncSequentialExecutionPhase = 1;
},
});
asyncSequentialExecutionSuite.addTestCase({
name: "2 (Pass)",
async test() {
ProtocolTest.assert(asyncSequentialExecutionPhase === 1);
asyncSequentialExecutionPhase = 2;
},
});
asyncSequentialExecutionSuite.addTestCase({
name: "3 (Pass)",
async test() {
ProtocolTest.assert(asyncSequentialExecutionPhase === 2);
asyncSequentialExecutionPhase = 3;
},
});
asyncSequentialExecutionSuite.addTestCase({
name: "4 (Pass)",
async test() {
ProtocolTest.assert(asyncSequentialExecutionPhase === 3);
asyncSequentialExecutionPhase = 4;
},
});
checkResult(asyncSequentialExecutionSuite, {
runCount: 4,
passCount: 4,
failCount: 0,
skipCount: 0,
});
result = result.then(() => {
ProtocolTest.assert(asyncSequentialExecutionPhase === 4);
});
let asyncContinueOnFailureSuite = ProtocolTest.createAsyncSuite("AsyncTestSuite.AsyncContinueOnFailure");
asyncContinueOnFailureSuite.addTestCase({
name: "1 (Pass)",
async test() {
},
});
asyncContinueOnFailureSuite.addTestCase({
name: "2 (Fail)",
async test() {
ProtocolTest.log("Throwing...");
throw {x: "AsyncContinueOnFailure throw"};
},
});
asyncContinueOnFailureSuite.addTestCase({
name: "3 (Pass)",
async test() {
},
});
asyncContinueOnFailureSuite.addTestCase({
name: "4 (Fail)",
async test() {
ProtocolTest.log("Throwing...");
({}).x.x.x;
},
});
asyncContinueOnFailureSuite.addTestCase({
name: "5 (Pass)",
async test() {
},
});
asyncContinueOnFailureSuite.addTestCase({
name: "6 (Fail)",
async test() {
ProtocolTest.log("Rejecting...");
return Promise.reject("AsyncContinueOnFailure reject");
},
});
checkResult(asyncContinueOnFailureSuite, {
runCount: 6,
passCount: 3,
failCount: 3,
skipCount: 0,
});
let asyncSetupAndTeardownPhase = 0;
let asyncSetupAndTeardownSuite = ProtocolTest.createAsyncSuite("AsyncTestSuite.AsyncSetupAndTeardown");
asyncSetupAndTeardownSuite.addTestCase({
name: "AsyncTestWithSetupAndTeardown",
async setup() {
ProtocolTest.assert(asyncSetupAndTeardownPhase === 0);
asyncSetupAndTeardownPhase = 1;
},
async test() {
ProtocolTest.assert(asyncSetupAndTeardownPhase === 1);
asyncSetupAndTeardownPhase = 2;
},
async teardown() {
ProtocolTest.assert(asyncSetupAndTeardownPhase === 2);
asyncSetupAndTeardownPhase = 3;
},
});
asyncSetupAndTeardownSuite.addTestCase({
name: "AsyncTestRunningAfterTeardown",
async test() {
ProtocolTest.assert(asyncSetupAndTeardownPhase === 3);
},
});
checkResult(asyncSetupAndTeardownSuite, {
runCount: 2,
passCount: 2,
failCount: 0,
skipCount: 0,
});
let asyncSetupExplicitExceptionSuite = ProtocolTest.createAsyncSuite("AsyncTestSuite.AsyncSetupExplicitException");
asyncSetupExplicitExceptionSuite.addTestCase({
name: "AsyncTestWithExplicitExceptionDuringSetup",
async setup() {
ProtocolTest.log("Throwing...");
throw "AsyncSetupExplicitException throw";
},
async test() {
ProtocolTest.fail("Test should not execute if its setup action threw an exception.");
},
async teardown() {
ProtocolTest.fail("Teardown action should not execute if its setup action threw an exception.");
},
});
asyncSetupExplicitExceptionSuite.addTestCase({
name: "AsyncTestAfterSetupExplicitException",
async setup() {
ProtocolTest.pass("Setup action should still execute if previous test's setup action threw an exception.");
},
async test() {
ProtocolTest.pass("Test should still execute if previous test's setup action threw an exception.");
},
async teardown() {
ProtocolTest.pass("Teardown action should still execute if previous test's setup action threw an exception.");
},
});
checkResult(asyncSetupExplicitExceptionSuite, {
runCount: 1,
passCount: 1,
failCount: 1,
skipCount: 1,
});
let asyncSetupRuntimeExceptionSuite = ProtocolTest.createAsyncSuite("AsyncTestSuite.AsyncSetupRuntimeException");
asyncSetupRuntimeExceptionSuite.addTestCase({
name: "AsyncTestWithRuntimeExceptionDuringSetup",
async setup() {
ProtocolTest.log("Throwing...");
({}).x.x.x;
},
async test() {
ProtocolTest.fail("Test should not execute if its setup action threw an exception.");
},
async teardown() {
ProtocolTest.fail("Teardown action should not execute if its setup action threw an exception.");
},
});
asyncSetupRuntimeExceptionSuite.addTestCase({
name: "AsyncTestAfterSetupRuntimeException",
async setup() {
ProtocolTest.pass("Setup action should still execute if previous test's setup action threw an exception.");
},
async test() {
ProtocolTest.pass("Test should still execute if previous test's setup action threw an exception.");
},
async teardown() {
ProtocolTest.pass("Teardown action should still execute if previous test's setup action threw an exception.");
},
});
checkResult(asyncSetupRuntimeExceptionSuite, {
runCount: 1,
passCount: 1,
failCount: 1,
skipCount: 1,
});
let asyncSetupFailureSuite = ProtocolTest.createAsyncSuite("AsyncTestSuite.AsyncSetupFailure");
asyncSetupFailureSuite.addTestCase({
name: "AsyncTestWithFailureDuringSetup",
async setup() {
ProtocolTest.log("Rejecting...");
return Promise.reject("AsyncSetupFailure reject");
},
async test() {
},
});
asyncSetupFailureSuite.addTestCase({
name: "AsyncTestAfterSetupFailure",
async setup() {
ProtocolTest.pass("Setup action should still execute if previous test's setup action failed.");
},
async test() {
ProtocolTest.pass("Test should still execute if previous test's setup action failed.");
},
async teardown() {
ProtocolTest.pass("Setup action should still execute if previous test's setup action failed.");
},
});
checkResult(asyncSetupFailureSuite, {
runCount: 1,
passCount: 1,
failCount: 1,
skipCount: 1,
});
let asyncTeardownExplicitExceptionSuite = ProtocolTest.createAsyncSuite("AsyncTestSuite.AsyncTeardownExplicitException");
asyncTeardownExplicitExceptionSuite.addTestCase({
name: "AsyncTestWithExplicitExceptionDuringTeardown",
async test() {
},
async teardown() {
ProtocolTest.log("Throwing...");
throw "AsyncTeardownExplicitException throw";
},
});
asyncTeardownExplicitExceptionSuite.addTestCase({
name: "AsyncTestAfterTeardownExplicitException",
async setup() {
ProtocolTest.pass("Setup action should still execute if previous test's teardown action threw an exception.");
},
async test() {
ProtocolTest.pass("Test should still execute if previous test's teardown action threw an exception.");
},
async teardown() {
ProtocolTest.pass("Teardown action should still execute if previous test's teardown action threw an exception.");
},
});
checkResult(asyncTeardownExplicitExceptionSuite, {
runCount: 2,
passCount: 1,
failCount: 1,
skipCount: 0,
});
let asyncTeardownRuntimeExceptionSuite = ProtocolTest.createAsyncSuite("AsyncTestSuite.AsyncTeardownRuntimeException");
asyncTeardownRuntimeExceptionSuite.addTestCase({
name: "AsyncTestWithRuntimeExceptionDuringTeardown",
async test() {
},
async teardown() {
ProtocolTest.log("Throwing...");
({}).x.x.x;
},
});
asyncTeardownRuntimeExceptionSuite.addTestCase({
name: "AsyncTestAfterTeardownRuntimeException",
async setup() {
ProtocolTest.pass("Setup action should still execute if previous test's teardown action threw an exception.");
},
async test() {
ProtocolTest.pass("Test should still execute if previous test's teardown action threw an exception.");
},
async teardown() {
ProtocolTest.pass("Teardown action should still execute if previous test's teardown action threw an exception.");
},
});
checkResult(asyncTeardownRuntimeExceptionSuite, {
runCount: 2,
passCount: 1,
failCount: 1,
skipCount: 0,
});
let asyncTeardownFailureSuite = ProtocolTest.createAsyncSuite("AsyncTestSuite.AsyncTeardownFailure");
asyncTeardownFailureSuite.addTestCase({
name: "AsyncTestWithFailureDuringTeardown",
async test() {
},
async teardown() {
ProtocolTest.log("Rejecting...");
return Promise.reject("AsyncTeardownFailure reject");
},
});
asyncTeardownFailureSuite.addTestCase({
name: "AsyncTestAfterTeardownFailure",
async setup() {
ProtocolTest.pass("Setup action should still execute if previous test's teardown action failed.");
},
async test() {
ProtocolTest.pass("Test should still execute if previous test's teardown action failed.");
},
async teardown() {
ProtocolTest.pass("Teardown action should still execute if previous test's teardown action failed.");
},
});
checkResult(asyncTeardownFailureSuite, {
runCount: 2,
passCount: 1,
failCount: 1,
skipCount: 0,
});
let asyncTimeoutSuite = ProtocolTest.createAsyncSuite("AsyncTestSuite.AsyncTimeout");
asyncTimeoutSuite.addTestCase({
name: "AsyncTestWithTimeout",
async test() {
ProtocolTest.log("Timeout...");
await Promise.delay(50);
},
timeout: 5,
});
asyncTimeoutSuite.addTestCase({
name: "AsyncTestAfterTimeout",
async setup() {
ProtocolTest.pass("Setup action should still execute if previous test timed out.");
},
async test() {
ProtocolTest.pass("Test should still execute if previous test timed out.");
},
async teardown() {
ProtocolTest.pass("Teardown action should still execute if previous test timed out.");
},
});
checkResult(asyncTimeoutSuite, {
runCount: 2,
passCount: 1,
failCount: 1,
skipCount: 0,
});
// This will finish the test whether the chain was resolved or rejected.
result = result.then(() => {
ProtocolTest.completeTest();
});
}
</script>
</head>
<body onLoad="runTest()">
</body>
</html>