Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / LayoutTests / http / tests / inspector / sources / debugger / async-callstack-network-initiator.html
1 <html>
2 <head>
3 <script src="/inspector/inspector-test.js"></script>
4 <script src="/inspector/debugger-test.js"></script>
5 <script src="/inspector/console-test.js"></script>
6 <script>
7
8 function testFunction()
9 {
10     debugger;
11     console.clear();
12     setTimeout(timeout1, 0);
13 }
14
15 function timeout1()
16 {
17     setTimeout(timeout2, 0);
18 }
19
20 function timeout2()
21 {
22     sendXHR();
23 }
24
25 function sendXHR()
26 {
27     var xhr = new XMLHttpRequest();
28     xhr.open("POST", "/failure/foo", true /* async */);
29     xhr.send();
30 }
31
32 var test = function()
33 {
34     var maxAsyncCallStackDepth = 4;
35     var numberOfConsoleMessages = 2;
36
37     InspectorTest.setQuiet(true);
38     InspectorTest.startDebuggerTest(step1);
39
40     function step1()
41     {
42         DebuggerAgent.setPauseOnExceptions(WebInspector.DebuggerModel.PauseOnExceptionsState.DontPauseOnExceptions);
43         DebuggerAgent.setAsyncCallStackDepth(0);
44         InspectorTest.runTestFunctionAndWaitUntilPaused(step2);
45     }
46
47     function step2()
48     {
49         DebuggerAgent.setAsyncCallStackDepth(maxAsyncCallStackDepth, didPause);
50     }
51
52     function didPause()
53     {
54         InspectorTest.waitUntilNthMessageReceived(numberOfConsoleMessages, expandAndDumpConsoleMessages);
55         InspectorTest.resumeExecution();
56     }
57
58     function expandAndDumpConsoleMessages()
59     {
60         InspectorTest.expandConsoleMessages(dumpConsoleMessages);
61     }
62
63     function dumpConsoleMessages()
64     {
65         InspectorTest.dumpConsoleMessages(false, false, InspectorTest.textContentWithLineBreaks);
66         InspectorTest.completeDebuggerTest();
67     }
68 }
69
70 </script>
71 </head>
72
73 <body onload="runTest()">
74 <p>
75 Tests asynchronous call stacks printed in console for a Network.Initiator.
76 </p>
77 </body>
78 </html>