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

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: Implement identifier escaping for id and class attribute values 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..ae8c272226bed2473a6cd5c23ab8b318e4812b76
--- /dev/null
+++ b/LayoutTests/inspector/elements/elements-css-path.html
@@ -0,0 +1,105 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<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.expandElementsTree(enqueueNodes);
+
+ function enqueueNodes()
+ {
+ enqueueNode("", getDocumentElement());
+ 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"));
+ var escapedPath = cssPath.replace(/\\/g, "\\\\");
aandrey 2013/11/20 12:49:02 do we really have to do this? maybe we should retu
+ InspectorTest.evaluateInPage("matchingElements('" + escapedPath + "')", 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 id="ids">
+ <div>1</div>
+ <div>2</div>
+ <div id="inner-id">3</div>
+ <div id='#"ridiculous".id'>4</div>
+ <div id="'quoted.value'">5</div>
+ <div id=".foo.bar">6</div>
+ <div id="-">7</div>
+ <div id="-a">8</div>
+ <div id="-0">9</div>
+ <div id="7">10</div>
+ <div id="ид">11 ид</div>
+ <p>12</p>
+</div>
+
+<div id="classes">
+ <div class="foo bar">13</div>
+ <div class=" foo foo ">14</div>
+ <div class=".foo">15</div>
+ <div class=".foo.bar">16</div>
+ <div class="-">17</div>
+ <div class="-a">18</div>
+ <div class="-0">19</div>
+ <div class="7">20</div>
+ <div class="класс">21 класс</div>
+ <span class="bar">22</span>
+ <div id="id-with-class" class="moo">23</div>
+</div>
+
aandrey 2013/11/20 12:49:02 can you plz also add the following test: <div id=
+</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