Upstream version 5.34.98.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / LayoutTests / inspector / debugger / script-formatter-search.html
1 <html>
2 <head>
3 <script src="../../http/tests/inspector/inspector-test.js"></script>
4 <script src="../../http/tests/inspector/debugger-test.js"></script>
5 <script src="../../http/tests/inspector/search/search-test.js"></script>
6 <script>
7
8 function nonFormattedFunction() { var  i = 2 + 2; var a = 4; return a + i; }
9
10 var test = function()
11 {
12     var scriptSource;
13     var shouldRequestContent = false;
14
15     InspectorTest.startDebuggerTest(started);
16
17     function started()
18     {
19         InspectorTest.showScriptSource("script-formatter-search.html", didShowScriptSource);
20     }
21
22     function didShowScriptSource(frame)
23     {
24         scriptSource = frame._uiSourceCode;
25         InspectorTest.addSniffer(scriptSource._project, "requestFileContent", requestContentSniffer);
26         scriptSource.searchInContent("magic-string", true, false, dump1);
27     }
28
29     function dump1(matches)
30     {
31         InspectorTest.addResult("Pre-format search results:");
32         InspectorTest.dumpSearchMatches(matches);
33         shouldRequestContent = true;
34         scriptSource.addEventListener(WebInspector.UISourceCode.Events.FormattedChanged, didFormat, this);
35         scriptSource.setFormatted(true);
36     }
37
38     function didFormat()
39     {
40         scriptSource.removeEventListener(WebInspector.UISourceCode.Events.FormattedChanged, didFormat, this);
41         scriptSource.searchInContent("magic-string", true, false, dump2);
42     }
43
44     function dump2(matches)
45     {
46         InspectorTest.addResult("Post-format search results:");
47         InspectorTest.dumpSearchMatches(matches);
48         InspectorTest.completeTest();
49     }
50
51     function requestContentSniffer()
52     {
53         if (shouldRequestContent)
54             InspectorTest.addResult("Original content was requested.");
55         else
56             InspectorTest.addResult("Failure: original content should not be requested.");
57     }
58 }
59
60 </script>
61
62 </head>
63
64 <body onload="runTest()">
65 <p>Tests that search across files works with formatted scripts.
66 </p>
67
68 </body>
69 </html>