3 <script src=
"../../../http/tests/inspector/inspector-test.js"></script>
4 <script src=
"../../../http/tests/inspector/debugger-test.js"></script>
7 function makeClosure(n
, callback
, withScope
)
9 var makeClosureLocalVar
= 'local.' + n
;
10 return function innerFunction(x
) {
11 var innerFunctionLocalVar
= x
+ 2;
13 throw new Error("An exception");
24 return n
+ makeClosureLocalVar
+ x
+ innerFunctionLocalVar
;
28 function testFunction()
31 setTimeout(timeout1
, delay1
);
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);
47 var localInTimeout2
= "timeout2";
48 function innerTimeout2()
50 var localInInnerTimeout2
= "innerTimeout2";
53 makeClosure(2, innerTimeout2
, { foo
: "bar2", __proto__
: null })(200);
58 var maxAsyncCallStackDepth
= 4;
60 InspectorTest
.setQuiet(true);
61 InspectorTest
.startDebuggerTest(step1
);
65 InspectorTest
.DebuggerAgent
.setAsyncCallStackDepth(maxAsyncCallStackDepth
, step2
);
70 InspectorTest
.runTestFunctionAndWaitUntilPaused(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");
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());
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
)
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
);
111 InspectorTest
.completeDebuggerTest();
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.