OLD | NEW |
---|---|
1 <html> | 1 <html> |
2 <head> | 2 <head> |
3 <script src="../../http/tests/inspector/inspector-test.js"></script> | 3 <script src="../../http/tests/inspector/inspector-test.js"></script> |
4 <script src="../../http/tests/inspector/console-test.js"></script> | 4 <script src="../../http/tests/inspector/console-test.js"></script> |
5 <script> | 5 <script> |
6 | 6 |
7 var tested = 0; | 7 function createRejectedPromises() |
8 function runNextPromiseTest() | |
9 { | |
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; | |
19 } | |
20 | |
21 function promiseTest1() | |
22 { | 8 { |
23 Promise.reject(new Error("err1")) | 9 Promise.reject(new Error("err1")) |
24 .then() | 10 .then() |
25 .then() | 11 .then() |
26 .then(); // Last is unhandled. | 12 .then(); // Last is unhandled. |
27 } | |
28 | 13 |
29 function promiseTest2() | 14 var reject; |
30 { | |
31 var reject | |
32 var m0 = new Promise(function(res, rej) { reject = rej; }); | 15 var m0 = new Promise(function(res, rej) { reject = rej; }); |
33 var m1 = m0.then(function() {}); | 16 var m1 = m0.then(function() {}); |
34 var m2 = m0.then(function() {}); | 17 var m2 = m0.then(function() {}); |
35 var m3 = m0.then(function() {}); | 18 var m3 = m0.then(function() {}); |
36 var m4 = 0; | 19 var m4 = 0; |
37 m0.catch(function() { | 20 m0.catch(function() { |
38 m2.catch(function() { | 21 m2.catch(function() { |
39 m1.catch(function() { | 22 m1.catch(function() { |
40 m4 = m3.then(function() {}); // Unhandled. | 23 m4 = m3.then(function() {}); // Unhandled. |
24 setTimeout(rejectWithDOMException, 0); | |
41 }); | 25 }); |
42 }); | 26 }); |
43 }); | 27 }); |
44 reject(new Error("err2")); | 28 reject(new Error("err2")); |
45 } | 29 } |
46 | 30 |
47 function promiseTest3() | 31 function rejectWithDOMException() |
48 { | 32 { |
49 var reject; | 33 var reject; |
50 var p = new Promise(function(res, rej) { | 34 var p = new Promise(function(res, rej) { |
51 reject = rej; | 35 reject = rej; |
52 }); | 36 }); |
53 p.then().catch(function catcher() { | 37 p.then().catch(function catcher() { |
54 throwDOMException(); | 38 throwDOMException(); |
55 }); | 39 }); |
56 reject(new Error("FAIL: Should not be printed to console")); | 40 reject(new Error("FAIL: Should not be printed to console")); |
57 | 41 |
58 function throwDOMException() | 42 function throwDOMException() |
59 { | 43 { |
44 setTimeout(showWebInspector, 0); | |
60 var a = document.createElement("div"); | 45 var a = document.createElement("div"); |
61 var b = document.createElement("div"); | 46 var b = document.createElement("div"); |
62 a.removeChild(b); | 47 a.removeChild(b); |
63 } | 48 } |
64 } | 49 } |
65 | 50 |
51 function onload() | |
52 { | |
53 if (window.testRunner) { | |
54 testRunner.dumpAsText(); | |
55 testRunner.waitUntilDone(); | |
56 } | |
57 createRejectedPromises(); | |
58 } | |
59 | |
60 function showWebInspector() | |
61 { | |
62 if (window.testRunner) | |
63 testRunner.showWebInspector(); | |
64 runTest(); | |
65 } | |
66 | |
66 function test() | 67 function test() |
67 { | 68 { |
68 InspectorTest.addConsoleViewSniffer(checkConsoleMessages, true); | 69 InspectorTest.expandConsoleMessages(onExpanded); |
vsevik
2014/11/12 15:46:12
They should be useful even before expanding.
| |
69 WebInspector.console.showPromise().done(); | |
70 | 70 |
71 checkConsoleMessages(); | 71 function onExpanded() |
72 | |
73 function checkConsoleMessages() | |
74 { | |
75 InspectorTest.evaluateInPage("runNextPromiseTest()", callback); | |
76 | |
77 function callback(result) | |
78 { | |
79 if (!result.value) | |
80 InspectorTest.expandConsoleMessages(dump); | |
81 } | |
82 } | |
83 | |
84 function dump() | |
85 { | 72 { |
86 InspectorTest.dumpConsoleMessages(false, false, InspectorTest.textConten tWithLineBreaks); | 73 InspectorTest.dumpConsoleMessages(false, false, InspectorTest.textConten tWithLineBreaks); |
87 InspectorTest.completeTest(); | 74 InspectorTest.completeTest(); |
88 } | 75 } |
89 } | 76 } |
90 | 77 |
91 </script> | 78 </script> |
92 </head> | 79 </head> |
93 | 80 |
94 <body onload="runTest()"> | 81 <body onload="onload()"> |
95 <p> | 82 <p> |
96 Tests that uncaught promise rejections are logged into console. | 83 Tests that uncaught promise rejection messages have line numbers when the inspec tor is closed and stack traces are not collected. |
97 </p> | 84 </p> |
98 | 85 |
99 </body> | 86 </body> |
100 </html> | 87 </html> |
OLD | NEW |