Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / LayoutTests / inspector / sources / debugger / async-callstack-in-console.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 src="../../../http/tests/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     console.trace();
18     setTimeout(timeout2, 0);
19 }
20
21 function timeout2()
22 {
23     setTimeout(timeout3, 0);
24     throw Error("foo");
25 }
26
27 function timeout3()
28 {
29     console.trace();
30     var iframeWidnow = document.getElementById("iframe").contentWindow;
31     tryPostMessage(iframeWidnow, "http://www.example.com");
32 }
33
34 function tryPostMessage(win, origin)
35 {
36     try {
37         win.postMessage("Trying origin=" + origin, origin);
38     } catch(ex) {
39         console.error("FAIL: Error sending message to " + origin + ". " + ex);
40     }
41 }
42
43 var test = function()
44 {
45     var maxAsyncCallStackDepth = 4;
46     var numberOfConsoleMessages = 5;
47
48     InspectorTest.setQuiet(true);
49     InspectorTest.startDebuggerTest(step1);
50
51     function step1()
52     {
53         DebuggerAgent.setPauseOnExceptions(WebInspector.DebuggerModel.PauseOnExceptionsState.DontPauseOnExceptions);
54         DebuggerAgent.setAsyncCallStackDepth(0);
55         InspectorTest.runTestFunctionAndWaitUntilPaused(step2);
56     }
57
58     function step2()
59     {
60         DebuggerAgent.setAsyncCallStackDepth(maxAsyncCallStackDepth, didPause);
61     }
62
63     function didPause()
64     {
65         InspectorTest.waitUntilNthMessageReceived(numberOfConsoleMessages, expandAndDumpConsoleMessages);
66         InspectorTest.resumeExecution();
67     }
68
69     function expandAndDumpConsoleMessages()
70     {
71         InspectorTest.expandConsoleMessages(dumpConsoleMessages);
72     }
73
74     function dumpConsoleMessages()
75     {
76         InspectorTest.dumpConsoleMessages(false, false, InspectorTest.textContentWithLineBreaks);
77         InspectorTest.completeDebuggerTest();
78     }
79 }
80
81 </script>
82 </head>
83
84 <body onload="runTest()">
85 <p>
86 Tests asynchronous call stacks printed in console.
87 </p>
88 <div><iframe src="resources/post-message-listener.html"
89     id="iframe" width="800" height="100" style="border: 1px solid black;">
90 </iframe></div>
91 </body>
92 </html>