3 <script src=
"../../../http/tests/inspector/inspector-test.js"></script>
4 <script src=
"../../../http/tests/inspector/debugger-test.js"></script>
7 function testFunction()
10 setTimeout(callback1
, 0);
15 setTimeout(callback2
, 0);
22 setTimeout(callback3
, 0);
23 // Pressing RESUME here, thus the following async promise events should not be reported to the front-end.
36 setTimeout(callback4
, 0);
46 function runIntervals()
48 setInterval(function f1() {}, 50);
49 setInterval(function f2() {}, 60);
50 setInterval(function f3() {}, 70);
55 var maxAsyncCallStackDepth
= 4;
56 InspectorTest
.startDebuggerTest(step1
, true);
60 InspectorTest
.runTestFunctionAndWaitUntilPaused(step2
);
65 InspectorTest
.debuggerModel
.addEventListener(WebInspector
.DebuggerModel
.Events
.AsyncOperationStarted
, onAsyncOperationStarted
);
66 InspectorTest
.debuggerModel
.addEventListener(WebInspector
.DebuggerModel
.Events
.AsyncOperationCompleted
, onAsyncOperationCompleted
);
67 InspectorTest
.DebuggerAgent
.setAsyncCallStackDepth(maxAsyncCallStackDepth
, step3
);
73 "StepOver", "StepOver", "StepOver", "Print", // @ callback1
74 "StepOver", "StepOver", "StepOver", "StepOver", "StepOver", "Print", // @ callback2
75 "StepOver", "StepOver", "Resume",
78 InspectorTest
.waitUntilPausedAndPerformSteppingActions(actions
, step4
);
81 var asyncOperations
= {};
82 var setIntervalEventCount
= 3;
83 var noAsyncOperationsCallback
= null;
85 function onAsyncOperationStarted(event
)
87 var operation
= event
.data
;
88 var description
= asyncOperationDescription(operation
);
89 asyncOperations
[operation
.id
] = description
;
90 InspectorTest
.addResult("==> AsyncOperationStarted: " + description
);
92 if (description
.indexOf("runIntervals") !== -1) {
93 if (!--setIntervalEventCount
)
94 InspectorTest
.completeDebuggerTest();
98 function onAsyncOperationCompleted(event
)
100 var operationId
= event
.data
;
101 InspectorTest
.addResult("==> AsyncOperationCompleted: " + asyncOperations
[operationId
]);
102 delete asyncOperations
[operationId
];
103 maybeRunNoAsyncOperationsCallback();
106 function asyncOperationDescription(operation
)
109 var callFrame
= operation
.stackTrace
&& operation
.stackTrace
[0];
111 var url
= WebInspector
.displayNameForURL(callFrame
.url
);
112 link
= " " + callFrame
.functionName
+ " @ " + url
+ ":" + callFrame
.lineNumber
;
114 return ("[" + operation
.description
+ "]" + link
);
117 function maybeRunNoAsyncOperationsCallback()
119 if (!noAsyncOperationsCallback
)
121 for (var id
in asyncOperations
)
123 var callback
= noAsyncOperationsCallback
;
124 noAsyncOperationsCallback
= null;
130 noAsyncOperationsCallback
= step5
;
131 maybeRunNoAsyncOperationsCallback();
136 InspectorTest
.addResult("Scheduling few setInterval's...");
137 InspectorTest
.evaluateInPage("runIntervals()", step6
);
142 InspectorTest
.addResult("All setInterval's were scheduled.");
143 InspectorTest
.addResult("Requesting all pending AsyncOperation events from backend...");
144 InspectorTest
.DebuggerAgent
.flushAsyncOperationEvents();
152 <body onload=
"runTest()">
154 Tests debugger AsyncOperation events while in a debugger stepping session.