OLD | NEW |
(Empty) | |
| 1 <html> |
| 2 <head> |
| 3 <script src="../http/tests/inspector/inspector-test.js"></script> |
| 4 <script src="../http/tests/inspector/workspace-test.js"></script> |
| 5 <script src="resources/blink-fs.js"></script> |
| 6 <script src="editor/editor-test.js"></script> |
| 7 <script> |
| 8 function test() |
| 9 { |
| 10 WebInspector.experimentsSettings.jumpToPreviousLocation.enableForTest(); |
| 11 WebInspector.showPanel("scripts"); |
| 12 var panel = WebInspector.panels.scripts; |
| 13 var project = WebInspector.workspace.projectsForType(WebInspector.projectTyp
es.Network)[0]; |
| 14 var sourceCodes = project.uiSourceCodes(); |
| 15 |
| 16 function findSourceCode(substring) |
| 17 { |
| 18 for (var i = 0; i < sourceCodes.length; ++i) { |
| 19 if (sourceCodes[i].path().indexOf(substring) >= 0) |
| 20 return sourceCodes[i]; |
| 21 } |
| 22 return null; |
| 23 } |
| 24 |
| 25 function clickAtEditor(editor, lineNumber, columnNumber) |
| 26 { |
| 27 editor.scrollToLine(lineNumber); |
| 28 var coordinates = editor.cursorPositionToCoordinates(lineNumber, columnN
umber); |
| 29 eventSender.mouseMoveTo(coordinates.x, coordinates.y); |
| 30 eventSender.mouseDown(); |
| 31 eventSender.mouseUp(); |
| 32 dumpSelection(editor, "Mouse click (" + lineNumber + ", " + columnNumber
+ ")"); |
| 33 } |
| 34 |
| 35 function clickAndDump(editor, callback, lines, columns) |
| 36 { |
| 37 var iterationsAmount = lines.length; |
| 38 function innerClickAndDump(iteration) |
| 39 { |
| 40 if (iteration === iterationsAmount) { |
| 41 callback(); |
| 42 return; |
| 43 } |
| 44 clickAtEditor(editor, lines[iteration], columns[iteration]); |
| 45 setTimeout(innerClickAndDump.bind(this, iteration + 1), 0); |
| 46 } |
| 47 innerClickAndDump(0); |
| 48 } |
| 49 |
| 50 function dumpSelection(editor, label) |
| 51 { |
| 52 InspectorTest.addResult("<" + label + "> line: " + editor.selection().st
artLine + |
| 53 " column: " + editor.selection().startColumn + |
| 54 " [" + editor._url.split("/").pop() + "]"); |
| 55 } |
| 56 |
| 57 InspectorTest.runTestSuite([ |
| 58 function testSimpleMovements(next) |
| 59 { |
| 60 var uiSourceCode = findSourceCode("blink-fs"); |
| 61 panel._showFile(uiSourceCode); |
| 62 uiSourceCode.requestContent(onContentLoaded); |
| 63 function onContentLoaded() |
| 64 { |
| 65 var editor = panel.visibleView.textEditor; |
| 66 dumpSelection(editor, "Initial position"); |
| 67 clickAtEditor(editor, 4, 7); |
| 68 |
| 69 InspectorTest.typeIn("\nSome more text here"); |
| 70 dumpSelection(editor, "Typed in some text"); |
| 71 |
| 72 panel._previousPosition(); |
| 73 dumpSelection(editor, "Rolled back"); |
| 74 InspectorTest.typeIn("\nSome more text here as well\n"); |
| 75 dumpSelection(editor, "Typed in some text"); |
| 76 |
| 77 panel._nextPosition(); |
| 78 dumpSelection(editor, "Rolled over"); |
| 79 next(); |
| 80 } |
| 81 }, |
| 82 |
| 83 function testSequentialJumps(next) |
| 84 { |
| 85 var editor = panel.visibleView.textEditor; |
| 86 const jumpsToDo = 4; |
| 87 clickAndDump(editor, jumpBack, [10, 11, 12, 13], [3, 4, 5, 6]); |
| 88 |
| 89 function jumpBack() |
| 90 { |
| 91 for (var i = 0; i < jumpsToDo; ++i) { |
| 92 panel._previousPosition(); |
| 93 dumpSelection(editor, "Rolled back"); |
| 94 } |
| 95 for (var i = 0; i < jumpsToDo; ++i) { |
| 96 panel._nextPosition(); |
| 97 dumpSelection(editor, "Rolled over"); |
| 98 } |
| 99 next(); |
| 100 } |
| 101 }, |
| 102 |
| 103 function testDeletePreviousJumpLocations(next) |
| 104 { |
| 105 var editor = panel.visibleView.textEditor; |
| 106 editor.editRange(new WebInspector.TextRange(9, 0, 15, 0), ""); |
| 107 dumpSelection(editor, "Removed lines from 9 to 15"); |
| 108 panel._previousPosition(); |
| 109 dumpSelection(editor, "Rolled back"); |
| 110 panel._nextPosition(); |
| 111 dumpSelection(editor, "Rolled over"); |
| 112 next(); |
| 113 }, |
| 114 |
| 115 function testDeleteNextJumpLocations(next) |
| 116 { |
| 117 var editor = panel.visibleView.textEditor; |
| 118 const jumpsToDo = 4; |
| 119 clickAndDump(editor, step2, [10, 11, 12, 13], [3, 4, 5, 6]); |
| 120 |
| 121 function step2() |
| 122 { |
| 123 for (var i = 0; i < jumpsToDo; ++i) |
| 124 panel._previousPosition(); |
| 125 dumpSelection(editor, "Rolled back 4 times"); |
| 126 editor.editRange(new WebInspector.TextRange(9, 0, 11, 0), ""); |
| 127 dumpSelection(editor, "Removed lines from 9 to 11"); |
| 128 panel._nextPosition(); |
| 129 dumpSelection(editor, "Rolled over"); |
| 130 next(); |
| 131 } |
| 132 }, |
| 133 |
| 134 function testCrossFileJump(next) |
| 135 { |
| 136 var uiSourceCode = findSourceCode("workspace-test.js"); |
| 137 panel._showFile(uiSourceCode); |
| 138 uiSourceCode.requestContent(onContentLoaded); |
| 139 function onContentLoaded() |
| 140 { |
| 141 var editor = panel.visibleView.textEditor; |
| 142 dumpSelection(editor, "Opened workspace-test.js"); |
| 143 clickAndDump(editor, step2, [10, 11], [1, 1]); |
| 144 } |
| 145 function step2() |
| 146 { |
| 147 for (var i = 0; i < 4; ++i) { |
| 148 panel._previousPosition(); |
| 149 dumpSelection(panel.visibleView.textEditor, "Rolled back"); |
| 150 } |
| 151 for (var i = 0; i < 4; ++i) { |
| 152 panel._nextPosition(); |
| 153 dumpSelection(panel.visibleView.textEditor, "Rolled over"); |
| 154 } |
| 155 next(); |
| 156 } |
| 157 }, |
| 158 |
| 159 function testCloseCrossFile(next) |
| 160 { |
| 161 var selectedTab = panel._editorContainer._tabbedPane.selectedTabId; |
| 162 panel._editorContainer._tabbedPane.closeTab(selectedTab); |
| 163 dumpSelection(panel.visibleView.textEditor, "Close active tab"); |
| 164 for (var i = 0; i < 1; ++i) { |
| 165 panel._previousPosition(); |
| 166 dumpSelection(panel.visibleView.textEditor, "Rolled back"); |
| 167 } |
| 168 for (var i = 0; i < 3; ++i) { |
| 169 panel._nextPosition(); |
| 170 dumpSelection(panel.visibleView.textEditor, "Rolled over"); |
| 171 } |
| 172 next(); |
| 173 }, |
| 174 |
| 175 function testHistoryDepth(next) |
| 176 { |
| 177 var lines = []; |
| 178 var columns = []; |
| 179 const jumpsAmount = WebInspector.ScriptsPanel.JumpHistoryDepth; |
| 180 for(var i = 0; i < jumpsAmount; ++i) { |
| 181 lines.push(i + 10); |
| 182 columns.push(7); |
| 183 } |
| 184 var editor = panel.visibleView.textEditor; |
| 185 clickAndDump(editor, step2, lines, columns); |
| 186 function step2() |
| 187 { |
| 188 for (var i = 0; i < jumpsAmount; ++i) { |
| 189 panel._previousPosition(); |
| 190 dumpSelection(editor, "Rolled back"); |
| 191 } |
| 192 next(); |
| 193 } |
| 194 } |
| 195 ]); |
| 196 }; |
| 197 </script> |
| 198 </head> |
| 199 <body onload="runTest()"> |
| 200 <p>Tests that scripts panel UI elements work as intended.</p> |
| 201 </body> |
| 202 </html> |
OLD | NEW |