Move parseFontFaceDescriptor to CSSPropertyParser.cpp
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / inspector / jump-to-previous-editing-location.html
blob4250fb4763a0ea59cc5fe541d719c1f3dde42cd5
1 <html>
2 <head>
3 <script src="../http/tests/inspector/inspector-test.js"></script>
4 <script src="../http/tests/inspector/console-test.js"></script>
5 <script src="../http/tests/inspector/workspace-test.js"></script>
6 <script src="../http/tests/inspector/debugger-test.js"></script>
7 <script src="resources/example-fileset-for-test.js"></script>
8 <script src="editor/editor-test.js"></script>
9 <script>
10 function test()
12 var panel = WebInspector.panels.sources;
13 var sourcesView = panel._sourcesView;
14 var historyManager = sourcesView._historyManager;
15 var editorContainer = sourcesView._editorContainer;
17 function rollback()
19 historyManager.rollback();
22 function rollover()
24 historyManager.rollover();
27 function dumpSelection(editor, label)
29 var selection = editor.selection();
30 var label = "<" + label + ">";
31 var fileName = "[" + editor._url.split("/").pop() + "]";
32 var selectionText = "";
33 if (selection.isEmpty())
34 selectionText = "line: " + selection.startLine + " column: " + selection.startColumn;
35 else
36 selectionText = "(NOT EMPTY): " + selection.toString();
37 InspectorTest.addResult(label + " " + selectionText + " " + fileName);
40 function eventSenderClickAtEditor(editor, lineNumber, columnNumber)
42 editor.scrollToLine(lineNumber);
43 var coordinates = editor.cursorPositionToCoordinates(lineNumber, columnNumber);
44 eventSender.mouseMoveTo(coordinates.x, coordinates.y);
45 eventSender.mouseDown();
46 eventSender.mouseUp();
47 dumpSelection(editor, "Mouse click (" + lineNumber + ", " + columnNumber + ")");
50 function clickAndDump(editor, lines, columns)
52 for (var i = 0; i < lines.length; ++i) {
53 var lineNumber = lines[i];
54 var columnNumber = columns[i];
55 var originSelection = editor.selection();
56 editor.setSelection(WebInspector.TextRange.createFromLocation(lineNumber, columnNumber));
57 editor._delegate.onJumpToPosition(originSelection, editor.selection());
58 dumpSelection(editor, "Mouse click (" + lineNumber + ", " + columnNumber + ")");
62 InspectorTest.runTestSuite([
63 function testSimpleMovements(next)
65 InspectorTest.showScriptSource("example-fileset-for-test.js", onContentLoaded);
67 function onContentLoaded()
69 var editor = panel.visibleView.textEditor;
70 dumpSelection(editor, "Initial position");
71 eventSenderClickAtEditor(editor, 4, 7, true);
73 InspectorTest.typeIn(editor, "\nSome more text here", step2);
76 function step2() {
77 var editor = panel.visibleView.textEditor;
78 dumpSelection(editor, "Typed in some text");
80 rollback();
81 dumpSelection(editor, "Rolled back");
82 InspectorTest.typeIn(editor, "\nSome more text here as well\n", step3);
85 function step3() {
86 var editor = panel.visibleView.textEditor;
87 dumpSelection(editor, "Typed in some text");
89 rollover();
90 dumpSelection(editor, "Rolled over");
91 next();
95 function testSequentialJumps(next)
97 var editor = panel.visibleView.textEditor;
98 // Hide inspector view to significantly speed up following tests from testsuite.
99 InspectorTest.hideInspectorView();
100 const jumpsToDo = 4;
101 clickAndDump(editor, [10, 11, 12, 13], [3, 4, 5, 6]);
103 for (var i = 0; i < jumpsToDo; ++i) {
104 rollback();
105 dumpSelection(editor, "Rolled back");
107 for (var i = 0; i < jumpsToDo; ++i) {
108 rollover();
109 dumpSelection(editor, "Rolled over");
111 next();
114 function testDeletePreviousJumpLocations(next)
116 var editor = panel.visibleView.textEditor;
117 editor.editRange(new WebInspector.TextRange(9, 0, 15, 0), "");
118 dumpSelection(editor, "Removed lines from 9 to 15");
119 rollback();
120 dumpSelection(editor, "Rolled back");
121 rollover();
122 dumpSelection(editor, "Rolled over");
123 next();
126 function testDeleteNextJumpLocations(next)
128 var editor = panel.visibleView.textEditor;
129 const jumpsToDo = 4;
130 clickAndDump(editor, [10, 11, 12, 13], [3, 4, 5, 6]);
132 for (var i = 0; i < jumpsToDo; ++i)
133 rollback();
134 dumpSelection(editor, "Rolled back 4 times");
135 editor.editRange(new WebInspector.TextRange(9, 0, 11, 0), "");
136 dumpSelection(editor, "Removed lines from 9 to 11");
137 rollover();
138 dumpSelection(editor, "Rolled over");
139 next();
142 function testCrossFileJump(next)
144 InspectorTest.showScriptSource("workspace-test.js", onContentLoaded);
145 function onContentLoaded()
147 var editor = panel.visibleView.textEditor;
148 dumpSelection(editor, "Opened workspace-test.js");
149 clickAndDump(editor, [10, 11], [1, 1]);
150 for (var i = 0; i < 4; ++i) {
151 rollback();
152 dumpSelection(panel.visibleView.textEditor, "Rolled back");
154 for (var i = 0; i < 4; ++i) {
155 rollover();
156 dumpSelection(panel.visibleView.textEditor, "Rolled over");
158 next();
162 function testCloseCrossFile(next)
164 var selectedTab = editorContainer._tabbedPane.selectedTabId;
165 editorContainer._tabbedPane.closeTab(selectedTab);
166 dumpSelection(panel.visibleView.textEditor, "Close active tab");
167 for (var i = 0; i < 1; ++i) {
168 rollback();
169 dumpSelection(panel.visibleView.textEditor, "Rolled back");
171 for (var i = 0; i < 3; ++i) {
172 rollover();
173 dumpSelection(panel.visibleView.textEditor, "Rolled over");
175 next();
178 function testHistoryDepth(next)
180 var lines = [];
181 var columns = [];
182 const jumpsAmount = WebInspector.EditingLocationHistoryManager.HistoryDepth;
183 for(var i = 0; i < jumpsAmount; ++i) {
184 lines.push(i + 10);
185 columns.push(7);
187 var editor = panel.visibleView.textEditor;
188 clickAndDump(editor, lines, columns);
189 for (var i = 0; i < jumpsAmount; ++i) {
190 rollback();
191 dumpSelection(editor, "Rolled back");
193 next();
196 function testInFileSearch(next)
198 var searchableView = panel.searchableView();
200 dumpSelection(panel.visibleView.textEditor, "Before searching");
202 searchableView.showSearchField();
203 searchableView._searchInputElement.value = "generate_";
204 searchableView._performSearch(true, true);
205 for (var i = 0; i < 3; ++i)
206 searchableView.handleFindNextShortcut();
207 searchableView.handleCancelSearchShortcut();
209 dumpSelection(panel.visibleView.textEditor, "After searching");
210 rollback();
211 dumpSelection(panel.visibleView.textEditor, "Rolled back");
212 rollover();
213 dumpSelection(panel.visibleView.textEditor, "Rolled over");
214 next();
217 function testShowAnchorLocation(next)
219 dumpSelection(panel.visibleView.textEditor, "Before switching to other panel");
220 InspectorTest.waitForScriptSource("workspace-test.js", onScriptSource);
221 function onScriptSource(uiSourceCode)
223 var linkifier = new WebInspector.Linkifier();
224 var anchorURI = WebInspector.networkMapping.networkURL(uiSourceCode);
225 var anchor = linkifier.linkifyScriptLocation(WebInspector.targetManager.mainTarget(), null, anchorURI, 10, 1);
226 WebInspector.Revealer.revealPromise(anchor[WebInspector.Linkifier._uiLocationSymbol]).then(function() {
227 InspectorTest.addResult("Selection: " + panel.visibleView.textEditor.selection().toString());
228 dumpSelection(panel.visibleView.textEditor, "Showed anchor in " + anchorURI.split("/").pop() + " with line 333 column 3");
229 rollback();
230 dumpSelection(panel.visibleView.textEditor, "Rolled back");
231 rollover();
232 dumpSelection(panel.visibleView.textEditor, "Rolled over");
233 next();
238 function testShowUISourceCode(next)
240 dumpSelection(panel.visibleView.textEditor, "Initial state");
242 InspectorTest.waitForScriptSource("example-fileset-for-test.js", onScriptSourceLoaded);
243 function onScriptSourceLoaded(uiSourceCode)
245 var jumps = [20, 10, 30];
246 for (var i = 0; i < jumps.length; ++i) {
247 panel.showUISourceCode(uiSourceCode, jumps[i]);
248 dumpSelection(panel.visibleView.textEditor, "jump to line " + jumps[i]);
250 panel.showUISourceCode(uiSourceCode, 40, 10);
251 dumpSelection(panel.visibleView.textEditor, "highlight line 40");
252 for (var i = 0; i < jumps.length + 1; ++i) {
253 rollback();
254 dumpSelection(panel.visibleView.textEditor, "rollback");
256 next();
261 </script>
262 </head>
263 <body onload="runTest()">
264 <p>Tests that jumping to previous location works as intended.</p>
265 </body>
266 </html>