| 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 src="resources/framework.js"></script> | |
| 6 <script> | |
| 7 | |
| 8 var dummy = function FAIL_should_not_pause_here() { return 0; }; | |
| 9 | |
| 10 function testFunction() | |
| 11 { | |
| 12 debugger; | |
| 13 | |
| 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); | |
| 20 | |
| 21 debugger; // Stop the debugger to receive pending AsyncOperation events. | |
| 22 } | |
| 23 | |
| 24 function callback1() | |
| 25 { | |
| 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; | |
| 32 } | |
| 33 | |
| 34 function callback2() | |
| 35 { | |
| 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; | |
| 44 } | |
| 45 | |
| 46 function callback3() | |
| 47 { | |
| 48 return 3; | |
| 49 } | |
| 50 | |
| 51 function test() | |
| 52 { | |
| 53 var maxAsyncCallStackDepth = 4; | |
| 54 var frameworkRegexString = "/framework\\.js$"; | |
| 55 WebInspector.settingForTest("skipStackFramesPattern").set(frameworkRegexStri
ng); | |
| 56 | |
| 57 InspectorTest.startDebuggerTest(step1, true); | |
| 58 | |
| 59 function step1() | |
| 60 { | |
| 61 InspectorTest.runTestFunctionAndWaitUntilPaused(step2); | |
| 62 } | |
| 63 | |
| 64 function step2() | |
| 65 { | |
| 66 InspectorTest.debuggerModel.addEventListener(WebInspector.DebuggerModel.
Events.AsyncOperationStarted, onAsyncOperationStarted); | |
| 67 InspectorTest.DebuggerAgent.setAsyncCallStackDepth(maxAsyncCallStackDept
h, step3); | |
| 68 } | |
| 69 | |
| 70 function step3() | |
| 71 { | |
| 72 var callbackFuncCount = 3; | |
| 73 iterate(); | |
| 74 | |
| 75 function iterate() | |
| 76 { | |
| 77 if (!callbackFuncCount--) { | |
| 78 InspectorTest.completeDebuggerTest(); | |
| 79 return; | |
| 80 } | |
| 81 InspectorTest.waitUntilPausedAndPerformSteppingActions(["Resume", "R
esume"], InspectorTest.waitUntilPaused.bind(InspectorTest, didPause)); | |
| 82 } | |
| 83 | |
| 84 function didPause(callFrames, reason, breakpointIds, asyncStackTrace) | |
| 85 { | |
| 86 InspectorTest.captureStackTrace(callFrames); | |
| 87 InspectorTest.addResult("Pause reason: " + reason); | |
| 88 iterate(); | |
| 89 } | |
| 90 } | |
| 91 | |
| 92 function onAsyncOperationStarted(event) | |
| 93 { | |
| 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(operatio
n.id); | |
| 100 break; | |
| 101 } | |
| 102 } | |
| 103 } | |
| 104 } | |
| 105 | |
| 106 </script> | |
| 107 </head> | |
| 108 | |
| 109 <body onload="runTest()"> | |
| 110 <p> | |
| 111 Tests AsyncOperation breakpoints. | |
| 112 </p> | |
| 113 </body> | |
| 114 </html> | |
| OLD | NEW |