3 <script src=
"../../../http/tests/inspector/inspector-test.js"></script>
4 <script src=
"../../../http/tests/inspector/debugger-test.js"></script>
7 function testFunction()
9 var promise1
= new Promise(
10 function promiseConstructor1(resolve
, reject
)
15 var promise2
= new Promise(
16 function promiseConstructor2(resolve
, reject
)
22 .then(thenCallback1
, thenCallback1
)
26 function thenCallback1()
31 function thenCallback2()
33 if (window
.GCController
)
34 GCController
.collectAll();
43 InspectorTest
.startDebuggerTest(step1
, true);
47 InspectorTest
.DebuggerAgent
.enablePromiseTracker(true);
48 InspectorTest
.debuggerModel
.addEventListener(WebInspector
.DebuggerModel
.Events
.PromiseUpdated
, promiseUpdated
);
49 InspectorTest
.runTestFunctionAndWaitUntilPaused(step2
);
52 function promiseUpdated(event
)
54 var promiseId
= event
.data
.promise
.id
;
55 minPromiseId
= Math
.min(minPromiseId
, promiseId
) || promiseId
;
56 events
.push(event
.data
);
62 InspectorTest
.DebuggerAgent
.disablePromiseTracker();
63 InspectorTest
.completeDebuggerTest();
66 function outputResults()
69 for (var i
= 0; i
< events
.length
; i
++) {
70 var eventType
= events
[i
].eventType
;
71 var promise
= events
[i
].promise
;
74 "id: " + (promise
.id
- minPromiseId
)
78 var callFrame
= promise
.callFrame
;
80 var url
= WebInspector
.displayNameForURL(callFrame
.url
);
81 outputItem
.push(callFrame
.functionName
+ " " + url
+ ":" + callFrame
.lineNumber
);
85 if (promise
.status
!== "pending") {
86 outputItem
.push("status: " + promise
.status
)
87 var callFrame
= promise
.settlementStack
&& promise
.settlementStack
[0];
89 var url
= WebInspector
.displayNameForURL(callFrame
.url
);
90 outputItem
.push(callFrame
.functionName
+ " " + url
+ ":" + callFrame
.lineNumber
);
93 outputItem
.push("parent id: " + (promise
.parentId
- minPromiseId
));
97 output
.push(outputItem
.join("\n "));
100 InspectorTest
.addResults(output
);
107 <body onload=
"runTest()">
109 Tests promise tracker events in debugger.