Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / inspector / console / console-uncaught-promise.html
blob3610449568ec73ad66ca3da21dc30db6afb99d46
1 <html>
2 <head>
3 <script src="../../http/tests/inspector/inspector-test.js"></script>
4 <script src="../../http/tests/inspector/console-test.js"></script>
5 <script>
7 var tested = 0;
8 function runNextPromiseTest()
10 ++tested;
11 var name = "promiseTest" + tested;
12 if (typeof window[name] !== "function")
13 return false;
14 // setTimeout to cut off VM call frames from the stack trace.
15 setTimeout(function timeout() {
16 window[name].call(window);
17 }, 0);
18 return true;
21 function promiseTest1()
23 Promise.reject(new Error("err1"))
24 .then()
25 .then()
26 .then(); // Last is unhandled.
29 function promiseTest2()
31 var reject;
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() {});
36 var m4 = 0;
37 m0.catch(function() {
38 m2.catch(function() {
39 m1.catch(function() {
40 m4 = m3.then(function() {}); // Unhandled.
41 });
42 });
43 });
44 reject(new Error("err2"));
47 function promiseTest3()
49 var reject;
50 var p = new Promise(function(res, rej) {
51 reject = rej;
52 });
53 p.then().catch(function catcher() {
54 throwDOMException();
55 });
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");
62 a.removeChild(b);
66 function promiseTest4()
68 Promise.reject(42);
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()
88 Promise.reject();
91 function promiseTest9()
93 navigator.serviceWorker.register('404');
96 function test()
98 InspectorTest.addConsoleViewSniffer(checkConsoleMessages, true);
99 WebInspector.console.showPromise();
101 checkConsoleMessages();
103 function checkConsoleMessages()
105 InspectorTest.evaluateInPage("runNextPromiseTest()", callback);
107 function callback(result)
109 if (!result.value)
110 InspectorTest.expandConsoleMessages(dump);
114 function dump()
116 InspectorTest.dumpConsoleMessagesIgnoreErrorStackFrames();
117 InspectorTest.completeTest();
121 </script>
122 </head>
124 <body onload="runTest()">
126 Tests that uncaught promise rejections are logged into console.
127 </p>
129 </body>
130 </html>