OLD | NEW |
| (Empty) |
1 <html> | |
2 <head> | |
3 <script src="../../../http/tests/inspector/inspector-test.js"></script> | |
4 <script src="../../../http/tests/inspector/debugger-test.js"></script> | |
5 <script> | |
6 | |
7 function testFunction() | |
8 { | |
9 var promise1 = new Promise( | |
10 function promiseConstructor1(resolve, reject) | |
11 { | |
12 resolve("Resolved!"); | |
13 } | |
14 ); | |
15 var promise2 = new Promise( | |
16 function promiseConstructor2(resolve, reject) | |
17 { | |
18 reject("Rejected!"); | |
19 } | |
20 ); | |
21 promise2 | |
22 .then(thenCallback1, thenCallback1) | |
23 .then(thenCallback2); | |
24 } | |
25 | |
26 function thenCallback1() | |
27 { | |
28 return 0; | |
29 } | |
30 | |
31 function thenCallback2() | |
32 { | |
33 if (window.GCController) | |
34 GCController.collectAll(); | |
35 debugger; | |
36 } | |
37 | |
38 function test() | |
39 { | |
40 var events = []; | |
41 var minPromiseId; | |
42 | |
43 InspectorTest.startDebuggerTest(step1, true); | |
44 | |
45 function step1() | |
46 { | |
47 InspectorTest.DebuggerAgent.enablePromiseTracker(true); | |
48 InspectorTest.debuggerModel.addEventListener(WebInspector.DebuggerModel.
Events.PromiseUpdated, promiseUpdated); | |
49 InspectorTest.runTestFunctionAndWaitUntilPaused(step2); | |
50 } | |
51 | |
52 function promiseUpdated(event) | |
53 { | |
54 var promiseId = event.data.promise.id; | |
55 minPromiseId = Math.min(minPromiseId, promiseId) || promiseId; | |
56 events.push(event.data); | |
57 } | |
58 | |
59 function step2() | |
60 { | |
61 outputResults(); | |
62 InspectorTest.DebuggerAgent.disablePromiseTracker(); | |
63 InspectorTest.completeDebuggerTest(); | |
64 } | |
65 | |
66 function outputResults() | |
67 { | |
68 var output = []; | |
69 for (var i = 0; i < events.length; i++) { | |
70 var eventType = events[i].eventType; | |
71 var promise = events[i].promise; | |
72 var outputItem = [ | |
73 eventType + ":", | |
74 "id: " + (promise.id - minPromiseId) | |
75 ]; | |
76 switch (eventType) { | |
77 case "new": | |
78 var callFrame = promise.callFrame; | |
79 if (callFrame) { | |
80 var url = WebInspector.displayNameForURL(callFrame.url); | |
81 outputItem.push(callFrame.functionName + " " + url + ":" + c
allFrame.lineNumber); | |
82 } | |
83 break; | |
84 case "update": | |
85 if (promise.status !== "pending") { | |
86 outputItem.push("status: " + promise.status) | |
87 var callFrame = promise.settlementStack && promise.settlemen
tStack[0]; | |
88 if (callFrame) { | |
89 var url = WebInspector.displayNameForURL(callFrame.url); | |
90 outputItem.push(callFrame.functionName + " " + url + ":"
+ callFrame.lineNumber); | |
91 } | |
92 } else { | |
93 outputItem.push("parent id: " + (promise.parentId - minPromi
seId)); | |
94 } | |
95 break; | |
96 } | |
97 output.push(outputItem.join("\n ")); | |
98 } | |
99 output.sort(); | |
100 InspectorTest.addResults(output); | |
101 } | |
102 } | |
103 | |
104 </script> | |
105 </head> | |
106 | |
107 <body onload="runTest()"> | |
108 <p> | |
109 Tests promise tracker events in debugger. | |
110 </p> | |
111 </body> | |
112 </html> | |
OLD | NEW |