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

Unified Diff: LayoutTests/inspector/elements/elements-css-path.html

Issue 75253002: DevTools: [Elements] Implement "Copy CSS Path" context menu item for elements (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Comments addressed Created 7 years, 1 month 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
Index: LayoutTests/inspector/elements/elements-css-path.html
diff --git a/LayoutTests/inspector/elements/elements-css-path.html b/LayoutTests/inspector/elements/elements-css-path.html
new file mode 100644
index 0000000000000000000000000000000000000000..10c05bff3b731fcb998b7d8e13138db032515738
--- /dev/null
+++ b/LayoutTests/inspector/elements/elements-css-path.html
@@ -0,0 +1,96 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src="../../http/tests/inspector/inspector-test.js" id="script-id"></script>
+<script src="../../http/tests/inspector/elements-test.js"></script>
+<script id="test-script">
+function matchingElements(selector)
+{
+ return document.querySelectorAll(selector).length;
+}
+
+function test()
+{
+ var nodeQueue = [];
+
+ InspectorTest.runTestSuite([
aandrey 2013/11/18 15:36:26 I thought every function passed to the suite shoul
+ function init(next)
+ {
+ InspectorTest.expandElementsTree(next);
+ },
+
+ function enqueueNodes(next)
+ {
+ enqueueNode("", getDocumentElement());
+ next();
+ },
+
+ function dumpNodes(next)
+ {
+ dumpNodeData();
+
+ function dumpNodeData()
+ {
+ var entry = nodeQueue.shift();
+ if (!entry) {
+ InspectorTest.completeTest();
+ return;
+ }
+ var cssPath = entry.node.cssPath(true);
+ var result = entry.prefix + cssPath;
+ InspectorTest.addResult(result.replace(/\n/g, "\\n"));
+ InspectorTest.evaluateInPage("matchingElements('" + cssPath + "')", callback);
+
+ function callback(result)
+ {
+ InspectorTest.assertEquals(1, result.value);
+ dumpNodeData();
+ }
+ }
+ }
+ ]);
+
+ function getDocumentElement()
+ {
+ var map = WebInspector.domAgent._idToDOMNode;
+ for (var id in map) {
+ if (map[id].nodeName() === "#document")
+ return map[id];
+ }
+
+ return null;
+ }
+
+
+ function enqueueNode(prefix, node)
+ {
+ if (node.nodeType() === Node.ELEMENT_NODE)
+ nodeQueue.push({prefix: prefix, node: node});
+ var children = node.children();
+ for (var i = 0; children && i < children.length; ++i)
+ enqueueNode(prefix + " ", children[i]);
+ }
+
+}
+</script>
+</head>
+
+<body onload="runTest()">
+<p>Tests DOMNode.cssPath()</p>
+
+<article>First</article>
+<article>Second</article>
+
+<div class="foo bar">1</div>
+<div class="foo foo">2</div>
+<span class="bar">3</span>
+
+<div id="container">
+ <div>4</div>
+ <div>5</div>
+ <div id="inner-id">6</div>
+ <p>7</p>
+</div>
+
+</body>
+</html>
« no previous file with comments | « no previous file | LayoutTests/inspector/elements/elements-css-path-expected.txt » ('j') | Source/devtools/front_end/DOMAgent.js » ('J')

Powered by Google App Engine
This is Rietveld 408576698