3 <script src=
"../../http/tests/inspector/inspector-test.js"></script>
4 <script src=
"../../http/tests/inspector/debugger-test.js"></script>
5 <script src=
"../sources/debugger/resources/edit-me.js"></script>
6 <script src=
"resources/search-me.js"></script>
12 var searchString
= "FINDME";
13 var searchableView
= WebInspector
.panels
.sources
.searchableView();
15 InspectorTest
.showScriptSource("search-me.js", didShowScriptSource
);
17 function didShowScriptSource(shownSourceFrame
)
19 sourceFrame
= shownSourceFrame
;
20 textEditor
= sourceFrame
._textEditor
;
21 // We are probably still updating the editor in current callstack, so postponing the test execution.
22 setImmediate(textEditorUpdated
);
25 function textEditorUpdated(sourceFrame
)
27 searchableView
.showSearchField();
29 InspectorTest
.addResult("Performing search...");
30 searchableView
._searchInputElement
.value
= searchString
;
31 searchableView
._performSearch(true, true);
32 InspectorTest
.addResult("Recording editor viewport after searching...");
34 var originalViewport
= { from: textEditor
.firstVisibleLine(), to
: textEditor
.lastVisibleLine() };
35 var originalSelectionRange
= textEditor
.selection();
37 InspectorTest
.showScriptSource("edit-me.js", didShowAnotherSource
);
39 function didShowAnotherSource(anotherSourceFrame
)
41 InspectorTest
.showScriptSource("search-me.js", didShowScriptSourceAgain
);
44 function didShowScriptSourceAgain(sourceFrame
)
46 InspectorTest
.addResult("Recording editor viewport after switching tabs...");
47 var newViewport
= { from: textEditor
.firstVisibleLine(), to
: textEditor
.lastVisibleLine() };
48 var newSelectionRange
= textEditor
.selection();
49 InspectorTest
.addResult("Comparing viewports...");
50 if (originalViewport
.from === newViewport
.from && originalViewport
.to
=== newViewport
.to
)
51 InspectorTest
.addResult(" viewports match, SUCCESS");
53 InspectorTest
.addResult(" viewports do not match, FAIL");
54 InspectorTest
.addResult("Comparing selection ranges...");
55 InspectorTest
.addResult(" original selection range: " + originalSelectionRange
.toString());
56 InspectorTest
.addResult(" current selection range: " + newSelectionRange
.toString());
57 InspectorTest
.completeTest();
63 <body onload=
"runTest()">
64 <p>Tests that switching editor tabs after searching does not affect editor selection and viewport.
</p>