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 setTimeout(timeout, 0); | |
10 } | |
11 | |
12 function timeout() | |
13 { | |
14 sendSyncXHR(); | |
15 sendAsyncXHR(); | |
16 } | |
17 | |
18 function sendAsyncXHR() { sendXHR(true); } | |
19 function sendSyncXHR() { sendXHR(false); } | |
20 | |
21 function sendXHR(async) | |
22 { | |
23 var count = sendXHR.__count = (sendXHR.__count || 0) + 1; | |
yurys
2013/12/23 09:11:57
Why not simply put count into the global scope, or
aandrey
2013/12/23 12:09:38
Done.
| |
24 var xhr = new XMLHttpRequest(); | |
25 xhr.onreadystatechange = function() | |
26 { | |
27 if (xhr.readyState == 4) { | |
28 xhr.onreadystatechange = null; | |
29 debugger; | |
30 } | |
31 }; | |
32 function downloadEnd() | |
33 { | |
34 xhr.removeEventListener("loadend", downloadEnd, false); | |
35 debugger; | |
36 } | |
37 function uploadEnd() | |
38 { | |
39 xhr.upload.removeEventListener("loadend", uploadEnd, false); | |
40 debugger; | |
41 } | |
42 function downloadProgress() | |
43 { | |
44 debugger; | |
45 xhr.removeEventListener("progress", downloadProgress, false); | |
46 } | |
47 function uploadProgress() | |
48 { | |
49 debugger; | |
50 xhr.upload.removeEventListener("progress", uploadProgress, false); | |
51 } | |
52 xhr.addEventListener("loadend", downloadEnd, false); | |
53 if (async) { | |
54 xhr.upload.addEventListener("loadend", uploadEnd, false); | |
55 xhr.addEventListener("progress", downloadProgress, false); | |
56 xhr.upload.addEventListener("progress", uploadProgress, false); | |
57 } | |
58 xhr.open("POST", "/foo?count=" + count + "&now=" + Date.now(), async); | |
59 xhr.send(String(sendXHR)); | |
60 } | |
61 | |
62 var test = function() | |
63 { | |
64 var totalDebuggerStatements = 7; | |
65 InspectorTest.runAsyncCallStacksTest(totalDebuggerStatements); | |
66 } | |
67 | |
68 </script> | |
69 </head> | |
70 | |
71 <body onload="runTest()"> | |
72 <p> | |
73 Tests asynchronous call stacks for XHRs. | |
74 </p> | |
75 | |
76 </body> | |
77 </html> | |
OLD | NEW |