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

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: Protect from ridiculous IDs 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 <script src="../../http/tests/inspector/inspector-test.js" id="script-id"></scri pt>
5 <script src="../../http/tests/inspector/elements-test.js"></script>
6 <script id="test-script">
7 function matchingElements(selector)
8 {
9 var res = document.querySelectorAll(selector).length;
10 return res;
11 }
12
13 function test()
14 {
15 var nodeQueue = [];
16
17 InspectorTest.runTestSuite([
18 function init(next)
19 {
20 InspectorTest.expandElementsTree(next);
21 },
22
23 function enqueueNodes(next)
24 {
25 enqueueNode("", getDocumentElement());
26 next();
27 },
28
29 function dumpNodes(next)
30 {
31 dumpNodeData();
32
33 function dumpNodeData()
34 {
35 var entry = nodeQueue.shift();
36 if (!entry) {
37 InspectorTest.completeTest();
38 return;
39 }
40 var cssPath = entry.node.cssPath(true);
41 var result = entry.prefix + cssPath;
42 InspectorTest.addResult(result.replace(/\n/g, "\\n"));
43 var escapedPath = cssPath.replace(/'/g, "\\\'");
44 InspectorTest.evaluateInPage("matchingElements('" + escapedPath + "')", callback);
45
46 function callback(result)
47 {
48 InspectorTest.assertEquals(1, result.value);
49 dumpNodeData();
50 }
51 }
52 }
53 ]);
54
55 function getDocumentElement()
56 {
57 var map = WebInspector.domAgent._idToDOMNode;
58 for (var id in map) {
59 if (map[id].nodeName() === "#document")
60 return map[id];
61 }
62
63 return null;
64 }
65
66
67 function enqueueNode(prefix, node)
68 {
69 if (node.nodeType() === Node.ELEMENT_NODE)
70 nodeQueue.push({prefix: prefix, node: node});
71 var children = node.children();
72 for (var i = 0; children && i < children.length; ++i)
73 enqueueNode(prefix + " ", children[i]);
74 }
75
76 }
77 </script>
78 </head>
79
80 <body onload="runTest()">
81 <p>Tests DOMNode.cssPath()</p>
82
83 <article>First</article>
84 <article>Second</article>
85
86 <div class="foo bar">1</div>
87 <div class=" foo foo ">2</div>
88 <span class="bar">3</span>
89 <div id="id-with-class" class="moo">4</div>
90
91 <div id="container">
92 <div>5</div>
93 <div>6</div>
94 <div id="inner-id">7</div>
95 <div id='#"ridiculous".id'>8</div>
96 <div id="'quoted.value'">9</div>
97 <div id=".foo.bar">10</div>
98 <p>11</p>
99 </div>
100
101 </body>
102 </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