OLD | NEW |
(Empty) | |
| 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> |
| 6 |
| 7 function runPromises(source) |
| 8 { |
| 9 Promise.reject(new Error(source + ".err1")) |
| 10 .then() |
| 11 .then() |
| 12 .then(); // Last is unhandled. |
| 13 |
| 14 var reject |
| 15 var m0 = new Promise(function(res, rej) { reject = rej; }); |
| 16 var m1 = m0.then(function() {}); |
| 17 var m2 = m0.then(function() {}); |
| 18 var m3 = m0.then(function() {}); |
| 19 var m4 = 0; |
| 20 m0.catch(function() { |
| 21 m2.catch(function() { |
| 22 m1.catch(function() { |
| 23 m4 = m3.then(function() {}); // Unhandled. |
| 24 }); |
| 25 }); |
| 26 }); |
| 27 reject(new Error(source + ".err2")); |
| 28 } |
| 29 |
| 30 function onload() |
| 31 { |
| 32 runPromises("onload"); |
| 33 runTest(); |
| 34 } |
| 35 |
| 36 function test() |
| 37 { |
| 38 InspectorTest.addConsoleViewSniffer(addMessage, true); |
| 39 |
| 40 WebInspector.console.showPromise().then(function() { |
| 41 InspectorTest.evaluateInPage("runPromises('inspector')"); |
| 42 }); |
| 43 |
| 44 var count = 0; |
| 45 function addMessage(uiMessage) |
| 46 { |
| 47 if (uiMessage.toString().indexOf("inspector.err") !== -1) |
| 48 ++count; |
| 49 if (count === 2) |
| 50 InspectorTest.expandConsoleMessages(dump); |
| 51 } |
| 52 |
| 53 function dump() |
| 54 { |
| 55 // Sort console messages from async Promises to avoid flakiness. |
| 56 var results = InspectorTest.dumpConsoleMessagesIntoArray(false, false, I
nspectorTest.textContentWithLineBreaks); |
| 57 results.sort(); |
| 58 InspectorTest.addResults(results); |
| 59 InspectorTest.completeTest(); |
| 60 } |
| 61 |
| 62 } |
| 63 |
| 64 </script> |
| 65 </head> |
| 66 |
| 67 <body onload="onload()"> |
| 68 <p> |
| 69 Tests that uncaught promise rejections are logged into console. |
| 70 </p> |
| 71 |
| 72 </body> |
| 73 </html> |
OLD | NEW |