Modified: trunk/LayoutTests/inspector/unit-tests/async-test-suite.html (223808 => 223809)
--- trunk/LayoutTests/inspector/unit-tests/async-test-suite.html 2017-10-21 06:16:54 UTC (rev 223808)
+++ trunk/LayoutTests/inspector/unit-tests/async-test-suite.html 2017-10-21 06:52:47 UTC (rev 223809)
@@ -9,44 +9,44 @@
try {
let result = new AsyncTestSuite(this);
- ProtocolTest.log("FAIL: instantiating AsyncTestSuite requires name argument.");
+ ProtocolTest.fail("instantiating AsyncTestSuite requires name argument.");
} catch (e) {
- ProtocolTest.log("PASS: instantiating AsyncTestSuite requires name argument.");
+ ProtocolTest.pass("instantiating AsyncTestSuite requires name argument.");
}
try {
let result = new AsyncTestSuite(this, {});
- ProtocolTest.log("FAIL: instantiating AsyncTestSuite requires string name argument.");
+ ProtocolTest.fail("instantiating AsyncTestSuite requires string name argument.");
} catch (e) {
- ProtocolTest.log("PASS: instantiating AsyncTestSuite requires string name argument.");
+ ProtocolTest.pass("instantiating AsyncTestSuite requires string name argument.");
}
try {
let result = new AsyncTestSuite(this, " ");
- ProtocolTest.log("FAIL: instantiating AsyncTestSuite requires non-whitespace name argument.");
+ ProtocolTest.fail("instantiating AsyncTestSuite requires non-whitespace name argument.");
} catch (e) {
- ProtocolTest.log("PASS: instantiating AsyncTestSuite requires non-whitespace name argument.");
+ ProtocolTest.pass("instantiating AsyncTestSuite requires non-whitespace name argument.");
}
try {
let result = new AsyncTestSuite("something", {});
- ProtocolTest.log("FAIL: instantiating AsyncTestSuite requires test harness argument.");
+ ProtocolTest.fail("instantiating AsyncTestSuite requires test harness argument.");
} catch (e) {
- ProtocolTest.log("PASS: instantiating AsyncTestSuite requires test harness argument.");
+ ProtocolTest.pass("instantiating AsyncTestSuite requires test harness argument.");
}
let badArgsSuite = ProtocolTest.createAsyncSuite("dummy");
try {
badArgsSuite.addTestCase();
- ProtocolTest.log("FAIL: should not be able to add empty test case.");
+ ProtocolTest.fail("should not be able to add empty test case.");
} catch (e) {
- ProtocolTest.log("PASS: should not be able to add empty test case.");
+ ProtocolTest.pass("should not be able to add empty test case.");
}
try {
badArgsSuite.addTestCase("string");
- ProtocolTest.log("FAIL: should not be able to add non-object test case.");
+ ProtocolTest.fail("should not be able to add non-object test case.");
} catch (e) {
- ProtocolTest.log("PASS: should not be able to add non-object test case.");
+ ProtocolTest.pass("should not be able to add non-object test case.");
}
try {
badArgsSuite.addTestCase({
@@ -53,9 +53,9 @@
name: {},
test() {},
});
- ProtocolTest.log("FAIL: test case should require string name.");
+ ProtocolTest.fail("test case should require string name.");
} catch (e) {
- ProtocolTest.log("PASS: test case should require string name.");
+ ProtocolTest.pass("test case should require string name.");
}
try {
badArgsSuite.addTestCase({
@@ -62,9 +62,9 @@
name: " ",
test() {},
});
- ProtocolTest.log("FAIL: test case should require non-whitespace name.");
+ ProtocolTest.fail("test case should require non-whitespace name.");
} catch (e) {
- ProtocolTest.log("PASS: test case should require non-whitespace name.");
+ ProtocolTest.pass("test case should require non-whitespace name.");
}
try {
badArgsSuite.addTestCase({
@@ -71,9 +71,9 @@
name: "foo",
test: null,
});
- ProtocolTest.log("FAIL: test case should require test function.");
+ ProtocolTest.fail("test case should require test function.");
} catch (e) {
- ProtocolTest.log("PASS: test case should require test function.");
+ ProtocolTest.pass("test case should require test function.");
}
try {
badArgsSuite.addTestCase({
@@ -81,9 +81,9 @@
test() {},
setup: "astd"
});
- ProtocolTest.log("FAIL: should not be able to specify non-Function `setup` parameter.");
+ ProtocolTest.fail("should not be able to specify non-Function `setup` parameter.");
} catch (e) {
- ProtocolTest.log("PASS: should not be able to specify non-Function `setup` parameter.");
+ ProtocolTest.pass("should not be able to specify non-Function `setup` parameter.");
}
try {
badArgsSuite.addTestCase({
@@ -91,9 +91,9 @@
test() {},
setup: 123
});
- ProtocolTest.log("FAIL: should not be able to specify non-Function `setup` parameter.");
+ ProtocolTest.fail("should not be able to specify non-Function `setup` parameter.");
} catch (e) {
- ProtocolTest.log("PASS: should not be able to specify non-Function `setup` parameter.");
+ ProtocolTest.pass("should not be able to specify non-Function `setup` parameter.");
}
try {
badArgsSuite.addTestCase({
@@ -101,9 +101,9 @@
test() {},
setup: {}
});
- ProtocolTest.log("FAIL: should not be able to specify non-Function `setup` parameter.");
+ ProtocolTest.fail("should not be able to specify non-Function `setup` parameter.");
} catch (e) {
- ProtocolTest.log("PASS: should not be able to specify non-Function `setup` parameter.");
+ ProtocolTest.pass("should not be able to specify non-Function `setup` parameter.");
}
try {
badArgsSuite.addTestCase({
@@ -111,9 +111,9 @@
test() {},
teardown: "astd"
});
- ProtocolTest.log("FAIL: should not be able to specify non-Function `teardown` parameter.");
+ ProtocolTest.fail("should not be able to specify non-Function `teardown` parameter.");
} catch (e) {
- ProtocolTest.log("PASS: should not be able to specify non-Function `teardown` parameter.");
+ ProtocolTest.pass("should not be able to specify non-Function `teardown` parameter.");
}
try {
badArgsSuite.addTestCase({
@@ -121,9 +121,9 @@
test() {},
teardown: 123
});
- ProtocolTest.log("FAIL: should not be able to specify non-Function `teardown` parameter.");
+ ProtocolTest.fail("should not be able to specify non-Function `teardown` parameter.");
} catch (e) {
- ProtocolTest.log("PASS: should not be able to specify non-Function `teardown` parameter.");
+ ProtocolTest.pass("should not be able to specify non-Function `teardown` parameter.");
}
try {
badArgsSuite.addTestCase({
@@ -131,17 +131,17 @@
test() {},
teardown: {}
});
- ProtocolTest.log("FAIL: should not be able to specify non-Function `teardown` parameter.");
+ ProtocolTest.fail("should not be able to specify non-Function `teardown` parameter.");
} catch (e) {
- ProtocolTest.log("PASS: should not be able to specify non-Function `teardown` parameter.");
+ ProtocolTest.pass("should not be able to specify non-Function `teardown` parameter.");
}
let runEmptySuite = ProtocolTest.createAsyncSuite("AsyncTestSuite.RunEmptySuite");
try {
runEmptySuite.runTestCases();
- ProtocolTest.log("FAIL: should not be able to run empty test suite.");
+ ProtocolTest.fail("should not be able to run empty test suite.");
} catch (e) {
- ProtocolTest.log("PASS: should not be able to run empty test suite.");
+ ProtocolTest.pass("should not be able to run empty test suite.");
}
let runTwiceSuite = ProtocolTest.createAsyncSuite("AsyncTestSuite.RunTwiceSuite");
@@ -156,9 +156,9 @@
// 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();
- ProtocolTest.log("FAIL: should not be able to run a test suite twice.");
+ ProtocolTest.fail("should not be able to run a test suite twice.");
} catch (e) {
- ProtocolTest.log("PASS: should not be able to run a test suite twice.");
+ ProtocolTest.pass("should not be able to run a test suite twice.");
}
let rejectToken = {"token": 666};
@@ -209,10 +209,10 @@
return promise;
});
result = result.then(function resolved() {
- ProtocolTest.log("FAIL: Promise from sequentialExecutionSuite.runTestCases() should reject when a test case fails.");
+ ProtocolTest.fail("Promise from sequentialExecutionSuite.runTestCases() should reject when a test case fails.");
return Promise.resolve(); // Continue this test.
}, function rejected(e) {
- ProtocolTest.log("PASS: Promise from sequentialExecutionSuite.runTestCases() should reject when a test case fails.");
+ ProtocolTest.pass("Promise from sequentialExecutionSuite.runTestCases() should reject when a test case fails.");
ProtocolTest.expectThat(e === thrownError, "Promise from sequentialExecutionSuite.runTestCases() should reject without altering its result value.");
ProtocolTest.expectThat(sequentialExecutionSuite.runCount === 4, "sequentialExecutionSuite should have executed four tests.");
@@ -225,10 +225,10 @@
result = result.then(() => {
return abortOnFailureSuite.runTestCases();
}).then(function resolved() {
- ProtocolTest.log("FAIL: Promise from abortOnFailureSuite.runTestCases() should reject when a test case fails.");
+ ProtocolTest.fail("Promise from abortOnFailureSuite.runTestCases() should reject when a test case fails.");
return Promise.resolve(); // Continue this test.
}, function rejected(e) {
- ProtocolTest.log("PASS: Promise from abortOnFailureSuite.runTestCases() should reject when a test case fails.");
+ ProtocolTest.pass("Promise from abortOnFailureSuite.runTestCases() should reject when a test case fails.");
ProtocolTest.expectThat(e === rejectToken, "Promise from abortOnFailureSuite.runTestCases() should reject without altering its result value.");
ProtocolTest.expectThat(abortOnFailureSuite.runCount === 2, "abortOnFailureSuite should have executed two tests.");
ProtocolTest.expectThat(abortOnFailureSuite.passCount === 1, "abortOnFailureSuite should have passed one test.");
@@ -272,10 +272,10 @@
result = result.then(() => {
return setupAndTeardownTestSuite.runTestCases();
}).then(function resolved() {
- ProtocolTest.log("PASS: Promise from setupAndTeardownTestSuite.runTestCases() should resolve.");
+ ProtocolTest.pass("Promise from setupAndTeardownTestSuite.runTestCases() should resolve.");
return Promise.resolve(); // Continue this test.
}, function rejected(e) {
- ProtocolTest.log("FAIL: Promise from setupAndTeardownTestSuite.runTestCases() should resolve.");
+ ProtocolTest.fail("Promise from setupAndTeardownTestSuite.runTestCases() should resolve.");
return Promise.resolve(); // Continue this test.
});
@@ -297,10 +297,10 @@
result = result.then(() => {
return setupExceptionTestSuite.runTestCases();
}).then(function resolved() {
- ProtocolTest.log("FAIL: Promise from setupExceptionTestSuite.runTestCases() should reject.");
+ ProtocolTest.fail("Promise from setupExceptionTestSuite.runTestCases() should reject.");
return Promise.resolve(); // Continue this test.
}, function rejected(e) {
- ProtocolTest.log("PASS: Promise from setupExceptionTestSuite.runTestCases() should reject.");
+ ProtocolTest.pass("Promise from setupExceptionTestSuite.runTestCases() should reject.");
return Promise.resolve(); // Continue this test.
});
@@ -322,10 +322,10 @@
result = result.then(() => {
return setupFailureTestSuite.runTestCases();
}).then(function resolved() {
- ProtocolTest.log("FAIL: Promise from setupFailureTestSuite.runTestCases() should reject.");
+ ProtocolTest.fail("Promise from setupFailureTestSuite.runTestCases() should reject.");
return Promise.resolve(); // Continue this test.
}, function rejected(e) {
- ProtocolTest.log("PASS: Promise from setupFailureTestSuite.runTestCases() should reject.");
+ ProtocolTest.pass("Promise from setupFailureTestSuite.runTestCases() should reject.");
return Promise.resolve(); // Continue this test.
});
@@ -352,10 +352,10 @@
result = result.then(() => {
return teardownExceptionTestSuite.runTestCases();
}).then(function resolved() {
- ProtocolTest.log("FAIL: Promise from teardownExceptionTestSuite.runTestCases() should reject.");
+ ProtocolTest.fail("Promise from teardownExceptionTestSuite.runTestCases() should reject.");
return Promise.resolve(); // Continue this test.
}, function rejected(e) {
- ProtocolTest.log("PASS: Promise from teardownExceptionTestSuite.runTestCases() should reject.");
+ ProtocolTest.pass("Promise from teardownExceptionTestSuite.runTestCases() should reject.");
return Promise.resolve(); // Continue this test.
});
@@ -382,13 +382,85 @@
result = result.then(() => {
return teardownFailureTestSuite.runTestCases();
}).then(function resolved() {
- ProtocolTest.log("FAIL: Promise from teardownFailureTestSuite.runTestCases() should reject.");
+ ProtocolTest.fail("Promise from teardownFailureTestSuite.runTestCases() should reject.");
return Promise.resolve(); // Continue this test.
}, function rejected(e) {
- ProtocolTest.log("PASS: Promise from teardownFailureTestSuite.runTestCases() should reject.");
+ ProtocolTest.pass("Promise from teardownFailureTestSuite.runTestCases() should reject.");
return Promise.resolve(); // Continue this test.
});
+
+ let asyncFunctionSuccessTestSuiteDidEvaluate = false;
+ let asyncFunctionSuccessTestSuite = ProtocolTest.createAsyncSuite("AsyncTestSuite.AsyncFunctionSuccess");
+ asyncFunctionSuccessTestSuite.addTestCase({
+ name: "AsyncFunctionSuccess",
+ description: "Check that an async suite with async test functions can succeed",
+ async test() {
+ asyncFunctionSuccessTestSuiteDidEvaluate = true;
+ return 42;
+ }
+ });
+
+ result = result.then(() => {
+ return asyncFunctionSuccessTestSuite.runTestCases();
+ }).then(function resolve(x) {
+ ProtocolTest.pass("Promise from asyncFunctionSuccessTestSuite.runTestCases() should succeed.");
+ ProtocolTest.expectThat(asyncFunctionSuccessTestSuiteDidEvaluate, "Promise did evaluate the async test function.");
+ ProtocolTest.expectEqual(x, 42, "Resolved value should be 42.");
+ return Promise.resolve(); // Continue this test.
+ }, function rejected(e) {
+ ProtocolTest.fail("Promise from asyncFunctionSuccessTestSuite.runTestCases() should succeed.");
+ return Promise.resolve(); // Continue this test.
+ });
+
+
+ let asyncFunctionExplicitFailureTestSuiteDidEvaluate = false;
+ let asyncFunctionExplicitFailureTestSuite = ProtocolTest.createAsyncSuite("AsyncTestSuite.AsyncFunctionExplicitFailure");
+ asyncFunctionExplicitFailureTestSuite.addTestCase({
+ name: "AsyncFunctionFailure",
+ description: "Check that an async suite with async test functions that throws will reject",
+ async test() {
+ asyncFunctionExplicitFailureTestSuiteDidEvaluate = true;
+ throw "AsyncFunctionFailure Exception Message";
+ }
+ });
+
+ result = result.then(() => {
+ return asyncFunctionExplicitFailureTestSuite.runTestCases();
+ }).then(function resolve() {
+ ProtocolTest.fail("Promise from asyncFunctionExplicitFailureTestSuite.runTestCases() should reject.");
+ return Promise.resolve(); // Continue this test.
+ }, function rejected(e) {
+ ProtocolTest.pass("Promise from asyncFunctionExplicitFailureTestSuite.runTestCases() should reject.");
+ ProtocolTest.expectThat(asyncFunctionExplicitFailureTestSuiteDidEvaluate, "Promise did evaluate the async test function.");
+ ProtocolTest.expectEqual(e, "AsyncFunctionFailure Exception Message", "Rejected value should be thrown exception.");
+ return Promise.resolve(); // Continue this test.
+ });
+
+
+ let asyncFunctionRuntimeFailureTestSuiteDidEvaluate = false;
+ let asyncFunctionRuntimeFailureTestSuite = ProtocolTest.createAsyncSuite("AsyncTestSuite.AsyncFunctionRuntimeFailure");
+ asyncFunctionRuntimeFailureTestSuite.addTestCase({
+ name: "AsyncFunctionFailure",
+ description: "Check that an async suite with async test functions that throws with a runtime error will reject",
+ async test() {
+ asyncFunctionRuntimeFailureTestSuiteDidEvaluate = true;
+ ({}).x.x.x;
+ }
+ });
+
+ result = result.then(() => {
+ return asyncFunctionRuntimeFailureTestSuite.runTestCases();
+ }).then(function resolve() {
+ ProtocolTest.fail("Promise from asyncFunctionRuntimeFailureTestSuite.runTestCases() should reject.");
+ return Promise.resolve(); // Continue this test.
+ }, function rejected(e) {
+ ProtocolTest.pass("Promise from asyncFunctionRuntimeFailureTestSuite.runTestCases() should reject.");
+ ProtocolTest.expectThat(asyncFunctionRuntimeFailureTestSuiteDidEvaluate, "Promise did evaluate the async test function.");
+ ProtocolTest.expectThat(e instanceof TypeError, "Rejected value should be a runtime exception.");
+ return Promise.resolve(); // Continue this test.
+ });
+
// This will finish the test whether the chain was resolved or rejected.
result = result.then(() => { ProtocolTest.completeTest(); });
}
Modified: trunk/LayoutTests/inspector/unit-tests/target-manager.html (223808 => 223809)
--- trunk/LayoutTests/inspector/unit-tests/target-manager.html 2017-10-21 06:16:54 UTC (rev 223808)
+++ trunk/LayoutTests/inspector/unit-tests/target-manager.html 2017-10-21 06:52:47 UTC (rev 223809)
@@ -37,7 +37,7 @@
suite.addTestCase({
name: "TargetManager.MainTarget",
description: "We should always have the main target.",
- test(resolve, reject) {
+ async test() {
InspectorTest.assert(WI.targets === WI.targetManager.targets);
InspectorTest.expectEqual(WI.targets.size, 1, "Targets list should always start out with the main target.");
InspectorTest.expectEqual([...WI.targets][0], WI.mainTarget, "Target list should always contain the main target.");
@@ -44,7 +44,6 @@
InspectorTest.expectNotNull(WI.mainTarget.executionContext, "Main target should have an ExecutionContext.");
InspectorTest.expectEqual(WI.mainTarget.RuntimeAgent, RuntimeAgent, "Main target should have the global RuntimeAgent.");
dumpTargets();
- resolve();
}
});
@@ -51,18 +50,16 @@
suite.addTestCase({
name: "TargetManager.WorkerTarget.Create",
description: "Creating a Worker should create a new Worker Target.",
- test(resolve, reject) {
+ async test() {
InspectorTest.evaluateInPage("createWorker()");
- WI.targetManager.singleFireEventListener(WI.TargetManager.Event.TargetAdded, (event) => {
- let target = event.data.target;
- InspectorTest.assert(target instanceof WI.Target);
- InspectorTest.expectEqual(target.type, WI.Target.Type.Worker, "Added Target should have Worker type.");
- InspectorTest.expectNotNull(target.executionContext, "Added Target should have an ExecutionContext.");
- InspectorTest.expectNotNull(target.RuntimeAgent, "Added Target should have a RuntimeAgent.");
- InspectorTest.expectNotEqual(target.RuntimeAgent, RuntimeAgent, "Added Target RuntimeAgent should not be the global RuntimeAgent.");
- dumpTargets();
- resolve();
- });
+ let event = await WI.targetManager.awaitEvent(WI.TargetManager.Event.TargetAdded);
+ let target = event.data.target;
+ InspectorTest.assert(target instanceof WI.Target);
+ InspectorTest.expectEqual(target.type, WI.Target.Type.Worker, "Added Target should have Worker type.");
+ InspectorTest.expectNotNull(target.executionContext, "Added Target should have an ExecutionContext.");
+ InspectorTest.expectNotNull(target.RuntimeAgent, "Added Target should have a RuntimeAgent.");
+ InspectorTest.expectNotEqual(target.RuntimeAgent, RuntimeAgent, "Added Target RuntimeAgent should not be the global RuntimeAgent.");
+ dumpTargets();
}
});
@@ -69,15 +66,13 @@
suite.addTestCase({
name: "TargetManager.WorkerTarget.Remove",
description: "Creating a Worker should create a new Worker Target.",
- test(resolve, reject) {
+ async test() {
InspectorTest.evaluateInPage("terminateWorker()");
- WI.targetManager.singleFireEventListener(WI.TargetManager.Event.TargetRemoved, (event) => {
- let target = event.data.target;
- InspectorTest.assert(target instanceof WI.Target);
- InspectorTest.expectEqual(target.type, WI.Target.Type.Worker, "Removed Target should have Worker type.");
- dumpTargets();
- resolve();
- });
+ let event = await WI.targetManager.awaitEvent(WI.TargetManager.Event.TargetRemoved);
+ let target = event.data.target;
+ InspectorTest.assert(target instanceof WI.Target);
+ InspectorTest.expectEqual(target.type, WI.Target.Type.Worker, "Removed Target should have Worker type.");
+ dumpTargets();
}
});