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