| OLD | NEW |
| 1 <html> | 1 <html> |
| 2 <head> | 2 <head> |
| 3 <script src="../../../http/tests/inspector/inspector-test.js"></script> | 3 <script src="../../../http/tests/inspector/inspector-test.js"></script> |
| 4 <script src="../../../http/tests/inspector/elements-test.js"></script> | 4 <script src="../../../http/tests/inspector/elements-test.js"></script> |
| 5 <script src="../../../http/tests/inspector/debugger-test.js"></script> | 5 <script src="../../../http/tests/inspector/debugger-test.js"></script> |
| 6 <script> | 6 <script> |
| 7 | 7 |
| 8 var globalObject = { | 8 var globalObject = { |
| 9 foo: { | 9 foo: { |
| 10 bar: { | 10 bar: { |
| 11 baz: 2012 | 11 baz: 2012 |
| 12 } | 12 } |
| 13 } | 13 } |
| 14 }; | 14 }; |
| 15 var windowAlias = window; | 15 var windowAlias = window; |
| 16 var array = []; |
| 17 for (var i = 0; i < 300; ++i) |
| 18 array[i] = i; |
| 19 |
| 20 (function() |
| 21 { |
| 22 var a = 10; |
| 23 var b = 100; |
| 24 window.func = function() {return a + b;} |
| 25 }()); |
| 16 | 26 |
| 17 var test = function() | 27 var test = function() |
| 18 { | 28 { |
| 19 var watchExpressionsPane = WebInspector.panels.sources.sidebarPanes.watchExp
ressions; | 29 var watchExpressionsPane = WebInspector.panels.sources.sidebarPanes.watchExp
ressions; |
| 20 watchExpressionsPane.expand(); | 30 watchExpressionsPane.expand(); |
| 21 watchExpressionsPane.addExpression("globalObject"); | 31 watchExpressionsPane.addExpression("globalObject"); |
| 22 watchExpressionsPane.addExpression("windowAlias"); | 32 watchExpressionsPane.addExpression("windowAlias"); |
| 33 watchExpressionsPane.addExpression("array"); |
| 34 watchExpressionsPane.addExpression("func"); |
| 23 InspectorTest.runAfterPendingDispatches(step2); | 35 InspectorTest.runAfterPendingDispatches(step2); |
| 24 | 36 |
| 25 function step2() | 37 function step2() |
| 26 { | 38 { |
| 27 InspectorTest.addResult("Watch expressions added."); | 39 InspectorTest.addResult("Watch expressions added."); |
| 28 expandWatchExpression(["globalObject", "foo", "bar"], step3); | 40 var expandArray = expandWatchExpression.bind(null, ["array", "[200 \u202
6 299]", "299"], step3); |
| 41 var expandFunc = expandWatchExpression.bind(null, ["func", "<function sc
ope>", "Closure", "a"], expandArray); |
| 42 expandWatchExpression(["globalObject", "foo", "bar"], expandFunc); |
| 29 } | 43 } |
| 30 | 44 |
| 31 function step3() | 45 function step3() |
| 32 { | 46 { |
| 33 InspectorTest.addResult("Watch expressions expanded."); | 47 InspectorTest.addResult("Watch expressions expanded."); |
| 34 dumpWatchExpressions(); | 48 dumpWatchExpressions(); |
| 35 InspectorTest.reloadPage(step4); | 49 InspectorTest.reloadPage(step4); |
| 36 } | 50 } |
| 37 | 51 |
| 38 function step4() | 52 function step4() |
| (...skipping 10 matching lines...) Expand all Loading... |
| 49 for (var i = 0; i < pane._watchExpressions.length; i++) { | 63 for (var i = 0; i < pane._watchExpressions.length; i++) { |
| 50 var watch = pane._watchExpressions[i]; | 64 var watch = pane._watchExpressions[i]; |
| 51 InspectorTest.addResult(watch.expression() + ": " + watch._objectPro
pertiesSection._object._description); | 65 InspectorTest.addResult(watch.expression() + ": " + watch._objectPro
pertiesSection._object._description); |
| 52 dumpObjectPropertiesTreeElement(watch._objectPropertiesSection.objec
tTreeElement(), " "); | 66 dumpObjectPropertiesTreeElement(watch._objectPropertiesSection.objec
tTreeElement(), " "); |
| 53 } | 67 } |
| 54 } | 68 } |
| 55 | 69 |
| 56 function dumpObjectPropertiesTreeElement(treeElement, indent) | 70 function dumpObjectPropertiesTreeElement(treeElement, indent) |
| 57 { | 71 { |
| 58 if (treeElement.property) | 72 if (treeElement.property) |
| 59 InspectorTest.addResult(indent + treeElement.property.name + ": " +
treeElement.property.value._description); | 73 addResult(indent + treeElement.property.name + ": " + treeElement.pr
operty.value._description); |
| 74 else if (typeof treeElement.title === "string") |
| 75 addResult(indent + treeElement.title); |
| 76 |
| 60 for (var i = 0; i < treeElement.children().length; i++) | 77 for (var i = 0; i < treeElement.children().length; i++) |
| 61 dumpObjectPropertiesTreeElement(treeElement.children()[i], " " + in
dent); | 78 dumpObjectPropertiesTreeElement(treeElement.children()[i], " " + in
dent); |
| 62 } | 79 } |
| 63 | 80 |
| 64 function expandProperties(treeoutline, path, callback) | 81 function expandProperties(treeoutline, path, callback) |
| 65 { | 82 { |
| 66 treeoutline.addEventListener(TreeOutline.Events.ElementAttached, element
Attached); | 83 treeoutline.addEventListener(TreeOutline.Events.ElementAttached, element
Attached); |
| 67 treeoutline.expand(); | 84 treeoutline.expand(); |
| 68 | 85 |
| 69 function elementAttached(event) | 86 function elementAttached(event) |
| 70 { | 87 { |
| 71 var treeElement = event.data; | 88 var treeElement = event.data; |
| 72 if (treeElement.property.name !== path[0]) | 89 var currentName = treeElement.property ? treeElement.property.name :
treeElement.title; |
| 90 if (currentName !== path[0]) |
| 73 return; | 91 return; |
| 74 | 92 |
| 75 var childName = path.shift(); | 93 var childName = path.shift(); |
| 76 InspectorTest.addResult("expanded " + childName + " " + treeElement.
property.value); | 94 addResult("expanded " + childName + " " + (treeElement.property ? tr
eeElement.property.value : "")); |
| 77 | 95 |
| 78 if (path.length) { | 96 if (path.length) { |
| 79 treeElement.expand(); | 97 treeElement.expand(); |
| 80 return; | 98 return; |
| 81 } | 99 } |
| 82 | 100 |
| 83 treeoutline.removeEventListener(TreeOutline.Events.ElementAttached,
elementAttached); | 101 treeoutline.removeEventListener(TreeOutline.Events.ElementAttached,
elementAttached); |
| 84 callback(); | 102 callback(); |
| 85 } | 103 } |
| 86 } | 104 } |
| 87 | 105 |
| 88 function expandWatchExpression(path, callback) | 106 function expandWatchExpression(path, callback) |
| 89 { | 107 { |
| 90 var pane = WebInspector.panels.sources.sidebarPanes.watchExpressions; | 108 var pane = WebInspector.panels.sources.sidebarPanes.watchExpressions; |
| 91 var expression = path.shift(); | 109 var expression = path.shift(); |
| 92 for (var i = 0; i < pane._watchExpressions.length; i++) { | 110 for (var i = 0; i < pane._watchExpressions.length; i++) { |
| 93 var watch = pane._watchExpressions[i]; | 111 var watch = pane._watchExpressions[i]; |
| 94 if (watch.expression() === expression) { | 112 if (watch.expression() === expression) { |
| 95 expandProperties(watch._objectPropertiesSection, path, callback)
; | 113 expandProperties(watch._objectPropertiesSection, path, callback)
; |
| 96 break; | 114 break; |
| 97 } | 115 } |
| 98 } | 116 } |
| 117 } |
| 99 | 118 |
| 119 function addResult(string) |
| 120 { |
| 121 InspectorTest.addResult(string.replace("\u2026", "..")); |
| 100 } | 122 } |
| 101 } | 123 } |
| 102 | 124 |
| 103 </script> | 125 </script> |
| 104 </head> | 126 </head> |
| 105 <body onload="runTest()"> | 127 <body onload="runTest()"> |
| 106 <p>Test that watch expressions expansion state is restored after update.</p> | 128 <p>Test that watch expressions expansion state is restored after update.</p> |
| 107 <a href="https://bugs.webkit.org/show_bug.cgi?id=99304">Bug 99304</a> | 129 <a href="https://bugs.webkit.org/show_bug.cgi?id=99304">Bug 99304</a> |
| 108 </body> | 130 </body> |
| 109 </html> | 131 </html> |
| OLD | NEW |