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