2010-05-03 Abhishek Arya <inferno@chromium.org>
[WebKit-https.git] / LayoutTests / inspector / elements-panel-search.html
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
2 <html>
3 <head>
4 <script src="../http/tests/inspector/inspector-test.js"></script>
5 <script>
6 function doit()
7 {
8     function callback(searchResults)
9     {
10         output("====================================");
11         output("Results:");
12         for (var i = 0; i < searchResults.length; ++i)
13             output(searchResults[i]);
14         notifyDone();
15     }
16     evaluateInWebInspector("frontend_performSearch", callback);
17 }
18
19
20 // Frontend functions.
21
22 function frontend_performSearch(testController)
23 {
24     testController.waitUntilDone();
25
26     var searchResults = [];
27     function addSearchResult(markupValue)
28     {
29         searchResults.push(markupValue);
30     }
31
32     WebInspector.addNodesToSearchResult = function(nodeIds)
33     {
34         var nodeIds = nodeIds.split(",");
35         for (var i = 0; i < nodeIds.length; ++i) {
36             var node = WebInspector.domAgent.nodeForId(nodeIds[i]);
37             if (node.nodeType === Node.TEXT_NODE)
38                 searchResults.push(node.nodeValue);
39             else
40                 InjectedScriptAccess.get(node.injectedScriptId).getNodePropertyValue(node.id, "outerHTML", addSearchResult);
41         }
42     }
43     // Plain text.
44     InjectedScriptAccess.getDefault().performSearch("Foo" + "Bar", true, function() {});
45     // Partial text.
46     InjectedScriptAccess.getDefault().performSearch("oo" + "Ba", true, function() {});
47     // Start tag.
48     InjectedScriptAccess.getDefault().performSearch("<inpu" + "t", true, function() {});
49     // Partial tag.
50     InjectedScriptAccess.getDefault().performSearch("npu" + "t", true, function() {});
51     // Exact attribute name.
52     InjectedScriptAccess.getDefault().performSearch("valu" + "e", true, function() {});
53     // Exact attribute val<>ue.
54     InjectedScriptAccess.getDefault().performSearch("In" + "putVa" + "l", true, function() {});
55     // Partial attribute val<>ue.
56     InjectedScriptAccess.getDefault().performSearch("n" + "putVa" + "l", true, function() {});
57
58     testController.runAfterPendingDispatches(function() {
59         testController.notifyDone(searchResults);
60     });
61 }
62 </script>
63 </head>
64
65 <body onload="onload()">
66 <p>
67 Tests that elements panel search is returning proper results.
68 </p>
69
70 <div>FooBar</div>
71 <input value="InputVal">
72
73 </body>
74 </html>