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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <meta charset="utf-8">
5 <script src="../../http/tests/inspector/inspector-test.js" id="script-id"></scri pt>
6 <script src="../../http/tests/inspector/elements-test.js"></script>
7 <script id="test-script">
8 function matchingElements(selector)
9 {
10 return document.querySelectorAll(selector).length;
11 }
12
13 function test()
14 {
15 var nodeQueue = [];
16 InspectorTest.expandElementsTree(enqueueNodes);
17
18 function enqueueNodes()
19 {
20 enqueueNode("", getDocumentElement());
21 dumpNodeData();
22 }
23
24 function dumpNodeData()
25 {
26 var entry = nodeQueue.shift();
27 if (!entry) {
28 InspectorTest.completeTest();
29 return;
30 }
31 var cssPath = entry.node.cssPath(true);
32 var result = entry.prefix + cssPath;
33 InspectorTest.addResult(result.replace(/\n/g, "\\n"));
34 var escapedPath = cssPath.replace(/\\/g, "\\\\");
aandrey 2013/11/20 12:49:02 do we really have to do this? maybe we should retu
35 InspectorTest.evaluateInPage("matchingElements('" + escapedPath + "')", callback);
36
37 function callback(result)
38 {
39 InspectorTest.assertEquals(1, result.value);
40 dumpNodeData();
41 }
42 }
43
44 function getDocumentElement()
45 {
46 var map = WebInspector.domAgent._idToDOMNode;
47 for (var id in map) {
48 if (map[id].nodeName() === "#document")
49 return map[id];
50 }
51
52 return null;
53 }
54
55 function enqueueNode(prefix, node)
56 {
57 if (node.nodeType() === Node.ELEMENT_NODE)
58 nodeQueue.push({prefix: prefix, node: node});
59 var children = node.children();
60 for (var i = 0; children && i < children.length; ++i)
61 enqueueNode(prefix + " ", children[i]);
62 }
63
64 }
65 </script>
66 </head>
67
68 <body onload="runTest()">
69 <p>Tests DOMNode.cssPath()</p>
70
71 <article>First</article>
72 <article>Second</article>
73
74
75 <div id="ids">
76 <div>1</div>
77 <div>2</div>
78 <div id="inner-id">3</div>
79 <div id='#"ridiculous".id'>4</div>
80 <div id="'quoted.value'">5</div>
81 <div id=".foo.bar">6</div>
82 <div id="-">7</div>
83 <div id="-a">8</div>
84 <div id="-0">9</div>
85 <div id="7">10</div>
86 <div id="ид">11 ид</div>
87 <p>12</p>
88 </div>
89
90 <div id="classes">
91 <div class="foo bar">13</div>
92 <div class=" foo foo ">14</div>
93 <div class=".foo">15</div>
94 <div class=".foo.bar">16</div>
95 <div class="-">17</div>
96 <div class="-a">18</div>
97 <div class="-0">19</div>
98 <div class="7">20</div>
99 <div class="класс">21 класс</div>
100 <span class="bar">22</span>
101 <div id="id-with-class" class="moo">23</div>
102 </div>
103
aandrey 2013/11/20 12:49:02 can you plz also add the following test: <div id=
104 </body>
105 </html>
OLDNEW
« 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