Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / inspector / sources / debugger-ui / watch-expressions-preserve-expansion.html
blob013a783d7b08f3dbfd991096dd93a5da263a8895
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>
8 var globalObject = {
9 foo: {
10 bar: {
11 baz: 2012
15 var windowAlias = window;
17 var test = function()
19 var watchExpressionsSection;
20 InspectorTest.startDebuggerTest(step1);
22 function step1()
24 var watchExpressionsPane = WebInspector.panels.sources.sidebarPanes.watchExpressions;
25 watchExpressionsPane.expand();
27 watchExpressionsSection = watchExpressionsPane.section;
28 watchExpressionsSection.watchExpressions = [];
29 watchExpressionsSection.watchExpressions.push("globalObject");
30 watchExpressionsSection.watchExpressions.push("windowAlias");
32 InspectorTest.addSniffer(WebInspector.WatchExpressionsSection.prototype, "updateProperties", step2);
33 watchExpressionsSection.update();
36 function expandProperty(parent, path, callback)
38 if (!path.length) return callback();
39 var childName = path.shift();
40 var child = InspectorTest._findChildPropertyTreeElement(parent, childName);
41 if (!child) {
42 InspectorTest.addResult("Child not found: " + childName);
43 InspectorTest.completeTest()
44 return;
46 InspectorTest.addResult("expanded " + childName + " " + child.property.value);
47 function afterGetOwnProperties() {
48 InspectorTest.runAfterPendingDispatches(expandProperty.bind(this, child, path, callback));
50 InspectorTest.addSniffer(child.property.value, "getOwnProperties", afterGetOwnProperties.bind(this));
51 child.expand();
55 function dumpObjectPropertiesTreeElement(treeElement, indent)
57 if (treeElement.property)
58 InspectorTest.addResult(indent + treeElement.property.name + ": " + treeElement.property.value._description);
59 for (var i = 0; i < treeElement.children.length; i++)
60 dumpObjectPropertiesTreeElement(treeElement.children[i], " " + indent);
63 function step2()
65 InspectorTest.addResult("Watch expressions added.");
66 expandProperty(watchExpressionsSection.propertiesTreeOutline, ["globalObject", "foo", "bar"], step3);
69 function step3()
71 InspectorTest.addResult("Watch expressions expanded.");
72 dumpObjectPropertiesTreeElement(watchExpressionsSection.propertiesTreeOutline, "");
73 InspectorTest.reloadPage(step4);
76 function step4()
78 InspectorTest.addResult("Watch expressions after page reload:");
79 dumpObjectPropertiesTreeElement(watchExpressionsSection.propertiesTreeOutline, "");
81 // Clear watch expressions after execution.
82 watchExpressionsSection.watchExpressions = [];
83 watchExpressionsSection.update();
84 InspectorTest.completeDebuggerTest();
88 </script>
89 </head>
90 <body onload="runTest()">
91 <p>Test that watch expressions expansion state is restored after update.</p>
92 <a href="https://bugs.webkit.org/show_bug.cgi?id=99304">Bug 99304</a>
93 </body>
94 </html>