Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / LayoutTests / inspector / sources / debugger / async-callstack-xhrs.html
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 xhrCount = 0;
8
9 function testFunction()
10 {
11     setTimeout(timeout, 0);
12 }
13
14 function timeout()
15 {
16     sendSyncXHR();
17     sendAsyncXHR();
18 }
19
20 function sendAsyncXHR() { sendXHR(true); }
21 function sendSyncXHR() { sendXHR(false); }
22
23 function sendXHR(async)
24 {
25     var xhr = new XMLHttpRequest();
26     xhr.onreadystatechange = function() 
27     {
28         if (xhr.readyState == 4) {
29             xhr.onreadystatechange = null;
30             debugger;
31         }
32     };
33     function downloadEnd1()
34     {
35         xhr.removeEventListener("loadend", downloadEnd1, false);
36         debugger;
37     }
38     function downloadEnd2()
39     {
40         xhr.removeEventListener("loadend", downloadEnd2, true);
41         debugger;
42     }
43     function uploadEnd()
44     {
45         xhr.upload.removeEventListener("loadend", uploadEnd, false);
46         debugger;
47     }
48     function downloadProgress()
49     {
50         debugger;
51         xhr.removeEventListener("progress", downloadProgress, false);
52     }
53     function uploadProgress()
54     {
55         debugger;
56         xhr.upload.removeEventListener("progress", uploadProgress, false);
57     }
58     xhr.addEventListener("loadend", downloadEnd1, false);
59     xhr.addEventListener("loadend", downloadEnd2, true);
60     if (async) {
61         xhr.upload.addEventListener("loadend", uploadEnd, false);
62         xhr.addEventListener("progress", downloadProgress, false);
63         xhr.upload.addEventListener("progress", uploadProgress, false);
64     }
65     xhr.open("POST", "/foo?count=" + (++xhrCount) + "&now=" + Date.now(), async);
66     xhr.send(String(sendXHR));
67 }
68
69 var test = function()
70 {
71     var totalDebuggerStatements = 9;
72     var maxAsyncCallStackDepth = 4;
73     InspectorTest.runAsyncCallStacksTest(totalDebuggerStatements, maxAsyncCallStackDepth);
74 }
75
76 </script>
77 </head>
78
79 <body onload="runTest()">
80 <p>
81 Tests asynchronous call stacks for XHRs.
82 </p>
83
84 </body>
85 </html>