Web Inspector: Search: allow DOM searches to be case sensitive
[WebKit-https.git] / LayoutTests / inspector / dom / dom-search-caseSensitive.html
1 <html>
2 <head>
3 <script src="../../http/tests/inspector/resources/protocol-test.js"></script>
4 <script src="../../http/tests/inspector/dom/resources/InspectorDOMListener.js"></script>
5 <!-- Loading the queries from external file to avoid having them show up in the results. -->
6 <script src="resources/dom-search-queries.js"></script>
7 <script>
8 function test()
9 {
10     // Create a DOM listener to convert nodeIds to tag names.
11     var dom = createDOMListener();
12
13     // Caching the output to avoid searching through the log.
14     var output = [];
15
16     InspectorProtocol.sendCommand("DOM.getDocument", {}, onGotDocument);
17
18     function onGotDocument(message) {
19         InspectorProtocol.checkForError(message);
20         dom.collectNode(message.result.root);
21         performSearches(domSearchQueries, testFinished);
22     }
23
24     function performSearches(list, callback)
25     {
26         function next() {
27             if (list.length)
28                 search(list.shift(), next);
29             else
30                 callback();
31         }
32         next();
33     }
34
35     function search(query, callback)
36     {
37         output.push("=== Query: " + JSON.stringify(query) + " ===");
38         InspectorProtocol.sendCommand("DOM.performSearch", {query, caseSensitive: true}, function(message) {
39             InspectorProtocol.checkForError(message);
40             printSearchResults(message.result, callback);
41         });
42     }
43
44     function printSearchResults(results, callback)
45     {
46         output.push("Count: " + results.resultCount);
47         if (!results.resultCount)
48             return callback();
49
50         var options = {"searchId": results.searchId, "fromIndex": 0, "toIndex": results.resultCount};
51         InspectorProtocol.sendCommand("DOM.getSearchResults", options, function onResultsReceived(message) {
52             for (var nodeId of message.result.nodeIds)
53                 output.push(dom.getNodeIdentifier(nodeId));
54             callback();
55         });
56     }
57
58     function testFinished()
59     {
60         ProtocolTest.log(output.join("\n"));
61         ProtocolTest.completeTest();
62     }
63 }
64 </script>
65 </head>
66 <body onload="runTest()" class="main-frame">
67     <p>Testing DOM.performSearch with no parent node ids.</p>
68     <iframe src="resources/dom-search-iframe.html"></iframe>
69 </body>
70 </html>