| 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 debugger; | |
| 10 setTimeout(callback1, 0); | |
| 11 } | |
| 12 | |
| 13 function callback1() | |
| 14 { | |
| 15 setTimeout(callback2, 0); | |
| 16 Promise.resolve(42) | |
| 17 .then(function() {}); | |
| 18 } | |
| 19 | |
| 20 function callback2() | |
| 21 { | |
| 22 setTimeout(callback3, 0); | |
| 23 // Pressing RESUME here, thus the following async promise events should not
be reported to the front-end. | |
| 24 Promise.resolve(43) | |
| 25 .then(function() {}) | |
| 26 .then(function() {}); | |
| 27 } | |
| 28 | |
| 29 function callback3() | |
| 30 { | |
| 31 Promise.resolve(44) | |
| 32 .then(function() {}) | |
| 33 .then( | |
| 34 function() | |
| 35 { | |
| 36 setTimeout(callback4, 0); | |
| 37 } | |
| 38 ); | |
| 39 } | |
| 40 | |
| 41 function callback4() | |
| 42 { | |
| 43 debugger; | |
| 44 } | |
| 45 | |
| 46 function runIntervals() | |
| 47 { | |
| 48 setInterval(function f1() {}, 50); | |
| 49 setInterval(function f2() {}, 60); | |
| 50 setInterval(function f3() {}, 70); | |
| 51 } | |
| 52 | |
| 53 function test() | |
| 54 { | |
| 55 var maxAsyncCallStackDepth = 4; | |
| 56 InspectorTest.startDebuggerTest(step1, true); | |
| 57 | |
| 58 function step1() | |
| 59 { | |
| 60 InspectorTest.runTestFunctionAndWaitUntilPaused(step2); | |
| 61 } | |
| 62 | |
| 63 function step2() | |
| 64 { | |
| 65 InspectorTest.debuggerModel.addEventListener(WebInspector.DebuggerModel.
Events.AsyncOperationStarted, onAsyncOperationStarted); | |
| 66 InspectorTest.debuggerModel.addEventListener(WebInspector.DebuggerModel.
Events.AsyncOperationCompleted, onAsyncOperationCompleted); | |
| 67 InspectorTest.DebuggerAgent.setAsyncCallStackDepth(maxAsyncCallStackDept
h, step3); | |
| 68 } | |
| 69 | |
| 70 function step3() | |
| 71 { | |
| 72 var actions = [ | |
| 73 "StepOver", "StepOver", "StepOver", "Print", // @ callback1 | |
| 74 "StepOver", "StepOver", "StepOver", "StepOver", "StepOver", "Print",
// @ callback2 | |
| 75 "StepOver", "StepOver", "Resume", | |
| 76 "Resume", | |
| 77 ]; | |
| 78 InspectorTest.waitUntilPausedAndPerformSteppingActions(actions, step4); | |
| 79 } | |
| 80 | |
| 81 var asyncOperations = {}; | |
| 82 var setIntervalEventCount = 3; | |
| 83 var noAsyncOperationsCallback = null; | |
| 84 | |
| 85 function onAsyncOperationStarted(event) | |
| 86 { | |
| 87 var operation = event.data; | |
| 88 var description = asyncOperationDescription(operation); | |
| 89 asyncOperations[operation.id] = description; | |
| 90 InspectorTest.addResult("==> AsyncOperationStarted: " + description); | |
| 91 | |
| 92 if (description.indexOf("runIntervals") !== -1) { | |
| 93 if (!--setIntervalEventCount) | |
| 94 InspectorTest.completeDebuggerTest(); | |
| 95 } | |
| 96 } | |
| 97 | |
| 98 function onAsyncOperationCompleted(event) | |
| 99 { | |
| 100 var operationId = event.data; | |
| 101 InspectorTest.addResult("==> AsyncOperationCompleted: " + asyncOperation
s[operationId]); | |
| 102 delete asyncOperations[operationId]; | |
| 103 maybeRunNoAsyncOperationsCallback(); | |
| 104 } | |
| 105 | |
| 106 function asyncOperationDescription(operation) | |
| 107 { | |
| 108 var link = ""; | |
| 109 var callFrame = operation.stackTrace && operation.stackTrace[0]; | |
| 110 if (callFrame) { | |
| 111 var url = WebInspector.displayNameForURL(callFrame.url); | |
| 112 link = " " + callFrame.functionName + " @ " + url + ":" + callFrame.
lineNumber; | |
| 113 } | |
| 114 return ("[" + operation.description + "]" + link); | |
| 115 } | |
| 116 | |
| 117 function maybeRunNoAsyncOperationsCallback() | |
| 118 { | |
| 119 if (!noAsyncOperationsCallback) | |
| 120 return; | |
| 121 for (var id in asyncOperations) | |
| 122 return; | |
| 123 var callback = noAsyncOperationsCallback; | |
| 124 noAsyncOperationsCallback = null; | |
| 125 callback(); | |
| 126 } | |
| 127 | |
| 128 function step4() | |
| 129 { | |
| 130 noAsyncOperationsCallback = step5; | |
| 131 maybeRunNoAsyncOperationsCallback(); | |
| 132 } | |
| 133 | |
| 134 function step5() | |
| 135 { | |
| 136 InspectorTest.addResult("Scheduling few setInterval's..."); | |
| 137 InspectorTest.evaluateInPage("runIntervals()", step6); | |
| 138 } | |
| 139 | |
| 140 function step6() | |
| 141 { | |
| 142 InspectorTest.addResult("All setInterval's were scheduled."); | |
| 143 InspectorTest.addResult("Requesting all pending AsyncOperation events fr
om backend..."); | |
| 144 InspectorTest.DebuggerAgent.flushAsyncOperationEvents(); | |
| 145 } | |
| 146 | |
| 147 } | |
| 148 | |
| 149 </script> | |
| 150 </head> | |
| 151 | |
| 152 <body onload="runTest()"> | |
| 153 <p> | |
| 154 Tests debugger AsyncOperation events while in a debugger stepping session. | |
| 155 </p> | |
| 156 </body> | |
| 157 </html> | |
| OLD | NEW |