Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(113)

Unified Diff: LayoutTests/inspector/editor/text-editor-search-switch-editor.html

Issue 669043002: DevTools: Fix the way search works when switching between editor tabs. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Comments addressed Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: LayoutTests/inspector/editor/text-editor-search-switch-editor.html
diff --git a/LayoutTests/inspector/editor/text-editor-search-switch-editor.html b/LayoutTests/inspector/editor/text-editor-search-switch-editor.html
new file mode 100644
index 0000000000000000000000000000000000000000..df25503ed761d24b0d015014de1af88ea2eb50d5
--- /dev/null
+++ b/LayoutTests/inspector/editor/text-editor-search-switch-editor.html
@@ -0,0 +1,66 @@
+<html>
+<head>
+<script src="../../http/tests/inspector/inspector-test.js"></script>
+<script src="../../http/tests/inspector/debugger-test.js"></script>
+<script src="../debugger/resources/edit-me.js"></script>
+<script src="resources/search-me.js"></script>
+<script>
+
+function test()
+{
+ var textEditor;
+ var searchString = "FINDME";
+ var searchableView = WebInspector.panels.sources.searchableView();
+ var sourceFrame;
+ InspectorTest.showScriptSource("search-me.js", didShowScriptSource);
+
+ function didShowScriptSource(shownSourceFrame)
+ {
+ sourceFrame = shownSourceFrame;
+ textEditor = sourceFrame._textEditor;
+ // We are probably still updating the editor in current callstack, so postponing the test execution.
+ setImmediate(textEditorUpdated);
+ }
+
+ function textEditorUpdated(sourceFrame)
+ {
+ searchableView.showSearchField();
+
+ InspectorTest.addResult("Performing search...");
+ searchableView._searchInputElement.value = searchString;
+ searchableView._performSearch(true, true);
+ InspectorTest.addResult("Recording editor viewport after searching...");
+
+ var originalViewport = { from: textEditor.firstVisibleLine(), to: textEditor.lastVisibleLine() };
+ var originalSelectionRange = textEditor.selection();
+
+ InspectorTest.showScriptSource("edit-me.js", didShowAnotherSource);
+
+ function didShowAnotherSource(anotherSourceFrame)
+ {
+ InspectorTest.showScriptSource("search-me.js", didShowScriptSourceAgain);
+ }
+
+ function didShowScriptSourceAgain(sourceFrame)
+ {
+ InspectorTest.addResult("Recording editor viewport after switching tabs...");
+ var newViewport = { from: textEditor.firstVisibleLine(), to: textEditor.lastVisibleLine() };
+ var newSelectionRange = textEditor.selection();
+ InspectorTest.addResult("Comparing viewports...");
+ if (originalViewport.from === newViewport.from && originalViewport.to === newViewport.to)
+ InspectorTest.addResult(" viewports match, SUCCESS");
+ else
+ InspectorTest.addResult(" viewports do not match, FAIL");
+ InspectorTest.addResult("Comparing selection ranges...");
+ InspectorTest.addResult(" original selection range: " + originalSelectionRange.toString());
+ InspectorTest.addResult(" current selection range: " + newSelectionRange.toString());
+ InspectorTest.completeTest();
+ }
+ }
+};
+</script>
+</head>
+<body onload="runTest()">
+<p>Tests that switching editor tabs after searching does not affect editor selection and viewport.</p>
+</body>
+</html>

Powered by Google App Engine
This is Rietveld 408576698