| 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..67a2d5b2b48d7105b51b51486224942b4156d6b2
|
| --- /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");
|
| +
|
| + WebInspector.jumpHistoryManager.rollback();
|
| + dumpSelection(editor, "Rolled back");
|
| + InspectorTest.typeIn("\nSome more text here as well\n");
|
| + dumpSelection(editor, "Typed in some text");
|
| +
|
| + WebInspector.jumpHistoryManager.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) {
|
| + WebInspector.jumpHistoryManager.rollback();
|
| + dumpSelection(editor, "Rolled back");
|
| + }
|
| + for (var i = 0; i < jumpsToDo; ++i) {
|
| + WebInspector.jumpHistoryManager.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");
|
| + WebInspector.jumpHistoryManager.rollback();
|
| + dumpSelection(editor, "Rolled back");
|
| + WebInspector.jumpHistoryManager.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)
|
| + WebInspector.jumpHistoryManager.rollback();
|
| + dumpSelection(editor, "Rolled back 4 times");
|
| + editor.editRange(new WebInspector.TextRange(9, 0, 11, 0), "");
|
| + dumpSelection(editor, "Removed lines from 9 to 11");
|
| + WebInspector.jumpHistoryManager.rollover();
|
| + 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) {
|
| + WebInspector.jumpHistoryManager.rollback();
|
| + dumpSelection(panel.visibleView.textEditor, "Rolled back");
|
| + }
|
| + for (var i = 0; i < 4; ++i) {
|
| + WebInspector.jumpHistoryManager.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) {
|
| + WebInspector.jumpHistoryManager.rollback();
|
| + dumpSelection(panel.visibleView.textEditor, "Rolled back");
|
| + }
|
| + for (var i = 0; i < 3; ++i) {
|
| + WebInspector.jumpHistoryManager.rollover();
|
| + dumpSelection(panel.visibleView.textEditor, "Rolled over");
|
| + }
|
| + next();
|
| + },
|
| +
|
| + function testHistoryDepth(next)
|
| + {
|
| + var lines = [];
|
| + var columns = [];
|
| + const jumpsAmount = WebInspector.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) {
|
| + WebInspector.jumpHistoryManager.rollback();
|
| + dumpSelection(editor, "Rolled back");
|
| + }
|
| + next();
|
| + }
|
| + }
|
| + ]);
|
| +};
|
| +</script>
|
| +</head>
|
| +<body onload="runTest()">
|
| +<p>Tests that scripts panel UI elements work as intended.</p>
|
| +</body>
|
| +</html>
|
|
|