Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(549)

Side by Side Diff: LayoutTests/inspector/debugger/async-callstack-middle-run.html

Issue 118293002: DevTools: Support XHR async call stacks in the debugger. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: addressed Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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 var images = [ document.createElement("img"), document.createElement("img"), doc ument.createElement("img"), document.createElement("img") ];
8
9 function testFunction()
10 {
11 setTimeout(timeoutOffCapturing, 0);
12 }
13
14 function timeoutOffCapturing()
15 {
16 images[0].addEventListener("click", clickedOffCapturing, false);
17 images[2].addEventListener("click", clickedOffCapturing, false);
18 images[0].addEventListener("error", imageErrorOffCapturing, false);
19 images[2].addEventListener("error", imageErrorOffCapturing, false);
20 debugger; // Will start capturing async stacks from this point.
21 setTimeout(timeoutOnCapturing, 0);
22 }
23
24 function timeoutOnCapturing()
25 {
26 debugger;
27 images[1].addEventListener("click", clickedOnCapturing, false);
28 images[3].addEventListener("click", clickedOnCapturing, false);
29 images[1].addEventListener("error", imageErrorOnCapturing, false);
30 images[3].addEventListener("error", imageErrorOnCapturing, false);
31
32 images[0].click();
33 images[1].click();
34
35 setImageNonExistingSrc(0);
36 }
37
38 function clickedOffCapturing(e) { onClick(e.target); }
39 function clickedOnCapturing(e) { onClick(e.target); }
40
41 function onClick(img)
42 {
43 var index = images.indexOf(img);
44 switch (index) {
45 case 0:
46 images[1].click();
47 break;
48 case 1:
49 images[2].click();
50 break;
51 case 2:
52 images[3].click();
53 break;
54 case 3:
55 debugger;
56 break;
57 }
58 }
59
60 function imageErrorOffCapturing(e) { onImageError(e.target); }
61 function imageErrorOnCapturing(e) { onImageError(e.target); }
62
63 var imageErrorsCount = 0;
64 function onImageError(img)
65 {
66 var index = images.indexOf(img);
67 switch (index) {
68 case 0:
69 setImageNonExistingSrc(1);
70 break;
71 case 1:
72 setImageNonExistingSrc(2);
73 break;
74 case 2:
75 setImageNonExistingSrc(3);
76 debugger;
77 break;
78 case 3:
79 debugger;
80 break;
81 }
82 }
83
84 function setImageNonExistingSrc(imgIndex)
85 {
86 images[imgIndex].src = "/non_existing.png?count=" + (++imageErrorsCount) + " &now=" + Date.now();
87 }
88
89 var test = function()
90 {
91 var totalDebuggerStatements = 6;
92 var maxAsyncCallStackDepth = 4;
93
94 InspectorTest.setQuiet(true);
95 InspectorTest.startDebuggerTest(step1);
96
97 function step1()
98 {
99 DebuggerAgent.setAsyncCallStackDepth(0, step2);
100 }
101
102 function step2()
103 {
104 InspectorTest.runTestFunctionAndWaitUntilPaused(didPaused);
105 }
106
107 function resumeExecution()
108 {
109 InspectorTest.resumeExecution(InspectorTest.waitUntilPaused.bind(Inspect orTest, didPaused));
110 }
111
112 var step = 0;
113 var callStacksOutput = [];
114 function didPaused(callFrames, reason, breakpointIds, asyncStackTrace)
115 {
116 ++step;
117 if (step === 1) {
118 DebuggerAgent.setAsyncCallStackDepth(maxAsyncCallStackDepth, resumeE xecution);
119 return;
120 }
121
122 callStacksOutput.push(InspectorTest.captureStackTraceIntoString(callFram es, asyncStackTrace) + "\n");
123 if (step < totalDebuggerStatements) {
124 resumeExecution();
125 } else {
126 InspectorTest.addResult("Captured call stacks in no particular order :");
127 callStacksOutput.sort();
128 InspectorTest.addResults(callStacksOutput);
129 InspectorTest.completeDebuggerTest();
130 }
131 }
132 }
133
134 </script>
135 </head>
136
137 <body onload="runTest()">
138 <p>
139 Tests that capturing asynchronous call stacks in debugger works if started after some time since the page loads.
140 </p>
141
142 </body>
143 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698