Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / inspector / sources / debugger-async / async-operation-breakpoints.html
blob03886d65f9c4c2a9bfc7ba0cc63b3519a5b60797
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 src="../debugger/resources/framework.js"></script>
6 <script>
8 var dummy = function FAIL_should_not_pause_here() { return 0; };
10 function testFunction()
12 debugger;
14 setTimeout(dummy, 0);
15 setTimeout(dummy, 30);
16 (function setAsyncBreakpointForMe() { setTimeout(callback1, 20); })();
17 setTimeout(dummy, 0);
18 Promise.resolve(42)
19 .then(dummy);
21 debugger; // Stop the debugger to receive pending AsyncOperation events.
24 function callback1()
26 var func = setTimeout.bind(null, callback2, 0);
27 func = setTimeout.bind(null, func, 0);
28 func = setTimeout.bind(null, func, 0);
29 (function setAsyncBreakpointForMe() { setTimeout(func); })();
30 debugger;
31 return 1;
34 function callback2()
36 var func = Framework.willSchedule(callback3);
37 func = Framework.willSchedule(func);
38 func = Framework.willSchedule(func);
39 (function setAsyncBreakpointForMe() { Framework.schedule(func); })();
40 debugger;
41 Promise.resolve().then(dummy).then(dummy).then(dummy);
42 setTimeout(dummy, 0);
43 return 2;
46 function callback3()
48 return 3;
51 function test()
53 var maxAsyncCallStackDepth = 4;
54 var frameworkRegexString = "/framework\\.js$";
55 WebInspector.settingForTest("skipStackFramesPattern").set(frameworkRegexString);
57 InspectorTest.startDebuggerTest(step1, true);
59 function step1()
61 InspectorTest.runTestFunctionAndWaitUntilPaused(step2);
64 function step2()
66 InspectorTest.debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.AsyncOperationStarted, onAsyncOperationStarted);
67 InspectorTest.DebuggerAgent.setAsyncCallStackDepth(maxAsyncCallStackDepth, step3);
70 function step3()
72 var callbackFuncCount = 3;
73 iterate();
75 function iterate()
77 if (!callbackFuncCount--) {
78 InspectorTest.completeDebuggerTest();
79 return;
81 InspectorTest.waitUntilPausedAndPerformSteppingActions(["Resume", "Resume"], InspectorTest.waitUntilPaused.bind(InspectorTest, didPause));
84 function didPause(callFrames, reason, breakpointIds, asyncStackTrace)
86 InspectorTest.captureStackTrace(callFrames);
87 InspectorTest.addResult("Pause reason: " + reason);
88 iterate();
92 function onAsyncOperationStarted(event)
94 var operation = event.data;
95 var callFrames = operation.stackTrace || [];
96 for (var callFrame of callFrames) {
97 var functionName = callFrame && callFrame.functionName;
98 if (functionName === "setAsyncBreakpointForMe") {
99 InspectorTest.DebuggerAgent.setAsyncOperationBreakpoint(operation.id);
100 break;
106 </script>
107 </head>
109 <body onload="runTest()">
111 Tests AsyncOperation breakpoints.
112 </p>
113 </body>
114 </html>