| <html> |
| <head> |
| <script src="../../http/tests/inspector/resources/protocol-test.js"></script> |
| <script src="../../http/tests/inspector/dom/resources/InspectorDOMListener.js"></script> |
| <!-- Loading the queries from external file to avoid having them show up in the results. --> |
| <script src="resources/dom-search-queries.js"></script> |
| <script> |
| function test() |
| { |
| // Create a DOM listener to convert nodeIds to tag names. |
| var dom = createDOMListener(); |
| |
| // Caching the output to avoid searching through the log. |
| var output = []; |
| |
| InspectorProtocol.sendCommand("DOM.getDocument", {}, onGotDocument); |
| |
| function onGotDocument(message) { |
| InspectorProtocol.checkForError(message); |
| dom.collectNode(message.result.root); |
| performSearches(domSearchQueries, testFinished); |
| } |
| |
| function performSearches(list, callback) |
| { |
| function next() { |
| if (list.length) |
| search(list.shift(), next); |
| else |
| callback(); |
| } |
| next(); |
| } |
| |
| function search(query, callback) |
| { |
| output.push("=== Query: " + JSON.stringify(query) + " ==="); |
| InspectorProtocol.sendCommand("DOM.performSearch", {query, caseSensitive: true}, function(message) { |
| InspectorProtocol.checkForError(message); |
| printSearchResults(message.result, callback); |
| }); |
| } |
| |
| function printSearchResults(results, callback) |
| { |
| output.push("Count: " + results.resultCount); |
| if (!results.resultCount) |
| return callback(); |
| |
| var options = {"searchId": results.searchId, "fromIndex": 0, "toIndex": results.resultCount}; |
| InspectorProtocol.sendCommand("DOM.getSearchResults", options, function onResultsReceived(message) { |
| for (var nodeId of message.result.nodeIds) |
| output.push(dom.getNodeIdentifier(nodeId)); |
| callback(); |
| }); |
| } |
| |
| function testFinished() |
| { |
| ProtocolTest.log(output.join("\n")); |
| ProtocolTest.completeTest(); |
| } |
| } |
| </script> |
| </head> |
| <body onload="runTest()" class="main-frame"> |
| <p>Testing DOM.performSearch with no parent node ids.</p> |
| <iframe src="resources/dom-search-iframe.html"></iframe> |
| </body> |
| </html> |