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 var p = []; |
| 8 |
| 9 function createPromises() |
| 10 { |
| 11 for (var i = 0; i < 3; ++i) |
| 12 p.push(Promise.reject(new Error("Handled error"))); |
| 13 } |
| 14 |
| 15 function handleSomeRejections() |
| 16 { |
| 17 p[0].catch(function() {}); |
| 18 p[2].catch(function() {}); |
| 19 } |
| 20 |
| 21 function test() |
| 22 { |
| 23 InspectorTest.consoleModel.addEventListener(WebInspector.ConsoleModel.Events
.MessageAdded, messageAdded); |
| 24 |
| 25 InspectorTest.addResult("Creating promise"); |
| 26 InspectorTest.evaluateInPageWithTimeout("createPromises()"); |
| 27 |
| 28 function messageAdded(event) |
| 29 { |
| 30 InspectorTest.addResult(""); |
| 31 InspectorTest.addResult("Message added: " + event.data.level + " " + eve
nt.data.type); |
| 32 InspectorTest.addResult("errors: " + InspectorTest.consoleModel.errors()
); |
| 33 InspectorTest.addResult("revokedErrors: " + InspectorTest.consoleModel.r
evokedErrors()); |
| 34 |
| 35 if (event.data.level === WebInspector.ConsoleMessage.MessageLevel.Error)
{ |
| 36 InspectorTest.consoleModel.removeEventListener(WebInspector.ConsoleM
odel.Events.MessageAdded, messageAdded); |
| 37 // Process array as a batch. |
| 38 setTimeout(function() { |
| 39 InspectorTest.consoleModel.addEventListener(WebInspector.Console
Model.Events.MessageUpdated, messageUpdated); |
| 40 InspectorTest.dumpConsoleClassesBrief(); |
| 41 InspectorTest.addResult(""); |
| 42 InspectorTest.addResult("Handling promise"); |
| 43 InspectorTest.evaluateInPageWithTimeout("handleSomeRejections()"
); |
| 44 }); |
| 45 } |
| 46 } |
| 47 |
| 48 function messageUpdated() |
| 49 { |
| 50 // Process array as a batch. |
| 51 setTimeout(function() { |
| 52 InspectorTest.dumpConsoleClassesBrief(); |
| 53 InspectorTest.completeTest(); |
| 54 }); |
| 55 } |
| 56 } |
| 57 |
| 58 </script> |
| 59 </head> |
| 60 |
| 61 <body onload="runTest()"> |
| 62 <p>Tests that console revokes lazily handled promise rejections.</p> |
| 63 |
| 64 </body> |
| 65 </html> |
OLD | NEW |