Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / LayoutTests / inspector / sources / debugger / debugger-expand-scope.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 makeClosure(n) {
8   var makeClosureLocalVar = 'local.' + n;
9   return function innerFunction(x) {
10     var innerFunctionLocalVar = x + 2;
11     var negInf = -Infinity;
12     var negZero = 1 / negInf;
13     try {
14       throw new Error("An exception");
15     } catch (e) {
16       e.toString();
17       debugger;
18     }
19     return n + makeClosureLocalVar + x + innerFunctionLocalVar;
20   }
21 }
22
23 function testFunction() {
24   var f = makeClosure('TextParam');
25   f(2010);
26 }
27
28
29 function test()
30 {
31     var scriptToEvaluate = "setTimeout(testFunction, 0)";
32
33     InspectorTest.startDebuggerTest(step1);
34
35     function step1()
36     {
37         InspectorTest.evaluateInPage(scriptToEvaluate, InspectorTest.addResult.bind(InspectorTest, "Evaluated script in console."));
38         InspectorTest.waitUntilPaused(step2);
39     }
40
41     function step2()
42     {
43         // Expand all but global scopes. Expanding global scope takes for too long
44         // so we keep it collapsed.
45         var sections = WebInspector.inspectorView.currentPanel().sidebarPanes.scopechain._sections;
46         // global scope is always the last one.
47         for (var i = 0; i < sections.length - 1; i++)
48             sections[i].expand();
49         InspectorTest.runAfterPendingDispatches(step3);
50     }
51
52     function step3()
53     {
54     
55         var sections = WebInspector.inspectorView.currentPanel().sidebarPanes.scopechain._sections;
56         InspectorTest.addResult("");
57         InspectorTest.addResult("Dump scope sections:");
58         for (var i = 0; i < sections.length; i++) {
59             var section = sections[i];
60             var properties = section.propertiesForTest;
61             InspectorTest.addResult(InspectorTest.textContentWithLineBreaks(section.element));
62             if (!section.expanded)
63                 InspectorTest.addResult("    <section collapsed>");
64         }
65         InspectorTest.completeDebuggerTest();
66     }
67 }
68
69 </script>
70 </head>
71
72 <body onload="runTest()">
73 <input type='button' onclick='testFunction()' value='Test'/>
74 <p>
75 Test that sections representing scopes of the current call frame are expandable
76 and contain correct data.
77 </p>
78 </body>
79 </html>