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