Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / inspector / sources / debugger-async / async-callstack-scopes.html
blob1779e87e9769d3a6ade0336dc3c8f1cea893613c
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>
7 function makeClosure(n, callback, withScope)
9 var makeClosureLocalVar = 'local.' + n;
10 return function innerFunction(x) {
11 var innerFunctionLocalVar = x + 2;
12 try {
13 throw new Error("An exception");
14 } catch (e) {
15 e.toString();
16 if (withScope) {
17 with (withScope) {
18 callback();
20 } else {
21 callback();
24 return n + makeClosureLocalVar + x + innerFunctionLocalVar;
28 function testFunction()
30 var delay1 = 0;
31 setTimeout(timeout1, delay1);
34 function timeout1()
36 var localInTimeout1 = "timeout1";
37 function innerTimeout1()
39 var localInInnerTimeout1 = "innerTimeout1";
40 setTimeout(timeout2, Number(localInInnerTimeout1 + localInTimeout1) || 0);
42 makeClosure(1, innerTimeout1, { foo: "bar1", __proto__: null })(100);
45 function timeout2()
47 var localInTimeout2 = "timeout2";
48 function innerTimeout2()
50 var localInInnerTimeout2 = "innerTimeout2";
51 debugger;
53 makeClosure(2, innerTimeout2, { foo: "bar2", __proto__: null })(200);
56 function test()
58 var maxAsyncCallStackDepth = 4;
60 InspectorTest.setQuiet(true);
61 InspectorTest.startDebuggerTest(step1);
63 function step1()
65 InspectorTest.DebuggerAgent.setAsyncCallStackDepth(maxAsyncCallStackDepth, step2);
68 function step2()
70 InspectorTest.runTestFunctionAndWaitUntilPaused(didPause);
73 function didPause()
75 var callStackPane = WebInspector.panels.sources.sidebarPanes.callstack;
76 var scopeChainPane = WebInspector.panels.sources.sidebarPanes.scopechain;
77 InspectorTest.addResult("Dumping call frames with scope chains:\n");
78 printNextCallFrame();
80 function printNextCallFrame()
82 var index = callStackPane._selectedCallFrameIndex();
83 InspectorTest.assertGreaterOrEqual(index, 0);
84 var frame = callStackPane.callFrames[index];
85 InspectorTest.addResult((index + 1) + ") " + frame.title() + " " + frame.subtitle());
86 expandScopeChain();
89 function expandScopeChain()
91 // Expand all but global scopes. Expanding global scope takes too long
92 // so we keep it collapsed.
93 var sections = scopeChainPane._sections;
94 // global scope is always the last one.
95 for (var i = 0; i < sections.length - 1; ++i)
96 sections[i].expand();
97 InspectorTest.runAfterPendingDispatches(printScopeChain);
100 function printScopeChain()
102 InspectorTest.dumpScopeVariablesSidebarPane();
103 InspectorTest.addResult("");
105 // Dump up to the testFunction() - we don't care what was before.
106 var index = callStackPane._selectedCallFrameIndex();
107 var frame = callStackPane.callFrames[index];
108 if (frame.title() !== "testFunction" && callStackPane._selectNextCallFrameOnStack())
109 InspectorTest.runAfterPendingDispatches(printNextCallFrame);
110 else
111 InspectorTest.completeDebuggerTest();
116 </script>
117 </head>
119 <body onload="runTest()">
120 <input type='button' onclick='testFunction()' value='Test'/>
122 Test that sections representing scopes are expandable and contain correct data for async call frames.
123 </p>
124 </body>
125 </html>