Index: LayoutTests/inspector/debugger/async-callstack-middle-run.html |
diff --git a/LayoutTests/inspector/debugger/async-callstack-middle-run.html b/LayoutTests/inspector/debugger/async-callstack-middle-run.html |
new file mode 100644 |
index 0000000000000000000000000000000000000000..2e0d3776f32cf2870034850212f97602282ac69f |
--- /dev/null |
+++ b/LayoutTests/inspector/debugger/async-callstack-middle-run.html |
@@ -0,0 +1,143 @@ |
+<html> |
+<head> |
+<script src="../../http/tests/inspector/inspector-test.js"></script> |
+<script src="../../http/tests/inspector/debugger-test.js"></script> |
+<script> |
+ |
+var images = [ document.createElement("img"), document.createElement("img"), document.createElement("img"), document.createElement("img") ]; |
+ |
+function testFunction() |
+{ |
+ setTimeout(timeoutOffCapturing, 0); |
+} |
+ |
+function timeoutOffCapturing() |
+{ |
+ images[0].addEventListener("click", clickedOffCapturing, false); |
+ images[2].addEventListener("click", clickedOffCapturing, false); |
+ images[0].addEventListener("error", imageErrorOffCapturing, false); |
+ images[2].addEventListener("error", imageErrorOffCapturing, false); |
+ debugger; // Will start capturing async stacks from this point. |
+ setTimeout(timeoutOnCapturing, 0); |
+} |
+ |
+function timeoutOnCapturing() |
+{ |
+ debugger; |
+ images[1].addEventListener("click", clickedOnCapturing, false); |
+ images[3].addEventListener("click", clickedOnCapturing, false); |
+ images[1].addEventListener("error", imageErrorOnCapturing, false); |
+ images[3].addEventListener("error", imageErrorOnCapturing, false); |
+ |
+ images[0].click(); |
+ images[1].click(); |
+ |
+ setImageNonExistingSrc(0); |
+} |
+ |
+function clickedOffCapturing(e) { onClick(e.target); } |
+function clickedOnCapturing(e) { onClick(e.target); } |
+ |
+function onClick(img) |
+{ |
+ var index = images.indexOf(img); |
+ switch (index) { |
+ case 0: |
+ images[1].click(); |
+ break; |
+ case 1: |
+ images[2].click(); |
+ break; |
+ case 2: |
+ images[3].click(); |
+ break; |
+ case 3: |
+ debugger; |
+ break; |
+ } |
+} |
+ |
+function imageErrorOffCapturing(e) { onImageError(e.target); } |
+function imageErrorOnCapturing(e) { onImageError(e.target); } |
+ |
+var imageErrorsCount = 0; |
+function onImageError(img) |
+{ |
+ var index = images.indexOf(img); |
+ switch (index) { |
+ case 0: |
+ setImageNonExistingSrc(1); |
+ break; |
+ case 1: |
+ setImageNonExistingSrc(2); |
+ break; |
+ case 2: |
+ setImageNonExistingSrc(3); |
+ debugger; |
+ break; |
+ case 3: |
+ debugger; |
+ break; |
+ } |
+} |
+ |
+function setImageNonExistingSrc(imgIndex) |
+{ |
+ images[imgIndex].src = "/non_existing.png?count=" + (++imageErrorsCount) + "&now=" + Date.now(); |
+} |
+ |
+var test = function() |
+{ |
+ var totalDebuggerStatements = 6; |
+ var maxAsyncCallStackDepth = 4; |
+ |
+ InspectorTest.setQuiet(true); |
+ InspectorTest.startDebuggerTest(step1); |
+ |
+ function step1() |
+ { |
+ DebuggerAgent.setAsyncCallStackDepth(0, step2); |
+ } |
+ |
+ function step2() |
+ { |
+ InspectorTest.runTestFunctionAndWaitUntilPaused(didPaused); |
+ } |
+ |
+ function resumeExecution() |
+ { |
+ InspectorTest.resumeExecution(InspectorTest.waitUntilPaused.bind(InspectorTest, didPaused)); |
+ } |
+ |
+ var step = 0; |
+ var callStacksOutput = []; |
+ function didPaused(callFrames, reason, breakpointIds, asyncStackTrace) |
+ { |
+ ++step; |
+ if (step === 1) { |
+ DebuggerAgent.setAsyncCallStackDepth(maxAsyncCallStackDepth, resumeExecution); |
+ return; |
+ } |
+ |
+ callStacksOutput.push(InspectorTest.captureStackTraceIntoString(callFrames, asyncStackTrace) + "\n"); |
+ if (step < totalDebuggerStatements) { |
+ resumeExecution(); |
+ } else { |
+ InspectorTest.addResult("Captured call stacks in no particular order:"); |
+ callStacksOutput.sort(); |
+ InspectorTest.addResults(callStacksOutput); |
+ InspectorTest.completeDebuggerTest(); |
+ } |
+ } |
+} |
+ |
+</script> |
+</head> |
+ |
+<body onload="runTest()"> |
+<p> |
+Tests that capturing asynchronous call stacks in debugger works if started after some time since the page loads. |
+</p> |
+ |
+</body> |
+</html> |