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 | // nsDoTestsForAutoCompleteWithComposition tests autocomplete with composition. |
michael@0 | 2 | // Users must include SimpleTest.js and EventUtils.js. |
michael@0 | 3 | |
michael@0 | 4 | function nsDoTestsForAutoCompleteWithComposition(aDescription, |
michael@0 | 5 | aWindow, |
michael@0 | 6 | aTarget, |
michael@0 | 7 | aAutoCompleteController, |
michael@0 | 8 | aIsFunc, |
michael@0 | 9 | aGetTargetValueFunc, |
michael@0 | 10 | aOnFinishFunc) |
michael@0 | 11 | { |
michael@0 | 12 | this._description = aDescription; |
michael@0 | 13 | this._window = aWindow; |
michael@0 | 14 | this._target = aTarget; |
michael@0 | 15 | this._controller = aAutoCompleteController; |
michael@0 | 16 | |
michael@0 | 17 | this._is = aIsFunc; |
michael@0 | 18 | this._getTargetValue = aGetTargetValueFunc; |
michael@0 | 19 | this._onFinish = aOnFinishFunc; |
michael@0 | 20 | |
michael@0 | 21 | this._target.focus(); |
michael@0 | 22 | |
michael@0 | 23 | this._DefaultCompleteDefaultIndex = |
michael@0 | 24 | this._controller.input.completeDefaultIndex; |
michael@0 | 25 | |
michael@0 | 26 | this._doTests(); |
michael@0 | 27 | } |
michael@0 | 28 | |
michael@0 | 29 | nsDoTestsForAutoCompleteWithComposition.prototype = { |
michael@0 | 30 | _window: null, |
michael@0 | 31 | _target: null, |
michael@0 | 32 | _controller: null, |
michael@0 | 33 | _DefaultCompleteDefaultIndex: false, |
michael@0 | 34 | _description: "", |
michael@0 | 35 | |
michael@0 | 36 | _is: null, |
michael@0 | 37 | _getTargetValue: function () { return "not initialized"; }, |
michael@0 | 38 | _onFinish: null, |
michael@0 | 39 | |
michael@0 | 40 | _doTests: function () |
michael@0 | 41 | { |
michael@0 | 42 | if (++this._testingIndex == this._tests.length) { |
michael@0 | 43 | this._controller.input.completeDefaultIndex = |
michael@0 | 44 | this._DefaultCompleteDefaultIndex; |
michael@0 | 45 | this._onFinish(); |
michael@0 | 46 | return; |
michael@0 | 47 | } |
michael@0 | 48 | |
michael@0 | 49 | var test = this._tests[this._testingIndex]; |
michael@0 | 50 | if (this._controller.input.completeDefaultIndex != test.completeDefaultIndex) { |
michael@0 | 51 | this._controller.input.completeDefaultIndex = test.completeDefaultIndex; |
michael@0 | 52 | } |
michael@0 | 53 | test.execute(this._window); |
michael@0 | 54 | |
michael@0 | 55 | var timeout = this._controller.input.timeout + 10; |
michael@0 | 56 | this._waitResult(timeout); |
michael@0 | 57 | }, |
michael@0 | 58 | |
michael@0 | 59 | _waitResult: function (aTimes) |
michael@0 | 60 | { |
michael@0 | 61 | var obj = this; |
michael@0 | 62 | if (aTimes-- > 0) { |
michael@0 | 63 | setTimeout(function () { obj._waitResult(aTimes); }, 0); |
michael@0 | 64 | } else { |
michael@0 | 65 | setTimeout(function () { obj._checkResult(); }, 0); |
michael@0 | 66 | } |
michael@0 | 67 | }, |
michael@0 | 68 | |
michael@0 | 69 | _checkResult: function () |
michael@0 | 70 | { |
michael@0 | 71 | var test = this._tests[this._testingIndex]; |
michael@0 | 72 | this._is(this._getTargetValue(), test.value, |
michael@0 | 73 | this._description + ", " + test.description + ": value"); |
michael@0 | 74 | this._is(this._controller.searchString, test.searchString, |
michael@0 | 75 | this._description + ", " + test.description +": searchString"); |
michael@0 | 76 | this._is(this._controller.input.popupOpen, test.popup, |
michael@0 | 77 | this._description + ", " + test.description + ": popupOpen"); |
michael@0 | 78 | this._doTests(); |
michael@0 | 79 | }, |
michael@0 | 80 | |
michael@0 | 81 | _testingIndex: -1, |
michael@0 | 82 | _tests: [ |
michael@0 | 83 | // Simple composition when popup hasn't been shown. |
michael@0 | 84 | // The autocomplete popup should not be shown during composition, but |
michael@0 | 85 | // after compositionend, the popup should be shown. |
michael@0 | 86 | { description: "compositionstart shouldn't open the popup", |
michael@0 | 87 | completeDefaultIndex: false, |
michael@0 | 88 | execute: function (aWindow) { |
michael@0 | 89 | synthesizeKey("m", { type: "keydown", shiftKey: true }, aWindow); |
michael@0 | 90 | synthesizeComposition({ type: "compositionstart" }, aWindow); |
michael@0 | 91 | synthesizeComposition({ type: "compositionupdate", data: "M" }, aWindow); |
michael@0 | 92 | synthesizeText( |
michael@0 | 93 | { "composition": |
michael@0 | 94 | { "string": "M", |
michael@0 | 95 | "clauses": |
michael@0 | 96 | [ |
michael@0 | 97 | { "length": 1, "attr": COMPOSITION_ATTR_RAWINPUT } |
michael@0 | 98 | ] |
michael@0 | 99 | }, |
michael@0 | 100 | "caret": { "start": 1, "length": 0 } |
michael@0 | 101 | }, aWindow); |
michael@0 | 102 | }, popup: false, value: "M", searchString: "" |
michael@0 | 103 | }, |
michael@0 | 104 | { description: "compositionupdate shouldn't open the popup", |
michael@0 | 105 | completeDefaultIndex: false, |
michael@0 | 106 | execute: function (aWindow) { |
michael@0 | 107 | synthesizeComposition({ type: "compositionupdate", data: "Mo" }, aWindow); |
michael@0 | 108 | synthesizeText( |
michael@0 | 109 | { "composition": |
michael@0 | 110 | { "string": "Mo", |
michael@0 | 111 | "clauses": |
michael@0 | 112 | [ |
michael@0 | 113 | { "length": 2, "attr": COMPOSITION_ATTR_RAWINPUT } |
michael@0 | 114 | ] |
michael@0 | 115 | }, |
michael@0 | 116 | "caret": { "start": 2, "length": 0 } |
michael@0 | 117 | }, aWindow); |
michael@0 | 118 | }, popup: false, value: "Mo", searchString: "" |
michael@0 | 119 | }, |
michael@0 | 120 | { description: "compositionend should open the popup", |
michael@0 | 121 | completeDefaultIndex: false, |
michael@0 | 122 | execute: function (aWindow) { |
michael@0 | 123 | synthesizeText( |
michael@0 | 124 | { "composition": |
michael@0 | 125 | { "string": "Mo", |
michael@0 | 126 | "clauses": |
michael@0 | 127 | [ |
michael@0 | 128 | { "length": 0, "attr": 0 } |
michael@0 | 129 | ] |
michael@0 | 130 | }, |
michael@0 | 131 | "caret": { "start": 2, "length": 0 } |
michael@0 | 132 | }, aWindow); |
michael@0 | 133 | synthesizeComposition({ type: "compositionend", data: "Mo" }, aWindow); |
michael@0 | 134 | synthesizeKey("VK_RETURN", { type: "keyup" }, aWindow); |
michael@0 | 135 | }, popup: true, value: "Mo", searchString: "Mo" |
michael@0 | 136 | }, |
michael@0 | 137 | // If composition starts when popup is shown, the compositionstart event |
michael@0 | 138 | // should cause closing the popup. |
michael@0 | 139 | { description: "compositionstart should close the popup", |
michael@0 | 140 | completeDefaultIndex: false, |
michael@0 | 141 | execute: function (aWindow) { |
michael@0 | 142 | synthesizeKey("z", { type: "keydown" }, aWindow); |
michael@0 | 143 | synthesizeComposition({ type: "compositionstart" }, aWindow); |
michael@0 | 144 | synthesizeComposition({ type: "compositionupdate", data: "z" }, aWindow); |
michael@0 | 145 | synthesizeText( |
michael@0 | 146 | { "composition": |
michael@0 | 147 | { "string": "z", |
michael@0 | 148 | "clauses": |
michael@0 | 149 | [ |
michael@0 | 150 | { "length": 1, "attr": COMPOSITION_ATTR_RAWINPUT } |
michael@0 | 151 | ] |
michael@0 | 152 | }, |
michael@0 | 153 | "caret": { "start": 1, "length": 0 } |
michael@0 | 154 | }, aWindow); |
michael@0 | 155 | }, popup: false, value: "Moz", searchString: "Mo" |
michael@0 | 156 | }, |
michael@0 | 157 | { description: "compositionupdate shouldn't reopen the popup", |
michael@0 | 158 | completeDefaultIndex: false, |
michael@0 | 159 | execute: function (aWindow) { |
michael@0 | 160 | synthesizeComposition({ type: "compositionupdate", data: "zi" }, aWindow); |
michael@0 | 161 | synthesizeText( |
michael@0 | 162 | { "composition": |
michael@0 | 163 | { "string": "zi", |
michael@0 | 164 | "clauses": |
michael@0 | 165 | [ |
michael@0 | 166 | { "length": 2, "attr": COMPOSITION_ATTR_RAWINPUT } |
michael@0 | 167 | ] |
michael@0 | 168 | }, |
michael@0 | 169 | "caret": { "start": 2, "length": 0 } |
michael@0 | 170 | }, aWindow); |
michael@0 | 171 | }, popup: false, value: "Mozi", searchString: "Mo" |
michael@0 | 172 | }, |
michael@0 | 173 | { description: "compositionend should research the result and open the popup", |
michael@0 | 174 | completeDefaultIndex: false, |
michael@0 | 175 | execute: function (aWindow) { |
michael@0 | 176 | synthesizeText( |
michael@0 | 177 | { "composition": |
michael@0 | 178 | { "string": "zi", |
michael@0 | 179 | "clauses": |
michael@0 | 180 | [ |
michael@0 | 181 | { "length": 0, "attr": 0 } |
michael@0 | 182 | ] |
michael@0 | 183 | }, |
michael@0 | 184 | "caret": { "start": 2, "length": 0 } |
michael@0 | 185 | }); |
michael@0 | 186 | synthesizeComposition({ type: "compositionend", data: "zi" }, aWindow); |
michael@0 | 187 | synthesizeKey("VK_RETURN", { type: "keyup" }, aWindow); |
michael@0 | 188 | }, popup: true, value: "Mozi", searchString: "Mozi" |
michael@0 | 189 | }, |
michael@0 | 190 | // If composition is cancelled, the value shouldn't be changed. |
michael@0 | 191 | { description: "compositionstart should reclose the popup", |
michael@0 | 192 | completeDefaultIndex: false, |
michael@0 | 193 | execute: function (aWindow) { |
michael@0 | 194 | synthesizeKey("l", { type: "keydown" }, aWindow); |
michael@0 | 195 | synthesizeComposition({ type: "compositionstart" }, aWindow); |
michael@0 | 196 | synthesizeComposition({ type: "compositionupdate", data: "l" }, aWindow); |
michael@0 | 197 | synthesizeText( |
michael@0 | 198 | { "composition": |
michael@0 | 199 | { "string": "l", |
michael@0 | 200 | "clauses": |
michael@0 | 201 | [ |
michael@0 | 202 | { "length": 1, "attr": COMPOSITION_ATTR_RAWINPUT } |
michael@0 | 203 | ] |
michael@0 | 204 | }, |
michael@0 | 205 | "caret": { "start": 1, "length": 0 } |
michael@0 | 206 | }, aWindow); |
michael@0 | 207 | }, popup: false, value: "Mozil", searchString: "Mozi" |
michael@0 | 208 | }, |
michael@0 | 209 | { description: "compositionupdate shouldn't reopen the popup", |
michael@0 | 210 | completeDefaultIndex: false, |
michael@0 | 211 | execute: function (aWindow) { |
michael@0 | 212 | synthesizeComposition({ type: "compositionupdate", data: "ll" }, aWindow); |
michael@0 | 213 | synthesizeText( |
michael@0 | 214 | { "composition": |
michael@0 | 215 | { "string": "ll", |
michael@0 | 216 | "clauses": |
michael@0 | 217 | [ |
michael@0 | 218 | { "length": 2, "attr": COMPOSITION_ATTR_RAWINPUT } |
michael@0 | 219 | ] |
michael@0 | 220 | }, |
michael@0 | 221 | "caret": { "start": 2, "length": 0 } |
michael@0 | 222 | }, aWindow); |
michael@0 | 223 | }, popup: false, value: "Mozill", searchString: "Mozi" |
michael@0 | 224 | }, |
michael@0 | 225 | { description: "empty compositionupdate shouldn't reopen the popup", |
michael@0 | 226 | completeDefaultIndex: false, |
michael@0 | 227 | execute: function (aWindow) { |
michael@0 | 228 | synthesizeComposition({ type: "compositionupdate", data: "" }, aWindow); |
michael@0 | 229 | synthesizeText( |
michael@0 | 230 | { "composition": |
michael@0 | 231 | { "string": "", |
michael@0 | 232 | "clauses": |
michael@0 | 233 | [ |
michael@0 | 234 | { "length": 0, "attr": 0 } |
michael@0 | 235 | ] |
michael@0 | 236 | }, |
michael@0 | 237 | "caret": { "start": 0, "length": 0 } |
michael@0 | 238 | }, aWindow); |
michael@0 | 239 | }, popup: false, value: "Mozi", searchString: "Mozi" |
michael@0 | 240 | }, |
michael@0 | 241 | { description: "cancled compositionend should reopen the popup", |
michael@0 | 242 | completeDefaultIndex: false, |
michael@0 | 243 | execute: function (aWindow) { |
michael@0 | 244 | synthesizeText( |
michael@0 | 245 | { "composition": |
michael@0 | 246 | { "string": "", |
michael@0 | 247 | "clauses": |
michael@0 | 248 | [ |
michael@0 | 249 | { "length": 0, "attr": 0 } |
michael@0 | 250 | ] |
michael@0 | 251 | }, |
michael@0 | 252 | "caret": { "start": 0, "length": 0 } |
michael@0 | 253 | }, aWindow); |
michael@0 | 254 | synthesizeComposition({ type: "compositionend", data: "" }, aWindow); |
michael@0 | 255 | synthesizeKey("VK_ESCAPE", { type: "keyup" }, aWindow); |
michael@0 | 256 | }, popup: true, value: "Mozi", searchString: "Mozi" |
michael@0 | 257 | }, |
michael@0 | 258 | // But if composition replaces some characters and canceled, the search |
michael@0 | 259 | // string should be the latest value. |
michael@0 | 260 | { description: "compositionstart with selected string should close the popup", |
michael@0 | 261 | completeDefaultIndex: false, |
michael@0 | 262 | execute: function (aWindow) { |
michael@0 | 263 | synthesizeKey("VK_LEFT", { shiftKey: true }, aWindow); |
michael@0 | 264 | synthesizeKey("VK_LEFT", { shiftKey: true }, aWindow); |
michael@0 | 265 | synthesizeKey("z", { type: "keydown" }, aWindow); |
michael@0 | 266 | synthesizeComposition({ type: "compositionstart" }, aWindow); |
michael@0 | 267 | synthesizeComposition({ type: "compositionupdate", data: "z" }, aWindow); |
michael@0 | 268 | synthesizeText( |
michael@0 | 269 | { "composition": |
michael@0 | 270 | { "string": "z", |
michael@0 | 271 | "clauses": |
michael@0 | 272 | [ |
michael@0 | 273 | { "length": 1, "attr": COMPOSITION_ATTR_RAWINPUT } |
michael@0 | 274 | ] |
michael@0 | 275 | }, |
michael@0 | 276 | "caret": { "start": 1, "length": 0 } |
michael@0 | 277 | }, aWindow); |
michael@0 | 278 | }, popup: false, value: "Moz", searchString: "Mozi" |
michael@0 | 279 | }, |
michael@0 | 280 | { description: "compositionupdate shouldn't reopen the popup", |
michael@0 | 281 | completeDefaultIndex: false, |
michael@0 | 282 | execute: function (aWindow) { |
michael@0 | 283 | synthesizeComposition({ type: "compositionupdate", data: "zi" }, aWindow); |
michael@0 | 284 | synthesizeText( |
michael@0 | 285 | { "composition": |
michael@0 | 286 | { "string": "zi", |
michael@0 | 287 | "clauses": |
michael@0 | 288 | [ |
michael@0 | 289 | { "length": 2, "attr": COMPOSITION_ATTR_RAWINPUT } |
michael@0 | 290 | ] |
michael@0 | 291 | }, |
michael@0 | 292 | "caret": { "start": 2, "length": 0 } |
michael@0 | 293 | }, aWindow); |
michael@0 | 294 | }, popup: false, value: "Mozi", searchString: "Mozi" |
michael@0 | 295 | }, |
michael@0 | 296 | { description: "empty compositionupdate shouldn't reopen the popup", |
michael@0 | 297 | completeDefaultIndex: false, |
michael@0 | 298 | execute: function (aWindow) { |
michael@0 | 299 | synthesizeComposition({ type: "compositionupdate", data: "" }, aWindow); |
michael@0 | 300 | synthesizeText( |
michael@0 | 301 | { "composition": |
michael@0 | 302 | { "string": "", |
michael@0 | 303 | "clauses": |
michael@0 | 304 | [ |
michael@0 | 305 | { "length": 0, "attr": 0 } |
michael@0 | 306 | ] |
michael@0 | 307 | }, |
michael@0 | 308 | "caret": { "start": 0, "length": 0 } |
michael@0 | 309 | }, aWindow); |
michael@0 | 310 | }, popup: false, value: "Mo", searchString: "Mozi" |
michael@0 | 311 | }, |
michael@0 | 312 | { description: "canceled compositionend should seach the result with the latest value", |
michael@0 | 313 | completeDefaultIndex: false, |
michael@0 | 314 | execute: function (aWindow) { |
michael@0 | 315 | synthesizeText( |
michael@0 | 316 | { "composition": |
michael@0 | 317 | { "string": "", |
michael@0 | 318 | "clauses": |
michael@0 | 319 | [ |
michael@0 | 320 | { "length": 0, "attr": 0 } |
michael@0 | 321 | ] |
michael@0 | 322 | }, |
michael@0 | 323 | "caret": { "start": 0, "length": 0 } |
michael@0 | 324 | }, aWindow); |
michael@0 | 325 | synthesizeComposition({ type: "compositionend", data: "" }, aWindow); |
michael@0 | 326 | synthesizeKey("VK_ESCAPE", { type: "keyup" }, aWindow); |
michael@0 | 327 | }, popup: true, value: "Mo", searchString: "Mo" |
michael@0 | 328 | }, |
michael@0 | 329 | //If all characters are removed, the popup should be closed. |
michael@0 | 330 | { description: "the value becomes empty by backspace, the popup should be closed", |
michael@0 | 331 | completeDefaultIndex: false, |
michael@0 | 332 | execute: function (aWindow) { |
michael@0 | 333 | synthesizeKey("VK_BACK_SPACE", {}, aWindow); |
michael@0 | 334 | synthesizeKey("VK_BACK_SPACE", {}, aWindow); |
michael@0 | 335 | }, popup: false, value: "", searchString: "" |
michael@0 | 336 | }, |
michael@0 | 337 | // composition which is canceled shouldn't cause opening the popup. |
michael@0 | 338 | { description: "compositionstart shouldn't open the popup", |
michael@0 | 339 | completeDefaultIndex: false, |
michael@0 | 340 | execute: function (aWindow) { |
michael@0 | 341 | synthesizeKey("m", { type: "keydown", shiftKey: true }, aWindow); |
michael@0 | 342 | synthesizeComposition({ type: "compositionstart" }, aWindow); |
michael@0 | 343 | synthesizeComposition({ type: "compositionupdate", data: "M" }, aWindow); |
michael@0 | 344 | synthesizeText( |
michael@0 | 345 | { "composition": |
michael@0 | 346 | { "string": "M", |
michael@0 | 347 | "clauses": |
michael@0 | 348 | [ |
michael@0 | 349 | { "length": 1, "attr": COMPOSITION_ATTR_RAWINPUT } |
michael@0 | 350 | ] |
michael@0 | 351 | }, |
michael@0 | 352 | "caret": { "start": 1, "length": 0 } |
michael@0 | 353 | }, aWindow); |
michael@0 | 354 | }, popup: false, value: "M", searchString: "" |
michael@0 | 355 | }, |
michael@0 | 356 | { description: "compositionupdate shouldn't open the popup", |
michael@0 | 357 | completeDefaultIndex: false, |
michael@0 | 358 | execute: function (aWindow) { |
michael@0 | 359 | synthesizeComposition({ type: "compositionupdate", data: "Mo" }, aWindow); |
michael@0 | 360 | synthesizeText( |
michael@0 | 361 | { "composition": |
michael@0 | 362 | { "string": "Mo", |
michael@0 | 363 | "clauses": |
michael@0 | 364 | [ |
michael@0 | 365 | { "length": 2, "attr": COMPOSITION_ATTR_RAWINPUT } |
michael@0 | 366 | ] |
michael@0 | 367 | }, |
michael@0 | 368 | "caret": { "start": 2, "length": 0 } |
michael@0 | 369 | }, aWindow); |
michael@0 | 370 | }, popup: false, value: "Mo", searchString: "" |
michael@0 | 371 | }, |
michael@0 | 372 | { description: "empty compositionupdate shouldn't open the popup", |
michael@0 | 373 | completeDefaultIndex: false, |
michael@0 | 374 | execute: function (aWindow) { |
michael@0 | 375 | synthesizeComposition({ type: "compositionupdate", data: "" }, aWindow); |
michael@0 | 376 | synthesizeText( |
michael@0 | 377 | { "composition": |
michael@0 | 378 | { "string": "", |
michael@0 | 379 | "clauses": |
michael@0 | 380 | [ |
michael@0 | 381 | { "length": 0, "attr": 0 } |
michael@0 | 382 | ] |
michael@0 | 383 | }, |
michael@0 | 384 | "caret": { "start": 0, "length": 0 } |
michael@0 | 385 | }, aWindow); |
michael@0 | 386 | }, popup: false, value: "", searchString: "" |
michael@0 | 387 | }, |
michael@0 | 388 | { description: "canceled compositionend shouldn't open the popup if it was closed", |
michael@0 | 389 | completeDefaultIndex: false, |
michael@0 | 390 | execute: function (aWindow) { |
michael@0 | 391 | synthesizeText( |
michael@0 | 392 | { "composition": |
michael@0 | 393 | { "string": "", |
michael@0 | 394 | "clauses": |
michael@0 | 395 | [ |
michael@0 | 396 | { "length": 0, "attr": 0 } |
michael@0 | 397 | ] |
michael@0 | 398 | }, |
michael@0 | 399 | "caret": { "start": 0, "length": 0 } |
michael@0 | 400 | }, aWindow); |
michael@0 | 401 | synthesizeComposition({ type: "compositionend", data: "" }, aWindow); |
michael@0 | 402 | synthesizeKey("VK_ESCAPE", { type: "keyup" }, aWindow); |
michael@0 | 403 | }, popup: false, value: "", searchString: "" |
michael@0 | 404 | }, |
michael@0 | 405 | // Down key should open the popup even if the editor is empty. |
michael@0 | 406 | { description: "DOWN key should open the popup even if the value is empty", |
michael@0 | 407 | completeDefaultIndex: false, |
michael@0 | 408 | execute: function (aWindow) { |
michael@0 | 409 | synthesizeKey("VK_DOWN", {}, aWindow); |
michael@0 | 410 | }, popup: true, value: "", searchString: "" |
michael@0 | 411 | }, |
michael@0 | 412 | // If popup is open at starting composition, the popup should be reopened |
michael@0 | 413 | // after composition anyway. |
michael@0 | 414 | { description: "compositionstart shouldn't open the popup", |
michael@0 | 415 | completeDefaultIndex: false, |
michael@0 | 416 | execute: function (aWindow) { |
michael@0 | 417 | synthesizeKey("m", { type: "keydown", shiftKey: true }, aWindow); |
michael@0 | 418 | synthesizeComposition({ type: "compositionstart" }, aWindow); |
michael@0 | 419 | synthesizeComposition({ type: "compositionupdate", data: "M" }, aWindow); |
michael@0 | 420 | synthesizeText( |
michael@0 | 421 | { "composition": |
michael@0 | 422 | { "string": "M", |
michael@0 | 423 | "clauses": |
michael@0 | 424 | [ |
michael@0 | 425 | { "length": 1, "attr": COMPOSITION_ATTR_RAWINPUT } |
michael@0 | 426 | ] |
michael@0 | 427 | }, |
michael@0 | 428 | "caret": { "start": 1, "length": 0 } |
michael@0 | 429 | }, aWindow); |
michael@0 | 430 | }, popup: false, value: "M", searchString: "" |
michael@0 | 431 | }, |
michael@0 | 432 | { description: "compositionupdate shouldn't open the popup", |
michael@0 | 433 | completeDefaultIndex: false, |
michael@0 | 434 | execute: function (aWindow) { |
michael@0 | 435 | synthesizeComposition({ type: "compositionupdate", data: "Mo" }, aWindow); |
michael@0 | 436 | synthesizeText( |
michael@0 | 437 | { "composition": |
michael@0 | 438 | { "string": "Mo", |
michael@0 | 439 | "clauses": |
michael@0 | 440 | [ |
michael@0 | 441 | { "length": 2, "attr": COMPOSITION_ATTR_RAWINPUT } |
michael@0 | 442 | ] |
michael@0 | 443 | }, |
michael@0 | 444 | "caret": { "start": 2, "length": 0 } |
michael@0 | 445 | }, aWindow); |
michael@0 | 446 | }, popup: false, value: "Mo", searchString: "" |
michael@0 | 447 | }, |
michael@0 | 448 | { description: "empty compositionupdate shouldn't open the popup", |
michael@0 | 449 | completeDefaultIndex: false, |
michael@0 | 450 | execute: function (aWindow) { |
michael@0 | 451 | synthesizeComposition({ type: "compositionupdate", data: "" }, aWindow); |
michael@0 | 452 | synthesizeText( |
michael@0 | 453 | { "composition": |
michael@0 | 454 | { "string": "", |
michael@0 | 455 | "clauses": |
michael@0 | 456 | [ |
michael@0 | 457 | { "length": 0, "attr": 0 } |
michael@0 | 458 | ] |
michael@0 | 459 | }, |
michael@0 | 460 | "caret": { "start": 0, "length": 0 } |
michael@0 | 461 | }, aWindow); |
michael@0 | 462 | }, popup: false, value: "", searchString: "" |
michael@0 | 463 | }, |
michael@0 | 464 | { description: "canceled compositionend should open the popup if it was opened", |
michael@0 | 465 | completeDefaultIndex: false, |
michael@0 | 466 | execute: function (aWindow) { |
michael@0 | 467 | synthesizeText( |
michael@0 | 468 | { "composition": |
michael@0 | 469 | { "string": "", |
michael@0 | 470 | "clauses": |
michael@0 | 471 | [ |
michael@0 | 472 | { "length": 0, "attr": 0 } |
michael@0 | 473 | ] |
michael@0 | 474 | }, |
michael@0 | 475 | "caret": { "start": 0, "length": 0 } |
michael@0 | 476 | }, aWindow); |
michael@0 | 477 | synthesizeComposition({ type: "compositionend", data: "" }, aWindow); |
michael@0 | 478 | synthesizeKey("VK_ESCAPE", { type: "keyup" }, aWindow); |
michael@0 | 479 | }, popup: true, value: "", searchString: "" |
michael@0 | 480 | }, |
michael@0 | 481 | // Type normally, and hit escape, the popup should be closed. |
michael@0 | 482 | { description: "ESCAPE should close the popup after typing something", |
michael@0 | 483 | completeDefaultIndex: false, |
michael@0 | 484 | execute: function (aWindow) { |
michael@0 | 485 | synthesizeKey("M", { shiftKey: true }, aWindow); |
michael@0 | 486 | synthesizeKey("o", { shiftKey: true }, aWindow); |
michael@0 | 487 | synthesizeKey("VK_ESCAPE", {}, aWindow); |
michael@0 | 488 | }, popup: false, value: "Mo", searchString: "Mo" |
michael@0 | 489 | }, |
michael@0 | 490 | // Even if the popup is closed, composition which is canceled should open |
michael@0 | 491 | // the popup if the value isn't empty. |
michael@0 | 492 | // XXX This might not be good behavior, but anyway, this is minor issue... |
michael@0 | 493 | { description: "compositionstart shouldn't open the popup", |
michael@0 | 494 | completeDefaultIndex: false, |
michael@0 | 495 | execute: function (aWindow) { |
michael@0 | 496 | synthesizeKey("z", { type: "keydown", shiftKey: true }, aWindow); |
michael@0 | 497 | synthesizeComposition({ type: "compositionstart" }, aWindow); |
michael@0 | 498 | synthesizeComposition({ type: "compositionupdate", data: "z" }, aWindow); |
michael@0 | 499 | synthesizeText( |
michael@0 | 500 | { "composition": |
michael@0 | 501 | { "string": "z", |
michael@0 | 502 | "clauses": |
michael@0 | 503 | [ |
michael@0 | 504 | { "length": 1, "attr": COMPOSITION_ATTR_RAWINPUT } |
michael@0 | 505 | ] |
michael@0 | 506 | }, |
michael@0 | 507 | "caret": { "start": 1, "length": 0 } |
michael@0 | 508 | }, aWindow); |
michael@0 | 509 | }, popup: false, value: "Moz", searchString: "Mo" |
michael@0 | 510 | }, |
michael@0 | 511 | { description: "compositionupdate shouldn't open the popup", |
michael@0 | 512 | completeDefaultIndex: false, |
michael@0 | 513 | execute: function (aWindow) { |
michael@0 | 514 | synthesizeComposition({ type: "compositionupdate", data: "zi" }, aWindow); |
michael@0 | 515 | synthesizeText( |
michael@0 | 516 | { "composition": |
michael@0 | 517 | { "string": "zi", |
michael@0 | 518 | "clauses": |
michael@0 | 519 | [ |
michael@0 | 520 | { "length": 2, "attr": COMPOSITION_ATTR_RAWINPUT } |
michael@0 | 521 | ] |
michael@0 | 522 | }, |
michael@0 | 523 | "caret": { "start": 2, "length": 0 } |
michael@0 | 524 | }, aWindow); |
michael@0 | 525 | }, popup: false, value: "Mozi", searchString: "Mo" |
michael@0 | 526 | }, |
michael@0 | 527 | { description: "empty compositionupdate shouldn't open the popup", |
michael@0 | 528 | completeDefaultIndex: false, |
michael@0 | 529 | execute: function (aWindow) { |
michael@0 | 530 | synthesizeComposition({ type: "compositionupdate", data: "" }, aWindow); |
michael@0 | 531 | synthesizeText( |
michael@0 | 532 | { "composition": |
michael@0 | 533 | { "string": "", |
michael@0 | 534 | "clauses": |
michael@0 | 535 | [ |
michael@0 | 536 | { "length": 0, "attr": 0 } |
michael@0 | 537 | ] |
michael@0 | 538 | }, |
michael@0 | 539 | "caret": { "start": 0, "length": 0 } |
michael@0 | 540 | }, aWindow); |
michael@0 | 541 | }, popup: false, value: "Mo", searchString: "Mo" |
michael@0 | 542 | }, |
michael@0 | 543 | { description: "canceled compositionend shouldn't open the popup if the popup was closed", |
michael@0 | 544 | completeDefaultIndex: false, |
michael@0 | 545 | execute: function (aWindow) { |
michael@0 | 546 | synthesizeText( |
michael@0 | 547 | { "composition": |
michael@0 | 548 | { "string": "", |
michael@0 | 549 | "clauses": |
michael@0 | 550 | [ |
michael@0 | 551 | { "length": 0, "attr": 0 } |
michael@0 | 552 | ] |
michael@0 | 553 | }, |
michael@0 | 554 | "caret": { "start": 0, "length": 0 } |
michael@0 | 555 | }, aWindow); |
michael@0 | 556 | synthesizeComposition({ type: "compositionend", data: "" }, aWindow); |
michael@0 | 557 | synthesizeKey("VK_ESCAPE", { type: "keyup" }, aWindow); |
michael@0 | 558 | }, popup: true, value: "Mo", searchString: "Mo" |
michael@0 | 559 | }, |
michael@0 | 560 | // House keeping... |
michael@0 | 561 | { description: "house keeping for next tests", |
michael@0 | 562 | completeDefaultIndex: false, |
michael@0 | 563 | execute: function (aWindow) { |
michael@0 | 564 | synthesizeKey("VK_BACK_SPACE", {}, aWindow); |
michael@0 | 565 | synthesizeKey("VK_BACK_SPACE", {}, aWindow); |
michael@0 | 566 | }, popup: false, value: "", searchString: "" |
michael@0 | 567 | }, |
michael@0 | 568 | // Testing for nsIAutoCompleteInput.completeDefaultIndex being true. |
michael@0 | 569 | { description: "compositionstart shouldn't open the popup (completeDefaultIndex is true)", |
michael@0 | 570 | completeDefaultIndex: true, |
michael@0 | 571 | execute: function (aWindow) { |
michael@0 | 572 | synthesizeKey("m", { type: "keydown", shiftKey: true }, aWindow); |
michael@0 | 573 | synthesizeComposition({ type: "compositionstart" }, aWindow); |
michael@0 | 574 | synthesizeComposition({ type: "compositionupdate", data: "M" }, aWindow); |
michael@0 | 575 | synthesizeText( |
michael@0 | 576 | { "composition": |
michael@0 | 577 | { "string": "M", |
michael@0 | 578 | "clauses": |
michael@0 | 579 | [ |
michael@0 | 580 | { "length": 1, "attr": COMPOSITION_ATTR_RAWINPUT } |
michael@0 | 581 | ] |
michael@0 | 582 | }, |
michael@0 | 583 | "caret": { "start": 1, "length": 0 } |
michael@0 | 584 | }, aWindow); |
michael@0 | 585 | }, popup: false, value: "M", searchString: "" |
michael@0 | 586 | }, |
michael@0 | 587 | { description: "compositionupdate shouldn't open the popup (completeDefaultIndex is true)", |
michael@0 | 588 | completeDefaultIndex: true, |
michael@0 | 589 | execute: function (aWindow) { |
michael@0 | 590 | synthesizeComposition({ type: "compositionupdate", data: "Mo" }, aWindow); |
michael@0 | 591 | synthesizeText( |
michael@0 | 592 | { "composition": |
michael@0 | 593 | { "string": "Mo", |
michael@0 | 594 | "clauses": |
michael@0 | 595 | [ |
michael@0 | 596 | { "length": 2, "attr": COMPOSITION_ATTR_RAWINPUT } |
michael@0 | 597 | ] |
michael@0 | 598 | }, |
michael@0 | 599 | "caret": { "start": 2, "length": 0 } |
michael@0 | 600 | }, aWindow); |
michael@0 | 601 | }, popup: false, value: "Mo", searchString: "" |
michael@0 | 602 | }, |
michael@0 | 603 | { description: "compositionend should open the popup (completeDefaultIndex is true)", |
michael@0 | 604 | completeDefaultIndex: true, |
michael@0 | 605 | execute: function (aWindow) { |
michael@0 | 606 | synthesizeText( |
michael@0 | 607 | { "composition": |
michael@0 | 608 | { "string": "Mo", |
michael@0 | 609 | "clauses": |
michael@0 | 610 | [ |
michael@0 | 611 | { "length": 0, "attr": 0 } |
michael@0 | 612 | ] |
michael@0 | 613 | }, |
michael@0 | 614 | "caret": { "start": 2, "length": 0 } |
michael@0 | 615 | }, aWindow); |
michael@0 | 616 | synthesizeComposition({ type: "compositionend", data: "Mo" }, aWindow); |
michael@0 | 617 | synthesizeKey("VK_RETURN", { type: "keyup" }, aWindow); |
michael@0 | 618 | }, popup: true, value: "Mozilla", searchString: "Mo" |
michael@0 | 619 | }, |
michael@0 | 620 | // House keeping... |
michael@0 | 621 | { description: "house keeping for next tests", |
michael@0 | 622 | completeDefaultIndex: false, |
michael@0 | 623 | execute: function (aWindow) { |
michael@0 | 624 | synthesizeKey("VK_BACK_SPACE", {}, aWindow); |
michael@0 | 625 | synthesizeKey("VK_BACK_SPACE", {}, aWindow); |
michael@0 | 626 | synthesizeKey("VK_BACK_SPACE", {}, aWindow); |
michael@0 | 627 | synthesizeKey("VK_BACK_SPACE", {}, aWindow); |
michael@0 | 628 | synthesizeKey("VK_BACK_SPACE", {}, aWindow); |
michael@0 | 629 | synthesizeKey("VK_BACK_SPACE", {}, aWindow); |
michael@0 | 630 | }, popup: false, value: "", searchString: "" |
michael@0 | 631 | } |
michael@0 | 632 | ] |
michael@0 | 633 | }; |