Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / inspector / elements / node-xpath.xhtml
blobd08c3af789844bf17fb42ddbecf6ef9c2ad0d335
1 <!-- Pre-comment -->
2 <html xmlns="http://www.w3.org/1999/xhtml">
3 <head>
4 <script src="../../http/tests/inspector/inspector-test.js" id="script-id"></script>
5 <script src="../../http/tests/inspector/elements-test.js"></script>
6 <script id="test-script">
7 //<![CDATA[
8 function test()
10 InspectorTest.expandElementsTree(dumpNodes.bind(null, ""));
11 var doc;
13 function dumpNodes(prefix, node)
15 if (!doc) {
16 doc = getDocumentElement();
17 node = doc;
19 if (node.getAttribute("id") === "test-script")
20 return;
21 dumpNodeData(node, prefix);
22 var children = node.children();
23 for (var i = 0; children && i < children.length; ++i)
24 dumpNodes(prefix + " ", children[i]);
25 if (node === doc)
26 InspectorTest.completeTest();
29 function getDocumentElement()
31 var map = InspectorTest.domModel._idToDOMNode;
32 for (var id in map) {
33 if (map[id].nodeName() === "#document")
34 return map[id];
37 return null;
40 function dumpNodeData(node, prefix)
42 var result = prefix + "'" + node.nodeName() + "':'" + node.nodeValue() + "' - '" + WebInspector.DOMPresentationUtils.xPath(node, true) + "'";
43 InspectorTest.addResult(result.replace(/\r?\n/g, "\\n"));
46 //]]>
47 </script>
48 <script>
49 // Comment
50 //<![CDATA[
51 function f()
53 document.write("<");
55 //]]>
56 </script>
57 </head>
59 <body onload="runTest()">
60 <p>Tests node xPath construction</p>
62 <div id="id1" class="foo"></div>
63 <div id="id2" class="foo"></div>
65 <div id="container">
66 <div id="id3" class="foo">3 Prefix <![CDATA[<greeting>Hello, world!</greeting>]]> Suffix</div>
67 <div id="id4" class="foo">4</div>
68 <div id="id5" class="foo">5</div>
69 <div id="id6" class="foo">6</div>
70 </div>
72 </body>
73 </html>
74 <!-- Post-comment -->