Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / inspector / elements / dom-agent-query-selector.html
bloba3b6c77838e00a8c01c144702387d7eaf2f62c22
1 <html>
2 <head>
4 <script src="../../http/tests/inspector/inspector-test.js"></script>
5 <script src="../../http/tests/inspector/elements-test.js"></script>
6 <script>
8 function test()
10 InspectorTest.selectNodeWithId("container", step1);
12 function step1(node)
14 var containerId = node.id;
15 var documentId = node.ownerDocument.id;
17 InspectorTest.runTestSuite([
18 function testDocumentQuerySelector(next)
20 InspectorTest.DOMAgent.querySelector(documentId, "div.foo", dumpNodes.bind(null, next));
23 function testDocumentQuerySelectorAll(next)
25 InspectorTest.DOMAgent.querySelectorAll(documentId, "div.foo", dumpNodes.bind(null, next));
28 function testQuerySelector(next)
30 InspectorTest.DOMAgent.querySelector(containerId, "div.foo", dumpNodes.bind(null, next));
33 function testQuerySelectorAll(next)
35 InspectorTest.DOMAgent.querySelectorAll(containerId, "div.foo", dumpNodes.bind(null, next));
37 ]);
40 function dumpNodes(next, error, nodeIds)
42 if (error) {
43 InspectorTest.addResult(error);
44 next();
45 return;
48 if (!(nodeIds && nodeIds.constructor && nodeIds.constructor.name === "Array"))
49 nodeIds = [nodeIds];
51 for (var i = 0; i < nodeIds.length; ++i) {
52 if (!nodeIds[i])
53 InspectorTest.addResult("no results");
54 else {
55 var node = InspectorTest.domModel.nodeForId(nodeIds[i]);
56 InspectorTest.addResult("node id: " + node.getAttribute("id"));
59 next();
62 </script>
63 </head>
65 <body onload="runTest()">
66 <p>
67 Tests DOMAgent.querySelector and DOMAgent.querySelectorAll.
68 </p>
70 <div id="id1" class="foo"></div>
71 <div id="id2" class="foo"></div>
73 <div id="container">
74 <div id="id3" class="foo"></div>
75 <div id="id4" class="foo"></div>
76 <div id="id5" class="foo"></div>
77 <div id="id6" class="foo"></div>
78 </div>
80 </body>
81 </html>