Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Unified Diff: third_party/WebKit/LayoutTests/inspector/elements/elements-panel-restore-selection-when-node-comes-later.html

Issue 2428823002: DevTools: properly restore selected DOMNode in Elements panel. (Closed)
Patch Set: fix test Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/inspector/elements/elements-panel-restore-selection-when-node-comes-later-expected.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/LayoutTests/inspector/elements/elements-panel-restore-selection-when-node-comes-later.html
diff --git a/third_party/WebKit/LayoutTests/inspector/elements/elements-panel-restore-selection-when-node-comes-later.html b/third_party/WebKit/LayoutTests/inspector/elements/elements-panel-restore-selection-when-node-comes-later.html
new file mode 100644
index 0000000000000000000000000000000000000000..3a77fb01612b45b00d14615943e94db465245542
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/inspector/elements/elements-panel-restore-selection-when-node-comes-later.html
@@ -0,0 +1,112 @@
+<html>
+<head>
+<script src="../../http/tests/inspector/inspector-test.js"></script>
+<script src="../../http/tests/inspector/elements-test.js"></script>
+<script src="./shadow/elements-panel-shadow-selection-on-refresh.js"></script>
+<script>
+
+function test()
+{
+ var domModel = WebInspector.DOMModel.fromTarget(WebInspector.targetManager.mainTarget());
+ var node;
+
+ InspectorTest.runTestSuite([
+ function selectNode(next)
+ {
+ InspectorTest.nodeWithId("inspected", onNodeFound);
+
+ function onNodeFound(n)
+ {
+ node = n;
+ InspectorTest.selectNode(node).then(onNodeSelected);
+ }
+
+ function onNodeSelected()
+ {
+ dumpSelectedNode();
+ next();
+ }
+ },
+
+ function firstReloadWithoutNodeInDOM(next)
+ {
+ InspectorTest.addSniffer(WebInspector.ElementsPanel.prototype, "_lastSelectedNodeSelectedForTest", onNodeRestored);
+ // Do a reload and pretend page's DOM doesn't have a node to restore.
+ overridePushNodeForPath(node.path());
+ InspectorTest.reloadPage(function() { });
+
+ function onNodeRestored()
+ {
+ dumpSelectedNode();
+ next();
+ }
+ },
+
+ function secondReloadWithNodeInDOM(next)
+ {
+ var pageReloaded = false;
+ var nodeRestored = false;
+ InspectorTest.addSniffer(WebInspector.ElementsPanel.prototype, "_lastSelectedNodeSelectedForTest", onNodeRestored);
+ InspectorTest.reloadPage(onPageReloaded);
+
+ function onPageReloaded()
+ {
+ pageReloaded = true;
+ maybeNext();
+ }
+
+ function onNodeRestored()
+ {
+ nodeRestored = true;
+ maybeNext();
+ }
+
+ function maybeNext()
+ {
+ if (!nodeRestored || !pageReloaded)
+ return;
+ dumpSelectedNode();
+ next();
+ }
+ },
+
+ ]);
+
+ function dumpSelectedNode()
+ {
+ var selectedElement = InspectorTest.firstElementsTreeOutline().selectedTreeElement;
+ var nodeName = selectedElement ? selectedElement.node().nodeNameInCorrectCase() : "null";
+ InspectorTest.addResult("Selected node: '" + nodeName + "'");
+ }
+
+ /**
+ * @param {string} pathToIgnore
+ */
+ function overridePushNodeForPath(pathToIgnore)
+ {
+ var original = InspectorTest.override(WebInspector.DOMModel.prototype, "pushNodeByPathToFrontend", override);
+
+ function override(nodePath, callback)
+ {
+ if (nodePath === pathToIgnore) {
+ setTimeout(callback.bind(null), 0);
+ return;
+ }
+ original(nodePath, callback);
+ }
+ }
+}
+
+</script>
+</head>
+
+<body onload="runTest()">
+<p>
+Verify that last selected element is restored properly later, even if
+it failed to do so once.
+</p>
+<div>
+ <span id="inspected"></span>
+</div>
+</body>
+</html>
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/inspector/elements/elements-panel-restore-selection-when-node-comes-later-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698