browser/devtools/debugger/test/browser_dbg_search-basic-01.js

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

michael@0 1 /* Any copyright is dedicated to the Public Domain.
michael@0 2 http://creativecommons.org/publicdomain/zero/1.0/ */
michael@0 3
michael@0 4 /**
michael@0 5 * Tests basic search functionality (find token and jump to line).
michael@0 6 */
michael@0 7
michael@0 8 const TAB_URL = EXAMPLE_URL + "doc_recursion-stack.html";
michael@0 9
michael@0 10 let gTab, gDebuggee, gPanel, gDebugger;
michael@0 11 let gEditor, gSources, gFiltering, gSearchBox;
michael@0 12
michael@0 13 function test() {
michael@0 14 initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => {
michael@0 15 gTab = aTab;
michael@0 16 gDebuggee = aDebuggee;
michael@0 17 gPanel = aPanel;
michael@0 18 gDebugger = gPanel.panelWin;
michael@0 19 gEditor = gDebugger.DebuggerView.editor;
michael@0 20 gSources = gDebugger.DebuggerView.Sources;
michael@0 21 gFiltering = gDebugger.DebuggerView.Filtering;
michael@0 22 gSearchBox = gDebugger.DebuggerView.Filtering._searchbox;
michael@0 23
michael@0 24 waitForSourceShown(gPanel, ".html").then(performTest);
michael@0 25 });
michael@0 26 }
michael@0 27
michael@0 28 function performTest() {
michael@0 29 setText(gSearchBox, "#html");
michael@0 30
michael@0 31 EventUtils.synthesizeKey("VK_RETURN", { shiftKey: true }, gDebugger);
michael@0 32 is(gFiltering.searchData.toSource(), '["#", ["", "html"]]',
michael@0 33 "The searchbox data wasn't parsed correctly.");
michael@0 34 ok(isCaretPos(gPanel, 35, 7),
michael@0 35 "The editor didn't jump to the correct line.");
michael@0 36
michael@0 37 EventUtils.synthesizeKey("VK_RETURN", { shiftKey: true }, gDebugger);
michael@0 38 is(gFiltering.searchData.toSource(), '["#", ["", "html"]]',
michael@0 39 "The searchbox data wasn't parsed correctly.");
michael@0 40 ok(isCaretPos(gPanel, 5, 6),
michael@0 41 "The editor didn't jump to the correct line.");
michael@0 42
michael@0 43 EventUtils.synthesizeKey("VK_RETURN", { shiftKey: true }, gDebugger);
michael@0 44 is(gFiltering.searchData.toSource(), '["#", ["", "html"]]',
michael@0 45 "The searchbox data wasn't parsed correctly.");
michael@0 46 ok(isCaretPos(gPanel, 3, 15),
michael@0 47 "The editor didn't jump to the correct line.");
michael@0 48
michael@0 49 setText(gSearchBox, ":12");
michael@0 50 is(gFiltering.searchData.toSource(), '[":", ["", 12]]',
michael@0 51 "The searchbox data wasn't parsed correctly.");
michael@0 52 ok(isCaretPos(gPanel, 12),
michael@0 53 "The editor didn't jump to the correct line.");
michael@0 54
michael@0 55 EventUtils.synthesizeKey("g", { metaKey: true }, gDebugger);
michael@0 56 is(gFiltering.searchData.toSource(), '[":", ["", 13]]',
michael@0 57 "The searchbox data wasn't parsed correctly.");
michael@0 58 ok(isCaretPos(gPanel, 13),
michael@0 59 "The editor didn't jump to the correct line after Meta+G.");
michael@0 60
michael@0 61 EventUtils.synthesizeKey("n", { ctrlKey: true }, gDebugger);
michael@0 62 is(gFiltering.searchData.toSource(), '[":", ["", 14]]',
michael@0 63 "The searchbox data wasn't parsed correctly.");
michael@0 64 ok(isCaretPos(gPanel, 14),
michael@0 65 "The editor didn't jump to the correct line after Ctrl+N.");
michael@0 66
michael@0 67 EventUtils.synthesizeKey("G", { metaKey: true, shiftKey: true }, gDebugger);
michael@0 68 is(gFiltering.searchData.toSource(), '[":", ["", 13]]',
michael@0 69 "The searchbox data wasn't parsed correctly.");
michael@0 70 ok(isCaretPos(gPanel, 13),
michael@0 71 "The editor didn't jump to the correct line after Meta+Shift+G.");
michael@0 72
michael@0 73 EventUtils.synthesizeKey("p", { ctrlKey: true }, gDebugger);
michael@0 74 is(gFiltering.searchData.toSource(), '[":", ["", 12]]',
michael@0 75 "The searchbox data wasn't parsed correctly.");
michael@0 76 ok(isCaretPos(gPanel, 12),
michael@0 77 "The editor didn't jump to the correct line after Ctrl+P.");
michael@0 78
michael@0 79 for (let i = 0; i < 100; i++) {
michael@0 80 EventUtils.sendKey("DOWN", gDebugger);
michael@0 81 }
michael@0 82 is(gFiltering.searchData.toSource(), '[":", ["", 36]]',
michael@0 83 "The searchbox data wasn't parsed correctly.");
michael@0 84 ok(isCaretPos(gPanel, 36),
michael@0 85 "The editor didn't jump to the correct line after multiple DOWN keys.");
michael@0 86
michael@0 87 for (let i = 0; i < 100; i++) {
michael@0 88 EventUtils.sendKey("UP", gDebugger);
michael@0 89 }
michael@0 90 is(gFiltering.searchData.toSource(), '[":", ["", 1]]',
michael@0 91 "The searchbox data wasn't parsed correctly.");
michael@0 92 ok(isCaretPos(gPanel, 1),
michael@0 93 "The editor didn't jump to the correct line after multiple UP keys.");
michael@0 94
michael@0 95
michael@0 96 let token = "debugger";
michael@0 97 setText(gSearchBox, "#" + token);
michael@0 98 is(gFiltering.searchData.toSource(), '["#", ["", "debugger"]]',
michael@0 99 "The searchbox data wasn't parsed correctly.");
michael@0 100 ok(isCaretPos(gPanel, 8, 12 + token.length),
michael@0 101 "The editor didn't jump to the correct token (1).");
michael@0 102
michael@0 103 EventUtils.sendKey("DOWN", gDebugger);
michael@0 104 is(gFiltering.searchData.toSource(), '["#", ["", "debugger"]]',
michael@0 105 "The searchbox data wasn't parsed correctly.");
michael@0 106 ok(isCaretPos(gPanel, 14, 9 + token.length),
michael@0 107 "The editor didn't jump to the correct token (2).");
michael@0 108
michael@0 109 EventUtils.sendKey("DOWN", gDebugger);
michael@0 110 is(gFiltering.searchData.toSource(), '["#", ["", "debugger"]]',
michael@0 111 "The searchbox data wasn't parsed correctly.");
michael@0 112 ok(isCaretPos(gPanel, 18, 15 + token.length),
michael@0 113 "The editor didn't jump to the correct token (3).");
michael@0 114
michael@0 115 EventUtils.sendKey("RETURN", gDebugger);
michael@0 116 is(gFiltering.searchData.toSource(), '["#", ["", "debugger"]]',
michael@0 117 "The searchbox data wasn't parsed correctly.");
michael@0 118 ok(isCaretPos(gPanel, 26, 11 + token.length),
michael@0 119 "The editor didn't jump to the correct token (4).");
michael@0 120
michael@0 121 EventUtils.sendKey("RETURN", gDebugger);
michael@0 122 is(gFiltering.searchData.toSource(), '["#", ["", "debugger"]]',
michael@0 123 "The searchbox data wasn't parsed correctly.");
michael@0 124 ok(isCaretPos(gPanel, 8, 12 + token.length),
michael@0 125 "The editor didn't jump to the correct token (5).");
michael@0 126
michael@0 127 EventUtils.sendKey("UP", gDebugger);
michael@0 128 is(gFiltering.searchData.toSource(), '["#", ["", "debugger"]]',
michael@0 129 "The searchbox data wasn't parsed correctly.");
michael@0 130 ok(isCaretPos(gPanel, 26, 11 + token.length),
michael@0 131 "The editor didn't jump to the correct token (6).");
michael@0 132
michael@0 133 setText(gSearchBox, ":bogus#" + token + ";");
michael@0 134 is(gFiltering.searchData.toSource(), '["#", [":bogus", "debugger;"]]',
michael@0 135 "The searchbox data wasn't parsed correctly.");
michael@0 136 ok(isCaretPos(gPanel, 14, 9 + token.length + 1),
michael@0 137 "The editor didn't jump to the correct token (7).");
michael@0 138
michael@0 139 setText(gSearchBox, ":13#" + token + ";");
michael@0 140 is(gFiltering.searchData.toSource(), '["#", [":13", "debugger;"]]',
michael@0 141 "The searchbox data wasn't parsed correctly.");
michael@0 142 ok(isCaretPos(gPanel, 14, 9 + token.length + 1),
michael@0 143 "The editor didn't jump to the correct token (8).");
michael@0 144
michael@0 145 setText(gSearchBox, ":#" + token + ";");
michael@0 146 is(gFiltering.searchData.toSource(), '["#", [":", "debugger;"]]',
michael@0 147 "The searchbox data wasn't parsed correctly.");
michael@0 148 ok(isCaretPos(gPanel, 14, 9 + token.length + 1),
michael@0 149 "The editor didn't jump to the correct token (9).");
michael@0 150
michael@0 151 setText(gSearchBox, "::#" + token + ";");
michael@0 152 is(gFiltering.searchData.toSource(), '["#", ["::", "debugger;"]]',
michael@0 153 "The searchbox data wasn't parsed correctly.");
michael@0 154 ok(isCaretPos(gPanel, 14, 9 + token.length + 1),
michael@0 155 "The editor didn't jump to the correct token (10).");
michael@0 156
michael@0 157 setText(gSearchBox, ":::#" + token + ";");
michael@0 158 is(gFiltering.searchData.toSource(), '["#", [":::", "debugger;"]]',
michael@0 159 "The searchbox data wasn't parsed correctly.");
michael@0 160 ok(isCaretPos(gPanel, 14, 9 + token.length + 1),
michael@0 161 "The editor didn't jump to the correct token (11).");
michael@0 162
michael@0 163
michael@0 164 setText(gSearchBox, "#" + token + ";" + ":bogus");
michael@0 165 is(gFiltering.searchData.toSource(), '["#", ["", "debugger;:bogus"]]',
michael@0 166 "The searchbox data wasn't parsed correctly.");
michael@0 167 ok(isCaretPos(gPanel, 14, 9 + token.length + 1),
michael@0 168 "The editor didn't jump to the correct token (12).");
michael@0 169
michael@0 170 setText(gSearchBox, "#" + token + ";" + ":13");
michael@0 171 is(gFiltering.searchData.toSource(), '["#", ["", "debugger;:13"]]',
michael@0 172 "The searchbox data wasn't parsed correctly.");
michael@0 173 ok(isCaretPos(gPanel, 14, 9 + token.length + 1),
michael@0 174 "The editor didn't jump to the correct token (13).");
michael@0 175
michael@0 176 setText(gSearchBox, "#" + token + ";" + ":");
michael@0 177 is(gFiltering.searchData.toSource(), '["#", ["", "debugger;:"]]',
michael@0 178 "The searchbox data wasn't parsed correctly.");
michael@0 179 ok(isCaretPos(gPanel, 14, 9 + token.length + 1),
michael@0 180 "The editor didn't jump to the correct token (14).");
michael@0 181
michael@0 182 setText(gSearchBox, "#" + token + ";" + "::");
michael@0 183 is(gFiltering.searchData.toSource(), '["#", ["", "debugger;::"]]',
michael@0 184 "The searchbox data wasn't parsed correctly.");
michael@0 185 ok(isCaretPos(gPanel, 14, 9 + token.length + 1),
michael@0 186 "The editor didn't jump to the correct token (15).");
michael@0 187
michael@0 188 setText(gSearchBox, "#" + token + ";" + ":::");
michael@0 189 is(gFiltering.searchData.toSource(), '["#", ["", "debugger;:::"]]',
michael@0 190 "The searchbox data wasn't parsed correctly.");
michael@0 191 ok(isCaretPos(gPanel, 14, 9 + token.length + 1),
michael@0 192 "The editor didn't jump to the correct token (16).");
michael@0 193
michael@0 194
michael@0 195 setText(gSearchBox, ":i am not a number");
michael@0 196 is(gFiltering.searchData.toSource(), '[":", ["", 0]]',
michael@0 197 "The searchbox data wasn't parsed correctly.");
michael@0 198 ok(isCaretPos(gPanel, 14, 9 + token.length + 1),
michael@0 199 "The editor didn't remain at the correct token (17).");
michael@0 200
michael@0 201 setText(gSearchBox, "#__i do not exist__");
michael@0 202 is(gFiltering.searchData.toSource(), '["#", ["", "__i do not exist__"]]',
michael@0 203 "The searchbox data wasn't parsed correctly.");
michael@0 204 ok(isCaretPos(gPanel, 14, 9 + token.length + 1),
michael@0 205 "The editor didn't remain at the correct token (18).");
michael@0 206
michael@0 207
michael@0 208 setText(gSearchBox, "#" + token);
michael@0 209 is(gFiltering.searchData.toSource(), '["#", ["", "debugger"]]',
michael@0 210 "The searchbox data wasn't parsed correctly.");
michael@0 211 ok(isCaretPos(gPanel, 8, 12 + token.length),
michael@0 212 "The editor didn't jump to the correct token (19).");
michael@0 213
michael@0 214
michael@0 215 clearText(gSearchBox);
michael@0 216 is(gFiltering.searchData.toSource(), '["", [""]]',
michael@0 217 "The searchbox data wasn't parsed correctly.");
michael@0 218
michael@0 219 EventUtils.sendKey("RETURN", gDebugger);
michael@0 220 is(gFiltering.searchData.toSource(), '["", [""]]',
michael@0 221 "The searchbox data wasn't parsed correctly.");
michael@0 222 ok(isCaretPos(gPanel, 8, 12 + token.length),
michael@0 223 "The editor shouldn't jump to another token (20).");
michael@0 224
michael@0 225 EventUtils.sendKey("RETURN", gDebugger);
michael@0 226 is(gFiltering.searchData.toSource(), '["", [""]]',
michael@0 227 "The searchbox data wasn't parsed correctly.");
michael@0 228 ok(isCaretPos(gPanel, 8, 12 + token.length),
michael@0 229 "The editor shouldn't jump to another token (21).");
michael@0 230
michael@0 231
michael@0 232 setText(gSearchBox, ":1:2:3:a:b:c:::12");
michael@0 233 is(gFiltering.searchData.toSource(), '[":", [":1:2:3:a:b:c::", 12]]',
michael@0 234 "The searchbox data wasn't parsed correctly.");
michael@0 235 ok(isCaretPos(gPanel, 12),
michael@0 236 "The editor didn't jump to the correct line (22).");
michael@0 237
michael@0 238 setText(gSearchBox, "#don't#find#me#instead#find#" + token);
michael@0 239 is(gFiltering.searchData.toSource(), '["#", ["#don\'t#find#me#instead#find", "debugger"]]',
michael@0 240 "The searchbox data wasn't parsed correctly.");
michael@0 241 ok(isCaretPos(gPanel, 8, 12 + token.length),
michael@0 242 "The editor didn't jump to the correct token (23).");
michael@0 243
michael@0 244 EventUtils.sendKey("DOWN", gDebugger);
michael@0 245 is(gFiltering.searchData.toSource(), '["#", ["#don\'t#find#me#instead#find", "debugger"]]',
michael@0 246 "The searchbox data wasn't parsed correctly.");
michael@0 247 ok(isCaretPos(gPanel, 14, 9 + token.length),
michael@0 248 "The editor didn't jump to the correct token (24).");
michael@0 249
michael@0 250 EventUtils.sendKey("DOWN", gDebugger);
michael@0 251 is(gFiltering.searchData.toSource(), '["#", ["#don\'t#find#me#instead#find", "debugger"]]',
michael@0 252 "The searchbox data wasn't parsed correctly.");
michael@0 253 ok(isCaretPos(gPanel, 18, 15 + token.length),
michael@0 254 "The editor didn't jump to the correct token (25).");
michael@0 255
michael@0 256 EventUtils.sendKey("RETURN", gDebugger);
michael@0 257 is(gFiltering.searchData.toSource(), '["#", ["#don\'t#find#me#instead#find", "debugger"]]',
michael@0 258 "The searchbox data wasn't parsed correctly.");
michael@0 259 ok(isCaretPos(gPanel, 26, 11 + token.length),
michael@0 260 "The editor didn't jump to the correct token (26).");
michael@0 261
michael@0 262 EventUtils.sendKey("RETURN", gDebugger);
michael@0 263 is(gFiltering.searchData.toSource(), '["#", ["#don\'t#find#me#instead#find", "debugger"]]',
michael@0 264 "The searchbox data wasn't parsed correctly.");
michael@0 265 ok(isCaretPos(gPanel, 8, 12 + token.length),
michael@0 266 "The editor didn't jump to the correct token (27).");
michael@0 267
michael@0 268 EventUtils.sendKey("UP", gDebugger);
michael@0 269 is(gFiltering.searchData.toSource(), '["#", ["#don\'t#find#me#instead#find", "debugger"]]',
michael@0 270 "The searchbox data wasn't parsed correctly.");
michael@0 271 ok(isCaretPos(gPanel, 26, 11 + token.length),
michael@0 272 "The editor didn't jump to the correct token (28).");
michael@0 273
michael@0 274
michael@0 275 clearText(gSearchBox);
michael@0 276 is(gFiltering.searchData.toSource(), '["", [""]]',
michael@0 277 "The searchbox data wasn't parsed correctly.");
michael@0 278 ok(isCaretPos(gPanel, 26, 11 + token.length),
michael@0 279 "The editor didn't remain at the correct token (29).");
michael@0 280 is(gSources.visibleItems.length, 1,
michael@0 281 "Not all the sources are shown after the search (30).");
michael@0 282
michael@0 283
michael@0 284 gEditor.focus();
michael@0 285 gEditor.setSelection.apply(gEditor, gEditor.getPosition(1, 5));
michael@0 286 ok(isCaretPos(gPanel, 1, 6),
michael@0 287 "The editor caret position didn't update after selecting some text.");
michael@0 288
michael@0 289 EventUtils.synthesizeKey("F", { accelKey: true });
michael@0 290 is(gFiltering.searchData.toSource(), '["#", ["", "!-- "]]',
michael@0 291 "The searchbox data wasn't parsed correctly.");
michael@0 292 is(gSearchBox.value, "#!-- ",
michael@0 293 "The search field has the right initial value (1).");
michael@0 294
michael@0 295 gEditor.focus();
michael@0 296 gEditor.setSelection.apply(gEditor, gEditor.getPosition(415, 418));
michael@0 297 ok(isCaretPos(gPanel, 21, 30),
michael@0 298 "The editor caret position didn't update after selecting some number.");
michael@0 299
michael@0 300 EventUtils.synthesizeKey("L", { accelKey: true });
michael@0 301 is(gFiltering.searchData.toSource(), '[":", ["", 100]]',
michael@0 302 "The searchbox data wasn't parsed correctly.");
michael@0 303 is(gSearchBox.value, ":100",
michael@0 304 "The search field has the right initial value (2).");
michael@0 305
michael@0 306
michael@0 307 closeDebuggerAndFinish(gPanel);
michael@0 308 }
michael@0 309
michael@0 310 registerCleanupFunction(function() {
michael@0 311 gTab = null;
michael@0 312 gDebuggee = null;
michael@0 313 gPanel = null;
michael@0 314 gDebugger = null;
michael@0 315 gEditor = null;
michael@0 316 gSources = null;
michael@0 317 gFiltering = null;
michael@0 318 gSearchBox = null;
michael@0 319 });

mercurial