| Index: LayoutTests/inspector/console/console-uncaught-promise.html
|
| diff --git a/LayoutTests/inspector/console/console-uncaught-promise.html b/LayoutTests/inspector/console/console-uncaught-promise.html
|
| index 3b8382c7bb957320d5eee135d879f1504afcacbd..5f3af25880706a28e5f177bfb58470771d8aa4df 100644
|
| --- a/LayoutTests/inspector/console/console-uncaught-promise.html
|
| +++ b/LayoutTests/inspector/console/console-uncaught-promise.html
|
| @@ -4,13 +4,30 @@
|
| <script src="../../http/tests/inspector/console-test.js"></script>
|
| <script>
|
|
|
| -function runPromises(source)
|
| +var tested = 0;
|
| +function runNextPromiseTest()
|
| {
|
| - Promise.reject(new Error(source + ".err1"))
|
| + ++tested;
|
| + var name = "promiseTest" + tested;
|
| + if (typeof window[name] !== "function")
|
| + return false;
|
| + // setTimeout to cut off VM call frames from the stack trace.
|
| + setTimeout(function timeout() {
|
| + window[name].call(window);
|
| + }, 0);
|
| + return true;
|
| +}
|
| +
|
| +function promiseTest1()
|
| +{
|
| + Promise.reject(new Error("err1"))
|
| .then()
|
| .then()
|
| .then(); // Last is unhandled.
|
| +}
|
|
|
| +function promiseTest2()
|
| +{
|
| var reject
|
| var m0 = new Promise(function(res, rej) { reject = rej; });
|
| var m1 = m0.then(function() {});
|
| @@ -21,40 +38,31 @@ function runPromises(source)
|
| m2.catch(function() {
|
| m1.catch(function() {
|
| m4 = m3.then(function() {}); // Unhandled.
|
| - if (source === "onload")
|
| - scheduleRunTests();
|
| });
|
| });
|
| });
|
| - reject(new Error(source + ".err2"));
|
| + reject(new Error("err2"));
|
| }
|
|
|
| -function onload()
|
| +function promiseTest3()
|
| {
|
| - runPromises("onload");
|
| + var reject;
|
| + var p = new Promise(function(res, rej) {
|
| + reject = rej;
|
| + });
|
| + p.then().catch(function catcher() {
|
| + throwDOMException();
|
| + });
|
| + reject(new Error("FAIL: Should not be printed to console"));
|
|
|
| - if (window.testRunner) {
|
| - testRunner.dumpAsText();
|
| - testRunner.waitUntilDone();
|
| + function throwDOMException()
|
| + {
|
| + var a = document.createElement("div");
|
| + var b = document.createElement("div");
|
| + a.removeChild(b);
|
| }
|
| }
|
|
|
| -function runPromisesFromInspector()
|
| -{
|
| - // setTimeout to cut off VM call frames from the stack trace.
|
| - setTimeout(function timeout() {
|
| - runPromises("inspector")
|
| - }, 0);
|
| -}
|
| -
|
| -function scheduleRunTests()
|
| -{
|
| - // Run tests after all microtasks.
|
| - Promise.resolve().then(function() {
|
| - setTimeout(runTest, 0);
|
| - });
|
| -}
|
| -
|
| function test()
|
| {
|
| InspectorTest.addConsoleViewSniffer(checkConsoleMessages, true);
|
| @@ -64,11 +72,13 @@ function test()
|
|
|
| function checkConsoleMessages()
|
| {
|
| - var count = InspectorTest.consoleMessagesCount();
|
| - if (count === 2)
|
| - InspectorTest.evaluateInPage("runPromisesFromInspector()");
|
| - else if (count === 4)
|
| - InspectorTest.expandConsoleMessages(dump);
|
| + InspectorTest.evaluateInPage("runNextPromiseTest()", callback);
|
| +
|
| + function callback(result)
|
| + {
|
| + if (!result.value)
|
| + InspectorTest.expandConsoleMessages(dump);
|
| + }
|
| }
|
|
|
| function dump()
|
| @@ -81,7 +91,7 @@ function test()
|
| </script>
|
| </head>
|
|
|
| -<body onload="onload()">
|
| +<body onload="runTest()">
|
| <p>
|
| Tests that uncaught promise rejections are logged into console.
|
| </p>
|
|
|