| <html> |
| <head> |
| |
| <script src="../../http/tests/inspector/inspector-test.js"></script> |
| <script src="../../http/tests/inspector/elements-test.js"></script> |
| <script> |
| |
| function test() |
| { |
| InspectorTest.selectNodeWithId("container", step1); |
| |
| function step1(node) |
| { |
| var containerId = node.id; |
| var documentId = node.ownerDocument.id; |
| |
| InspectorTest.runTestSuite([ |
| function testDocumentQuerySelector(next) |
| { |
| DOMAgent.querySelector(documentId, "div.foo", dumpNodes.bind(null, next)); |
| }, |
| |
| function testDocumentQuerySelectorAll(next) |
| { |
| DOMAgent.querySelectorAll(documentId, "div.foo", dumpNodes.bind(null, next)); |
| }, |
| |
| function testQuerySelector(next) |
| { |
| DOMAgent.querySelector(containerId, "div.foo", dumpNodes.bind(null, next)); |
| }, |
| |
| function testQuerySelectorAll(next) |
| { |
| DOMAgent.querySelectorAll(containerId, "div.foo", dumpNodes.bind(null, next)); |
| } |
| ]); |
| } |
| |
| function dumpNodes(next, error, nodeIds) |
| { |
| if (error) { |
| InspectorTest.addResult(error); |
| next(); |
| return; |
| } |
| |
| if (!(nodeIds instanceof Array)) |
| nodeIds = [nodeIds]; |
| |
| for (var i = 0; i < nodeIds.length; ++i) { |
| if (!nodeIds[i]) |
| InspectorTest.addResult("no results"); |
| else { |
| var node = WebInspector.domAgent.nodeForId(nodeIds[i]); |
| InspectorTest.addResult("node id: " + node.getAttribute("id")); |
| } |
| } |
| next(); |
| } |
| } |
| </script> |
| </head> |
| |
| <body onload="runTest()"> |
| <p> |
| Tests DOMAgent.querySelector and DOMAgent.querySelectorAll. |
| </p> |
| |
| <div id="id1" class="foo"></div> |
| <div id="id2" class="foo"></div> |
| |
| <div id="container"> |
| <div id="id3" class="foo"></div> |
| <div id="id4" class="foo"></div> |
| <div id="id5" class="foo"></div> |
| <div id="id6" class="foo"></div> |
| </div> |
| |
| </body> |
| </html> |