3 <script src=
"../../http/tests/inspector/inspector-test.js"></script>
4 <script src=
"../../http/tests/inspector/console-test.js"></script>
8 function runNextPromiseTest()
11 var name
= "promiseTest" + tested
;
12 if (typeof window
[name
] !== "function")
14 // setTimeout to cut off VM call frames from the stack trace.
15 setTimeout(function timeout() {
16 window
[name
].call(window
);
21 function promiseTest1()
23 Promise
.reject(new Error("err1"))
26 .then(); // Last is unhandled.
29 function promiseTest2()
32 var m0
= new Promise(function(res
, rej
) { reject
= rej
; });
33 var m1
= m0
.then(function() {});
34 var m2
= m0
.then(function() {});
35 var m3
= m0
.then(function() {});
40 m4
= m3
.then(function() {}); // Unhandled.
44 reject(new Error("err2"));
47 function promiseTest3()
50 var p
= new Promise(function(res
, rej
) {
53 p
.then().catch(function catcher() {
56 reject(new Error("FAIL: Should not be printed to console"));
58 function throwDOMException()
60 var a
= document
.createElement("div");
61 var b
= document
.createElement("div");
66 function promiseTest4()
71 function promiseTest5()
73 Promise
.reject(1e+100);
76 function promiseTest6()
78 Promise
.reject("foo");
81 function promiseTest7()
83 Promise
.reject({ foo
: 42 });
86 function promiseTest8()
91 function promiseTest9()
93 navigator
.serviceWorker
.register('404');
98 InspectorTest
.addConsoleViewSniffer(checkConsoleMessages
, true);
99 WebInspector
.console
.showPromise();
101 checkConsoleMessages();
103 function checkConsoleMessages()
105 InspectorTest
.evaluateInPage("runNextPromiseTest()", callback
);
107 function callback(result
)
110 InspectorTest
.expandConsoleMessages(dump
);
116 InspectorTest
.dumpConsoleMessagesIgnoreErrorStackFrames();
117 InspectorTest
.completeTest();
124 <body onload=
"runTest()">
126 Tests that uncaught promise rejections are logged into console.