summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/LayoutTests/inspector/debugger/async-callstack-xhrs.html
blob: 50580462e53777c3d2f4b8d02097300510081022 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
<html>
<head>
<script src="../../http/tests/inspector/inspector-test.js"></script>
<script src="../../http/tests/inspector/debugger-test.js"></script>
<script>

var xhrCount = 0;

function testFunction()
{
    setTimeout(timeout, 0);
}

function timeout()
{
    sendSyncXHR();
    sendAsyncXHR();
}

function sendAsyncXHR() { sendXHR(true); }
function sendSyncXHR() { sendXHR(false); }

function sendXHR(async)
{
    var xhr = new XMLHttpRequest();
    xhr.onreadystatechange = function() 
    {
        if (xhr.readyState == 4) {
            xhr.onreadystatechange = null;
            debugger;
        }
    };
    function downloadEnd()
    {
        xhr.removeEventListener("loadend", downloadEnd, false);
        debugger;
    }
    function uploadEnd()
    {
        xhr.upload.removeEventListener("loadend", uploadEnd, false);
        debugger;
    }
    function downloadProgress()
    {
        debugger;
        xhr.removeEventListener("progress", downloadProgress, false);
    }
    function uploadProgress()
    {
        debugger;
        xhr.upload.removeEventListener("progress", uploadProgress, false);
    }
    xhr.addEventListener("loadend", downloadEnd, false);
    if (async) {
        xhr.upload.addEventListener("loadend", uploadEnd, false);
        xhr.addEventListener("progress", downloadProgress, false);
        xhr.upload.addEventListener("progress", uploadProgress, false);
    }
    xhr.open("POST", "/foo?count=" + (++xhrCount) + "&now=" + Date.now(), async);
    xhr.send(String(sendXHR));
}

var test = function()
{
    var totalDebuggerStatements = 7;
    var maxAsyncCallStackDepth = 4;
    InspectorTest.runAsyncCallStacksTest(totalDebuggerStatements, maxAsyncCallStackDepth);
}

</script>
</head>

<body onload="runTest()">
<p>
Tests asynchronous call stacks for XHRs.
</p>

</body>
</html>