blob: 391065e92d824f5284b68a776376baaa3faa3aa4 [file] [log] [blame]
<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)
{
InspectorTest.DOMAgent.querySelector(documentId, "div.foo").then(dumpNodes.bind(null, next));
},
function testDocumentQuerySelectorAll(next)
{
InspectorTest.DOMAgent.querySelectorAll(documentId, "div.foo").then(dumpNodes.bind(null, next));
},
function testQuerySelector(next)
{
InspectorTest.DOMAgent.querySelector(containerId, "div.foo").then(dumpNodes.bind(null, next));
},
function testQuerySelectorAll(next)
{
InspectorTest.DOMAgent.querySelectorAll(containerId, "div.foo").then(dumpNodes.bind(null, next));
}
]);
}
function dumpNodes(next, nodeIds)
{
if (!nodeIds) {
next();
return;
}
if (!(nodeIds.constructor && nodeIds.constructor.name === "Array"))
nodeIds = [nodeIds];
for (var i = 0; i < nodeIds.length; ++i) {
if (!nodeIds[i])
InspectorTest.addResult("no results");
else {
var node = InspectorTest.domModel.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>