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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
|
<html>
<head>
<script src="../../http/tests/inspector/inspector-test.js"></script>
<script src="../../http/tests/inspector/debugger-test.js"></script>
<script>
function testFunction()
{
function innerTestFunction()
{
timeout1();
}
setTimeout(innerTestFunction, 0);
document.getElementById("image").addEventListener("error", imageErrorHandler, false);
}
function timeout1()
{
debugger;
requestAnimationFrame(animFrame1);
var id = setInterval(innerInterval1, 0);
function innerInterval1()
{
clearInterval(id);
interval1();
}
}
function animFrame1()
{
debugger;
setTimeout(timeout2, 0);
requestAnimationFrame(animFrame2);
}
function interval1()
{
debugger;
}
function timeout2()
{
debugger;
}
function animFrame2()
{
document.getElementById("image").addEventListener("error", imageErrorHandler, true);
document.getElementById("image").addEventListener("click", imageClickHandlerSync, true);
debugger;
function longTail0()
{
timeout3();
}
var funcs = [];
for (var i = 0; i < 20; ++i)
funcs.push("function longTail" + (i + 1) + "() { setTimeout(longTail" + i + ", 0); };");
funcs.push("setTimeout(longTail" + i + ", 0);");
eval(funcs.join("\n"));
}
function timeout3()
{
debugger;
image.src = "non_existing.png";
image.click();
}
function imageErrorHandler()
{
debugger; // should hit 3 times with different async stacks
}
function imageClickHandlerSync()
{
debugger; // synchronous call => should have same async call chain as for timeout3()
}
var test = function()
{
var totalDebuggerStatements = 10;
var maxAsyncCallStackDepth = 4;
InspectorTest.runAsyncCallStacksTest(totalDebuggerStatements, maxAsyncCallStackDepth);
}
</script>
</head>
<body onload="runTest()">
<p>
Tests asynchronous call stacks in debugger.
</p>
<img id="image" onerror="imageErrorHandler()"></img>
</body>
</html>
|