Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
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 if the function searching works properly. |
michael@0 | 6 | */ |
michael@0 | 7 | |
michael@0 | 8 | const TAB_URL = EXAMPLE_URL + "doc_function-search.html"; |
michael@0 | 9 | |
michael@0 | 10 | let gTab, gDebuggee, gPanel, gDebugger; |
michael@0 | 11 | let gEditor, gSources, gSearchBox, gFilteredFunctions; |
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 | gSearchBox = gDebugger.DebuggerView.Filtering._searchbox; |
michael@0 | 22 | gFilteredFunctions = gDebugger.DebuggerView.FilteredFunctions; |
michael@0 | 23 | |
michael@0 | 24 | waitForSourceShown(gPanel, "-01.js") |
michael@0 | 25 | .then(() => showSource("doc_function-search.html")) |
michael@0 | 26 | .then(htmlSearch) |
michael@0 | 27 | .then(() => showSource("code_function-search-01.js")) |
michael@0 | 28 | .then(firstJsSearch) |
michael@0 | 29 | .then(() => showSource("code_function-search-02.js")) |
michael@0 | 30 | .then(secondJsSearch) |
michael@0 | 31 | .then(() => showSource("code_function-search-03.js")) |
michael@0 | 32 | .then(thirdJsSearch) |
michael@0 | 33 | .then(saveSearch) |
michael@0 | 34 | .then(filterSearch) |
michael@0 | 35 | .then(bogusSearch) |
michael@0 | 36 | .then(incrementalSearch) |
michael@0 | 37 | .then(emptySearch) |
michael@0 | 38 | .then(() => closeDebuggerAndFinish(gPanel)) |
michael@0 | 39 | .then(null, aError => { |
michael@0 | 40 | ok(false, "Got an error: " + aError.message + "\n" + aError.stack); |
michael@0 | 41 | }); |
michael@0 | 42 | }); |
michael@0 | 43 | } |
michael@0 | 44 | |
michael@0 | 45 | function htmlSearch() { |
michael@0 | 46 | let deferred = promise.defer(); |
michael@0 | 47 | |
michael@0 | 48 | once(gDebugger, "popupshown").then(() => { |
michael@0 | 49 | writeInfo(); |
michael@0 | 50 | |
michael@0 | 51 | is(gFilteredFunctions.selectedIndex, 0, |
michael@0 | 52 | "An item should be selected in the filtered functions view (1)."); |
michael@0 | 53 | ok(gFilteredFunctions.selectedItem, |
michael@0 | 54 | "An item should be selected in the filtered functions view (2)."); |
michael@0 | 55 | |
michael@0 | 56 | if (gSources.selectedValue.indexOf(".html") != -1) { |
michael@0 | 57 | let expectedResults = [ |
michael@0 | 58 | ["inline", ".html", "", 19, 16], |
michael@0 | 59 | ["arrow", ".html", "", 20, 11], |
michael@0 | 60 | ["foo", ".html", "", 22, 11], |
michael@0 | 61 | ["foo2", ".html", "", 23, 11], |
michael@0 | 62 | ["bar2", ".html", "", 23, 18] |
michael@0 | 63 | ]; |
michael@0 | 64 | |
michael@0 | 65 | for (let [label, value, description, line, column] of expectedResults) { |
michael@0 | 66 | let target = gFilteredFunctions.selectedItem.target; |
michael@0 | 67 | |
michael@0 | 68 | if (label) { |
michael@0 | 69 | is(target.querySelector(".results-panel-item-label").getAttribute("value"), |
michael@0 | 70 | gDebugger.SourceUtils.trimUrlLength(label + "()"), |
michael@0 | 71 | "The corect label (" + label + ") is currently selected."); |
michael@0 | 72 | } else { |
michael@0 | 73 | ok(!target.querySelector(".results-panel-item-label"), |
michael@0 | 74 | "Shouldn't create empty label nodes."); |
michael@0 | 75 | } |
michael@0 | 76 | if (value) { |
michael@0 | 77 | ok(target.querySelector(".results-panel-item-label-below").getAttribute("value").contains(value), |
michael@0 | 78 | "The corect value (" + value + ") is attached."); |
michael@0 | 79 | } else { |
michael@0 | 80 | ok(!target.querySelector(".results-panel-item-label-below"), |
michael@0 | 81 | "Shouldn't create empty label nodes."); |
michael@0 | 82 | } |
michael@0 | 83 | if (description) { |
michael@0 | 84 | is(target.querySelector(".results-panel-item-label-before").getAttribute("value"), description, |
michael@0 | 85 | "The corect description (" + description + ") is currently shown."); |
michael@0 | 86 | } else { |
michael@0 | 87 | ok(!target.querySelector(".results-panel-item-label-before"), |
michael@0 | 88 | "Shouldn't create empty label nodes."); |
michael@0 | 89 | } |
michael@0 | 90 | |
michael@0 | 91 | ok(isCaretPos(gPanel, line, column), |
michael@0 | 92 | "The editor didn't jump to the correct line."); |
michael@0 | 93 | |
michael@0 | 94 | EventUtils.sendKey("DOWN", gDebugger); |
michael@0 | 95 | } |
michael@0 | 96 | |
michael@0 | 97 | ok(isCaretPos(gPanel, expectedResults[0][3], expectedResults[0][4]), |
michael@0 | 98 | "The editor didn't jump to the correct line again."); |
michael@0 | 99 | |
michael@0 | 100 | deferred.resolve(); |
michael@0 | 101 | } else { |
michael@0 | 102 | ok(false, "How did you get here? Go away, you."); |
michael@0 | 103 | } |
michael@0 | 104 | }); |
michael@0 | 105 | |
michael@0 | 106 | setText(gSearchBox, "@"); |
michael@0 | 107 | return deferred.promise; |
michael@0 | 108 | } |
michael@0 | 109 | |
michael@0 | 110 | function firstJsSearch() { |
michael@0 | 111 | let deferred = promise.defer(); |
michael@0 | 112 | |
michael@0 | 113 | once(gDebugger, "popupshown").then(() => { |
michael@0 | 114 | writeInfo(); |
michael@0 | 115 | |
michael@0 | 116 | is(gFilteredFunctions.selectedIndex, 0, |
michael@0 | 117 | "An item should be selected in the filtered functions view (1)."); |
michael@0 | 118 | ok(gFilteredFunctions.selectedItem, |
michael@0 | 119 | "An item should be selected in the filtered functions view (2)."); |
michael@0 | 120 | |
michael@0 | 121 | if (gSources.selectedValue.indexOf("-01.js") != -1) { |
michael@0 | 122 | let s = " " + gDebugger.L10N.getStr("functionSearchSeparatorLabel") + " "; |
michael@0 | 123 | let expectedResults = [ |
michael@0 | 124 | ["test", "-01.js", "", 4, 10], |
michael@0 | 125 | ["anonymousExpression", "-01.js", "test.prototype", 9, 3], |
michael@0 | 126 | ["namedExpression" + s + "NAME", "-01.js", "test.prototype", 11, 3], |
michael@0 | 127 | ["a_test", "-01.js", "foo", 22, 3], |
michael@0 | 128 | ["n_test" + s + "x", "-01.js", "foo", 24, 3], |
michael@0 | 129 | ["a_test", "-01.js", "foo.sub", 27, 5], |
michael@0 | 130 | ["n_test" + s + "y", "-01.js", "foo.sub", 29, 5], |
michael@0 | 131 | ["a_test", "-01.js", "foo.sub.sub", 32, 7], |
michael@0 | 132 | ["n_test" + s + "z", "-01.js", "foo.sub.sub", 34, 7], |
michael@0 | 133 | ["test_SAME_NAME", "-01.js", "foo.sub.sub.sub", 37, 9] |
michael@0 | 134 | ]; |
michael@0 | 135 | |
michael@0 | 136 | for (let [label, value, description, line, column] of expectedResults) { |
michael@0 | 137 | let target = gFilteredFunctions.selectedItem.target; |
michael@0 | 138 | |
michael@0 | 139 | if (label) { |
michael@0 | 140 | is(target.querySelector(".results-panel-item-label").getAttribute("value"), |
michael@0 | 141 | gDebugger.SourceUtils.trimUrlLength(label + "()"), |
michael@0 | 142 | "The corect label (" + label + ") is currently selected."); |
michael@0 | 143 | } else { |
michael@0 | 144 | ok(!target.querySelector(".results-panel-item-label"), |
michael@0 | 145 | "Shouldn't create empty label nodes."); |
michael@0 | 146 | } |
michael@0 | 147 | if (value) { |
michael@0 | 148 | ok(target.querySelector(".results-panel-item-label-below").getAttribute("value").contains(value), |
michael@0 | 149 | "The corect value (" + value + ") is attached."); |
michael@0 | 150 | } else { |
michael@0 | 151 | ok(!target.querySelector(".results-panel-item-label-below"), |
michael@0 | 152 | "Shouldn't create empty label nodes."); |
michael@0 | 153 | } |
michael@0 | 154 | if (description) { |
michael@0 | 155 | is(target.querySelector(".results-panel-item-label-before").getAttribute("value"), description, |
michael@0 | 156 | "The corect description (" + description + ") is currently shown."); |
michael@0 | 157 | } else { |
michael@0 | 158 | ok(!target.querySelector(".results-panel-item-label-before"), |
michael@0 | 159 | "Shouldn't create empty label nodes."); |
michael@0 | 160 | } |
michael@0 | 161 | |
michael@0 | 162 | ok(isCaretPos(gPanel, line, column), |
michael@0 | 163 | "The editor didn't jump to the correct line."); |
michael@0 | 164 | |
michael@0 | 165 | EventUtils.sendKey("DOWN", gDebugger); |
michael@0 | 166 | } |
michael@0 | 167 | |
michael@0 | 168 | ok(isCaretPos(gPanel, expectedResults[0][3], expectedResults[0][4]), |
michael@0 | 169 | "The editor didn't jump to the correct line again."); |
michael@0 | 170 | |
michael@0 | 171 | deferred.resolve() |
michael@0 | 172 | } else { |
michael@0 | 173 | ok(false, "How did you get here? Go away, you."); |
michael@0 | 174 | } |
michael@0 | 175 | }); |
michael@0 | 176 | |
michael@0 | 177 | setText(gSearchBox, "@"); |
michael@0 | 178 | return deferred.promise; |
michael@0 | 179 | } |
michael@0 | 180 | |
michael@0 | 181 | function secondJsSearch() { |
michael@0 | 182 | let deferred = promise.defer(); |
michael@0 | 183 | |
michael@0 | 184 | once(gDebugger, "popupshown").then(() => { |
michael@0 | 185 | writeInfo(); |
michael@0 | 186 | |
michael@0 | 187 | is(gFilteredFunctions.selectedIndex, 0, |
michael@0 | 188 | "An item should be selected in the filtered functions view (1)."); |
michael@0 | 189 | ok(gFilteredFunctions.selectedItem, |
michael@0 | 190 | "An item should be selected in the filtered functions view (2)."); |
michael@0 | 191 | |
michael@0 | 192 | if (gSources.selectedValue.indexOf("-02.js") != -1) { |
michael@0 | 193 | let s = " " + gDebugger.L10N.getStr("functionSearchSeparatorLabel") + " "; |
michael@0 | 194 | let expectedResults = [ |
michael@0 | 195 | ["test2", "-02.js", "", 4, 5], |
michael@0 | 196 | ["test3" + s + "test3_NAME", "-02.js", "", 8, 5], |
michael@0 | 197 | ["test4_SAME_NAME", "-02.js", "", 11, 5], |
michael@0 | 198 | ["x" + s + "X", "-02.js", "test.prototype", 14, 1], |
michael@0 | 199 | ["y" + s + "Y", "-02.js", "test.prototype.sub", 16, 1], |
michael@0 | 200 | ["z" + s + "Z", "-02.js", "test.prototype.sub.sub", 18, 1], |
michael@0 | 201 | ["t", "-02.js", "test.prototype.sub.sub.sub", 20, 1], |
michael@0 | 202 | ["x", "-02.js", "this", 20, 32], |
michael@0 | 203 | ["y", "-02.js", "this", 20, 41], |
michael@0 | 204 | ["z", "-02.js", "this", 20, 50] |
michael@0 | 205 | ]; |
michael@0 | 206 | |
michael@0 | 207 | for (let [label, value, description, line, column] of expectedResults) { |
michael@0 | 208 | let target = gFilteredFunctions.selectedItem.target; |
michael@0 | 209 | |
michael@0 | 210 | if (label) { |
michael@0 | 211 | is(target.querySelector(".results-panel-item-label").getAttribute("value"), |
michael@0 | 212 | gDebugger.SourceUtils.trimUrlLength(label + "()"), |
michael@0 | 213 | "The corect label (" + label + ") is currently selected."); |
michael@0 | 214 | } else { |
michael@0 | 215 | ok(!target.querySelector(".results-panel-item-label"), |
michael@0 | 216 | "Shouldn't create empty label nodes."); |
michael@0 | 217 | } |
michael@0 | 218 | if (value) { |
michael@0 | 219 | ok(target.querySelector(".results-panel-item-label-below").getAttribute("value").contains(value), |
michael@0 | 220 | "The corect value (" + value + ") is attached."); |
michael@0 | 221 | } else { |
michael@0 | 222 | ok(!target.querySelector(".results-panel-item-label-below"), |
michael@0 | 223 | "Shouldn't create empty label nodes."); |
michael@0 | 224 | } |
michael@0 | 225 | if (description) { |
michael@0 | 226 | is(target.querySelector(".results-panel-item-label-before").getAttribute("value"), description, |
michael@0 | 227 | "The corect description (" + description + ") is currently shown."); |
michael@0 | 228 | } else { |
michael@0 | 229 | ok(!target.querySelector(".results-panel-item-label-before"), |
michael@0 | 230 | "Shouldn't create empty label nodes."); |
michael@0 | 231 | } |
michael@0 | 232 | |
michael@0 | 233 | ok(isCaretPos(gPanel, line, column), |
michael@0 | 234 | "The editor didn't jump to the correct line."); |
michael@0 | 235 | |
michael@0 | 236 | EventUtils.sendKey("DOWN", gDebugger); |
michael@0 | 237 | } |
michael@0 | 238 | |
michael@0 | 239 | ok(isCaretPos(gPanel, expectedResults[0][3], expectedResults[0][4]), |
michael@0 | 240 | "The editor didn't jump to the correct line again."); |
michael@0 | 241 | |
michael@0 | 242 | deferred.resolve(); |
michael@0 | 243 | } else { |
michael@0 | 244 | ok(false, "How did you get here? Go away, you."); |
michael@0 | 245 | } |
michael@0 | 246 | }); |
michael@0 | 247 | |
michael@0 | 248 | setText(gSearchBox, "@"); |
michael@0 | 249 | return deferred.promise; |
michael@0 | 250 | } |
michael@0 | 251 | |
michael@0 | 252 | function thirdJsSearch() { |
michael@0 | 253 | let deferred = promise.defer(); |
michael@0 | 254 | |
michael@0 | 255 | once(gDebugger, "popupshown").then(() => { |
michael@0 | 256 | writeInfo(); |
michael@0 | 257 | |
michael@0 | 258 | is(gFilteredFunctions.selectedIndex, 0, |
michael@0 | 259 | "An item should be selected in the filtered functions view (1)."); |
michael@0 | 260 | ok(gFilteredFunctions.selectedItem, |
michael@0 | 261 | "An item should be selected in the filtered functions view (2)."); |
michael@0 | 262 | |
michael@0 | 263 | if (gSources.selectedValue.indexOf("-03.js") != -1) { |
michael@0 | 264 | let s = " " + gDebugger.L10N.getStr("functionSearchSeparatorLabel") + " "; |
michael@0 | 265 | let expectedResults = [ |
michael@0 | 266 | ["namedEventListener", "-03.js", "", 4, 43], |
michael@0 | 267 | ["a" + s + "A", "-03.js", "bar", 10, 5], |
michael@0 | 268 | ["b" + s + "B", "-03.js", "bar.alpha", 15, 5], |
michael@0 | 269 | ["c" + s + "C", "-03.js", "bar.alpha.beta", 20, 5], |
michael@0 | 270 | ["d" + s + "D", "-03.js", "this.theta", 25, 5], |
michael@0 | 271 | ["fun", "-03.js", "", 29, 7], |
michael@0 | 272 | ["foo", "-03.js", "", 29, 13], |
michael@0 | 273 | ["bar", "-03.js", "", 29, 19], |
michael@0 | 274 | ["t_foo", "-03.js", "this", 29, 25], |
michael@0 | 275 | ["w_bar" + s + "baz", "-03.js", "window", 29, 38] |
michael@0 | 276 | ]; |
michael@0 | 277 | |
michael@0 | 278 | for (let [label, value, description, line, column] of expectedResults) { |
michael@0 | 279 | let target = gFilteredFunctions.selectedItem.target; |
michael@0 | 280 | |
michael@0 | 281 | if (label) { |
michael@0 | 282 | is(target.querySelector(".results-panel-item-label").getAttribute("value"), |
michael@0 | 283 | gDebugger.SourceUtils.trimUrlLength(label + "()"), |
michael@0 | 284 | "The corect label (" + label + ") is currently selected."); |
michael@0 | 285 | } else { |
michael@0 | 286 | ok(!target.querySelector(".results-panel-item-label"), |
michael@0 | 287 | "Shouldn't create empty label nodes."); |
michael@0 | 288 | } |
michael@0 | 289 | if (value) { |
michael@0 | 290 | ok(target.querySelector(".results-panel-item-label-below").getAttribute("value").contains(value), |
michael@0 | 291 | "The corect value (" + value + ") is attached."); |
michael@0 | 292 | } else { |
michael@0 | 293 | ok(!target.querySelector(".results-panel-item-label-below"), |
michael@0 | 294 | "Shouldn't create empty label nodes."); |
michael@0 | 295 | } |
michael@0 | 296 | if (description) { |
michael@0 | 297 | is(target.querySelector(".results-panel-item-label-before").getAttribute("value"), description, |
michael@0 | 298 | "The corect description (" + description + ") is currently shown."); |
michael@0 | 299 | } else { |
michael@0 | 300 | ok(!target.querySelector(".results-panel-item-label-before"), |
michael@0 | 301 | "Shouldn't create empty label nodes."); |
michael@0 | 302 | } |
michael@0 | 303 | |
michael@0 | 304 | ok(isCaretPos(gPanel, line, column), |
michael@0 | 305 | "The editor didn't jump to the correct line."); |
michael@0 | 306 | |
michael@0 | 307 | EventUtils.sendKey("DOWN", gDebugger); |
michael@0 | 308 | } |
michael@0 | 309 | |
michael@0 | 310 | ok(isCaretPos(gPanel, expectedResults[0][3], expectedResults[0][4]), |
michael@0 | 311 | "The editor didn't jump to the correct line again."); |
michael@0 | 312 | |
michael@0 | 313 | deferred.resolve(); |
michael@0 | 314 | } else { |
michael@0 | 315 | ok(false, "How did you get here? Go away, you."); |
michael@0 | 316 | } |
michael@0 | 317 | }); |
michael@0 | 318 | |
michael@0 | 319 | setText(gSearchBox, "@"); |
michael@0 | 320 | return deferred.promise; |
michael@0 | 321 | } |
michael@0 | 322 | |
michael@0 | 323 | function filterSearch() { |
michael@0 | 324 | let deferred = promise.defer(); |
michael@0 | 325 | |
michael@0 | 326 | once(gDebugger, "popupshown").then(() => { |
michael@0 | 327 | writeInfo(); |
michael@0 | 328 | |
michael@0 | 329 | is(gFilteredFunctions.selectedIndex, 0, |
michael@0 | 330 | "An item should be selected in the filtered functions view (1)."); |
michael@0 | 331 | ok(gFilteredFunctions.selectedItem, |
michael@0 | 332 | "An item should be selected in the filtered functions view (2)."); |
michael@0 | 333 | |
michael@0 | 334 | if (gSources.selectedValue.indexOf("-03.js") != -1) { |
michael@0 | 335 | let s = " " + gDebugger.L10N.getStr("functionSearchSeparatorLabel") + " "; |
michael@0 | 336 | let expectedResults = [ |
michael@0 | 337 | ["namedEventListener", "-03.js", "", 4, 43], |
michael@0 | 338 | ["bar", "-03.js", "", 29, 19], |
michael@0 | 339 | ["w_bar" + s + "baz", "-03.js", "window", 29, 38], |
michael@0 | 340 | ["anonymousExpression", "-01.js", "test.prototype", 9, 3], |
michael@0 | 341 | ["namedExpression" + s + "NAME", "-01.js", "test.prototype", 11, 3], |
michael@0 | 342 | ["arrow", ".html", "", 20, 11], |
michael@0 | 343 | ["bar2", ".html", "", 23, 18] |
michael@0 | 344 | ]; |
michael@0 | 345 | |
michael@0 | 346 | for (let [label, value, description, line, column] of expectedResults) { |
michael@0 | 347 | let target = gFilteredFunctions.selectedItem.target; |
michael@0 | 348 | |
michael@0 | 349 | if (label) { |
michael@0 | 350 | is(target.querySelector(".results-panel-item-label").getAttribute("value"), |
michael@0 | 351 | gDebugger.SourceUtils.trimUrlLength(label + "()"), |
michael@0 | 352 | "The corect label (" + label + ") is currently selected."); |
michael@0 | 353 | } else { |
michael@0 | 354 | ok(!target.querySelector(".results-panel-item-label"), |
michael@0 | 355 | "Shouldn't create empty label nodes."); |
michael@0 | 356 | } |
michael@0 | 357 | if (value) { |
michael@0 | 358 | ok(target.querySelector(".results-panel-item-label-below").getAttribute("value").contains(value), |
michael@0 | 359 | "The corect value (" + value + ") is attached."); |
michael@0 | 360 | } else { |
michael@0 | 361 | ok(!target.querySelector(".results-panel-item-label-below"), |
michael@0 | 362 | "Shouldn't create empty label nodes."); |
michael@0 | 363 | } |
michael@0 | 364 | if (description) { |
michael@0 | 365 | is(target.querySelector(".results-panel-item-label-before").getAttribute("value"), description, |
michael@0 | 366 | "The corect description (" + description + ") is currently shown."); |
michael@0 | 367 | } else { |
michael@0 | 368 | ok(!target.querySelector(".results-panel-item-label-before"), |
michael@0 | 369 | "Shouldn't create empty label nodes."); |
michael@0 | 370 | } |
michael@0 | 371 | |
michael@0 | 372 | ok(isCaretPos(gPanel, line, column), |
michael@0 | 373 | "The editor didn't jump to the correct line."); |
michael@0 | 374 | |
michael@0 | 375 | EventUtils.sendKey("DOWN", gDebugger); |
michael@0 | 376 | } |
michael@0 | 377 | |
michael@0 | 378 | ok(isCaretPos(gPanel, expectedResults[0][3], expectedResults[0][4]), |
michael@0 | 379 | "The editor didn't jump to the correct line again."); |
michael@0 | 380 | |
michael@0 | 381 | deferred.resolve(); |
michael@0 | 382 | } else { |
michael@0 | 383 | ok(false, "How did you get here? Go away, you."); |
michael@0 | 384 | } |
michael@0 | 385 | }); |
michael@0 | 386 | |
michael@0 | 387 | setText(gSearchBox, "@r"); |
michael@0 | 388 | return deferred.promise; |
michael@0 | 389 | } |
michael@0 | 390 | |
michael@0 | 391 | function bogusSearch() { |
michael@0 | 392 | let deferred = promise.defer(); |
michael@0 | 393 | |
michael@0 | 394 | once(gDebugger, "popuphidden").then(() => { |
michael@0 | 395 | ok(true, "Popup was successfully hidden after no matches were found."); |
michael@0 | 396 | deferred.resolve(); |
michael@0 | 397 | }); |
michael@0 | 398 | |
michael@0 | 399 | setText(gSearchBox, "@bogus"); |
michael@0 | 400 | return deferred.promise; |
michael@0 | 401 | } |
michael@0 | 402 | |
michael@0 | 403 | function incrementalSearch() { |
michael@0 | 404 | let deferred = promise.defer(); |
michael@0 | 405 | |
michael@0 | 406 | once(gDebugger, "popupshown").then(() => { |
michael@0 | 407 | ok(true, "Popup was successfully shown after some matches were found."); |
michael@0 | 408 | deferred.resolve(); |
michael@0 | 409 | }); |
michael@0 | 410 | |
michael@0 | 411 | setText(gSearchBox, "@NAME"); |
michael@0 | 412 | return deferred.promise; |
michael@0 | 413 | } |
michael@0 | 414 | |
michael@0 | 415 | function emptySearch() { |
michael@0 | 416 | let deferred = promise.defer(); |
michael@0 | 417 | |
michael@0 | 418 | once(gDebugger, "popuphidden").then(() => { |
michael@0 | 419 | ok(true, "Popup was successfully hidden when nothing was searched."); |
michael@0 | 420 | deferred.resolve(); |
michael@0 | 421 | }); |
michael@0 | 422 | |
michael@0 | 423 | clearText(gSearchBox); |
michael@0 | 424 | return deferred.promise; |
michael@0 | 425 | } |
michael@0 | 426 | |
michael@0 | 427 | function showSource(aLabel) { |
michael@0 | 428 | let deferred = promise.defer(); |
michael@0 | 429 | |
michael@0 | 430 | waitForSourceShown(gPanel, aLabel).then(deferred.resolve); |
michael@0 | 431 | gSources.selectedItem = e => e.attachment.label == aLabel; |
michael@0 | 432 | |
michael@0 | 433 | return deferred.promise; |
michael@0 | 434 | } |
michael@0 | 435 | |
michael@0 | 436 | function saveSearch() { |
michael@0 | 437 | let finished = once(gDebugger, "popuphidden"); |
michael@0 | 438 | |
michael@0 | 439 | // Either by pressing RETURN or clicking on an item in the popup, |
michael@0 | 440 | // the popup should hide and the item should become selected. |
michael@0 | 441 | let random = Math.random(); |
michael@0 | 442 | if (random >= 0.33) { |
michael@0 | 443 | EventUtils.sendKey("RETURN", gDebugger); |
michael@0 | 444 | } else if (random >= 0.66) { |
michael@0 | 445 | EventUtils.sendKey("RETURN", gDebugger); |
michael@0 | 446 | } else { |
michael@0 | 447 | EventUtils.sendMouseEvent({ type: "click" }, |
michael@0 | 448 | gFilteredFunctions.selectedItem.target, |
michael@0 | 449 | gDebugger); |
michael@0 | 450 | } |
michael@0 | 451 | |
michael@0 | 452 | return finished; |
michael@0 | 453 | } |
michael@0 | 454 | |
michael@0 | 455 | function writeInfo() { |
michael@0 | 456 | info("Current source url:\n" + gSources.selectedValue); |
michael@0 | 457 | info("Debugger editor text:\n" + gEditor.getText()); |
michael@0 | 458 | } |
michael@0 | 459 | |
michael@0 | 460 | registerCleanupFunction(function() { |
michael@0 | 461 | gTab = null; |
michael@0 | 462 | gDebuggee = null; |
michael@0 | 463 | gPanel = null; |
michael@0 | 464 | gDebugger = null; |
michael@0 | 465 | gEditor = null; |
michael@0 | 466 | gSources = null; |
michael@0 | 467 | gSearchBox = null; |
michael@0 | 468 | gFilteredFunctions = null; |
michael@0 | 469 | }); |