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 InspectorTest.addSniffer(WebInspector.ElementsPanel.prototype, "_las
tSelectedNodeSelectedForTest", onNodeRestored); | |
48 | |
49 InspectorTest.reloadPage(function() { }); | |
50 | |
51 function onNodeRestored() | |
52 { | |
53 dumpSelectedNode(); | |
54 next(); | |
55 } | |
56 }, | |
57 | |
58 ]); | |
59 | |
60 function dumpSelectedNode() | |
61 { | |
62 var selectedElement = InspectorTest.firstElementsTreeOutline().selectedT
reeElement; | |
63 var nodeName = selectedElement ? selectedElement.node().nodeNameInCorrec
tCase() : "null"; | |
64 InspectorTest.addResult("Selected node: '" + nodeName + "'"); | |
65 } | |
66 | |
67 /** | |
68 * @param {string} pathToIgnore | |
69 */ | |
70 function overridePushNodeForPath(pathToIgnore) | |
71 { | |
72 var original = InspectorTest.override(WebInspector.DOMModel.prototype, "
pushNodeByPathToFrontend", override); | |
73 | |
74 function override(nodePath, callback) | |
75 { | |
76 if (nodePath === pathToIgnore) { | |
77 setTimeout(callback.bind(null), 0); | |
78 return; | |
79 } | |
80 original(nodePath, callback); | |
81 } | |
82 } | |
83 } | |
84 | |
85 </script> | |
86 </head> | |
87 | |
88 <body onload="runTest()"> | |
89 <p> | |
90 Verify that last selected element is restored properly later, even if | |
91 it failed to do so once. | |
92 </p> | |
93 <div> | |
94 <span id="inspected"></span> | |
95 </div> | |
96 </body> | |
97 </html> | |
OLD | NEW |