Upstream version 5.34.104.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / LayoutTests / inspector / sources / debugger / watch-expressions-preserve-expansion.html
1 <html>
2 <head>
3 <script src="../../../http/tests/inspector/inspector-test.js"></script>
4 <script src="../../../http/tests/inspector/elements-test.js"></script>
5 <script src="../../../http/tests/inspector/debugger-test.js"></script>
6 <script>
7
8 var globalObject = {
9     foo: {
10         bar: {
11             baz: 2012
12         }
13     }
14 };
15 var windowAlias = window;
16
17 var test = function()
18 {
19     var watchExpressionsSection;
20
21     // We need to initialize sources panel so that watch expressions section is created.
22     WebInspector.showPanel("sources");
23     InspectorTest.startDebuggerTest(step1);
24
25     function step1()
26     {
27         var watchExpressionsPane = WebInspector.panels.sources.sidebarPanes.watchExpressions;
28         watchExpressionsPane.expand();
29
30         watchExpressionsSection = watchExpressionsPane.section;
31         watchExpressionsSection.watchExpressions = [];
32         watchExpressionsSection.watchExpressions.push("globalObject");
33         watchExpressionsSection.watchExpressions.push("windowAlias");
34
35         InspectorTest.addSniffer(WebInspector.WatchExpressionsSection.prototype, "updateProperties", step2);
36         watchExpressionsSection.update();
37     }
38
39     function expandProperty(parent, path, callback)
40     {
41         if (!path.length) return callback();
42         var childName = path.shift();
43         var child = InspectorTest._findChildPropertyTreeElement(parent, childName);
44         if (!child) {
45             InspectorTest.addResult("Child not found: " + childName);
46             InspectorTest.completeTest()
47             return;
48         }
49         InspectorTest.addResult("expanded " + childName + " " + child.property.value);
50         function afterGetOwnProperties() {
51             InspectorTest.runAfterPendingDispatches(expandProperty.bind(this, child, path, callback));
52         }
53         InspectorTest.addSniffer(child.property.value, "getOwnProperties", afterGetOwnProperties.bind(this));
54         child.expand();
55
56     }
57
58     function dumpObjectPropertiesTreeElement(treeElement, indent)
59     {
60         if (treeElement.property)
61             InspectorTest.addResult(indent + treeElement.property.name + ": " + treeElement.property.value._description);
62         for (var i = 0; i < treeElement.children.length; i++)
63             dumpObjectPropertiesTreeElement(treeElement.children[i], "  " + indent);
64     }
65
66     function step2()
67     {
68         InspectorTest.addResult("Watch expressions added.");
69         expandProperty(watchExpressionsSection.propertiesTreeOutline, ["globalObject", "foo", "bar"], step3);
70     }
71
72     function step3()
73     {
74         InspectorTest.addResult("Watch expressions expanded.");
75         dumpObjectPropertiesTreeElement(watchExpressionsSection.propertiesTreeOutline, "");
76         InspectorTest.reloadPage(step4);
77     }
78
79     function step4()
80     {
81         InspectorTest.addResult("Watch expressions after page reload:");
82         dumpObjectPropertiesTreeElement(watchExpressionsSection.propertiesTreeOutline, "");
83
84         // Clear watch expressions after execution.
85         watchExpressionsSection.watchExpressions = [];
86         watchExpressionsSection.update();
87         InspectorTest.completeDebuggerTest();
88     }
89 }
90
91 </script>
92 </head>
93 <body onload="runTest()">
94 <p>Test that watch expressions expansion state is restored after update.</p>
95 <a href="https://bugs.webkit.org/show_bug.cgi?id=99304">Bug 99304</a>
96 </body>
97 </html>