Index: LayoutTests/inspector/jump-to-previous-editing-location.html |
diff --git a/LayoutTests/inspector/jump-to-previous-editing-location.html b/LayoutTests/inspector/jump-to-previous-editing-location.html |
new file mode 100644 |
index 0000000000000000000000000000000000000000..18dbbfa8fe17a96fe8853b3d8c7aef8cb51446c9 |
--- /dev/null |
+++ b/LayoutTests/inspector/jump-to-previous-editing-location.html |
@@ -0,0 +1,202 @@ |
+<html> |
+<head> |
+<script src="../http/tests/inspector/inspector-test.js"></script> |
+<script src="../http/tests/inspector/workspace-test.js"></script> |
+<script src="resources/blink-fs.js"></script> |
+<script src="editor/editor-test.js"></script> |
+<script> |
+function test() |
+{ |
+ WebInspector.experimentsSettings.jumpToPreviousLocation.enableForTest(); |
+ WebInspector.showPanel("scripts"); |
+ var panel = WebInspector.panels.scripts; |
+ var project = WebInspector.workspace.projectsForType(WebInspector.projectTypes.Network)[0]; |
+ var sourceCodes = project.uiSourceCodes(); |
+ |
+ function findSourceCode(substring) |
+ { |
+ for (var i = 0; i < sourceCodes.length; ++i) { |
+ if (sourceCodes[i].path().indexOf(substring) >= 0) |
+ return sourceCodes[i]; |
+ } |
+ return null; |
+ } |
+ |
+ function clickAtEditor(editor, lineNumber, columnNumber) |
+ { |
+ editor.scrollToLine(lineNumber); |
+ var coordinates = editor.cursorPositionToCoordinates(lineNumber, columnNumber); |
+ eventSender.mouseMoveTo(coordinates.x, coordinates.y); |
+ eventSender.mouseDown(); |
+ eventSender.mouseUp(); |
+ dumpSelection(editor, "Mouse click (" + lineNumber + ", " + columnNumber + ")"); |
+ } |
+ |
+ function clickAndDump(editor, callback, lines, columns) |
+ { |
+ var iterationsAmount = lines.length; |
+ function innerClickAndDump(iteration) |
+ { |
+ if (iteration === iterationsAmount) { |
+ callback(); |
+ return; |
+ } |
+ clickAtEditor(editor, lines[iteration], columns[iteration]); |
+ setTimeout(innerClickAndDump.bind(this, iteration + 1), 0); |
+ } |
+ innerClickAndDump(0); |
+ } |
+ |
+ function dumpSelection(editor, label) |
+ { |
+ InspectorTest.addResult("<" + label + "> line: " + editor.selection().startLine + |
+ " column: " + editor.selection().startColumn + |
+ " [" + editor._url.split("/").pop() + "]"); |
+ } |
+ |
+ InspectorTest.runTestSuite([ |
+ function testSimpleMovements(next) |
+ { |
+ var uiSourceCode = findSourceCode("blink-fs"); |
+ panel._showFile(uiSourceCode); |
+ uiSourceCode.requestContent(onContentLoaded); |
+ function onContentLoaded() |
+ { |
+ var editor = panel.visibleView.textEditor; |
+ dumpSelection(editor, "Initial position"); |
+ clickAtEditor(editor, 4, 7); |
+ |
+ InspectorTest.typeIn("\nSome more text here"); |
+ dumpSelection(editor, "Typed in some text"); |
+ |
+ panel._previousPosition(); |
+ dumpSelection(editor, "Rolled back"); |
+ InspectorTest.typeIn("\nSome more text here as well\n"); |
+ dumpSelection(editor, "Typed in some text"); |
+ |
+ panel._nextPosition(); |
+ dumpSelection(editor, "Rolled over"); |
+ next(); |
+ } |
+ }, |
+ |
+ function testSequentialJumps(next) |
+ { |
+ var editor = panel.visibleView.textEditor; |
+ const jumpsToDo = 4; |
+ clickAndDump(editor, jumpBack, [10, 11, 12, 13], [3, 4, 5, 6]); |
+ |
+ function jumpBack() |
+ { |
+ for (var i = 0; i < jumpsToDo; ++i) { |
+ panel._previousPosition(); |
+ dumpSelection(editor, "Rolled back"); |
+ } |
+ for (var i = 0; i < jumpsToDo; ++i) { |
+ panel._nextPosition(); |
+ dumpSelection(editor, "Rolled over"); |
+ } |
+ next(); |
+ } |
+ }, |
+ |
+ function testDeletePreviousJumpLocations(next) |
+ { |
+ var editor = panel.visibleView.textEditor; |
+ editor.editRange(new WebInspector.TextRange(9, 0, 15, 0), ""); |
+ dumpSelection(editor, "Removed lines from 9 to 15"); |
+ panel._previousPosition(); |
+ dumpSelection(editor, "Rolled back"); |
+ panel._nextPosition(); |
+ dumpSelection(editor, "Rolled over"); |
+ next(); |
+ }, |
+ |
+ function testDeleteNextJumpLocations(next) |
+ { |
+ var editor = panel.visibleView.textEditor; |
+ const jumpsToDo = 4; |
+ clickAndDump(editor, step2, [10, 11, 12, 13], [3, 4, 5, 6]); |
+ |
+ function step2() |
+ { |
+ for (var i = 0; i < jumpsToDo; ++i) |
+ panel._previousPosition(); |
+ dumpSelection(editor, "Rolled back 4 times"); |
+ editor.editRange(new WebInspector.TextRange(9, 0, 11, 0), ""); |
+ dumpSelection(editor, "Removed lines from 9 to 11"); |
+ panel._nextPosition(); |
+ dumpSelection(editor, "Rolled over"); |
+ next(); |
+ } |
+ }, |
+ |
+ function testCrossFileJump(next) |
+ { |
+ var uiSourceCode = findSourceCode("workspace-test.js"); |
+ panel._showFile(uiSourceCode); |
+ uiSourceCode.requestContent(onContentLoaded); |
+ function onContentLoaded() |
+ { |
+ var editor = panel.visibleView.textEditor; |
+ dumpSelection(editor, "Opened workspace-test.js"); |
+ clickAndDump(editor, step2, [10, 11], [1, 1]); |
+ } |
+ function step2() |
+ { |
+ for (var i = 0; i < 4; ++i) { |
+ panel._previousPosition(); |
+ dumpSelection(panel.visibleView.textEditor, "Rolled back"); |
+ } |
+ for (var i = 0; i < 4; ++i) { |
+ panel._nextPosition(); |
+ dumpSelection(panel.visibleView.textEditor, "Rolled over"); |
+ } |
+ next(); |
+ } |
+ }, |
+ |
+ function testCloseCrossFile(next) |
+ { |
+ var selectedTab = panel._editorContainer._tabbedPane.selectedTabId; |
+ panel._editorContainer._tabbedPane.closeTab(selectedTab); |
+ dumpSelection(panel.visibleView.textEditor, "Close active tab"); |
+ for (var i = 0; i < 1; ++i) { |
+ panel._previousPosition(); |
+ dumpSelection(panel.visibleView.textEditor, "Rolled back"); |
+ } |
+ for (var i = 0; i < 3; ++i) { |
+ panel._nextPosition(); |
+ dumpSelection(panel.visibleView.textEditor, "Rolled over"); |
+ } |
+ next(); |
+ }, |
+ |
+ function testHistoryDepth(next) |
+ { |
+ var lines = []; |
+ var columns = []; |
+ const jumpsAmount = WebInspector.ScriptsPanel.JumpHistoryDepth; |
+ for(var i = 0; i < jumpsAmount; ++i) { |
+ lines.push(i + 10); |
+ columns.push(7); |
+ } |
+ var editor = panel.visibleView.textEditor; |
+ clickAndDump(editor, step2, lines, columns); |
+ function step2() |
+ { |
+ for (var i = 0; i < jumpsAmount; ++i) { |
+ panel._previousPosition(); |
+ dumpSelection(editor, "Rolled back"); |
+ } |
+ next(); |
+ } |
+ } |
+ ]); |
+}; |
+</script> |
+</head> |
+<body onload="runTest()"> |
+<p>Tests that scripts panel UI elements work as intended.</p> |
+</body> |
+</html> |