| 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..1c1c6ad480eefbae69bc5437fe1e543f9f5129c7
|
| --- /dev/null
|
| +++ b/LayoutTests/inspector/jump-to-previous-editing-location.html
|
| @@ -0,0 +1,269 @@
|
| +<html>
|
| +<head>
|
| +<script src="../http/tests/inspector/inspector-test.js"></script>
|
| +<script src="../http/tests/inspector/workspace-test.js"></script>
|
| +<script src="../http/tests/inspector/debugger-test.js"></script>
|
| +<script src="resources/blink-fs.js"></script>
|
| +<script src="editor/editor-test.js"></script>
|
| +<script>
|
| +function test()
|
| +{
|
| + WebInspector.showPanel("sources");
|
| + var panel = WebInspector.panels.sources;
|
| +
|
| + function rollback()
|
| + {
|
| + panel._historyManager.rollback();
|
| + }
|
| +
|
| + function rollover()
|
| + {
|
| + panel._historyManager.rollover();
|
| + }
|
| +
|
| + 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 dumpLineColumn(line, column)
|
| + {
|
| + return "line: " + line + " column: " + column;
|
| + }
|
| +
|
| + function dumpSelection(editor, label)
|
| + {
|
| + var selection = editor.selection();
|
| + var label = "<" + label + ">";
|
| + var fileName = "[" + editor._url.split("/").pop() + "]";
|
| + var selectionText = "";
|
| + if (selection.isEmpty())
|
| + selectionText = "line: " + selection.startLine + " column: " + selection.startColumn;
|
| + else
|
| + selectionText = "(NOT EMPTY): " + selection.toString();
|
| + InspectorTest.addResult(label + " " + selectionText + " " + fileName);
|
| + }
|
| +
|
| + InspectorTest.runTestSuite([
|
| + function testSimpleMovements(next)
|
| + {
|
| + InspectorTest.showScriptSource("blink-fs.js", 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");
|
| +
|
| + rollback();
|
| + dumpSelection(editor, "Rolled back");
|
| + InspectorTest.typeIn("\nSome more text here as well\n");
|
| + dumpSelection(editor, "Typed in some text");
|
| +
|
| + rollover();
|
| + 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) {
|
| + rollback();
|
| + dumpSelection(editor, "Rolled back");
|
| + }
|
| + for (var i = 0; i < jumpsToDo; ++i) {
|
| + rollover();
|
| + 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");
|
| + rollback();
|
| + dumpSelection(editor, "Rolled back");
|
| + rollover();
|
| + 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)
|
| + rollback();
|
| + dumpSelection(editor, "Rolled back 4 times");
|
| + editor.editRange(new WebInspector.TextRange(9, 0, 11, 0), "");
|
| + dumpSelection(editor, "Removed lines from 9 to 11");
|
| + rollover();
|
| + dumpSelection(editor, "Rolled over");
|
| + next();
|
| + }
|
| + },
|
| +
|
| + function testCrossFileJump(next)
|
| + {
|
| + InspectorTest.showScriptSource("workspace-test.js", 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) {
|
| + rollback();
|
| + dumpSelection(panel.visibleView.textEditor, "Rolled back");
|
| + }
|
| + for (var i = 0; i < 4; ++i) {
|
| + rollover();
|
| + 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) {
|
| + rollback();
|
| + dumpSelection(panel.visibleView.textEditor, "Rolled back");
|
| + }
|
| + for (var i = 0; i < 3; ++i) {
|
| + rollover();
|
| + dumpSelection(panel.visibleView.textEditor, "Rolled over");
|
| + }
|
| + next();
|
| + },
|
| +
|
| + function testHistoryDepth(next)
|
| + {
|
| + var lines = [];
|
| + var columns = [];
|
| + const jumpsAmount = WebInspector.EditingLocationHistoryManager.HistoryDepth;
|
| + 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) {
|
| + rollback();
|
| + dumpSelection(editor, "Rolled back");
|
| + }
|
| + next();
|
| + }
|
| + },
|
| +
|
| + function testInFileSearch(next)
|
| + {
|
| + var searchableView = panel.searchableView();
|
| + searchableView.showSearchField();
|
| + dumpSelection(panel.visibleView.textEditor, "Before searching");
|
| + InspectorTest.typeIn("generate_");
|
| + for (var i = 0; i < 3; ++i)
|
| + searchableView.handleFindPreviousShortcut();
|
| + searchableView.closeSearch();
|
| + dumpSelection(panel.visibleView.textEditor, "After searching");
|
| + rollback();
|
| + dumpSelection(panel.visibleView.textEditor, "Rolled back");
|
| + rollover();
|
| + dumpSelection(panel.visibleView.textEditor, "Rolled over");
|
| + next();
|
| + },
|
| +
|
| + function testShowAnchorLocation(next)
|
| + {
|
| + dumpSelection(panel.visibleView.textEditor, "Before switching to other panel");
|
| + InspectorTest.waitForScriptSource("workspace-test.js", onScriptSource);
|
| + function onScriptSource(uiSourceCode)
|
| + {
|
| + var linkifier = new WebInspector.Linkifier();
|
| + var anchorURI = uiSourceCode.uri();
|
| + var jumpAnchor = linkifier.linkifyLocation(anchorURI, 10, 1);
|
| + WebInspector.showPanel("timeline");
|
| + WebInspector.showAnchorLocation(jumpAnchor);
|
| + InspectorTest.addResult("Selection: " + panel.visibleView.textEditor.selection().toString());
|
| + dumpSelection(panel.visibleView.textEditor, "Showed anchor in " + anchorURI.split("/").pop() + " with line 333 column 3");
|
| + rollback();
|
| + dumpSelection(panel.visibleView.textEditor, "Rolled back");
|
| + rollover();
|
| + dumpSelection(panel.visibleView.textEditor, "Rolled over");
|
| + next();
|
| + }
|
| + },
|
| +
|
| + function testShowUISourceCode(next)
|
| + {
|
| + dumpSelection(panel.visibleView.textEditor, "Initial state");
|
| +
|
| + InspectorTest.waitForScriptSource("blink-fs.js", onScriptSourceLoaded);
|
| + function onScriptSourceLoaded(uiSourceCode)
|
| + {
|
| + var jumps = [20, 10, 30];
|
| + for (var i = 0; i < jumps.length; ++i) {
|
| + panel.showUISourceCode(uiSourceCode, jumps[i]);
|
| + dumpSelection(panel.visibleView.textEditor, "jump to line " + jumps[i]);
|
| + }
|
| + panel.highlightPosition(40, 10);
|
| + dumpSelection(panel.visibleView.textEditor, "highlight line 40");
|
| + for (var i = 0; i < jumps.length + 1; ++i) {
|
| + rollback();
|
| + dumpSelection(panel.visibleView.textEditor, "rollback");
|
| + }
|
| + next();
|
| + }
|
| + }
|
| + ]);
|
| +};
|
| +</script>
|
| +</head>
|
| +<body onload="runTest()">
|
| +<p>Tests that jumping to previous location works as intended.</p>
|
| +</body>
|
| +</html>
|
|
|