5 <script src=
"../../http/tests/inspector/inspector-test.js" id=
"script-id"></script>
6 <script src=
"../../http/tests/inspector/elements-test.js"></script>
7 <script id=
"test-script">
8 function matchingElements(selector)
10 return document.querySelectorAll(selector).length;
16 InspectorTest.expandElementsTree(enqueueNodes);
18 function enqueueNodes()
20 enqueueNode(
"", getDocumentElement());
24 function dumpNodeData()
26 var entry = nodeQueue.shift();
28 InspectorTest.completeTest();
31 var cssPath = WebInspector.DOMPresentationUtils.cssPath(entry.node, true);
32 var result = entry.prefix + cssPath;
33 InspectorTest.addResult(result.replace(/\n/g,
"\\n"));
34 var escapedPath = cssPath.replace(/\\/g,
"\\\\");
35 InspectorTest.evaluateInPage(
"matchingElements('" + escapedPath +
"')", callback);
37 function callback(result)
39 InspectorTest.assertEquals(
1, result.value);
44 function getDocumentElement()
46 var map = InspectorTest.domModel._idToDOMNode;
48 if (map[id].nodeName() ===
"#document")
55 function enqueueNode(prefix, node)
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]);
68 <body onload=
"runTest()">
69 <p>Tests DOMNode.cssPath()
</p>
73 <input type=
"number"/>
81 <div id=
"inner-id"></div>
82 <div id=
"__proto__"></div>
83 <div id='#
"ridiculous".id'
></div>
84 <div id=
"'quoted.value'"></div>
85 <div id=
".foo.bar"></div>
91 <input type=
"text" id=
"input-id"/>
97 <!-- Comment node 1 -->
98 <div class=
"foo bar"></div>
99 <!-- Comment node 2 -->
100 <div class=
" foo foo "></div>
101 <div class=
".foo"></div>
102 <div class=
".foo.bar"></div>
103 <div class=
"-"></div>
104 <div class=
"-a"></div>
105 <div class=
"-0"></div>
106 <div class=
"7"></div>
107 <div class=
"класс">класс
</div>
108 <div class=
"__proto__"></div>
109 <div class=
"__proto__ foo"></div>
110 <span class=
"bar"></span>
111 <div id=
"id-with-class" class=
"moo"></div>
112 <input type=
"text" class=
"input-class-one"/>
113 <input type=
"text" class=
"input-class-two"/>
114 <!-- Comment node 3 -->
117 <div id=
"non-unique-classes">
118 <!-- Comment node 1 -->
119 <span class=
"c1"></span>
120 <!-- Comment node 2 -->
121 <span class=
"c1"></span>
122 <!-- Comment node 3 -->
123 <span class=
"c1 c2"></span>
124 <!-- Comment node 4 -->
125 <span class=
"c1 c2 c3"></span>
126 <!-- Comment node 5 -->
128 <!-- Comment node 6 -->
129 <div class=
"c1"></div>
130 <!-- Comment node 7 -->
131 <div class=
"c1 c2"></div>
132 <!-- Comment node 8 -->
133 <div class=
"c3 c2"></div>
134 <!-- Comment node 9 -->
135 <div class=
"c3 c4"></div>
136 <!-- Comment node 10 -->
137 <div class=
"c1 c4"></div>
138 <!-- Comment node 11 -->
139 <input type=
"text" class=
"input-class"/>
140 <input type=
"text" class=
"input-class"/>