toolkit/content/tests/chrome/file_autocomplete_with_composition.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/toolkit/content/tests/chrome/file_autocomplete_with_composition.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,633 @@
     1.4 +// nsDoTestsForAutoCompleteWithComposition tests autocomplete with composition.
     1.5 +// Users must include SimpleTest.js and EventUtils.js.
     1.6 +
     1.7 +function nsDoTestsForAutoCompleteWithComposition(aDescription,
     1.8 +                                                 aWindow,
     1.9 +                                                 aTarget,
    1.10 +                                                 aAutoCompleteController,
    1.11 +                                                 aIsFunc,
    1.12 +                                                 aGetTargetValueFunc,
    1.13 +                                                 aOnFinishFunc)
    1.14 +{
    1.15 +  this._description = aDescription;
    1.16 +  this._window = aWindow;
    1.17 +  this._target = aTarget;
    1.18 +  this._controller = aAutoCompleteController;
    1.19 +
    1.20 +  this._is = aIsFunc;
    1.21 +  this._getTargetValue = aGetTargetValueFunc;
    1.22 +  this._onFinish = aOnFinishFunc;
    1.23 +
    1.24 +  this._target.focus();
    1.25 +
    1.26 +  this._DefaultCompleteDefaultIndex =
    1.27 +    this._controller.input.completeDefaultIndex;
    1.28 +
    1.29 +  this._doTests();
    1.30 +}
    1.31 +
    1.32 +nsDoTestsForAutoCompleteWithComposition.prototype = {
    1.33 +  _window: null,
    1.34 +  _target: null,
    1.35 +  _controller: null,
    1.36 +  _DefaultCompleteDefaultIndex: false,
    1.37 +  _description: "",
    1.38 +
    1.39 +  _is: null,
    1.40 +  _getTargetValue: function () { return "not initialized"; },
    1.41 +  _onFinish: null,
    1.42 +
    1.43 +  _doTests: function ()
    1.44 +  {
    1.45 +    if (++this._testingIndex == this._tests.length) {
    1.46 +      this._controller.input.completeDefaultIndex =
    1.47 +        this._DefaultCompleteDefaultIndex;
    1.48 +      this._onFinish();
    1.49 +      return;
    1.50 +    }
    1.51 +
    1.52 +    var test = this._tests[this._testingIndex];
    1.53 +    if (this._controller.input.completeDefaultIndex != test.completeDefaultIndex) {
    1.54 +      this._controller.input.completeDefaultIndex = test.completeDefaultIndex;
    1.55 +    }
    1.56 +    test.execute(this._window);
    1.57 +
    1.58 +    var timeout = this._controller.input.timeout + 10;
    1.59 +    this._waitResult(timeout);
    1.60 +  },
    1.61 +
    1.62 +  _waitResult: function (aTimes)
    1.63 +  {
    1.64 +    var obj = this;
    1.65 +    if (aTimes-- > 0) {
    1.66 +      setTimeout(function () { obj._waitResult(aTimes); }, 0);
    1.67 +    } else {
    1.68 +      setTimeout(function () { obj._checkResult(); }, 0);
    1.69 +    }
    1.70 +  },
    1.71 +
    1.72 +  _checkResult: function ()
    1.73 +  {
    1.74 +    var test = this._tests[this._testingIndex];
    1.75 +    this._is(this._getTargetValue(), test.value,
    1.76 +             this._description + ", " + test.description + ": value");
    1.77 +    this._is(this._controller.searchString, test.searchString,
    1.78 +             this._description + ", " + test.description +": searchString");
    1.79 +    this._is(this._controller.input.popupOpen, test.popup,
    1.80 +             this._description + ", " + test.description + ": popupOpen");
    1.81 +    this._doTests();
    1.82 +  },
    1.83 +
    1.84 +  _testingIndex: -1,
    1.85 +  _tests: [
    1.86 +    // Simple composition when popup hasn't been shown.
    1.87 +    // The autocomplete popup should not be shown during composition, but
    1.88 +    // after compositionend, the popup should be shown.
    1.89 +    { description: "compositionstart shouldn't open the popup",
    1.90 +      completeDefaultIndex: false,
    1.91 +      execute: function (aWindow) {
    1.92 +        synthesizeKey("m", { type: "keydown", shiftKey: true }, aWindow);
    1.93 +        synthesizeComposition({ type: "compositionstart" }, aWindow);
    1.94 +        synthesizeComposition({ type: "compositionupdate", data: "M" }, aWindow);
    1.95 +        synthesizeText(
    1.96 +          { "composition":
    1.97 +            { "string": "M",
    1.98 +              "clauses":
    1.99 +              [
   1.100 +                { "length": 1, "attr": COMPOSITION_ATTR_RAWINPUT }
   1.101 +              ]
   1.102 +            },
   1.103 +            "caret": { "start": 1, "length": 0 }
   1.104 +          }, aWindow);
   1.105 +      }, popup: false, value: "M", searchString: ""
   1.106 +    },
   1.107 +    { description: "compositionupdate shouldn't open the popup",
   1.108 +      completeDefaultIndex: false,
   1.109 +      execute: function (aWindow) {
   1.110 +        synthesizeComposition({ type: "compositionupdate", data: "Mo" }, aWindow);
   1.111 +        synthesizeText(
   1.112 +          { "composition":
   1.113 +            { "string": "Mo",
   1.114 +              "clauses":
   1.115 +              [
   1.116 +                { "length": 2, "attr": COMPOSITION_ATTR_RAWINPUT }
   1.117 +              ]
   1.118 +            },
   1.119 +            "caret": { "start": 2, "length": 0 }
   1.120 +          }, aWindow);
   1.121 +      }, popup: false, value: "Mo", searchString: ""
   1.122 +    },
   1.123 +    { description: "compositionend should open the popup",
   1.124 +      completeDefaultIndex: false,
   1.125 +      execute: function (aWindow) {
   1.126 +        synthesizeText(
   1.127 +          { "composition":
   1.128 +            { "string": "Mo",
   1.129 +              "clauses":
   1.130 +              [
   1.131 +                { "length": 0, "attr": 0 }
   1.132 +              ]
   1.133 +            },
   1.134 +            "caret": { "start": 2, "length": 0 }
   1.135 +          }, aWindow);
   1.136 +        synthesizeComposition({ type: "compositionend", data: "Mo" }, aWindow);
   1.137 +        synthesizeKey("VK_RETURN", { type: "keyup" }, aWindow);
   1.138 +      }, popup: true, value: "Mo", searchString: "Mo"
   1.139 +    },
   1.140 +    // If composition starts when popup is shown, the compositionstart event
   1.141 +    // should cause closing the popup.
   1.142 +    { description: "compositionstart should close the popup",
   1.143 +      completeDefaultIndex: false,
   1.144 +      execute: function (aWindow) {
   1.145 +        synthesizeKey("z", { type: "keydown" }, aWindow);
   1.146 +        synthesizeComposition({ type: "compositionstart" }, aWindow);
   1.147 +        synthesizeComposition({ type: "compositionupdate", data: "z" }, aWindow);
   1.148 +        synthesizeText(
   1.149 +          { "composition":
   1.150 +            { "string": "z",
   1.151 +              "clauses":
   1.152 +              [
   1.153 +                { "length": 1, "attr": COMPOSITION_ATTR_RAWINPUT }
   1.154 +              ]
   1.155 +            },
   1.156 +            "caret": { "start": 1, "length": 0 }
   1.157 +          }, aWindow);
   1.158 +      }, popup: false, value: "Moz", searchString: "Mo"
   1.159 +    },
   1.160 +    { description: "compositionupdate shouldn't reopen the popup",
   1.161 +      completeDefaultIndex: false,
   1.162 +      execute: function (aWindow) {
   1.163 +        synthesizeComposition({ type: "compositionupdate", data: "zi" }, aWindow);
   1.164 +        synthesizeText(
   1.165 +          { "composition":
   1.166 +            { "string": "zi",
   1.167 +              "clauses":
   1.168 +              [
   1.169 +                { "length": 2, "attr": COMPOSITION_ATTR_RAWINPUT }
   1.170 +              ]
   1.171 +            },
   1.172 +            "caret": { "start": 2, "length": 0 }
   1.173 +          }, aWindow);
   1.174 +      }, popup: false, value: "Mozi", searchString: "Mo"
   1.175 +    },
   1.176 +    { description: "compositionend should research the result and open the popup",
   1.177 +      completeDefaultIndex: false,
   1.178 +      execute: function (aWindow) {
   1.179 +        synthesizeText(
   1.180 +          { "composition":
   1.181 +            { "string": "zi",
   1.182 +              "clauses":
   1.183 +              [
   1.184 +                { "length": 0, "attr": 0 }
   1.185 +              ]
   1.186 +            },
   1.187 +            "caret": { "start": 2, "length": 0 }
   1.188 +          });
   1.189 +        synthesizeComposition({ type: "compositionend", data: "zi" }, aWindow);
   1.190 +        synthesizeKey("VK_RETURN", { type: "keyup" }, aWindow);
   1.191 +      }, popup: true, value: "Mozi", searchString: "Mozi"
   1.192 +    },
   1.193 +    // If composition is cancelled, the value shouldn't be changed.
   1.194 +    { description: "compositionstart should reclose the popup",
   1.195 +      completeDefaultIndex: false,
   1.196 +      execute: function (aWindow) {
   1.197 +        synthesizeKey("l", { type: "keydown" }, aWindow);
   1.198 +        synthesizeComposition({ type: "compositionstart" }, aWindow);
   1.199 +        synthesizeComposition({ type: "compositionupdate", data: "l" }, aWindow);
   1.200 +        synthesizeText(
   1.201 +          { "composition":
   1.202 +            { "string": "l",
   1.203 +              "clauses":
   1.204 +              [
   1.205 +                { "length": 1, "attr": COMPOSITION_ATTR_RAWINPUT }
   1.206 +              ]
   1.207 +            },
   1.208 +            "caret": { "start": 1, "length": 0 }
   1.209 +          }, aWindow);
   1.210 +      }, popup: false, value: "Mozil", searchString: "Mozi"
   1.211 +    },
   1.212 +    { description: "compositionupdate shouldn't reopen the popup",
   1.213 +      completeDefaultIndex: false,
   1.214 +      execute: function (aWindow) {
   1.215 +        synthesizeComposition({ type: "compositionupdate", data: "ll" }, aWindow);
   1.216 +        synthesizeText(
   1.217 +          { "composition":
   1.218 +            { "string": "ll",
   1.219 +              "clauses":
   1.220 +              [
   1.221 +                { "length": 2, "attr": COMPOSITION_ATTR_RAWINPUT }
   1.222 +              ]
   1.223 +            },
   1.224 +            "caret": { "start": 2, "length": 0 }
   1.225 +          }, aWindow);
   1.226 +      }, popup: false, value: "Mozill", searchString: "Mozi"
   1.227 +    },
   1.228 +    { description: "empty compositionupdate shouldn't reopen the popup",
   1.229 +      completeDefaultIndex: false,
   1.230 +      execute: function (aWindow) {
   1.231 +        synthesizeComposition({ type: "compositionupdate", data: "" }, aWindow);
   1.232 +        synthesizeText(
   1.233 +          { "composition":
   1.234 +            { "string": "",
   1.235 +              "clauses":
   1.236 +              [
   1.237 +                { "length": 0, "attr": 0 }
   1.238 +              ]
   1.239 +            },
   1.240 +            "caret": { "start": 0, "length": 0 }
   1.241 +          }, aWindow);
   1.242 +      }, popup: false, value: "Mozi", searchString: "Mozi"
   1.243 +    },
   1.244 +    { description: "cancled compositionend should reopen the popup",
   1.245 +      completeDefaultIndex: false,
   1.246 +      execute: function (aWindow) {
   1.247 +        synthesizeText(
   1.248 +          { "composition":
   1.249 +            { "string": "",
   1.250 +              "clauses":
   1.251 +              [
   1.252 +                { "length": 0, "attr": 0 }
   1.253 +              ]
   1.254 +            },
   1.255 +            "caret": { "start": 0, "length": 0 }
   1.256 +          }, aWindow);
   1.257 +        synthesizeComposition({ type: "compositionend", data: "" }, aWindow);
   1.258 +        synthesizeKey("VK_ESCAPE", { type: "keyup" }, aWindow);
   1.259 +      }, popup: true, value: "Mozi", searchString: "Mozi"
   1.260 +    },
   1.261 +    // But if composition replaces some characters and canceled, the search
   1.262 +    // string should be the latest value.
   1.263 +    { description: "compositionstart with selected string should close the popup",
   1.264 +      completeDefaultIndex: false,
   1.265 +      execute: function (aWindow) {
   1.266 +        synthesizeKey("VK_LEFT", { shiftKey: true }, aWindow);
   1.267 +        synthesizeKey("VK_LEFT", { shiftKey: true }, aWindow);
   1.268 +        synthesizeKey("z", { type: "keydown" }, aWindow);
   1.269 +        synthesizeComposition({ type: "compositionstart" }, aWindow);
   1.270 +        synthesizeComposition({ type: "compositionupdate", data: "z" }, aWindow);
   1.271 +        synthesizeText(
   1.272 +          { "composition":
   1.273 +            { "string": "z",
   1.274 +              "clauses":
   1.275 +              [
   1.276 +                { "length": 1, "attr": COMPOSITION_ATTR_RAWINPUT }
   1.277 +              ]
   1.278 +            },
   1.279 +            "caret": { "start": 1, "length": 0 }
   1.280 +          }, aWindow);
   1.281 +      }, popup: false, value: "Moz", searchString: "Mozi"
   1.282 +    },
   1.283 +    { description: "compositionupdate shouldn't reopen the popup",
   1.284 +      completeDefaultIndex: false,
   1.285 +      execute: function (aWindow) {
   1.286 +        synthesizeComposition({ type: "compositionupdate", data: "zi" }, aWindow);
   1.287 +        synthesizeText(
   1.288 +          { "composition":
   1.289 +            { "string": "zi",
   1.290 +              "clauses":
   1.291 +              [
   1.292 +                { "length": 2, "attr": COMPOSITION_ATTR_RAWINPUT }
   1.293 +              ]
   1.294 +            },
   1.295 +            "caret": { "start": 2, "length": 0 }
   1.296 +          }, aWindow);
   1.297 +      }, popup: false, value: "Mozi", searchString: "Mozi"
   1.298 +    },
   1.299 +    { description: "empty compositionupdate shouldn't reopen the popup",
   1.300 +      completeDefaultIndex: false,
   1.301 +      execute: function (aWindow) {
   1.302 +        synthesizeComposition({ type: "compositionupdate", data: "" }, aWindow);
   1.303 +        synthesizeText(
   1.304 +          { "composition":
   1.305 +            { "string": "",
   1.306 +              "clauses":
   1.307 +              [
   1.308 +                { "length": 0, "attr": 0 }
   1.309 +              ]
   1.310 +            },
   1.311 +            "caret": { "start": 0, "length": 0 }
   1.312 +          }, aWindow);
   1.313 +      }, popup: false, value: "Mo", searchString: "Mozi"
   1.314 +    },
   1.315 +    { description: "canceled compositionend should seach the result with the latest value",
   1.316 +      completeDefaultIndex: false,
   1.317 +      execute: function (aWindow) {
   1.318 +        synthesizeText(
   1.319 +          { "composition":
   1.320 +            { "string": "",
   1.321 +              "clauses":
   1.322 +              [
   1.323 +                { "length": 0, "attr": 0 }
   1.324 +              ]
   1.325 +            },
   1.326 +            "caret": { "start": 0, "length": 0 }
   1.327 +          }, aWindow);
   1.328 +        synthesizeComposition({ type: "compositionend", data: "" }, aWindow);
   1.329 +        synthesizeKey("VK_ESCAPE", { type: "keyup" }, aWindow);
   1.330 +      }, popup: true, value: "Mo", searchString: "Mo"
   1.331 +    },
   1.332 +    //If all characters are removed, the popup should be closed.
   1.333 +    { description: "the value becomes empty by backspace, the popup should be closed",
   1.334 +      completeDefaultIndex: false,
   1.335 +      execute: function (aWindow) {
   1.336 +        synthesizeKey("VK_BACK_SPACE", {}, aWindow);
   1.337 +        synthesizeKey("VK_BACK_SPACE", {}, aWindow);
   1.338 +      }, popup: false, value: "", searchString: ""
   1.339 +    },
   1.340 +    // composition which is canceled shouldn't cause opening the popup.
   1.341 +    { description: "compositionstart shouldn't open the popup",
   1.342 +      completeDefaultIndex: false,
   1.343 +      execute: function (aWindow) {
   1.344 +        synthesizeKey("m", { type: "keydown", shiftKey: true }, aWindow);
   1.345 +        synthesizeComposition({ type: "compositionstart" }, aWindow);
   1.346 +        synthesizeComposition({ type: "compositionupdate", data: "M" }, aWindow);
   1.347 +        synthesizeText(
   1.348 +          { "composition":
   1.349 +            { "string": "M",
   1.350 +              "clauses":
   1.351 +              [
   1.352 +                { "length": 1, "attr": COMPOSITION_ATTR_RAWINPUT }
   1.353 +              ]
   1.354 +            },
   1.355 +            "caret": { "start": 1, "length": 0 }
   1.356 +          }, aWindow);
   1.357 +      }, popup: false, value: "M", searchString: ""
   1.358 +    },
   1.359 +    { description: "compositionupdate shouldn't open the popup",
   1.360 +      completeDefaultIndex: false,
   1.361 +      execute: function (aWindow) {
   1.362 +        synthesizeComposition({ type: "compositionupdate", data: "Mo" }, aWindow);
   1.363 +        synthesizeText(
   1.364 +          { "composition":
   1.365 +            { "string": "Mo",
   1.366 +              "clauses":
   1.367 +              [
   1.368 +                { "length": 2, "attr": COMPOSITION_ATTR_RAWINPUT }
   1.369 +              ]
   1.370 +            },
   1.371 +            "caret": { "start": 2, "length": 0 }
   1.372 +          }, aWindow);
   1.373 +      }, popup: false, value: "Mo", searchString: ""
   1.374 +    },
   1.375 +    { description: "empty compositionupdate shouldn't open the popup",
   1.376 +      completeDefaultIndex: false,
   1.377 +      execute: function (aWindow) {
   1.378 +        synthesizeComposition({ type: "compositionupdate", data: "" }, aWindow);
   1.379 +        synthesizeText(
   1.380 +          { "composition":
   1.381 +            { "string": "",
   1.382 +              "clauses":
   1.383 +              [
   1.384 +                { "length": 0, "attr": 0 }
   1.385 +              ]
   1.386 +            },
   1.387 +            "caret": { "start": 0, "length": 0 }
   1.388 +          }, aWindow);
   1.389 +      }, popup: false, value: "", searchString: ""
   1.390 +    },
   1.391 +    { description: "canceled compositionend shouldn't open the popup if it was closed",
   1.392 +      completeDefaultIndex: false,
   1.393 +      execute: function (aWindow) {
   1.394 +        synthesizeText(
   1.395 +          { "composition":
   1.396 +            { "string": "",
   1.397 +              "clauses":
   1.398 +              [
   1.399 +                { "length": 0, "attr": 0 }
   1.400 +              ]
   1.401 +            },
   1.402 +            "caret": { "start": 0, "length": 0 }
   1.403 +          }, aWindow);
   1.404 +        synthesizeComposition({ type: "compositionend", data: "" }, aWindow);
   1.405 +        synthesizeKey("VK_ESCAPE", { type: "keyup" }, aWindow);
   1.406 +      }, popup: false, value: "", searchString: ""
   1.407 +    },
   1.408 +    // Down key should open the popup even if the editor is empty.
   1.409 +    { description: "DOWN key should open the popup even if the value is empty",
   1.410 +      completeDefaultIndex: false,
   1.411 +      execute: function (aWindow) {
   1.412 +        synthesizeKey("VK_DOWN", {}, aWindow);
   1.413 +      }, popup: true, value: "", searchString: ""
   1.414 +    },
   1.415 +    // If popup is open at starting composition, the popup should be reopened
   1.416 +    // after composition anyway.
   1.417 +    { description: "compositionstart shouldn't open the popup",
   1.418 +      completeDefaultIndex: false,
   1.419 +      execute: function (aWindow) {
   1.420 +        synthesizeKey("m", { type: "keydown", shiftKey: true }, aWindow);
   1.421 +        synthesizeComposition({ type: "compositionstart" }, aWindow);
   1.422 +        synthesizeComposition({ type: "compositionupdate", data: "M" }, aWindow);
   1.423 +        synthesizeText(
   1.424 +          { "composition":
   1.425 +            { "string": "M",
   1.426 +              "clauses":
   1.427 +              [
   1.428 +                { "length": 1, "attr": COMPOSITION_ATTR_RAWINPUT }
   1.429 +              ]
   1.430 +            },
   1.431 +            "caret": { "start": 1, "length": 0 }
   1.432 +          }, aWindow);
   1.433 +      }, popup: false, value: "M", searchString: ""
   1.434 +    },
   1.435 +    { description: "compositionupdate shouldn't open the popup",
   1.436 +      completeDefaultIndex: false,
   1.437 +      execute: function (aWindow) {
   1.438 +        synthesizeComposition({ type: "compositionupdate", data: "Mo" }, aWindow);
   1.439 +        synthesizeText(
   1.440 +          { "composition":
   1.441 +            { "string": "Mo",
   1.442 +              "clauses":
   1.443 +              [
   1.444 +                { "length": 2, "attr": COMPOSITION_ATTR_RAWINPUT }
   1.445 +              ]
   1.446 +            },
   1.447 +            "caret": { "start": 2, "length": 0 }
   1.448 +          }, aWindow);
   1.449 +      }, popup: false, value: "Mo", searchString: ""
   1.450 +    },
   1.451 +    { description: "empty compositionupdate shouldn't open the popup",
   1.452 +      completeDefaultIndex: false,
   1.453 +      execute: function (aWindow) {
   1.454 +        synthesizeComposition({ type: "compositionupdate", data: "" }, aWindow);
   1.455 +        synthesizeText(
   1.456 +          { "composition":
   1.457 +            { "string": "",
   1.458 +              "clauses":
   1.459 +              [
   1.460 +                { "length": 0, "attr": 0 }
   1.461 +              ]
   1.462 +            },
   1.463 +            "caret": { "start": 0, "length": 0 }
   1.464 +          }, aWindow);
   1.465 +      }, popup: false, value: "", searchString: ""
   1.466 +    },
   1.467 +    { description: "canceled compositionend should open the popup if it was opened",
   1.468 +      completeDefaultIndex: false,
   1.469 +      execute: function (aWindow) {
   1.470 +        synthesizeText(
   1.471 +          { "composition":
   1.472 +            { "string": "",
   1.473 +              "clauses":
   1.474 +              [
   1.475 +                { "length": 0, "attr": 0 }
   1.476 +              ]
   1.477 +            },
   1.478 +            "caret": { "start": 0, "length": 0 }
   1.479 +          }, aWindow);
   1.480 +        synthesizeComposition({ type: "compositionend", data: "" }, aWindow);
   1.481 +        synthesizeKey("VK_ESCAPE", { type: "keyup" }, aWindow);
   1.482 +      }, popup: true, value: "", searchString: ""
   1.483 +    },
   1.484 +    // Type normally, and hit escape, the popup should be closed.
   1.485 +    { description: "ESCAPE should close the popup after typing something",
   1.486 +      completeDefaultIndex: false,
   1.487 +      execute: function (aWindow) {
   1.488 +        synthesizeKey("M", { shiftKey: true }, aWindow);
   1.489 +        synthesizeKey("o", { shiftKey: true }, aWindow);
   1.490 +        synthesizeKey("VK_ESCAPE", {}, aWindow);
   1.491 +      }, popup: false, value: "Mo", searchString: "Mo"
   1.492 +    },
   1.493 +    // Even if the popup is closed, composition which is canceled should open
   1.494 +    // the popup if the value isn't empty.
   1.495 +    // XXX This might not be good behavior, but anyway, this is minor issue...
   1.496 +    { description: "compositionstart shouldn't open the popup",
   1.497 +      completeDefaultIndex: false,
   1.498 +      execute: function (aWindow) {
   1.499 +        synthesizeKey("z", { type: "keydown", shiftKey: true }, aWindow);
   1.500 +        synthesizeComposition({ type: "compositionstart" }, aWindow);
   1.501 +        synthesizeComposition({ type: "compositionupdate", data: "z" }, aWindow);
   1.502 +        synthesizeText(
   1.503 +          { "composition":
   1.504 +            { "string": "z",
   1.505 +              "clauses":
   1.506 +              [
   1.507 +                { "length": 1, "attr": COMPOSITION_ATTR_RAWINPUT }
   1.508 +              ]
   1.509 +            },
   1.510 +            "caret": { "start": 1, "length": 0 }
   1.511 +          }, aWindow);
   1.512 +      }, popup: false, value: "Moz", searchString: "Mo"
   1.513 +    },
   1.514 +    { description: "compositionupdate shouldn't open the popup",
   1.515 +      completeDefaultIndex: false,
   1.516 +      execute: function (aWindow) {
   1.517 +        synthesizeComposition({ type: "compositionupdate", data: "zi" }, aWindow);
   1.518 +        synthesizeText(
   1.519 +          { "composition":
   1.520 +            { "string": "zi",
   1.521 +              "clauses":
   1.522 +              [
   1.523 +                { "length": 2, "attr": COMPOSITION_ATTR_RAWINPUT }
   1.524 +              ]
   1.525 +            },
   1.526 +            "caret": { "start": 2, "length": 0 }
   1.527 +          }, aWindow);
   1.528 +      }, popup: false, value: "Mozi", searchString: "Mo"
   1.529 +    },
   1.530 +    { description: "empty compositionupdate shouldn't open the popup",
   1.531 +      completeDefaultIndex: false,
   1.532 +      execute: function (aWindow) {
   1.533 +        synthesizeComposition({ type: "compositionupdate", data: "" }, aWindow);
   1.534 +        synthesizeText(
   1.535 +          { "composition":
   1.536 +            { "string": "",
   1.537 +              "clauses":
   1.538 +              [
   1.539 +                { "length": 0, "attr": 0 }
   1.540 +              ]
   1.541 +            },
   1.542 +            "caret": { "start": 0, "length": 0 }
   1.543 +          }, aWindow);
   1.544 +      }, popup: false, value: "Mo", searchString: "Mo"
   1.545 +    },
   1.546 +    { description: "canceled compositionend shouldn't open the popup if the popup was closed",
   1.547 +      completeDefaultIndex: false,
   1.548 +      execute: function (aWindow) {
   1.549 +        synthesizeText(
   1.550 +          { "composition":
   1.551 +            { "string": "",
   1.552 +              "clauses":
   1.553 +              [
   1.554 +                { "length": 0, "attr": 0 }
   1.555 +              ]
   1.556 +            },
   1.557 +            "caret": { "start": 0, "length": 0 }
   1.558 +          }, aWindow);
   1.559 +        synthesizeComposition({ type: "compositionend", data: "" }, aWindow);
   1.560 +        synthesizeKey("VK_ESCAPE", { type: "keyup" }, aWindow);
   1.561 +      }, popup: true, value: "Mo", searchString: "Mo"
   1.562 +    },
   1.563 +    // House keeping...
   1.564 +    { description: "house keeping for next tests",
   1.565 +      completeDefaultIndex: false,
   1.566 +      execute: function (aWindow) {
   1.567 +        synthesizeKey("VK_BACK_SPACE", {}, aWindow);
   1.568 +        synthesizeKey("VK_BACK_SPACE", {}, aWindow);
   1.569 +      }, popup: false, value: "", searchString: ""
   1.570 +    },
   1.571 +    // Testing for nsIAutoCompleteInput.completeDefaultIndex being true.
   1.572 +    { description: "compositionstart shouldn't open the popup (completeDefaultIndex is true)",
   1.573 +      completeDefaultIndex: true,
   1.574 +      execute: function (aWindow) {
   1.575 +        synthesizeKey("m", { type: "keydown", shiftKey: true }, aWindow);
   1.576 +        synthesizeComposition({ type: "compositionstart" }, aWindow);
   1.577 +        synthesizeComposition({ type: "compositionupdate", data: "M" }, aWindow);
   1.578 +        synthesizeText(
   1.579 +          { "composition":
   1.580 +            { "string": "M",
   1.581 +              "clauses":
   1.582 +              [
   1.583 +                { "length": 1, "attr": COMPOSITION_ATTR_RAWINPUT }
   1.584 +              ]
   1.585 +            },
   1.586 +            "caret": { "start": 1, "length": 0 }
   1.587 +          }, aWindow);
   1.588 +      }, popup: false, value: "M", searchString: ""
   1.589 +    },
   1.590 +    { description: "compositionupdate shouldn't open the popup (completeDefaultIndex is true)",
   1.591 +      completeDefaultIndex: true,
   1.592 +      execute: function (aWindow) {
   1.593 +        synthesizeComposition({ type: "compositionupdate", data: "Mo" }, aWindow);
   1.594 +        synthesizeText(
   1.595 +          { "composition":
   1.596 +            { "string": "Mo",
   1.597 +              "clauses":
   1.598 +              [
   1.599 +                { "length": 2, "attr": COMPOSITION_ATTR_RAWINPUT }
   1.600 +              ]
   1.601 +            },
   1.602 +            "caret": { "start": 2, "length": 0 }
   1.603 +          }, aWindow);
   1.604 +      }, popup: false, value: "Mo", searchString: ""
   1.605 +    },
   1.606 +    { description: "compositionend should open the popup (completeDefaultIndex is true)",
   1.607 +      completeDefaultIndex: true,
   1.608 +      execute: function (aWindow) {
   1.609 +        synthesizeText(
   1.610 +          { "composition":
   1.611 +            { "string": "Mo",
   1.612 +              "clauses":
   1.613 +              [
   1.614 +                { "length": 0, "attr": 0 }
   1.615 +              ]
   1.616 +            },
   1.617 +            "caret": { "start": 2, "length": 0 }
   1.618 +          }, aWindow);
   1.619 +        synthesizeComposition({ type: "compositionend", data: "Mo" }, aWindow);
   1.620 +        synthesizeKey("VK_RETURN", { type: "keyup" }, aWindow);
   1.621 +      }, popup: true, value: "Mozilla", searchString: "Mo"
   1.622 +    },
   1.623 +    // House keeping...
   1.624 +    { description: "house keeping for next tests",
   1.625 +      completeDefaultIndex: false,
   1.626 +      execute: function (aWindow) {
   1.627 +        synthesizeKey("VK_BACK_SPACE", {}, aWindow);
   1.628 +        synthesizeKey("VK_BACK_SPACE", {}, aWindow);
   1.629 +        synthesizeKey("VK_BACK_SPACE", {}, aWindow);
   1.630 +        synthesizeKey("VK_BACK_SPACE", {}, aWindow);
   1.631 +        synthesizeKey("VK_BACK_SPACE", {}, aWindow);
   1.632 +        synthesizeKey("VK_BACK_SPACE", {}, aWindow);
   1.633 +      }, popup: false, value: "", searchString: ""
   1.634 +    }
   1.635 +  ]
   1.636 +};

mercurial