| 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="./shadow/elements-panel-shadow-selection-on-refresh.js"></script> | 5 <script src="./shadow/elements-panel-shadow-selection-on-refresh.js"></script> |
| 6 <script> | 6 <script> |
| 7 | 7 |
| 8 function test() | 8 function test() |
| 9 { | 9 { |
| 10 var domModel = WebInspector.DOMModel.fromTarget(WebInspector.targetManager.m
ainTarget()); | 10 var domModel = SDK.DOMModel.fromTarget(SDK.targetManager.mainTarget()); |
| 11 var node; | 11 var node; |
| 12 | 12 |
| 13 InspectorTest.runTestSuite([ | 13 InspectorTest.runTestSuite([ |
| 14 function selectNode(next) | 14 function selectNode(next) |
| 15 { | 15 { |
| 16 InspectorTest.nodeWithId("inspected", onNodeFound); | 16 InspectorTest.nodeWithId("inspected", onNodeFound); |
| 17 | 17 |
| 18 function onNodeFound(n) | 18 function onNodeFound(n) |
| 19 { | 19 { |
| 20 node = n; | 20 node = n; |
| 21 InspectorTest.selectNode(node).then(onNodeSelected); | 21 InspectorTest.selectNode(node).then(onNodeSelected); |
| 22 } | 22 } |
| 23 | 23 |
| 24 function onNodeSelected() | 24 function onNodeSelected() |
| 25 { | 25 { |
| 26 dumpSelectedNode(); | 26 dumpSelectedNode(); |
| 27 next(); | 27 next(); |
| 28 } | 28 } |
| 29 }, | 29 }, |
| 30 | 30 |
| 31 function firstReloadWithoutNodeInDOM(next) | 31 function firstReloadWithoutNodeInDOM(next) |
| 32 { | 32 { |
| 33 InspectorTest.addSniffer(WebInspector.ElementsPanel.prototype, "_las
tSelectedNodeSelectedForTest", onNodeRestored); | 33 InspectorTest.addSniffer(Elements.ElementsPanel.prototype, "_lastSel
ectedNodeSelectedForTest", onNodeRestored); |
| 34 // Do a reload and pretend page's DOM doesn't have a node to restore
. | 34 // Do a reload and pretend page's DOM doesn't have a node to restore
. |
| 35 overridePushNodeForPath(node.path()); | 35 overridePushNodeForPath(node.path()); |
| 36 InspectorTest.reloadPage(function() { }); | 36 InspectorTest.reloadPage(function() { }); |
| 37 | 37 |
| 38 function onNodeRestored() | 38 function onNodeRestored() |
| 39 { | 39 { |
| 40 dumpSelectedNode(); | 40 dumpSelectedNode(); |
| 41 next(); | 41 next(); |
| 42 } | 42 } |
| 43 }, | 43 }, |
| 44 | 44 |
| 45 function secondReloadWithNodeInDOM(next) | 45 function secondReloadWithNodeInDOM(next) |
| 46 { | 46 { |
| 47 var pageReloaded = false; | 47 var pageReloaded = false; |
| 48 var nodeRestored = false; | 48 var nodeRestored = false; |
| 49 InspectorTest.addSniffer(WebInspector.ElementsPanel.prototype, "_las
tSelectedNodeSelectedForTest", onNodeRestored); | 49 InspectorTest.addSniffer(Elements.ElementsPanel.prototype, "_lastSel
ectedNodeSelectedForTest", onNodeRestored); |
| 50 InspectorTest.reloadPage(onPageReloaded); | 50 InspectorTest.reloadPage(onPageReloaded); |
| 51 | 51 |
| 52 function onPageReloaded() | 52 function onPageReloaded() |
| 53 { | 53 { |
| 54 pageReloaded = true; | 54 pageReloaded = true; |
| 55 maybeNext(); | 55 maybeNext(); |
| 56 } | 56 } |
| 57 | 57 |
| 58 function onNodeRestored() | 58 function onNodeRestored() |
| 59 { | 59 { |
| (...skipping 17 matching lines...) Expand all Loading... |
| 77 var selectedElement = InspectorTest.firstElementsTreeOutline().selectedT
reeElement; | 77 var selectedElement = InspectorTest.firstElementsTreeOutline().selectedT
reeElement; |
| 78 var nodeName = selectedElement ? selectedElement.node().nodeNameInCorrec
tCase() : "null"; | 78 var nodeName = selectedElement ? selectedElement.node().nodeNameInCorrec
tCase() : "null"; |
| 79 InspectorTest.addResult("Selected node: '" + nodeName + "'"); | 79 InspectorTest.addResult("Selected node: '" + nodeName + "'"); |
| 80 } | 80 } |
| 81 | 81 |
| 82 /** | 82 /** |
| 83 * @param {string} pathToIgnore | 83 * @param {string} pathToIgnore |
| 84 */ | 84 */ |
| 85 function overridePushNodeForPath(pathToIgnore) | 85 function overridePushNodeForPath(pathToIgnore) |
| 86 { | 86 { |
| 87 var original = InspectorTest.override(WebInspector.DOMModel.prototype, "
pushNodeByPathToFrontend", override); | 87 var original = InspectorTest.override(SDK.DOMModel.prototype, "pushNodeB
yPathToFrontend", override); |
| 88 | 88 |
| 89 function override(nodePath, callback) | 89 function override(nodePath, callback) |
| 90 { | 90 { |
| 91 if (nodePath === pathToIgnore) { | 91 if (nodePath === pathToIgnore) { |
| 92 setTimeout(callback.bind(null), 0); | 92 setTimeout(callback.bind(null), 0); |
| 93 return; | 93 return; |
| 94 } | 94 } |
| 95 original(nodePath, callback); | 95 original(nodePath, callback); |
| 96 } | 96 } |
| 97 } | 97 } |
| 98 } | 98 } |
| 99 | 99 |
| 100 </script> | 100 </script> |
| 101 </head> | 101 </head> |
| 102 | 102 |
| 103 <body onload="runTest()"> | 103 <body onload="runTest()"> |
| 104 <p> | 104 <p> |
| 105 Verify that last selected element is restored properly later, even if | 105 Verify that last selected element is restored properly later, even if |
| 106 it failed to do so once. | 106 it failed to do so once. |
| 107 </p> | 107 </p> |
| 108 <div> | 108 <div> |
| 109 <span id="inspected"></span> | 109 <span id="inspected"></span> |
| 110 </div> | 110 </div> |
| 111 </body> | 111 </body> |
| 112 </html> | 112 </html> |
| OLD | NEW |