OLD | NEW |
(Empty) | |
| 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="../debugger/resources/edit-me.js"></script> |
| 6 <script src="resources/search-me.js"></script> |
| 7 <script> |
| 8 |
| 9 function test() |
| 10 { |
| 11 var textEditor; |
| 12 var searchString = "FINDME"; |
| 13 var searchableView = WebInspector.panels.sources.searchableView(); |
| 14 var sourceFrame; |
| 15 InspectorTest.showScriptSource("search-me.js", didShowScriptSource); |
| 16 |
| 17 function didShowScriptSource(shownSourceFrame) |
| 18 { |
| 19 sourceFrame = shownSourceFrame; |
| 20 textEditor = sourceFrame._textEditor; |
| 21 // We are probably still updating the editor in current callstack, so po
stponing the test execution. |
| 22 setImmediate(textEditorUpdated); |
| 23 } |
| 24 |
| 25 function textEditorUpdated(sourceFrame) |
| 26 { |
| 27 searchableView.showSearchField(); |
| 28 |
| 29 InspectorTest.addResult("Performing search..."); |
| 30 searchableView._searchInputElement.value = searchString; |
| 31 searchableView._performSearch(true, true); |
| 32 InspectorTest.addResult("Recording editor viewport after searching..."); |
| 33 |
| 34 var originalViewport = { from: textEditor.firstVisibleLine(), to: textEd
itor.lastVisibleLine() }; |
| 35 var originalSelectionRange = textEditor.selection(); |
| 36 |
| 37 InspectorTest.showScriptSource("edit-me.js", didShowAnotherSource); |
| 38 |
| 39 function didShowAnotherSource(anotherSourceFrame) |
| 40 { |
| 41 InspectorTest.showScriptSource("search-me.js", didShowScriptSourceAg
ain); |
| 42 } |
| 43 |
| 44 function didShowScriptSourceAgain(sourceFrame) |
| 45 { |
| 46 InspectorTest.addResult("Recording editor viewport after switching t
abs..."); |
| 47 var newViewport = { from: textEditor.firstVisibleLine(), to: textEdi
tor.lastVisibleLine() }; |
| 48 var newSelectionRange = textEditor.selection(); |
| 49 InspectorTest.addResult("Comparing viewports..."); |
| 50 if (originalViewport.from === newViewport.from && originalViewport.t
o === newViewport.to) |
| 51 InspectorTest.addResult(" viewports match, SUCCESS"); |
| 52 else |
| 53 InspectorTest.addResult(" viewports do not match, FAIL"); |
| 54 InspectorTest.addResult("Comparing selection ranges..."); |
| 55 InspectorTest.addResult(" original selection range: " + originalSel
ectionRange.toString()); |
| 56 InspectorTest.addResult(" current selection range: " + newSelection
Range.toString()); |
| 57 InspectorTest.completeTest(); |
| 58 } |
| 59 } |
| 60 }; |
| 61 </script> |
| 62 </head> |
| 63 <body onload="runTest()"> |
| 64 <p>Tests that switching editor tabs after searching does not affect editor selec
tion and viewport.</p> |
| 65 </body> |
| 66 </html> |
OLD | NEW |