Upstream version 5.34.98.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / LayoutTests / inspector / debugger / async-callstack.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 function testFunction()
8 {
9     function innerTestFunction()
10     {
11         timeout1();
12     }
13     setTimeout(innerTestFunction, 0);
14     document.getElementById("image").addEventListener("error", imageErrorHandler, false);
15 }
16
17 function timeout1()
18 {
19     debugger;
20     requestAnimationFrame(animFrame1);
21     var id = setInterval(innerInterval1, 0);
22     function innerInterval1()
23     {
24         clearInterval(id);
25         interval1();
26     }
27 }
28
29 function animFrame1()
30 {
31     debugger;
32     setTimeout(timeout2, 0);
33     requestAnimationFrame(animFrame2);
34 }
35
36 function interval1()
37 {
38     debugger;
39 }
40
41 function timeout2()
42 {
43     debugger;
44 }
45
46 function animFrame2()
47 {
48     document.getElementById("image").addEventListener("error", imageErrorHandler, true);
49     document.getElementById("image").addEventListener("click", imageClickHandlerSync, true);
50     debugger;
51     function longTail0()
52     {
53         timeout3();
54     }
55     var funcs = [];
56     for (var i = 0; i < 20; ++i)
57         funcs.push("function longTail" + (i + 1) + "() { setTimeout(longTail" + i + ", 0); };");
58     funcs.push("setTimeout(longTail" + i + ", 0);");
59     eval(funcs.join("\n"));
60 }
61
62 function timeout3()
63 {
64     debugger;
65     image.src = "non_existing.png";
66     image.click();
67 }
68
69 function imageErrorHandler()
70 {
71     debugger; // should hit 3 times with different async stacks
72 }
73
74 function imageClickHandlerSync()
75 {
76     debugger; // synchronous call => should have same async call chain as for timeout3()
77 }
78
79 var test = function()
80 {
81     var totalDebuggerStatements = 10;
82     var maxAsyncCallStackDepth = 4;
83     InspectorTest.runAsyncCallStacksTest(totalDebuggerStatements, maxAsyncCallStackDepth);
84 }
85
86 </script>
87 </head>
88
89 <body onload="runTest()">
90 <p>
91 Tests asynchronous call stacks in debugger.
92 </p>
93 <img id="image" onerror="imageErrorHandler()"></img>
94
95 </body>
96 </html>