widget/tests/window_composition_text_querycontent.xul

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 <?xml version="1.0"?>
michael@0 2 <?xml-stylesheet href="chrome://global/skin" type="text/css"?>
michael@0 3 <?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
michael@0 4 type="text/css"?>
michael@0 5 <window title="Testing composition, text and query content events"
michael@0 6 xmlns:html="http://www.w3.org/1999/xhtml"
michael@0 7 xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
michael@0 8 onunload="onunload();">
michael@0 9
michael@0 10 <script type="application/javascript"
michael@0 11 src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
michael@0 12 <script type="application/javascript"
michael@0 13 src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js" />
michael@0 14 <script type="text/javascript" src="chrome://mochikit/content/tests/SimpleTest/ChromeUtils.js"></script>
michael@0 15
michael@0 16 <panel id="panel" hidden="true"
michael@0 17 orient="vertical"
michael@0 18 onpopupshown="onPanelShown(event);"
michael@0 19 onpopuphidden="onPanelHidden(event);">
michael@0 20 <vbox id="vbox">
michael@0 21 <textbox id="textbox" onfocus="onFocusPanelTextbox(event);"
michael@0 22 multiline="true" cols="20" rows="4"/>
michael@0 23 </vbox>
michael@0 24 </panel>
michael@0 25
michael@0 26 <body xmlns="http://www.w3.org/1999/xhtml">
michael@0 27 <p id="display">
michael@0 28 <div id="div" style="margin: 0; padding: 0; font-size: 24px;">Here is a text frame.</div>
michael@0 29 <textarea style="margin: 0;" id="textarea" cols="20" rows="4"></textarea><br/>
michael@0 30 <iframe id="iframe" width="300" height="150"
michael@0 31 src="data:text/html,&lt;textarea id='textarea' cols='20' rows='4'&gt;&lt;/textarea&gt;"></iframe><br/>
michael@0 32 <iframe id="iframe2" width="300" height="150"
michael@0 33 src="data:text/html,&lt;body onload='document.designMode=%22on%22'&gt;body content&lt;/body&gt;"></iframe><br/>
michael@0 34 <iframe id="iframe3" width="300" height="150"
michael@0 35 src="data:text/html,&lt;body onload='document.designMode=%22on%22'&gt;body content&lt;/body&gt;"></iframe><br/>
michael@0 36 <input id="input" type="text"/><br/>
michael@0 37 </p>
michael@0 38 <div id="content" style="display: none">
michael@0 39
michael@0 40 </div>
michael@0 41 <pre id="test">
michael@0 42 </pre>
michael@0 43 </body>
michael@0 44
michael@0 45 <script class="testbody" type="application/javascript">
michael@0 46 <![CDATA[
michael@0 47
michael@0 48 window.opener.wrappedJSObject.SimpleTest.waitForFocus(runTest, window);
michael@0 49
michael@0 50 function ok(aCondition, aMessage)
michael@0 51 {
michael@0 52 window.opener.wrappedJSObject.SimpleTest.ok(aCondition, aMessage);
michael@0 53 }
michael@0 54
michael@0 55 function is(aLeft, aRight, aMessage)
michael@0 56 {
michael@0 57 window.opener.wrappedJSObject.SimpleTest.is(aLeft, aRight, aMessage);
michael@0 58 }
michael@0 59
michael@0 60 function isnot(aLeft, aRight, aMessage)
michael@0 61 {
michael@0 62 window.opener.wrappedJSObject.SimpleTest.isnot(aLeft, aRight, aMessage);
michael@0 63 }
michael@0 64
michael@0 65 function finish()
michael@0 66 {
michael@0 67 window.close();
michael@0 68 }
michael@0 69
michael@0 70 function onunload()
michael@0 71 {
michael@0 72 window.opener.wrappedJSObject.SimpleTest.finish();
michael@0 73 }
michael@0 74
michael@0 75 var div = document.getElementById("div");
michael@0 76 var textarea = document.getElementById("textarea");
michael@0 77 var panel = document.getElementById("panel");
michael@0 78 var textbox = document.getElementById("textbox");
michael@0 79 var iframe = document.getElementById("iframe");
michael@0 80 var iframe2 = document.getElementById("iframe2");
michael@0 81 var iframe3 = document.getElementById("iframe3");
michael@0 82 var input = document.getElementById("input");
michael@0 83 var textareaInFrame;
michael@0 84
michael@0 85 const nsIDOMNSEditableElement = Components.interfaces.nsIDOMNSEditableElement;
michael@0 86 const nsIEditorIMESupport = Components.interfaces.nsIEditorIMESupport;
michael@0 87 const nsIInterfaceRequestor = Components.interfaces.nsIInterfaceRequestor;
michael@0 88 const nsIWebNavigation = Components.interfaces.nsIWebNavigation;
michael@0 89 const nsIDocShell = Components.interfaces.nsIDocShell;
michael@0 90
michael@0 91 function hitEventLoop(aFunc, aTimes)
michael@0 92 {
michael@0 93 if (--aTimes) {
michael@0 94 setTimeout(hitEventLoop, 0, aFunc, aTimes);
michael@0 95 } else {
michael@0 96 setTimeout(aFunc, 20);
michael@0 97 }
michael@0 98 }
michael@0 99
michael@0 100 function getEditorIMESupport(aNode)
michael@0 101 {
michael@0 102 return aNode.QueryInterface(nsIDOMNSEditableElement).
michael@0 103 editor.
michael@0 104 QueryInterface(nsIEditorIMESupport);
michael@0 105 }
michael@0 106
michael@0 107 function getHTMLEditorIMESupport(aWindow)
michael@0 108 {
michael@0 109 return aWindow.QueryInterface(nsIInterfaceRequestor).
michael@0 110 getInterface(nsIWebNavigation).
michael@0 111 QueryInterface(nsIDocShell).
michael@0 112 editor;
michael@0 113 }
michael@0 114
michael@0 115 const kIsWin = (navigator.platform.indexOf("Win") == 0);
michael@0 116 const kIsMac = (navigator.platform.indexOf("Mac") == 0);
michael@0 117
michael@0 118 const kLFLen = kIsWin ? 2 : 1;
michael@0 119
michael@0 120 function checkQueryContentResult(aResult, aMessage)
michael@0 121 {
michael@0 122 ok(aResult, aMessage + ": the result is null");
michael@0 123 if (!aResult) {
michael@0 124 return false;
michael@0 125 }
michael@0 126 ok(aResult.succeeded, aMessage + ": the query content failed");
michael@0 127 return aResult.succeeded;
michael@0 128 }
michael@0 129
michael@0 130 function checkContent(aExpectedText, aMessage, aID)
michael@0 131 {
michael@0 132 var textContent = synthesizeQueryTextContent(0, 100);
michael@0 133 if (!checkQueryContentResult(textContent, aMessage +
michael@0 134 ": synthesizeQueryTextContent " + aID)) {
michael@0 135 return false;
michael@0 136 }
michael@0 137 is(textContent.text, aExpectedText,
michael@0 138 aMessage + ": composition string is wrong" + aID);
michael@0 139 return textContent.text == aExpectedText;
michael@0 140 }
michael@0 141
michael@0 142 function checkSelection(aExpectedOffset, aExpectedText, aMessage, aID)
michael@0 143 {
michael@0 144 var selectedText = synthesizeQuerySelectedText();
michael@0 145 if (!checkQueryContentResult(selectedText, aMessage +
michael@0 146 ": synthesizeQuerySelectedText " + aID)) {
michael@0 147 return false;
michael@0 148 }
michael@0 149 is(selectedText.offset, aExpectedOffset,
michael@0 150 aMessage + ": selection offset is wrong" + aID);
michael@0 151 is(selectedText.text, aExpectedText,
michael@0 152 aMessage + ": selected text is wrong" + aID);
michael@0 153 return selectedText.offset == aExpectedOffset &&
michael@0 154 selectedText.text == aExpectedText;
michael@0 155 }
michael@0 156
michael@0 157 function checkRect(aRect, aExpectedRect, aMessage)
michael@0 158 {
michael@0 159 is(aRect.left, aExpectedRect.left, aMessage + ": left is wrong");
michael@0 160 is(aRect.top, aExpectedRect.top, aMessage + " top is wrong");
michael@0 161 is(aRect.width, aExpectedRect.width, aMessage + ": width is wrong");
michael@0 162 is(aRect.height, aExpectedRect.height, aMessage + ": height is wrong");
michael@0 163 return aRect.left == aExpectedRect.left &&
michael@0 164 aRect.top == aExpectedRect.top &&
michael@0 165 aRect.width == aExpectedRect.width &&
michael@0 166 aRect.height == aExpectedRect.height;
michael@0 167 }
michael@0 168
michael@0 169 function checkRectContainsRect(aRect, aContainer, aMessage)
michael@0 170 {
michael@0 171 var container = { left: Math.ceil(aContainer.left),
michael@0 172 top: Math.ceil(aContainer.top),
michael@0 173 width: Math.floor(aContainer.width),
michael@0 174 height: Math.floor(aContainer.height) };
michael@0 175
michael@0 176 var ret = container.left <= aRect.left &&
michael@0 177 container.top <= aRect.top &&
michael@0 178 container.left + container.width >= aRect.left + aRect.width &&
michael@0 179 container.top + container.height >= aRect.top + aRect.height;
michael@0 180 ret = ret && aMessage;
michael@0 181 ok(ret, aMessage + " container={ left=" + container.left + ", top=" +
michael@0 182 container.top + ", width=" + container.width + ", height=" +
michael@0 183 container.height + " } rect={ left=" + aRect.left + ", top=" + aRect.top +
michael@0 184 ", width=" + aRect.width + ", height=" + aRect.height + " }");
michael@0 185 return ret;
michael@0 186 }
michael@0 187
michael@0 188 function runUndoRedoTest()
michael@0 189 {
michael@0 190 textarea.value = "";
michael@0 191 textarea.focus();
michael@0 192
michael@0 193 // start composition
michael@0 194 synthesizeComposition({ type: "compositionstart" });
michael@0 195
michael@0 196 // input raw characters
michael@0 197 synthesizeComposition({ type: "compositionupdate", data: "\u306D" });
michael@0 198 synthesizeText(
michael@0 199 { "composition":
michael@0 200 { "string": "\u306D",
michael@0 201 "clauses":
michael@0 202 [
michael@0 203 { "length": 1, "attr": COMPOSITION_ATTR_RAWINPUT }
michael@0 204 ]
michael@0 205 },
michael@0 206 "caret": { "start": 1, "length": 0 }
michael@0 207 });
michael@0 208
michael@0 209 synthesizeComposition({ type: "compositionupdate", data: "\u306D\u3053" });
michael@0 210 synthesizeText(
michael@0 211 { "composition":
michael@0 212 { "string": "\u306D\u3053",
michael@0 213 "clauses":
michael@0 214 [
michael@0 215 { "length": 2, "attr": COMPOSITION_ATTR_RAWINPUT }
michael@0 216 ]
michael@0 217 },
michael@0 218 "caret": { "start": 2, "length": 0 }
michael@0 219 });
michael@0 220
michael@0 221 // convert
michael@0 222 synthesizeComposition({ type: "compositionupdate", data: "\u732B" });
michael@0 223 synthesizeText(
michael@0 224 { "composition":
michael@0 225 { "string": "\u732B",
michael@0 226 "clauses":
michael@0 227 [
michael@0 228 { "length": 1,
michael@0 229 "attr": COMPOSITION_ATTR_SELECTEDCONVERTEDTEXT }
michael@0 230 ]
michael@0 231 },
michael@0 232 "caret": { "start": 1, "length": 0 }
michael@0 233 });
michael@0 234
michael@0 235 // commit
michael@0 236 synthesizeText(
michael@0 237 { "composition":
michael@0 238 { "string": "\u732B",
michael@0 239 "clauses":
michael@0 240 [
michael@0 241 { "length": 0, "attr": 0 }
michael@0 242 ]
michael@0 243 },
michael@0 244 "caret": { "start": 1, "length": 0 }
michael@0 245 });
michael@0 246
michael@0 247 // end composition
michael@0 248 synthesizeComposition({ type: "compositionend", data: "\u732B" });
michael@0 249
michael@0 250 // start composition
michael@0 251 synthesizeComposition({ type: "compositionstart" });
michael@0 252
michael@0 253 // input raw characters
michael@0 254 synthesizeComposition({ type: "compositionupdate", data: "\u307E" });
michael@0 255 synthesizeText(
michael@0 256 { "composition":
michael@0 257 { "string": "\u307E",
michael@0 258 "clauses":
michael@0 259 [
michael@0 260 { "length": 1, "attr": COMPOSITION_ATTR_RAWINPUT }
michael@0 261 ]
michael@0 262 },
michael@0 263 "caret": { "start": 1, "length": 0 }
michael@0 264 });
michael@0 265
michael@0 266 // cancel the composition
michael@0 267 synthesizeComposition({ type: "compositionupdate", data: "" });
michael@0 268 synthesizeText(
michael@0 269 { "composition":
michael@0 270 { "string": "",
michael@0 271 "clauses":
michael@0 272 [
michael@0 273 { "length": 0, "attr": 0 }
michael@0 274 ]
michael@0 275 },
michael@0 276 "caret": { "start": 0, "length": 0 }
michael@0 277 });
michael@0 278
michael@0 279 // end composition
michael@0 280 synthesizeComposition({ type: "compositionend", data: "" });
michael@0 281
michael@0 282 // start composition
michael@0 283 synthesizeComposition({ type: "compositionstart" });
michael@0 284
michael@0 285 // input raw characters
michael@0 286 synthesizeComposition({ type: "compositionupdate", data: "\u3080" });
michael@0 287 synthesizeText(
michael@0 288 { "composition":
michael@0 289 { "string": "\u3080",
michael@0 290 "clauses":
michael@0 291 [
michael@0 292 { "length": 1, "attr": COMPOSITION_ATTR_RAWINPUT }
michael@0 293 ]
michael@0 294 },
michael@0 295 "caret": { "start": 1, "length": 0 }
michael@0 296 });
michael@0 297
michael@0 298 synthesizeComposition({ type: "compositionupdate", data: "\u3080\u3059" });
michael@0 299 synthesizeText(
michael@0 300 { "composition":
michael@0 301 { "string": "\u3080\u3059",
michael@0 302 "clauses":
michael@0 303 [
michael@0 304 { "length": 2, "attr": COMPOSITION_ATTR_RAWINPUT }
michael@0 305 ]
michael@0 306 },
michael@0 307 "caret": { "start": 2, "length": 0 }
michael@0 308 });
michael@0 309
michael@0 310 synthesizeComposition({ type: "compositionupdate",
michael@0 311 data: "\u3080\u3059\u3081" });
michael@0 312 synthesizeText(
michael@0 313 { "composition":
michael@0 314 { "string": "\u3080\u3059\u3081",
michael@0 315 "clauses":
michael@0 316 [
michael@0 317 { "length": 3, "attr": COMPOSITION_ATTR_RAWINPUT }
michael@0 318 ]
michael@0 319 },
michael@0 320 "caret": { "start": 3, "length": 0 }
michael@0 321 });
michael@0 322
michael@0 323 // convert
michael@0 324 synthesizeComposition({ type: "compositionupdate", data: "\u5A18" });
michael@0 325 synthesizeText(
michael@0 326 { "composition":
michael@0 327 { "string": "\u5A18",
michael@0 328 "clauses":
michael@0 329 [
michael@0 330 { "length": 1,
michael@0 331 "attr": COMPOSITION_ATTR_SELECTEDCONVERTEDTEXT }
michael@0 332 ]
michael@0 333 },
michael@0 334 "caret": { "start": 1, "length": 0 }
michael@0 335 });
michael@0 336
michael@0 337 // commit
michael@0 338 synthesizeText(
michael@0 339 { "composition":
michael@0 340 { "string": "\u5A18",
michael@0 341 "clauses":
michael@0 342 [
michael@0 343 { "length": 0, "attr": 0 }
michael@0 344 ]
michael@0 345 },
michael@0 346 "caret": { "start": 1, "length": 0 }
michael@0 347 });
michael@0 348
michael@0 349 // end composition
michael@0 350 synthesizeComposition({ type: "compositionend", data: "\u5A18" });
michael@0 351
michael@0 352 synthesizeKey(" ", {});
michael@0 353 synthesizeKey("m", {});
michael@0 354 synthesizeKey("e", {});
michael@0 355 synthesizeKey("a", {});
michael@0 356 synthesizeKey("n", {});
michael@0 357 synthesizeKey("t", {});
michael@0 358 synthesizeKey("VK_BACK_SPACE", {});
michael@0 359 synthesizeKey("s", {});
michael@0 360 synthesizeKey(" ", {});
michael@0 361 synthesizeKey("\"", {});
michael@0 362 synthesizeKey("c", {});
michael@0 363 synthesizeKey("a", {});
michael@0 364 synthesizeKey("t", {});
michael@0 365 synthesizeKey("-", {});
michael@0 366 synthesizeKey("g", {});
michael@0 367 synthesizeKey("i", {});
michael@0 368 synthesizeKey("r", {});
michael@0 369 synthesizeKey("l", {});
michael@0 370 synthesizeKey("\"", {});
michael@0 371 synthesizeKey(".", {});
michael@0 372 synthesizeKey(" ", {});
michael@0 373 synthesizeKey("VK_SHIFT", { type: "keydown" });
michael@0 374 synthesizeKey("S", { shiftKey: true });
michael@0 375 synthesizeKey("VK_SHIFT", { type: "keyup" });
michael@0 376 synthesizeKey("h", {});
michael@0 377 synthesizeKey("e", {});
michael@0 378 synthesizeKey(" ", {});
michael@0 379 synthesizeKey("i", {});
michael@0 380 synthesizeKey("s", {});
michael@0 381 synthesizeKey(" ", {});
michael@0 382 synthesizeKey("a", {});
michael@0 383 synthesizeKey(" ", {});
michael@0 384
michael@0 385 // start composition
michael@0 386 synthesizeComposition({ type: "compositionstart" });
michael@0 387
michael@0 388 // input raw characters
michael@0 389 synthesizeComposition({ type: "compositionupdate", data: "\u3088" });
michael@0 390 synthesizeText(
michael@0 391 { "composition":
michael@0 392 { "string": "\u3088",
michael@0 393 "clauses":
michael@0 394 [
michael@0 395 { "length": 1, "attr": COMPOSITION_ATTR_RAWINPUT }
michael@0 396 ]
michael@0 397 },
michael@0 398 "caret": { "start": 1, "length": 0 }
michael@0 399 });
michael@0 400
michael@0 401 synthesizeComposition({ type: "compositionupdate", data: "\u3088\u3046" });
michael@0 402 synthesizeText(
michael@0 403 { "composition":
michael@0 404 { "string": "\u3088\u3046",
michael@0 405 "clauses":
michael@0 406 [
michael@0 407 { "length": 2, "attr": COMPOSITION_ATTR_RAWINPUT }
michael@0 408 ]
michael@0 409 },
michael@0 410 "caret": { "start": 2, "length": 0 }
michael@0 411 });
michael@0 412
michael@0 413 synthesizeComposition({ type: "compositionupdate",
michael@0 414 data: "\u3088\u3046\u304b" });
michael@0 415 synthesizeText(
michael@0 416 { "composition":
michael@0 417 { "string": "\u3088\u3046\u304b",
michael@0 418 "clauses":
michael@0 419 [
michael@0 420 { "length": 3, "attr": COMPOSITION_ATTR_RAWINPUT }
michael@0 421 ]
michael@0 422 },
michael@0 423 "caret": { "start": 3, "length": 0 }
michael@0 424 });
michael@0 425
michael@0 426 synthesizeComposition({ type: "compositionupdate",
michael@0 427 data: "\u3088\u3046\u304b\u3044" });
michael@0 428 synthesizeText(
michael@0 429 { "composition":
michael@0 430 { "string": "\u3088\u3046\u304b\u3044",
michael@0 431 "clauses":
michael@0 432 [
michael@0 433 { "length": 4, "attr": COMPOSITION_ATTR_RAWINPUT }
michael@0 434 ]
michael@0 435 },
michael@0 436 "caret": { "start": 4, "length": 0 }
michael@0 437 });
michael@0 438
michael@0 439 // convert
michael@0 440 synthesizeComposition({ type: "compositionupdate", data: "\u5996\u602a" });
michael@0 441 synthesizeText(
michael@0 442 { "composition":
michael@0 443 { "string": "\u5996\u602a",
michael@0 444 "clauses":
michael@0 445 [
michael@0 446 { "length": 2, "attr": COMPOSITION_ATTR_SELECTEDCONVERTEDTEXT }
michael@0 447 ]
michael@0 448 },
michael@0 449 "caret": { "start": 2, "length": 0 }
michael@0 450 });
michael@0 451
michael@0 452 // commit
michael@0 453 synthesizeText(
michael@0 454 { "composition":
michael@0 455 { "string": "\u5996\u602a",
michael@0 456 "clauses":
michael@0 457 [
michael@0 458 { "length": 0, "attr": 0 }
michael@0 459 ]
michael@0 460 },
michael@0 461 "caret": { "start": 2, "length": 0 }
michael@0 462 });
michael@0 463
michael@0 464 // end composition
michael@0 465 synthesizeComposition({ type: "compositionend", data: "\u5996\u602a" });
michael@0 466
michael@0 467 synthesizeKey("VK_BACK_SPACE", {});
michael@0 468 synthesizeKey("VK_BACK_SPACE", {});
michael@0 469 synthesizeKey("VK_BACK_SPACE", {});
michael@0 470 synthesizeKey("VK_BACK_SPACE", {});
michael@0 471 synthesizeKey("VK_BACK_SPACE", {});
michael@0 472 synthesizeKey("VK_BACK_SPACE", {});
michael@0 473 synthesizeKey("VK_BACK_SPACE", {});
michael@0 474 synthesizeKey("VK_BACK_SPACE", {});
michael@0 475 synthesizeKey("VK_BACK_SPACE", {});
michael@0 476 synthesizeKey("VK_BACK_SPACE", {});
michael@0 477 synthesizeKey("VK_BACK_SPACE", {});
michael@0 478 synthesizeKey("VK_BACK_SPACE", {});
michael@0 479
michael@0 480 var i = 0;
michael@0 481 if (!checkContent("\u732B\u5A18 means \"cat-girl\".",
michael@0 482 "runUndoRedoTest", "#" + ++i) ||
michael@0 483 !checkSelection(20, "", "runUndoRedoTest", "#" + i)) {
michael@0 484 return;
michael@0 485 }
michael@0 486
michael@0 487 synthesizeKey("Z", {accelKey: true});
michael@0 488
michael@0 489 if (!checkContent("\u732B\u5A18 means \"cat-girl\". She is a \u5996\u602A",
michael@0 490 "runUndoRedoTest", "#" + ++i) ||
michael@0 491 !checkSelection(32, "", "runUndoRedoTest", "#" + i)) {
michael@0 492 return;
michael@0 493 }
michael@0 494
michael@0 495 synthesizeKey("Z", {accelKey: true});
michael@0 496
michael@0 497 if (!checkContent("\u732B\u5A18 means \"cat-girl\". She is a ",
michael@0 498 "runUndoRedoTest", "#" + ++i) ||
michael@0 499 !checkSelection(30, "", "runUndoRedoTest", "#" + i)) {
michael@0 500 return;
michael@0 501 }
michael@0 502
michael@0 503 synthesizeKey("Z", {accelKey: true});
michael@0 504
michael@0 505 if (!checkContent("\u732B\u5A18 mean",
michael@0 506 "runUndoRedoTest", "#" + ++i) ||
michael@0 507 !checkSelection(7, "", "runUndoRedoTest", "#" + i)) {
michael@0 508 return;
michael@0 509 }
michael@0 510
michael@0 511 synthesizeKey("Z", {accelKey: true});
michael@0 512
michael@0 513 if (!checkContent("\u732B\u5A18 meant",
michael@0 514 "runUndoRedoTest", "#" + ++i) ||
michael@0 515 !checkSelection(8, "", "runUndoRedoTest", "#" + i)) {
michael@0 516 return;
michael@0 517 }
michael@0 518
michael@0 519 synthesizeKey("Z", {accelKey: true});
michael@0 520
michael@0 521 if (!checkContent("\u732B\u5A18",
michael@0 522 "runUndoRedoTest", "#" + ++i) ||
michael@0 523 !checkSelection(2, "", "runUndoRedoTest", "#" + i)) {
michael@0 524 return;
michael@0 525 }
michael@0 526
michael@0 527 synthesizeKey("Z", {accelKey: true});
michael@0 528
michael@0 529 if (!checkContent("\u732B",
michael@0 530 "runUndoRedoTest", "#" + ++i) ||
michael@0 531 !checkSelection(1, "", "runUndoRedoTest", "#" + i)) {
michael@0 532 return;
michael@0 533 }
michael@0 534
michael@0 535 synthesizeKey("Z", {accelKey: true});
michael@0 536
michael@0 537 // XXX this is unexpected behavior, see bug 258291
michael@0 538 if (!checkContent("\u732B",
michael@0 539 "runUndoRedoTest", "#" + ++i) ||
michael@0 540 !checkSelection(1, "", "runUndoRedoTest", "#" + i)) {
michael@0 541 return;
michael@0 542 }
michael@0 543
michael@0 544 synthesizeKey("Z", {accelKey: true});
michael@0 545
michael@0 546 if (!checkContent("",
michael@0 547 "runUndoRedoTest", "#" + ++i) ||
michael@0 548 !checkSelection(0, "", "runUndoRedoTest", "#" + i)) {
michael@0 549 return;
michael@0 550 }
michael@0 551
michael@0 552 synthesizeKey("Z", {accelKey: true});
michael@0 553
michael@0 554 if (!checkContent("",
michael@0 555 "runUndoRedoTest", "#" + ++i) ||
michael@0 556 !checkSelection(0, "", "runUndoRedoTest", "#" + i)) {
michael@0 557 return;
michael@0 558 }
michael@0 559
michael@0 560 synthesizeKey("Z", {accelKey: true, shiftKey: true});
michael@0 561
michael@0 562 if (!checkContent("\u732B",
michael@0 563 "runUndoRedoTest", "#" + ++i) ||
michael@0 564 !checkSelection(1, "", "runUndoRedoTest", "#" + i)) {
michael@0 565 return;
michael@0 566 }
michael@0 567
michael@0 568 synthesizeKey("Z", {accelKey: true, shiftKey: true});
michael@0 569
michael@0 570 // XXX this is unexpected behavior, see bug 258291
michael@0 571 if (!checkContent("\u732B",
michael@0 572 "runUndoRedoTest", "#" + ++i) ||
michael@0 573 !checkSelection(1, "", "runUndoRedoTest", "#" + i)) {
michael@0 574 return;
michael@0 575 }
michael@0 576
michael@0 577 synthesizeKey("Z", {accelKey: true, shiftKey: true});
michael@0 578
michael@0 579 if (!checkContent("\u732B\u5A18",
michael@0 580 "runUndoRedoTest", "#" + ++i) ||
michael@0 581 !checkSelection(2, "", "runUndoRedoTest", "#" + i)) {
michael@0 582 return;
michael@0 583 }
michael@0 584
michael@0 585 synthesizeKey("Z", {accelKey: true, shiftKey: true});
michael@0 586
michael@0 587 if (!checkContent("\u732B\u5A18 meant",
michael@0 588 "runUndoRedoTest", "#" + ++i) ||
michael@0 589 !checkSelection(8, "", "runUndoRedoTest", "#" + i)) {
michael@0 590 return;
michael@0 591 }
michael@0 592
michael@0 593 synthesizeKey("Z", {accelKey: true, shiftKey: true});
michael@0 594
michael@0 595 if (!checkContent("\u732B\u5A18 mean",
michael@0 596 "runUndoRedoTest", "#" + ++i) ||
michael@0 597 !checkSelection(7, "", "runUndoRedoTest", "#" + i)) {
michael@0 598 return;
michael@0 599 }
michael@0 600
michael@0 601 synthesizeKey("Z", {accelKey: true, shiftKey: true});
michael@0 602
michael@0 603 if (!checkContent("\u732B\u5A18 means \"cat-girl\". She is a ",
michael@0 604 "runUndoRedoTest", "#" + ++i) ||
michael@0 605 !checkSelection(30, "", "runUndoRedoTest", "#" + i)) {
michael@0 606 return;
michael@0 607 }
michael@0 608
michael@0 609 synthesizeKey("Z", {accelKey: true, shiftKey: true});
michael@0 610
michael@0 611 if (!checkContent("\u732B\u5A18 means \"cat-girl\". She is a \u5996\u602A",
michael@0 612 "runUndoRedoTest", "#" + ++i) ||
michael@0 613 !checkSelection(32, "", "runUndoRedoTest", "#" + i)) {
michael@0 614 return;
michael@0 615 }
michael@0 616
michael@0 617 synthesizeKey("Z", {accelKey: true, shiftKey: true});
michael@0 618
michael@0 619 if (!checkContent("\u732B\u5A18 means \"cat-girl\".",
michael@0 620 "runUndoRedoTest", "#" + ++i) ||
michael@0 621 !checkSelection(20, "", "runUndoRedoTest", "#" + i)) {
michael@0 622 return;
michael@0 623 }
michael@0 624
michael@0 625 synthesizeKey("Z", {accelKey: true, shiftKey: true});
michael@0 626
michael@0 627 if (!checkContent("\u732B\u5A18 means \"cat-girl\".",
michael@0 628 "runUndoRedoTest", "#" + ++i) ||
michael@0 629 !checkSelection(20, "", "runUndoRedoTest", "#" + i)) {
michael@0 630 return;
michael@0 631 }
michael@0 632 }
michael@0 633
michael@0 634 function runCompositionTest()
michael@0 635 {
michael@0 636 textarea.value = "";
michael@0 637 textarea.focus();
michael@0 638 var caretRects = [];
michael@0 639
michael@0 640 var caretRect = synthesizeQueryCaretRect(0);
michael@0 641 if (!checkQueryContentResult(caretRect,
michael@0 642 "runCompositionTest: synthesizeQueryCaretRect #0")) {
michael@0 643 return false;
michael@0 644 }
michael@0 645 caretRects[0] = caretRect;
michael@0 646
michael@0 647 // start composition
michael@0 648 synthesizeComposition({ type: "compositionstart" });
michael@0 649
michael@0 650 // input first character
michael@0 651 synthesizeComposition({ type: "compositionupdate", data: "\u3089" });
michael@0 652 synthesizeText(
michael@0 653 { "composition":
michael@0 654 { "string": "\u3089",
michael@0 655 "clauses":
michael@0 656 [
michael@0 657 { "length": 1, "attr": COMPOSITION_ATTR_RAWINPUT }
michael@0 658 ]
michael@0 659 },
michael@0 660 "caret": { "start": 1, "length": 0 }
michael@0 661 });
michael@0 662
michael@0 663 if (!checkContent("\u3089", "runCompositionTest", "#1-1") ||
michael@0 664 !checkSelection(1, "", "runCompositionTest", "#1-1")) {
michael@0 665 return;
michael@0 666 }
michael@0 667
michael@0 668 caretRect = synthesizeQueryCaretRect(1);
michael@0 669 if (!checkQueryContentResult(caretRect,
michael@0 670 "runCompositionTest: synthesizeQueryCaretRect #1-1")) {
michael@0 671 return false;
michael@0 672 }
michael@0 673 caretRects[1] = caretRect;
michael@0 674
michael@0 675 // input second character
michael@0 676 synthesizeComposition({ type: "compositionupdate", data: "\u3089\u30FC" });
michael@0 677 synthesizeText(
michael@0 678 { "composition":
michael@0 679 { "string": "\u3089\u30FC",
michael@0 680 "clauses":
michael@0 681 [
michael@0 682 { "length": 2, "attr": COMPOSITION_ATTR_RAWINPUT }
michael@0 683 ]
michael@0 684 },
michael@0 685 "caret": { "start": 2, "length": 0 }
michael@0 686 });
michael@0 687
michael@0 688 if (!checkContent("\u3089\u30FC", "runCompositionTest", "#1-2") ||
michael@0 689 !checkSelection(2, "", "runCompositionTest", "#1-2")) {
michael@0 690 return;
michael@0 691 }
michael@0 692
michael@0 693 caretRect = synthesizeQueryCaretRect(2);
michael@0 694 if (!checkQueryContentResult(caretRect,
michael@0 695 "runCompositionTest: synthesizeQueryCaretRect #1-2")) {
michael@0 696 return false;
michael@0 697 }
michael@0 698 caretRects[2] = caretRect;
michael@0 699
michael@0 700 isnot(caretRects[2].left, caretRects[1].left,
michael@0 701 "runCompositionTest: caret isn't moved (#1-2)");
michael@0 702 is(caretRects[2].top, caretRects[1].top,
michael@0 703 "runCompositionTest: caret is moved to another line (#1-2)");
michael@0 704 is(caretRects[2].width, caretRects[1].width,
michael@0 705 "runCompositionTest: caret width is wrong (#1-2)");
michael@0 706 is(caretRects[2].height, caretRects[1].height,
michael@0 707 "runCompositionTest: caret width is wrong (#1-2)");
michael@0 708
michael@0 709 // input third character
michael@0 710 synthesizeComposition({ type: "compositionupdate",
michael@0 711 data: "\u3089\u30FC\u3081" });
michael@0 712 synthesizeText(
michael@0 713 { "composition":
michael@0 714 { "string": "\u3089\u30FC\u3081",
michael@0 715 "clauses":
michael@0 716 [
michael@0 717 { "length": 3, "attr": COMPOSITION_ATTR_RAWINPUT }
michael@0 718 ]
michael@0 719 },
michael@0 720 "caret": { "start": 3, "length": 0 }
michael@0 721 });
michael@0 722
michael@0 723 if (!checkContent("\u3089\u30FC\u3081", "runCompositionTest", "#1-3") ||
michael@0 724 !checkSelection(3, "", "runCompositionTest", "#1-3")) {
michael@0 725 return;
michael@0 726 }
michael@0 727
michael@0 728 caretRect = synthesizeQueryCaretRect(3);
michael@0 729 if (!checkQueryContentResult(caretRect,
michael@0 730 "runCompositionTest: synthesizeQueryCaretRect #1-3")) {
michael@0 731 return false;
michael@0 732 }
michael@0 733 caretRects[3] = caretRect;
michael@0 734
michael@0 735 isnot(caretRects[3].left, caretRects[2].left,
michael@0 736 "runCompositionTest: caret isn't moved (#1-3)");
michael@0 737 is(caretRects[3].top, caretRects[2].top,
michael@0 738 "runCompositionTest: caret is moved to another line (#1-3)");
michael@0 739 is(caretRects[3].width, caretRects[2].width,
michael@0 740 "runCompositionTest: caret width is wrong (#1-3)");
michael@0 741 is(caretRects[3].height, caretRects[2].height,
michael@0 742 "runCompositionTest: caret height is wrong (#1-3)");
michael@0 743
michael@0 744 // moves the caret left
michael@0 745 synthesizeText(
michael@0 746 { "composition":
michael@0 747 { "string": "\u3089\u30FC\u3081",
michael@0 748 "clauses":
michael@0 749 [
michael@0 750 { "length": 3, "attr": COMPOSITION_ATTR_RAWINPUT }
michael@0 751 ]
michael@0 752 },
michael@0 753 "caret": { "start": 2, "length": 0 }
michael@0 754 });
michael@0 755
michael@0 756 if (!checkContent("\u3089\u30FC\u3081", "runCompositionTest", "#1-3-1") ||
michael@0 757 !checkSelection(2, "", "runCompositionTest", "#1-3-1")) {
michael@0 758 return;
michael@0 759 }
michael@0 760
michael@0 761
michael@0 762 caretRect = synthesizeQueryCaretRect(2);
michael@0 763 if (!checkQueryContentResult(caretRect,
michael@0 764 "runCompositionTest: synthesizeQueryCaretRect #1-3-1")) {
michael@0 765 return false;
michael@0 766 }
michael@0 767
michael@0 768 is(caretRect.left, caretRects[2].left,
michael@0 769 "runCompositionTest: caret rects are different (#1-3-1, left)");
michael@0 770 is(caretRect.top, caretRects[2].top,
michael@0 771 "runCompositionTest: caret rects are different (#1-3-1, top)");
michael@0 772 // by bug 335359, the caret width depends on the right side's character.
michael@0 773 is(caretRect.width, caretRects[2].width + 1,
michael@0 774 "runCompositionTest: caret rects are different (#1-3-1, width)");
michael@0 775 is(caretRect.height, caretRects[2].height,
michael@0 776 "runCompositionTest: caret rects are different (#1-3-1, height)");
michael@0 777
michael@0 778 // moves the caret left
michael@0 779 synthesizeText(
michael@0 780 { "composition":
michael@0 781 { "string": "\u3089\u30FC\u3081",
michael@0 782 "clauses":
michael@0 783 [
michael@0 784 { "length": 3, "attr": COMPOSITION_ATTR_RAWINPUT }
michael@0 785 ]
michael@0 786 },
michael@0 787 "caret": { "start": 1, "length": 0 }
michael@0 788 });
michael@0 789
michael@0 790 if (!checkContent("\u3089\u30FC\u3081", "runCompositionTest", "#1-3-2") ||
michael@0 791 !checkSelection(1, "", "runCompositionTest", "#1-3-2")) {
michael@0 792 return;
michael@0 793 }
michael@0 794
michael@0 795
michael@0 796 caretRect = synthesizeQueryCaretRect(1);
michael@0 797 if (!checkQueryContentResult(caretRect,
michael@0 798 "runCompositionTest: synthesizeQueryCaretRect #1-3-2")) {
michael@0 799 return false;
michael@0 800 }
michael@0 801
michael@0 802 is(caretRect.left, caretRects[1].left,
michael@0 803 "runCompositionTest: caret rects are different (#1-3-2, left)");
michael@0 804 is(caretRect.top, caretRects[1].top,
michael@0 805 "runCompositionTest: caret rects are different (#1-3-2, top)");
michael@0 806 // by bug 335359, the caret width depends on the right side's character.
michael@0 807 is(caretRect.width, caretRects[1].width + 1,
michael@0 808 "runCompositionTest: caret rects are different (#1-3-2, width)");
michael@0 809 is(caretRect.height, caretRects[1].height,
michael@0 810 "runCompositionTest: caret rects are different (#1-3-2, height)");
michael@0 811
michael@0 812 synthesizeComposition({ type: "compositionupdate",
michael@0 813 data: "\u3089\u30FC\u3081\u3093" });
michael@0 814 synthesizeText(
michael@0 815 { "composition":
michael@0 816 { "string": "\u3089\u30FC\u3081\u3093",
michael@0 817 "clauses":
michael@0 818 [
michael@0 819 { "length": 4, "attr": COMPOSITION_ATTR_RAWINPUT }
michael@0 820 ]
michael@0 821 },
michael@0 822 "caret": { "start": 4, "length": 0 }
michael@0 823 });
michael@0 824
michael@0 825 if (!checkContent("\u3089\u30FC\u3081\u3093", "runCompositionTest", "#1-4") ||
michael@0 826 !checkSelection(4, "", "runCompositionTest", "#1-4")) {
michael@0 827 return;
michael@0 828 }
michael@0 829
michael@0 830
michael@0 831 // backspace
michael@0 832 synthesizeComposition({ type: "compositionupdate",
michael@0 833 data: "\u3089\u30FC\u3081" });
michael@0 834 synthesizeText(
michael@0 835 { "composition":
michael@0 836 { "string": "\u3089\u30FC\u3081",
michael@0 837 "clauses":
michael@0 838 [
michael@0 839 { "length": 3, "attr": COMPOSITION_ATTR_RAWINPUT }
michael@0 840 ]
michael@0 841 },
michael@0 842 "caret": { "start": 3, "length": 0 }
michael@0 843 });
michael@0 844
michael@0 845 if (!checkContent("\u3089\u30FC\u3081", "runCompositionTest", "#1-5") ||
michael@0 846 !checkSelection(3, "", "runCompositionTest", "#1-5")) {
michael@0 847 return;
michael@0 848 }
michael@0 849
michael@0 850 // re-input
michael@0 851 synthesizeComposition({ type: "compositionupdate",
michael@0 852 data: "\u3089\u30FC\u3081\u3093" });
michael@0 853 synthesizeText(
michael@0 854 { "composition":
michael@0 855 { "string": "\u3089\u30FC\u3081\u3093",
michael@0 856 "clauses":
michael@0 857 [
michael@0 858 { "length": 4, "attr": COMPOSITION_ATTR_RAWINPUT }
michael@0 859 ]
michael@0 860 },
michael@0 861 "caret": { "start": 4, "length": 0 }
michael@0 862 });
michael@0 863
michael@0 864 if (!checkContent("\u3089\u30FC\u3081\u3093", "runCompositionTest", "#1-6") ||
michael@0 865 !checkSelection(4, "", "runCompositionTest", "#1-6")) {
michael@0 866 return;
michael@0 867 }
michael@0 868
michael@0 869 synthesizeComposition({ type: "compositionupdate",
michael@0 870 data: "\u3089\u30FC\u3081\u3093\u3055" });
michael@0 871 synthesizeText(
michael@0 872 { "composition":
michael@0 873 { "string": "\u3089\u30FC\u3081\u3093\u3055",
michael@0 874 "clauses":
michael@0 875 [
michael@0 876 { "length": 5, "attr": COMPOSITION_ATTR_RAWINPUT }
michael@0 877 ]
michael@0 878 },
michael@0 879 "caret": { "start": 5, "length": 0 }
michael@0 880 });
michael@0 881
michael@0 882 if (!checkContent("\u3089\u30FC\u3081\u3093\u3055", "runCompositionTest", "#1-7") ||
michael@0 883 !checkSelection(5, "", "runCompositionTest", "#1-7")) {
michael@0 884 return;
michael@0 885 }
michael@0 886
michael@0 887 synthesizeComposition({ type: "compositionupdate",
michael@0 888 data: "\u3089\u30FC\u3081\u3093\u3055\u3044" });
michael@0 889 synthesizeText(
michael@0 890 { "composition":
michael@0 891 { "string": "\u3089\u30FC\u3081\u3093\u3055\u3044",
michael@0 892 "clauses":
michael@0 893 [
michael@0 894 { "length": 6, "attr": COMPOSITION_ATTR_RAWINPUT }
michael@0 895 ]
michael@0 896 },
michael@0 897 "caret": { "start": 6, "length": 0 }
michael@0 898 });
michael@0 899
michael@0 900 if (!checkContent("\u3089\u30FC\u3081\u3093\u3055\u3044", "runCompositionTest", "#1-8") ||
michael@0 901 !checkSelection(6, "", "runCompositionTest", "#1-8")) {
michael@0 902 return;
michael@0 903 }
michael@0 904
michael@0 905 synthesizeComposition({ type: "compositionupdate",
michael@0 906 data: "\u3089\u30FC\u3081\u3093\u3055\u3044\u3053" });
michael@0 907 synthesizeText(
michael@0 908 { "composition":
michael@0 909 { "string": "\u3089\u30FC\u3081\u3093\u3055\u3044\u3053",
michael@0 910 "clauses":
michael@0 911 [
michael@0 912 { "length": 7, "attr": COMPOSITION_ATTR_RAWINPUT }
michael@0 913 ]
michael@0 914 },
michael@0 915 "caret": { "start": 7, "length": 0 }
michael@0 916 });
michael@0 917
michael@0 918 if (!checkContent("\u3089\u30FC\u3081\u3093\u3055\u3044\u3053", "runCompositionTest", "#1-8") ||
michael@0 919 !checkSelection(7, "", "runCompositionTest", "#1-8")) {
michael@0 920 return;
michael@0 921 }
michael@0 922
michael@0 923 synthesizeComposition({ type: "compositionupdate",
michael@0 924 data: "\u3089\u30FC\u3081\u3093\u3055\u3044\u3053\u3046" });
michael@0 925 synthesizeText(
michael@0 926 { "composition":
michael@0 927 { "string": "\u3089\u30FC\u3081\u3093\u3055\u3044\u3053\u3046",
michael@0 928 "clauses":
michael@0 929 [
michael@0 930 { "length": 8, "attr": COMPOSITION_ATTR_RAWINPUT }
michael@0 931 ]
michael@0 932 },
michael@0 933 "caret": { "start": 8, "length": 0 }
michael@0 934 });
michael@0 935
michael@0 936 if (!checkContent("\u3089\u30FC\u3081\u3093\u3055\u3044\u3053\u3046",
michael@0 937 "runCompositionTest", "#1-9") ||
michael@0 938 !checkSelection(8, "", "runCompositionTest", "#1-9")) {
michael@0 939 return;
michael@0 940 }
michael@0 941
michael@0 942 // convert
michael@0 943 synthesizeComposition({ type: "compositionupdate",
michael@0 944 data: "\u30E9\u30FC\u30E1\u30F3\u6700\u9AD8" });
michael@0 945 synthesizeText(
michael@0 946 { "composition":
michael@0 947 { "string": "\u30E9\u30FC\u30E1\u30F3\u6700\u9AD8",
michael@0 948 "clauses":
michael@0 949 [
michael@0 950 { "length": 4,
michael@0 951 "attr": COMPOSITION_ATTR_SELECTEDCONVERTEDTEXT },
michael@0 952 { "length": 2,
michael@0 953 "attr": COMPOSITION_ATTR_CONVERTEDTEXT }
michael@0 954 ]
michael@0 955 },
michael@0 956 "caret": { "start": 4, "length": 0 }
michael@0 957 });
michael@0 958
michael@0 959 if (!checkContent("\u30E9\u30FC\u30E1\u30F3\u6700\u9AD8",
michael@0 960 "runCompositionTest", "#1-10") ||
michael@0 961 !checkSelection(4, "", "runCompositionTest", "#1-10")) {
michael@0 962 return;
michael@0 963 }
michael@0 964
michael@0 965 // change the selected clause
michael@0 966 synthesizeText(
michael@0 967 { "composition":
michael@0 968 { "string": "\u30E9\u30FC\u30E1\u30F3\u6700\u9AD8",
michael@0 969 "clauses":
michael@0 970 [
michael@0 971 { "length": 4,
michael@0 972 "attr": COMPOSITION_ATTR_CONVERTEDTEXT },
michael@0 973 { "length": 2,
michael@0 974 "attr": COMPOSITION_ATTR_SELECTEDCONVERTEDTEXT }
michael@0 975 ]
michael@0 976 },
michael@0 977 "caret": { "start": 6, "length": 0 }
michael@0 978 });
michael@0 979
michael@0 980 if (!checkContent("\u30E9\u30FC\u30E1\u30F3\u6700\u9AD8",
michael@0 981 "runCompositionTest", "#1-11") ||
michael@0 982 !checkSelection(6, "", "runCompositionTest", "#1-11")) {
michael@0 983 return;
michael@0 984 }
michael@0 985
michael@0 986 // reset clauses
michael@0 987 synthesizeComposition({ type: "compositionupdate",
michael@0 988 data: "\u30E9\u30FC\u30E1\u30F3\u3055\u884C\u3053\u3046" });
michael@0 989 synthesizeText(
michael@0 990 { "composition":
michael@0 991 { "string": "\u30E9\u30FC\u30E1\u30F3\u3055\u884C\u3053\u3046",
michael@0 992 "clauses":
michael@0 993 [
michael@0 994 { "length": 5,
michael@0 995 "attr": COMPOSITION_ATTR_SELECTEDCONVERTEDTEXT },
michael@0 996 { "length": 3,
michael@0 997 "attr": COMPOSITION_ATTR_CONVERTEDTEXT }
michael@0 998 ]
michael@0 999 },
michael@0 1000 "caret": { "start": 5, "length": 0 }
michael@0 1001 });
michael@0 1002
michael@0 1003 if (!checkContent("\u30E9\u30FC\u30E1\u30F3\u3055\u884C\u3053\u3046",
michael@0 1004 "runCompositionTest", "#1-12") ||
michael@0 1005 !checkSelection(5, "", "runCompositionTest", "#1-12")) {
michael@0 1006 return;
michael@0 1007 }
michael@0 1008
michael@0 1009
michael@0 1010 var textRect1 = synthesizeQueryTextRect(0, 1);
michael@0 1011 var textRect2 = synthesizeQueryTextRect(1, 1);
michael@0 1012 if (!checkQueryContentResult(textRect1,
michael@0 1013 "runCompositionTest: synthesizeQueryTextRect #1-12-1") ||
michael@0 1014 !checkQueryContentResult(textRect2,
michael@0 1015 "runCompositionTest: synthesizeQueryTextRect #1-12-2")) {
michael@0 1016 return false;
michael@0 1017 }
michael@0 1018
michael@0 1019 // commit the composition string
michael@0 1020 synthesizeText(
michael@0 1021 { "composition":
michael@0 1022 { "string": "\u30E9\u30FC\u30E1\u30F3\u3055\u884C\u3053\u3046",
michael@0 1023 "clauses":
michael@0 1024 [
michael@0 1025 { "length": 0, "attr": 0 }
michael@0 1026 ]
michael@0 1027 },
michael@0 1028 "caret": { "start": 8, "length": 0 }
michael@0 1029 });
michael@0 1030
michael@0 1031 if (!checkContent("\u30E9\u30FC\u30E1\u30F3\u3055\u884C\u3053\u3046",
michael@0 1032 "runCompositionTest", "#1-13") ||
michael@0 1033 !checkSelection(8, "", "runCompositionTest", "#1-13")) {
michael@0 1034 return;
michael@0 1035 }
michael@0 1036
michael@0 1037 synthesizeComposition({ type: "compositionend",
michael@0 1038 data: "\u30E9\u30FC\u30E1\u30F3\u3055\u884C\u3053\u3046" });
michael@0 1039
michael@0 1040 var textRect3 = synthesizeQueryTextRect(0, 1);
michael@0 1041 var textRect4 = synthesizeQueryTextRect(1, 1);
michael@0 1042
michael@0 1043 if (!checkQueryContentResult(textRect3,
michael@0 1044 "runCompositionTest: synthesizeQueryTextRect #1-13-1") ||
michael@0 1045 !checkQueryContentResult(textRect4,
michael@0 1046 "runCompositionTest: synthesizeQueryTextRect #1-13-2")) {
michael@0 1047 return false;
michael@0 1048 }
michael@0 1049
michael@0 1050 checkRect(textRect3, textRect1, "runCompositionTest: textRect #1-13-1");
michael@0 1051 checkRect(textRect4, textRect2, "runCompositionTest: textRect #1-13-2");
michael@0 1052
michael@0 1053 // restart composition
michael@0 1054 synthesizeComposition({ type: "compositionstart" });
michael@0 1055
michael@0 1056 // input characters
michael@0 1057 synthesizeComposition({ type: "compositionupdate", data: "\u3057" });
michael@0 1058 synthesizeText(
michael@0 1059 { "composition":
michael@0 1060 { "string": "\u3057",
michael@0 1061 "clauses":
michael@0 1062 [
michael@0 1063 { "length": 1, "attr": COMPOSITION_ATTR_RAWINPUT }
michael@0 1064 ]
michael@0 1065 },
michael@0 1066 "caret": { "start": 1, "length": 0 }
michael@0 1067 });
michael@0 1068
michael@0 1069 if (!checkContent("\u30E9\u30FC\u30E1\u30F3\u3055\u884C\u3053\u3046\u3057",
michael@0 1070 "runCompositionTest", "#2-1") ||
michael@0 1071 !checkSelection(8 + 1, "", "runCompositionTest", "#2-1")) {
michael@0 1072 return;
michael@0 1073 }
michael@0 1074
michael@0 1075 synthesizeComposition({ type: "compositionupdate", data: "\u3058" });
michael@0 1076 synthesizeText(
michael@0 1077 { "composition":
michael@0 1078 { "string": "\u3058",
michael@0 1079 "clauses":
michael@0 1080 [
michael@0 1081 { "length": 1, "attr": COMPOSITION_ATTR_RAWINPUT }
michael@0 1082 ]
michael@0 1083 },
michael@0 1084 "caret": { "start": 1, "length": 0 }
michael@0 1085 });
michael@0 1086
michael@0 1087 if (!checkContent("\u30E9\u30FC\u30E1\u30F3\u3055\u884C\u3053\u3046\u3058",
michael@0 1088 "runCompositionTest", "#2-2") ||
michael@0 1089 !checkSelection(8 + 1, "", "runCompositionTest", "#2-2")) {
michael@0 1090 return;
michael@0 1091 }
michael@0 1092
michael@0 1093 synthesizeComposition({ type: "compositionupdate", data: "\u3058\u3087" });
michael@0 1094 synthesizeText(
michael@0 1095 { "composition":
michael@0 1096 { "string": "\u3058\u3087",
michael@0 1097 "clauses":
michael@0 1098 [
michael@0 1099 { "length": 2, "attr": COMPOSITION_ATTR_RAWINPUT }
michael@0 1100 ]
michael@0 1101 },
michael@0 1102 "caret": { "start": 2, "length": 0 }
michael@0 1103 });
michael@0 1104
michael@0 1105 if (!checkContent("\u30E9\u30FC\u30E1\u30F3\u3055\u884C\u3053\u3046\u3058\u3087",
michael@0 1106 "runCompositionTest", "#2-3") ||
michael@0 1107 !checkSelection(8 + 2, "", "runCompositionTest", "#2-3")) {
michael@0 1108 return;
michael@0 1109 }
michael@0 1110
michael@0 1111 synthesizeComposition({ type: "compositionupdate",
michael@0 1112 data: "\u3058\u3087\u3046" });
michael@0 1113 synthesizeText(
michael@0 1114 { "composition":
michael@0 1115 { "string": "\u3058\u3087\u3046",
michael@0 1116 "clauses":
michael@0 1117 [
michael@0 1118 { "length": 3, "attr": COMPOSITION_ATTR_RAWINPUT }
michael@0 1119 ]
michael@0 1120 },
michael@0 1121 "caret": { "start": 3, "length": 0 }
michael@0 1122 });
michael@0 1123
michael@0 1124 if (!checkContent("\u30E9\u30FC\u30E1\u30F3\u3055\u884C\u3053\u3046\u3058\u3087\u3046",
michael@0 1125 "runCompositionTest", "#2-4") ||
michael@0 1126 !checkSelection(8 + 3, "", "runCompositionTest", "#2-4")) {
michael@0 1127 return;
michael@0 1128 }
michael@0 1129
michael@0 1130 // commit the composition string
michael@0 1131 synthesizeText(
michael@0 1132 { "composition":
michael@0 1133 { "string": "\u3058\u3087\u3046",
michael@0 1134 "clauses":
michael@0 1135 [
michael@0 1136 { "length": 0, "attr": 0 }
michael@0 1137 ]
michael@0 1138 },
michael@0 1139 "caret": { "start": 3, "length": 0 }
michael@0 1140 });
michael@0 1141
michael@0 1142 if (!checkContent("\u30E9\u30FC\u30E1\u30F3\u3055\u884C\u3053\u3046\u3058\u3087\u3046",
michael@0 1143 "runCompositionTest", "#2-4") ||
michael@0 1144 !checkSelection(8 + 3, "", "runCompositionTest", "#2-4")) {
michael@0 1145 return;
michael@0 1146 }
michael@0 1147
michael@0 1148 synthesizeComposition({ type: "compositionend", data: "\u3058\u3087\u3046" });
michael@0 1149
michael@0 1150 // set selection
michael@0 1151 var selectionSetTest = synthesizeSelectionSet(4, 7, false);
michael@0 1152 ok(selectionSetTest, "runCompositionTest: selectionSetTest failed");
michael@0 1153
michael@0 1154 if (!checkSelection(4, "\u3055\u884C\u3053\u3046\u3058\u3087\u3046", "runCompositionTest", "#3-1")) {
michael@0 1155 return;
michael@0 1156 }
michael@0 1157
michael@0 1158 // start composition with selection
michael@0 1159 synthesizeComposition({ type: "compositionstart" });
michael@0 1160
michael@0 1161 synthesizeComposition({ type: "compositionupdate", data: "\u304A" });
michael@0 1162 synthesizeText(
michael@0 1163 { "composition":
michael@0 1164 { "string": "\u304A",
michael@0 1165 "clauses":
michael@0 1166 [
michael@0 1167 { "length": 1, "attr": COMPOSITION_ATTR_RAWINPUT }
michael@0 1168 ]
michael@0 1169 },
michael@0 1170 "caret": { "start": 1, "length": 0 }
michael@0 1171 });
michael@0 1172
michael@0 1173 if (!checkContent("\u30E9\u30FC\u30E1\u30F3\u304A",
michael@0 1174 "runCompositionTest", "#3-2") ||
michael@0 1175 !checkSelection(4 + 1, "", "runCompositionTest", "#3-2")) {
michael@0 1176 return;
michael@0 1177 }
michael@0 1178
michael@0 1179 // remove the composition string
michael@0 1180 synthesizeComposition({ type: "compositionupdate", data: "" });
michael@0 1181 synthesizeText(
michael@0 1182 { "composition":
michael@0 1183 { "string": "",
michael@0 1184 "clauses":
michael@0 1185 [
michael@0 1186 { "length": 0, "attr": 0 }
michael@0 1187 ]
michael@0 1188 },
michael@0 1189 "caret": { "start": 0, "length": 0 }
michael@0 1190 });
michael@0 1191
michael@0 1192 if (!checkContent("\u30E9\u30FC\u30E1\u30F3",
michael@0 1193 "runCompositionTest", "#3-3") ||
michael@0 1194 !checkSelection(4, "", "runCompositionTest", "#3-3")) {
michael@0 1195 return;
michael@0 1196 }
michael@0 1197
michael@0 1198 // re-input the composition string
michael@0 1199 synthesizeComposition({ type: "compositionupdate", data: "\u3046" });
michael@0 1200 synthesizeText(
michael@0 1201 { "composition":
michael@0 1202 { "string": "\u3046",
michael@0 1203 "clauses":
michael@0 1204 [
michael@0 1205 { "length": 1, "attr": COMPOSITION_ATTR_RAWINPUT }
michael@0 1206 ]
michael@0 1207 },
michael@0 1208 "caret": { "start": 1, "length": 0 }
michael@0 1209 });
michael@0 1210
michael@0 1211 if (!checkContent("\u30E9\u30FC\u30E1\u30F3\u3046",
michael@0 1212 "runCompositionTest", "#3-4") ||
michael@0 1213 !checkSelection(4 + 1, "", "runCompositionTest", "#3-4")) {
michael@0 1214 return;
michael@0 1215 }
michael@0 1216
michael@0 1217 // cancel the composition
michael@0 1218 synthesizeComposition({ type: "compositionupdate", data: "" });
michael@0 1219 synthesizeText(
michael@0 1220 { "composition":
michael@0 1221 { "string": "",
michael@0 1222 "clauses":
michael@0 1223 [
michael@0 1224 { "length": 0, "attr": 0 }
michael@0 1225 ]
michael@0 1226 },
michael@0 1227 "caret": { "start": 0, "length": 0 }
michael@0 1228 });
michael@0 1229
michael@0 1230 synthesizeComposition({ type: "compositionend", data: "" });
michael@0 1231
michael@0 1232 if (!checkContent("\u30E9\u30FC\u30E1\u30F3",
michael@0 1233 "runCompositionTest", "#3-5") ||
michael@0 1234 !checkSelection(4, "", "runCompositionTest", "#3-5")) {
michael@0 1235 return;
michael@0 1236 }
michael@0 1237
michael@0 1238 // bug 271815, some Chinese IMEs for Linux make empty composition string
michael@0 1239 // and compty clause information when it lists up Chinese characters on
michael@0 1240 // its candidate window.
michael@0 1241 synthesizeComposition({ type: "compositionstart" });
michael@0 1242
michael@0 1243 synthesizeText(
michael@0 1244 { "composition":
michael@0 1245 { "string": "",
michael@0 1246 "clauses":
michael@0 1247 [
michael@0 1248 { "length": 0, "attr": 0 }
michael@0 1249 ]
michael@0 1250 },
michael@0 1251 "caret": { "start": 0, "length": 0 }
michael@0 1252 });
michael@0 1253
michael@0 1254 if (!checkContent("\u30E9\u30FC\u30E1\u30F3",
michael@0 1255 "runCompositionTest", "#4-1") ||
michael@0 1256 !checkSelection(4, "", "runCompositionTest", "#4-1")) {
michael@0 1257 return;
michael@0 1258 }
michael@0 1259
michael@0 1260 synthesizeText(
michael@0 1261 { "composition":
michael@0 1262 { "string": "",
michael@0 1263 "clauses":
michael@0 1264 [
michael@0 1265 { "length": 0, "attr": 0 }
michael@0 1266 ]
michael@0 1267 },
michael@0 1268 "caret": { "start": 0, "length": 0 }
michael@0 1269 });
michael@0 1270
michael@0 1271 if (!checkContent("\u30E9\u30FC\u30E1\u30F3",
michael@0 1272 "runCompositionTest", "#4-2") ||
michael@0 1273 !checkSelection(4, "", "runCompositionTest", "#4-2")) {
michael@0 1274 return;
michael@0 1275 }
michael@0 1276
michael@0 1277 synthesizeComposition({ type: "compositionupdate", data: "\u6700" });
michael@0 1278 synthesizeText(
michael@0 1279 { "composition":
michael@0 1280 { "string": "\u6700",
michael@0 1281 "clauses":
michael@0 1282 [
michael@0 1283 { "length": 0, "attr": 0 }
michael@0 1284 ]
michael@0 1285 },
michael@0 1286 "caret": { "start": 1, "length": 0 }
michael@0 1287 });
michael@0 1288
michael@0 1289 if (!checkContent("\u30E9\u30FC\u30E1\u30F3\u6700",
michael@0 1290 "runCompositionTest", "#4-3") ||
michael@0 1291 !checkSelection(5, "", "runCompositionTest", "#4-3")) {
michael@0 1292 return;
michael@0 1293 }
michael@0 1294
michael@0 1295 synthesizeComposition({ type: "compositionend", data: "\u6700" });
michael@0 1296
michael@0 1297 if (!checkContent("\u30E9\u30FC\u30E1\u30F3\u6700",
michael@0 1298 "runCompositionTest", "#4-4") ||
michael@0 1299 !checkSelection(5, "", "runCompositionTest", "#4-4")) {
michael@0 1300 return;
michael@0 1301 }
michael@0 1302
michael@0 1303 // testing the canceling case
michael@0 1304 synthesizeComposition({ type: "compositionstart" });
michael@0 1305
michael@0 1306 synthesizeText(
michael@0 1307 { "composition":
michael@0 1308 { "string": "",
michael@0 1309 "clauses":
michael@0 1310 [
michael@0 1311 { "length": 0, "attr": 0 }
michael@0 1312 ]
michael@0 1313 },
michael@0 1314 "caret": { "start": 0, "length": 0 }
michael@0 1315 });
michael@0 1316
michael@0 1317 if (!checkContent("\u30E9\u30FC\u30E1\u30F3\u6700",
michael@0 1318 "runCompositionTest", "#4-5") ||
michael@0 1319 !checkSelection(5, "", "runCompositionTest", "#4-5")) {
michael@0 1320 return;
michael@0 1321 }
michael@0 1322
michael@0 1323 synthesizeText(
michael@0 1324 { "composition":
michael@0 1325 { "string": "",
michael@0 1326 "clauses":
michael@0 1327 [
michael@0 1328 { "length": 0, "attr": 0 }
michael@0 1329 ]
michael@0 1330 },
michael@0 1331 "caret": { "start": 0, "length": 0 }
michael@0 1332 });
michael@0 1333
michael@0 1334 if (!checkContent("\u30E9\u30FC\u30E1\u30F3\u6700",
michael@0 1335 "runCompositionTest", "#4-6") ||
michael@0 1336 !checkSelection(5, "", "runCompositionTest", "#4-6")) {
michael@0 1337 return;
michael@0 1338 }
michael@0 1339
michael@0 1340 synthesizeComposition({ type: "compositionend", data: "\u6700" });
michael@0 1341
michael@0 1342 if (!checkContent("\u30E9\u30FC\u30E1\u30F3\u6700",
michael@0 1343 "runCompositionTest", "#4-7") ||
michael@0 1344 !checkSelection(5, "", "runCompositionTest", "#4-7")) {
michael@0 1345 return;
michael@0 1346 }
michael@0 1347
michael@0 1348 // testing whether the empty composition string deletes selected string.
michael@0 1349 synthesizeKey("VK_LEFT", { shiftKey: true });
michael@0 1350
michael@0 1351 synthesizeComposition({ type: "compositionstart" });
michael@0 1352
michael@0 1353 synthesizeText(
michael@0 1354 { "composition":
michael@0 1355 { "string": "",
michael@0 1356 "clauses":
michael@0 1357 [
michael@0 1358 { "length": 0, "attr": 0 }
michael@0 1359 ]
michael@0 1360 },
michael@0 1361 "caret": { "start": 0, "length": 0 }
michael@0 1362 });
michael@0 1363
michael@0 1364 if (!checkContent("\u30E9\u30FC\u30E1\u30F3",
michael@0 1365 "runCompositionTest", "#4-8") ||
michael@0 1366 !checkSelection(4, "", "runCompositionTest", "#4-8")) {
michael@0 1367 return;
michael@0 1368 }
michael@0 1369
michael@0 1370 synthesizeComposition({ type: "compositionupdate", data: "\u9AD8" });
michael@0 1371 synthesizeText(
michael@0 1372 { "composition":
michael@0 1373 { "string": "\u9AD8",
michael@0 1374 "clauses":
michael@0 1375 [
michael@0 1376 { "length": 0, "attr": 0 }
michael@0 1377 ]
michael@0 1378 },
michael@0 1379 "caret": { "start": 1, "length": 0 }
michael@0 1380 });
michael@0 1381
michael@0 1382 if (!checkContent("\u30E9\u30FC\u30E1\u30F3\u9AD8",
michael@0 1383 "runCompositionTest", "#4-9") ||
michael@0 1384 !checkSelection(5, "", "runCompositionTest", "#4-9")) {
michael@0 1385 return;
michael@0 1386 }
michael@0 1387
michael@0 1388 synthesizeComposition({ type: "compositionend", data: "\u9AD8" });
michael@0 1389
michael@0 1390 if (!checkContent("\u30E9\u30FC\u30E1\u30F3\u9AD8",
michael@0 1391 "runCompositionTest", "#4-10") ||
michael@0 1392 !checkSelection(5, "", "runCompositionTest", "#4-10")) {
michael@0 1393 return;
michael@0 1394 }
michael@0 1395
michael@0 1396 synthesizeKey("VK_BACK_SPACE", {});
michael@0 1397 if (!checkContent("\u30E9\u30FC\u30E1\u30F3",
michael@0 1398 "runCompositionTest", "#4-11") ||
michael@0 1399 !checkSelection(4, "", "runCompositionTest", "#4-11")) {
michael@0 1400 return;
michael@0 1401 }
michael@0 1402
michael@0 1403 // bug 23558, ancient Japanese IMEs on Window may send empty text event
michael@0 1404 // twice at canceling composition.
michael@0 1405 synthesizeComposition({ type: "compositionstart" });
michael@0 1406
michael@0 1407 synthesizeComposition({ type: "compositionupdate", data: "\u6700" });
michael@0 1408 synthesizeText(
michael@0 1409 { "composition":
michael@0 1410 { "string": "\u6700",
michael@0 1411 "clauses":
michael@0 1412 [
michael@0 1413 { "length": 1, "attr": COMPOSITION_ATTR_RAWINPUT }
michael@0 1414 ]
michael@0 1415 },
michael@0 1416 "caret": { "start": 1, "length": 0 }
michael@0 1417 });
michael@0 1418
michael@0 1419 if (!checkContent("\u30E9\u30FC\u30E1\u30F3\u6700",
michael@0 1420 "runCompositionTest", "#5-1") ||
michael@0 1421 !checkSelection(4 + 1, "", "runCompositionTest", "#5-1")) {
michael@0 1422 return;
michael@0 1423 }
michael@0 1424
michael@0 1425 synthesizeComposition({ type: "compositionupdate", data: "" });
michael@0 1426 synthesizeText(
michael@0 1427 { "composition":
michael@0 1428 { "string": "",
michael@0 1429 "clauses":
michael@0 1430 [
michael@0 1431 { "length": 0, "attr": 0 }
michael@0 1432 ]
michael@0 1433 },
michael@0 1434 "caret": { "start": 0, "length": 0 }
michael@0 1435 });
michael@0 1436
michael@0 1437 if (!checkContent("\u30E9\u30FC\u30E1\u30F3",
michael@0 1438 "runCompositionTest", "#5-2") ||
michael@0 1439 !checkSelection(4, "", "runCompositionTest", "#5-2")) {
michael@0 1440 return;
michael@0 1441 }
michael@0 1442
michael@0 1443 synthesizeText(
michael@0 1444 { "composition":
michael@0 1445 { "string": "",
michael@0 1446 "clauses":
michael@0 1447 [
michael@0 1448 { "length": 0, "attr": 0 }
michael@0 1449 ]
michael@0 1450 },
michael@0 1451 "caret": { "start": 0, "length": 0 }
michael@0 1452 });
michael@0 1453
michael@0 1454 if (!checkContent("\u30E9\u30FC\u30E1\u30F3",
michael@0 1455 "runCompositionTest", "#5-3") ||
michael@0 1456 !checkSelection(4, "", "runCompositionTest", "#5-3")) {
michael@0 1457 return;
michael@0 1458 }
michael@0 1459
michael@0 1460 synthesizeComposition({ type: "compositionend", data: "\u9AD8" });
michael@0 1461
michael@0 1462 if (!checkContent("\u30E9\u30FC\u30E1\u30F3",
michael@0 1463 "runCompositionTest", "#5-4") ||
michael@0 1464 !checkSelection(4, "", "runCompositionTest", "#5-4")) {
michael@0 1465 return;
michael@0 1466 }
michael@0 1467
michael@0 1468 // Undo tests for the testcases for bug 23558 and bug 271815
michael@0 1469 synthesizeKey("Z", { accelKey: true });
michael@0 1470
michael@0 1471 // XXX this is unexpected behavior, see bug 258291
michael@0 1472 if (!checkContent("\u30E9\u30FC\u30E1\u30F3",
michael@0 1473 "runCompositionTest", "#6-1") ||
michael@0 1474 !checkSelection(4, "", "runCompositionTest", "#6-1")) {
michael@0 1475 return;
michael@0 1476 }
michael@0 1477
michael@0 1478 synthesizeKey("Z", { accelKey: true });
michael@0 1479
michael@0 1480 if (!checkContent("\u30E9\u30FC\u30E1\u30F3\u9AD8",
michael@0 1481 "runCompositionTest", "#6-2") ||
michael@0 1482 !checkSelection(5, "", "runCompositionTest", "#6-2")) {
michael@0 1483 return;
michael@0 1484 }
michael@0 1485
michael@0 1486 synthesizeKey("Z", { accelKey: true });
michael@0 1487
michael@0 1488 if (!checkContent("\u30E9\u30FC\u30E1\u30F3\u6700",
michael@0 1489 "runCompositionTest", "#6-3") ||
michael@0 1490 !checkSelection(4, "\u6700", "runCompositionTest", "#6-3")) {
michael@0 1491 return;
michael@0 1492 }
michael@0 1493
michael@0 1494 synthesizeKey("Z", { accelKey: true });
michael@0 1495
michael@0 1496 // XXX this is unexpected behavior, see bug 258291
michael@0 1497 if (!checkContent("\u30E9\u30FC\u30E1\u30F3\u6700",
michael@0 1498 "runCompositionTest", "#6-4") ||
michael@0 1499 !checkSelection(5, "", "runCompositionTest", "#6-4")) {
michael@0 1500 return;
michael@0 1501 }
michael@0 1502
michael@0 1503 synthesizeKey("Z", { accelKey: true });
michael@0 1504
michael@0 1505 if (!checkContent("\u30E9\u30FC\u30E1\u30F3",
michael@0 1506 "runCompositionTest", "#6-5") ||
michael@0 1507 !checkSelection(4, "", "runCompositionTest", "#6-5")) {
michael@0 1508 return;
michael@0 1509 }
michael@0 1510 }
michael@0 1511
michael@0 1512 function runCompositionEventTest()
michael@0 1513 {
michael@0 1514 const kDescription = "runCompositionEventTest: ";
michael@0 1515 const kEvents = ["compositionstart", "compositionupdate", "compositionend",
michael@0 1516 "input"];
michael@0 1517
michael@0 1518 input.value = "";
michael@0 1519 input.focus();
michael@0 1520
michael@0 1521 var windowEventCounts = [], windowEventData = [], windowEventLocale = [];
michael@0 1522 var inputEventCounts = [], inputEventData = [], inputEventLocale = [];
michael@0 1523 var preventDefault = false;
michael@0 1524 var stopPropagation = false;
michael@0 1525
michael@0 1526 function initResults()
michael@0 1527 {
michael@0 1528 for (var i = 0; i < kEvents.length; i++) {
michael@0 1529 windowEventCounts[kEvents[i]] = 0;
michael@0 1530 windowEventData[kEvents[i]] = "";
michael@0 1531 windowEventLocale[kEvents[i]] = "";
michael@0 1532 inputEventCounts[kEvents[i]] = 0;
michael@0 1533 inputEventData[kEvents[i]] = "";
michael@0 1534 inputEventLocale[kEvents[i]] = "";
michael@0 1535 }
michael@0 1536 }
michael@0 1537
michael@0 1538 function compositionEventHandlerForWindow(aEvent)
michael@0 1539 {
michael@0 1540 windowEventCounts[aEvent.type]++;
michael@0 1541 windowEventData[aEvent.type] = aEvent.data;
michael@0 1542 windowEventLocale[aEvent.type] = aEvent.locale;
michael@0 1543 if (preventDefault) {
michael@0 1544 aEvent.preventDefault();
michael@0 1545 }
michael@0 1546 if (stopPropagation) {
michael@0 1547 aEvent.stopPropagation();
michael@0 1548 }
michael@0 1549 }
michael@0 1550
michael@0 1551 function formEventHandlerForWindow(aEvent)
michael@0 1552 {
michael@0 1553 ok(aEvent.isTrusted, "input events must be trusted events");
michael@0 1554 windowEventCounts[aEvent.type]++;
michael@0 1555 windowEventData[aEvent.type] = input.value;
michael@0 1556 }
michael@0 1557
michael@0 1558 function compositionEventHandlerForInput(aEvent)
michael@0 1559 {
michael@0 1560 inputEventCounts[aEvent.type]++;
michael@0 1561 inputEventData[aEvent.type] = aEvent.data;
michael@0 1562 inputEventLocale[aEvent.type] = aEvent.locale;
michael@0 1563 if (preventDefault) {
michael@0 1564 aEvent.preventDefault();
michael@0 1565 }
michael@0 1566 if (stopPropagation) {
michael@0 1567 aEvent.stopPropagation();
michael@0 1568 }
michael@0 1569 }
michael@0 1570
michael@0 1571 function formEventHandlerForInput(aEvent)
michael@0 1572 {
michael@0 1573 inputEventCounts[aEvent.type]++;
michael@0 1574 inputEventData[aEvent.type] = input.value;
michael@0 1575 }
michael@0 1576
michael@0 1577 window.addEventListener("compositionstart", compositionEventHandlerForWindow,
michael@0 1578 true, true);
michael@0 1579 window.addEventListener("compositionend", compositionEventHandlerForWindow,
michael@0 1580 true, true);
michael@0 1581 window.addEventListener("compositionupdate", compositionEventHandlerForWindow,
michael@0 1582 true, true);
michael@0 1583 window.addEventListener("input", formEventHandlerForWindow,
michael@0 1584 true, true);
michael@0 1585
michael@0 1586 input.addEventListener("compositionstart", compositionEventHandlerForInput,
michael@0 1587 true, true);
michael@0 1588 input.addEventListener("compositionend", compositionEventHandlerForInput,
michael@0 1589 true, true);
michael@0 1590 input.addEventListener("compositionupdate", compositionEventHandlerForInput,
michael@0 1591 true, true);
michael@0 1592 input.addEventListener("input", formEventHandlerForInput,
michael@0 1593 true, true);
michael@0 1594
michael@0 1595 // test for normal case
michael@0 1596 initResults();
michael@0 1597
michael@0 1598 synthesizeComposition({ type: "compositionstart" });
michael@0 1599 synthesizeComposition({ type: "compositionupdate", data: "\u3089" });
michael@0 1600 synthesizeText(
michael@0 1601 { "composition":
michael@0 1602 { "string": "\u3089",
michael@0 1603 "clauses":
michael@0 1604 [
michael@0 1605 { "length": 1, "attr": COMPOSITION_ATTR_RAWINPUT }
michael@0 1606 ]
michael@0 1607 },
michael@0 1608 "caret": { "start": 1, "length": 0 }
michael@0 1609 });
michael@0 1610
michael@0 1611 is(windowEventCounts["compositionstart"], 1,
michael@0 1612 kDescription + "compositionstart hasn't been handled by window #1");
michael@0 1613 is(windowEventData["compositionstart"], "",
michael@0 1614 kDescription + "data of compositionstart isn't empty (window) #1");
michael@0 1615 is(windowEventLocale["compositionstart"], "",
michael@0 1616 kDescription + "locale of compositionstart isn't empty (window) #1");
michael@0 1617 is(inputEventCounts["compositionstart"], 1,
michael@0 1618 kDescription + "compositionstart hasn't been handled by input #1");
michael@0 1619 is(inputEventData["compositionstart"], "",
michael@0 1620 kDescription + "data of compositionstart isn't empty (input) #1");
michael@0 1621 is(inputEventLocale["compositionstart"], "",
michael@0 1622 kDescription + "locale of compositionstart isn't empty (input) #1");
michael@0 1623
michael@0 1624 is(windowEventCounts["compositionupdate"], 1,
michael@0 1625 kDescription + "compositionupdate hasn't been handled by window #1");
michael@0 1626 is(windowEventData["compositionupdate"], "\u3089",
michael@0 1627 kDescription + "data of compositionupdate doesn't match (window) #1");
michael@0 1628 is(windowEventLocale["compositionupdate"], "",
michael@0 1629 kDescription + "locale of compositionupdate isn't empty (window) #1");
michael@0 1630 is(inputEventCounts["compositionupdate"], 1,
michael@0 1631 kDescription + "compositionupdate hasn't been handled by input #1");
michael@0 1632 is(inputEventData["compositionupdate"], "\u3089",
michael@0 1633 kDescription + "data of compositionupdate doesn't match (input) #1");
michael@0 1634 is(inputEventLocale["compositionupdate"], "",
michael@0 1635 kDescription + "locale of compositionupdate isn't empty (input) #1");
michael@0 1636
michael@0 1637 is(windowEventCounts["compositionend"], 0,
michael@0 1638 kDescription + "compositionend has been handled by window #1");
michael@0 1639 is(inputEventCounts["compositionend"], 0,
michael@0 1640 kDescription + "compositionend has been handled by input #1");
michael@0 1641
michael@0 1642 is(windowEventCounts["input"], 1,
michael@0 1643 kDescription + "input hasn't been handled by window #1");
michael@0 1644 is(windowEventData["input"], "\u3089",
michael@0 1645 kDescription + "value of input element wasn't modified (window) #1");
michael@0 1646 is(inputEventCounts["input"], 1,
michael@0 1647 kDescription + "input hasn't been handled by input #1");
michael@0 1648 is(inputEventData["input"], "\u3089",
michael@0 1649 kDescription + "value of input element wasn't modified (input) #1");
michael@0 1650
michael@0 1651 synthesizeComposition({ type: "compositionupdate", data: "\u3089\u30FC" });
michael@0 1652 synthesizeText(
michael@0 1653 { "composition":
michael@0 1654 { "string": "\u3089\u30FC",
michael@0 1655 "clauses":
michael@0 1656 [
michael@0 1657 { "length": 2, "attr": COMPOSITION_ATTR_RAWINPUT }
michael@0 1658 ]
michael@0 1659 },
michael@0 1660 "caret": { "start": 2, "length": 0 }
michael@0 1661 });
michael@0 1662
michael@0 1663 is(windowEventCounts["compositionstart"], 1,
michael@0 1664 kDescription + "compositionstart has been handled more than once by window #2");
michael@0 1665 is(inputEventCounts["compositionstart"], 1,
michael@0 1666 kDescription + "compositionstart has been handled more than once by input #2");
michael@0 1667
michael@0 1668 is(windowEventCounts["compositionupdate"], 2,
michael@0 1669 kDescription + "compositionupdate hasn't been handled by window #2");
michael@0 1670 is(windowEventData["compositionupdate"], "\u3089\u30FC",
michael@0 1671 kDescription + "data of compositionupdate doesn't match (window) #2");
michael@0 1672 is(windowEventLocale["compositionupdate"], "",
michael@0 1673 kDescription + "locale of compositionupdate isn't empty (window) #2");
michael@0 1674 is(inputEventCounts["compositionupdate"], 2,
michael@0 1675 kDescription + "compositionupdate hasn't been handled by input #2");
michael@0 1676 is(inputEventData["compositionupdate"], "\u3089\u30FC",
michael@0 1677 kDescription + "data of compositionupdate doesn't match (input) #2");
michael@0 1678 is(inputEventLocale["compositionupdate"], "",
michael@0 1679 kDescription + "locale of compositionupdate isn't empty (input) #2");
michael@0 1680
michael@0 1681 is(windowEventCounts["compositionend"], 0,
michael@0 1682 kDescription + "compositionend has been handled during composition by window #2");
michael@0 1683 is(inputEventCounts["compositionend"], 0,
michael@0 1684 kDescription + "compositionend has been handled during composition by input #2");
michael@0 1685
michael@0 1686 is(windowEventCounts["input"], 2,
michael@0 1687 kDescription + "input hasn't been handled by window #2");
michael@0 1688 is(windowEventData["input"], "\u3089\u30FC",
michael@0 1689 kDescription + "value of input element wasn't modified (window) #2");
michael@0 1690 is(inputEventCounts["input"], 2,
michael@0 1691 kDescription + "input hasn't been handled by input #2");
michael@0 1692 is(inputEventData["input"], "\u3089\u30FC",
michael@0 1693 kDescription + "value of input element wasn't modified (input) #2");
michael@0 1694
michael@0 1695 // text event shouldn't cause composition update, e.g., at committing.
michael@0 1696 synthesizeText(
michael@0 1697 { "composition":
michael@0 1698 { "string": "\u3089\u30FC",
michael@0 1699 "clauses":
michael@0 1700 [
michael@0 1701 { "length": 0, "attr": 0 }
michael@0 1702 ]
michael@0 1703 },
michael@0 1704 "caret": { "start": 2, "length": 0 }
michael@0 1705 });
michael@0 1706
michael@0 1707 synthesizeComposition({ type: "compositionend", data: "\u3089\u30FC" });
michael@0 1708
michael@0 1709 is(windowEventCounts["compositionstart"], 1,
michael@0 1710 kDescription + "compositionstart has been handled more than once by window #3");
michael@0 1711 is(inputEventCounts["compositionstart"], 1,
michael@0 1712 kDescription + "compositionstart has been handled more than once by input #3");
michael@0 1713
michael@0 1714 is(windowEventCounts["compositionupdate"], 2,
michael@0 1715 kDescription + "compositionupdate has been fired unexpectedly on window #3");
michael@0 1716 is(inputEventCounts["compositionupdate"], 2,
michael@0 1717 kDescription + "compositionupdate has been fired unexpectedly on input #3");
michael@0 1718
michael@0 1719 is(windowEventCounts["compositionend"], 1,
michael@0 1720 kDescription + "compositionend hasn't been handled by window #3");
michael@0 1721 is(windowEventData["compositionend"], "\u3089\u30FC",
michael@0 1722 kDescription + "data of compositionend doesn't match (window) #3");
michael@0 1723 is(windowEventLocale["compositionend"], "",
michael@0 1724 kDescription + "locale of compositionend isn't empty (window) #3");
michael@0 1725 is(inputEventCounts["compositionend"], 1,
michael@0 1726 kDescription + "compositionend hasn't been handled by input #3");
michael@0 1727 is(inputEventData["compositionend"], "\u3089\u30FC",
michael@0 1728 kDescription + "data of compositionend doesn't match (input) #3");
michael@0 1729 is(inputEventLocale["compositionend"], "",
michael@0 1730 kDescription + "locale of compositionend isn't empty (input) #3");
michael@0 1731
michael@0 1732 is(windowEventCounts["input"], 3,
michael@0 1733 kDescription + "input hasn't been handled by window #3");
michael@0 1734 is(windowEventData["input"], "\u3089\u30FC",
michael@0 1735 kDescription + "value of input element wasn't modified (window) #3");
michael@0 1736 is(inputEventCounts["input"], 3,
michael@0 1737 kDescription + "input hasn't been handled by input #3");
michael@0 1738 is(inputEventData["input"], "\u3089\u30FC",
michael@0 1739 kDescription + "value of input element wasn't modified (input) #3");
michael@0 1740
michael@0 1741 // select the second character, then, data of composition start should be
michael@0 1742 // the selected character.
michael@0 1743 initResults();
michael@0 1744 synthesizeKey("VK_LEFT", { shiftKey: true });
michael@0 1745
michael@0 1746 synthesizeComposition({ type: "compositionstart" });
michael@0 1747
michael@0 1748 synthesizeComposition({ type: "compositionupdate", data: "\u3089" });
michael@0 1749 synthesizeText(
michael@0 1750 { "composition":
michael@0 1751 { "string": "\u3089",
michael@0 1752 "clauses":
michael@0 1753 [
michael@0 1754 { "length": 1, "attr": COMPOSITION_ATTR_RAWINPUT }
michael@0 1755 ]
michael@0 1756 },
michael@0 1757 "caret": { "start": 1, "length": 0 }
michael@0 1758 });
michael@0 1759
michael@0 1760 synthesizeText(
michael@0 1761 { "composition":
michael@0 1762 { "string": "\u3089",
michael@0 1763 "clauses":
michael@0 1764 [
michael@0 1765 { "length": 0, "attr": 0 }
michael@0 1766 ]
michael@0 1767 },
michael@0 1768 "caret": { "start": 1, "length": 0 }
michael@0 1769 });
michael@0 1770
michael@0 1771 synthesizeComposition({ type: "compositionend", data: "\u3089" });
michael@0 1772
michael@0 1773 is(windowEventCounts["compositionstart"], 1,
michael@0 1774 kDescription + "compositionstart hasn't been handled by window #4");
michael@0 1775 is(windowEventData["compositionstart"], "\u30FC",
michael@0 1776 kDescription + "data of compositionstart is empty (window) #4");
michael@0 1777 is(windowEventLocale["compositionstart"], "",
michael@0 1778 kDescription + "locale of compositionstart isn't empty (window) #4");
michael@0 1779 is(inputEventCounts["compositionstart"], 1,
michael@0 1780 kDescription + "compositionstart hasn't been handled by input #4");
michael@0 1781 is(inputEventData["compositionstart"], "\u30FC",
michael@0 1782 kDescription + "data of compositionstart is empty (input) #4");
michael@0 1783 is(inputEventLocale["compositionstart"], "",
michael@0 1784 kDescription + "locale of compositionstart isn't empty (input) #4");
michael@0 1785
michael@0 1786 is(windowEventCounts["compositionupdate"], 1,
michael@0 1787 kDescription + "compositionupdate hasn't been handled by window #4");
michael@0 1788 is(windowEventData["compositionupdate"], "\u3089",
michael@0 1789 kDescription + "data of compositionupdate doesn't match (window) #4");
michael@0 1790 is(windowEventLocale["compositionupdate"], "",
michael@0 1791 kDescription + "locale of compositionupdate isn't empty (window) #4");
michael@0 1792 is(inputEventCounts["compositionupdate"], 1,
michael@0 1793 kDescription + "compositionupdate hasn't been handled by input #4");
michael@0 1794 is(inputEventData["compositionupdate"], "\u3089",
michael@0 1795 kDescription + "data of compositionupdate doesn't match (input) #4");
michael@0 1796 is(inputEventLocale["compositionupdate"], "",
michael@0 1797 kDescription + "locale of compositionupdate isn't empty (input) #4");
michael@0 1798
michael@0 1799 is(windowEventCounts["compositionend"], 1,
michael@0 1800 kDescription + "compositionend hasn't been handled by window #4");
michael@0 1801 is(windowEventData["compositionend"], "\u3089",
michael@0 1802 kDescription + "data of compositionend doesn't match (window) #4");
michael@0 1803 is(windowEventLocale["compositionend"], "",
michael@0 1804 kDescription + "locale of compositionend isn't empty (window) #4");
michael@0 1805 is(inputEventCounts["compositionend"], 1,
michael@0 1806 kDescription + "compositionend hasn't been handled by input #4");
michael@0 1807 is(inputEventData["compositionend"], "\u3089",
michael@0 1808 kDescription + "data of compositionend doesn't match (input) #4");
michael@0 1809 is(inputEventLocale["compositionend"], "",
michael@0 1810 kDescription + "locale of compositionend isn't empty (input) #4");
michael@0 1811
michael@0 1812 is(windowEventCounts["input"], 2,
michael@0 1813 kDescription + "input hasn't been handled by window #4");
michael@0 1814 is(windowEventData["input"], "\u3089\u3089",
michael@0 1815 kDescription + "value of input element wasn't modified (window) #4");
michael@0 1816 is(inputEventCounts["input"], 2,
michael@0 1817 kDescription + "input hasn't been handled by input #4");
michael@0 1818 is(inputEventData["input"], "\u3089\u3089",
michael@0 1819 kDescription + "value of input element wasn't modified (input) #4");
michael@0 1820
michael@0 1821 // preventDefault() should effect nothing.
michael@0 1822 preventDefault = true;
michael@0 1823
michael@0 1824 initResults();
michael@0 1825 synthesizeKey("A", { accelKey: true }); // Select All
michael@0 1826
michael@0 1827 synthesizeComposition({ type: "compositionstart" });
michael@0 1828
michael@0 1829 synthesizeComposition({ type: "compositionupdate", data: "\u306D" });
michael@0 1830 synthesizeText(
michael@0 1831 { "composition":
michael@0 1832 { "string": "\u306D",
michael@0 1833 "clauses":
michael@0 1834 [
michael@0 1835 { "length": 1, "attr": COMPOSITION_ATTR_RAWINPUT }
michael@0 1836 ]
michael@0 1837 },
michael@0 1838 "caret": { "start": 1, "length": 0 }
michael@0 1839 });
michael@0 1840
michael@0 1841 synthesizeText(
michael@0 1842 { "composition":
michael@0 1843 { "string": "\u306D",
michael@0 1844 "clauses":
michael@0 1845 [
michael@0 1846 { "length": 0, "attr": 0 }
michael@0 1847 ]
michael@0 1848 },
michael@0 1849 "caret": { "start": 1, "length": 0 }
michael@0 1850 });
michael@0 1851
michael@0 1852 synthesizeComposition({ type: "compositionend", data: "\u306D" });
michael@0 1853
michael@0 1854 is(windowEventCounts["compositionstart"], 1,
michael@0 1855 kDescription + "compositionstart hasn't been handled by window #5");
michael@0 1856 is(windowEventData["compositionstart"], "\u3089\u3089",
michael@0 1857 kDescription + "data of compositionstart is empty (window) #5");
michael@0 1858 is(windowEventLocale["compositionstart"], "",
michael@0 1859 kDescription + "locale of compositionstart isn't empty (window) #5");
michael@0 1860 is(inputEventCounts["compositionstart"], 1,
michael@0 1861 kDescription + "compositionstart hasn't been handled by input #5");
michael@0 1862 is(inputEventData["compositionstart"], "\u3089\u3089",
michael@0 1863 kDescription + "data of compositionstart is empty (input) #5");
michael@0 1864 is(inputEventLocale["compositionstart"], "",
michael@0 1865 kDescription + "locale of compositionstart isn't empty (input) #5");
michael@0 1866
michael@0 1867 is(windowEventCounts["compositionupdate"], 1,
michael@0 1868 kDescription + "compositionupdate hasn't been handled by window #5");
michael@0 1869 is(windowEventData["compositionupdate"], "\u306D",
michael@0 1870 kDescription + "data of compositionupdate doesn't match (window) #5");
michael@0 1871 is(windowEventLocale["compositionupdate"], "",
michael@0 1872 kDescription + "locale of compositionupdate isn't empty (window) #5");
michael@0 1873 is(inputEventCounts["compositionupdate"], 1,
michael@0 1874 kDescription + "compositionupdate hasn't been handled by input #5");
michael@0 1875 is(inputEventData["compositionupdate"], "\u306D",
michael@0 1876 kDescription + "data of compositionupdate doesn't match (input) #5");
michael@0 1877 is(inputEventLocale["compositionupdate"], "",
michael@0 1878 kDescription + "locale of compositionupdate isn't empty (input) #5");
michael@0 1879
michael@0 1880 is(windowEventCounts["compositionend"], 1,
michael@0 1881 kDescription + "compositionend hasn't been handled by window #5");
michael@0 1882 is(windowEventData["compositionend"], "\u306D",
michael@0 1883 kDescription + "data of compositionend doesn't match (window) #5");
michael@0 1884 is(windowEventLocale["compositionend"], "",
michael@0 1885 kDescription + "locale of compositionend isn't empty (window) #5");
michael@0 1886 is(inputEventCounts["compositionend"], 1,
michael@0 1887 kDescription + "compositionend hasn't been handled by input #5");
michael@0 1888 is(inputEventData["compositionend"], "\u306D",
michael@0 1889 kDescription + "data of compositionend doesn't match (input) #5");
michael@0 1890 is(inputEventLocale["compositionend"], "",
michael@0 1891 kDescription + "locale of compositionend isn't empty (input) #5");
michael@0 1892
michael@0 1893 is(windowEventCounts["input"], 2,
michael@0 1894 kDescription + "input hasn't been handled by window #5");
michael@0 1895 is(windowEventData["input"], "\u306D",
michael@0 1896 kDescription + "value of input element wasn't modified (window) #5");
michael@0 1897 is(inputEventCounts["input"], 2,
michael@0 1898 kDescription + "input hasn't been handled by input #5");
michael@0 1899 is(inputEventData["input"], "\u306D",
michael@0 1900 kDescription + "value of input element wasn't modified (input) #5");
michael@0 1901
michael@0 1902 prevnetDefault = false;
michael@0 1903
michael@0 1904 // stopPropagation() should effect nothing (except event count)
michael@0 1905 stopPropagation = true;
michael@0 1906
michael@0 1907 initResults();
michael@0 1908 synthesizeKey("A", { accelKey: true }); // Select All
michael@0 1909
michael@0 1910 synthesizeComposition({ type: "compositionstart" });
michael@0 1911
michael@0 1912 synthesizeComposition({ type: "compositionupdate", data: "\u306E" });
michael@0 1913 synthesizeText(
michael@0 1914 { "composition":
michael@0 1915 { "string": "\u306E",
michael@0 1916 "clauses":
michael@0 1917 [
michael@0 1918 { "length": 1, "attr": COMPOSITION_ATTR_RAWINPUT }
michael@0 1919 ]
michael@0 1920 },
michael@0 1921 "caret": { "start": 1, "length": 0 }
michael@0 1922 });
michael@0 1923
michael@0 1924 synthesizeText(
michael@0 1925 { "composition":
michael@0 1926 { "string": "\u306E",
michael@0 1927 "clauses":
michael@0 1928 [
michael@0 1929 { "length": 0, "attr": 0 }
michael@0 1930 ]
michael@0 1931 },
michael@0 1932 "caret": { "start": 1, "length": 0 }
michael@0 1933 });
michael@0 1934
michael@0 1935 synthesizeComposition({ type: "compositionend", data: "\u306E" });
michael@0 1936
michael@0 1937 is(windowEventCounts["compositionstart"], 1,
michael@0 1938 kDescription + "compositionstart hasn't been handled by window #6");
michael@0 1939 is(windowEventData["compositionstart"], "\u306D",
michael@0 1940 kDescription + "data of compositionstart is empty #6");
michael@0 1941 is(windowEventLocale["compositionstart"], "",
michael@0 1942 kDescription + "locale of compositionstart isn't empty #6");
michael@0 1943 is(inputEventCounts["compositionstart"], 0,
michael@0 1944 kDescription + "compositionstart has been handled by input #6");
michael@0 1945
michael@0 1946 is(windowEventCounts["compositionupdate"], 1,
michael@0 1947 kDescription + "compositionupdate hasn't been handled by window #6");
michael@0 1948 is(windowEventData["compositionupdate"], "\u306E",
michael@0 1949 kDescription + "data of compositionupdate doesn't match #6");
michael@0 1950 is(windowEventLocale["compositionupdate"], "",
michael@0 1951 kDescription + "locale of compositionupdate isn't empty #6");
michael@0 1952 is(inputEventCounts["compositionupdate"], 0,
michael@0 1953 kDescription + "compositionupdate has been handled by input #6");
michael@0 1954
michael@0 1955 is(windowEventCounts["compositionend"], 1,
michael@0 1956 kDescription + "compositionend hasn't been handled by window #6");
michael@0 1957 is(windowEventData["compositionend"], "\u306E",
michael@0 1958 kDescription + "data of compositionend doesn't match #6");
michael@0 1959 is(windowEventLocale["compositionend"], "",
michael@0 1960 kDescription + "locale of compositionend isn't empty #6");
michael@0 1961 is(inputEventCounts["compositionend"], 0,
michael@0 1962 kDescription + "compositionend has been handled by input #6");
michael@0 1963
michael@0 1964 is(windowEventCounts["input"], 2,
michael@0 1965 kDescription + "input hasn't been handled by window #6");
michael@0 1966 is(windowEventData["input"], "\u306E",
michael@0 1967 kDescription + "value of input element wasn't modified (window) #6");
michael@0 1968 is(inputEventCounts["input"], 2,
michael@0 1969 kDescription + "input hasn't been handled by input #6");
michael@0 1970 is(inputEventData["input"], "\u306E",
michael@0 1971 kDescription + "value of input element wasn't modified (input) #6");
michael@0 1972
michael@0 1973 stopPropagation = false;
michael@0 1974
michael@0 1975 // create event and dispatch it.
michael@0 1976 initResults();
michael@0 1977
michael@0 1978 input.value = "value of input";
michael@0 1979 synthesizeKey("A", { accelKey: true }); // Select All
michael@0 1980
michael@0 1981 var compositionstart = document.createEvent("CompositionEvent");
michael@0 1982 compositionstart.initCompositionEvent("compositionstart",
michael@0 1983 true, true, document.defaultView,
michael@0 1984 "start data", "start locale");
michael@0 1985 is(compositionstart.type, "compositionstart",
michael@0 1986 kDescription + "type doesn't match #7");
michael@0 1987 is(compositionstart.data, "start data",
michael@0 1988 kDescription + "data doesn't match #7");
michael@0 1989 is(compositionstart.locale, "start locale",
michael@0 1990 kDescription + "locale doesn't match #7");
michael@0 1991 is(compositionstart.detail, 0,
michael@0 1992 kDescription + "detail isn't 0 #7");
michael@0 1993
michael@0 1994 input.dispatchEvent(compositionstart);
michael@0 1995
michael@0 1996 is(windowEventCounts["compositionstart"], 1,
michael@0 1997 kDescription + "compositionstart hasn't been handled by window #7");
michael@0 1998 is(windowEventData["compositionstart"], "start data",
michael@0 1999 kDescription + "data of compositionstart was changed (window) #7");
michael@0 2000 is(windowEventLocale["compositionstart"], "start locale",
michael@0 2001 kDescription + "locale of compositionstart was changed (window) #7");
michael@0 2002 is(inputEventCounts["compositionstart"], 1,
michael@0 2003 kDescription + "compositionstart hasn't been handled by input #7");
michael@0 2004 is(inputEventData["compositionstart"], "start data",
michael@0 2005 kDescription + "data of compositionstart was changed (input) #7");
michael@0 2006 is(inputEventLocale["compositionstart"], "start locale",
michael@0 2007 kDescription + "locale of compositionstart was changed (input) #7");
michael@0 2008
michael@0 2009 is(input.value, "value of input",
michael@0 2010 kDescription + "input value was changed #7");
michael@0 2011
michael@0 2012 var compositionupdate1 = document.createEvent("compositionevent");
michael@0 2013 compositionupdate1.initCompositionEvent("compositionupdate",
michael@0 2014 true, false, document.defaultView,
michael@0 2015 "composing string", "composing locale");
michael@0 2016 is(compositionupdate1.type, "compositionupdate",
michael@0 2017 kDescription + "type doesn't match #8");
michael@0 2018 is(compositionupdate1.data, "composing string",
michael@0 2019 kDescription + "data doesn't match #8");
michael@0 2020 is(compositionupdate1.locale, "composing locale",
michael@0 2021 kDescription + "locale doesn't match #8");
michael@0 2022 is(compositionupdate1.detail, 0,
michael@0 2023 kDescription + "detail isn't 0 #8");
michael@0 2024
michael@0 2025 input.dispatchEvent(compositionupdate1);
michael@0 2026
michael@0 2027 is(windowEventCounts["compositionupdate"], 1,
michael@0 2028 kDescription + "compositionupdate hasn't been handled by window #8");
michael@0 2029 is(windowEventData["compositionupdate"], "composing string",
michael@0 2030 kDescription + "data of compositionupdate was changed (window) #8");
michael@0 2031 is(windowEventLocale["compositionupdate"], "composing locale",
michael@0 2032 kDescription + "locale of compositionupdate was changed (window) #8");
michael@0 2033 is(inputEventCounts["compositionupdate"], 1,
michael@0 2034 kDescription + "compositionupdate hasn't been handled by input #8");
michael@0 2035 is(inputEventData["compositionupdate"], "composing string",
michael@0 2036 kDescription + "data of compositionupdate was changed (input) #8");
michael@0 2037 is(inputEventLocale["compositionupdate"], "composing locale",
michael@0 2038 kDescription + "locale of compositionupdate was changed (input) #8");
michael@0 2039
michael@0 2040 is(input.value, "value of input",
michael@0 2041 kDescription + "input value was changed #8");
michael@0 2042
michael@0 2043 var compositionupdate2 = document.createEvent("compositionEvent");
michael@0 2044 compositionupdate2.initCompositionEvent("compositionupdate",
michael@0 2045 true, false, document.defaultView,
michael@0 2046 "commit string", "commit locale");
michael@0 2047 is(compositionupdate2.type, "compositionupdate",
michael@0 2048 kDescription + "type doesn't match #9");
michael@0 2049 is(compositionupdate2.data, "commit string",
michael@0 2050 kDescription + "data doesn't match #9");
michael@0 2051 is(compositionupdate2.locale, "commit locale",
michael@0 2052 kDescription + "locale doesn't match #9");
michael@0 2053 is(compositionupdate2.detail, 0,
michael@0 2054 kDescription + "detail isn't 0 #9");
michael@0 2055
michael@0 2056 input.dispatchEvent(compositionupdate2);
michael@0 2057
michael@0 2058 is(windowEventCounts["compositionupdate"], 2,
michael@0 2059 kDescription + "compositionupdate hasn't been handled by window #9");
michael@0 2060 is(windowEventData["compositionupdate"], "commit string",
michael@0 2061 kDescription + "data of compositionupdate was changed (window) #9");
michael@0 2062 is(windowEventLocale["compositionupdate"], "commit locale",
michael@0 2063 kDescription + "locale of compositionupdate was changed (window) #9");
michael@0 2064 is(inputEventCounts["compositionupdate"], 2,
michael@0 2065 kDescription + "compositionupdate hasn't been handled by input #9");
michael@0 2066 is(inputEventData["compositionupdate"], "commit string",
michael@0 2067 kDescription + "data of compositionupdate was changed (input) #9");
michael@0 2068 is(inputEventLocale["compositionupdate"], "commit locale",
michael@0 2069 kDescription + "locale of compositionupdate was changed (input) #9");
michael@0 2070
michael@0 2071 is(input.value, "value of input",
michael@0 2072 kDescription + "input value was changed #9");
michael@0 2073
michael@0 2074 var compositionend = document.createEvent("Compositionevent");
michael@0 2075 compositionend.initCompositionEvent("compositionend",
michael@0 2076 true, false, document.defaultView,
michael@0 2077 "end data", "end locale");
michael@0 2078 is(compositionend.type, "compositionend",
michael@0 2079 kDescription + "type doesn't match #10");
michael@0 2080 is(compositionend.data, "end data",
michael@0 2081 kDescription + "data doesn't match #10");
michael@0 2082 is(compositionend.locale, "end locale",
michael@0 2083 kDescription + "locale doesn't match #10");
michael@0 2084 is(compositionend.detail, 0,
michael@0 2085 kDescription + "detail isn't 0 #10");
michael@0 2086
michael@0 2087 input.dispatchEvent(compositionend);
michael@0 2088
michael@0 2089 is(windowEventCounts["compositionend"], 1,
michael@0 2090 kDescription + "compositionend hasn't been handled by window #10");
michael@0 2091 is(windowEventData["compositionend"], "end data",
michael@0 2092 kDescription + "data of compositionend was changed (window) #10");
michael@0 2093 is(windowEventLocale["compositionend"], "end locale",
michael@0 2094 kDescription + "locale of compositionend was changed (window) #10");
michael@0 2095 is(inputEventCounts["compositionend"], 1,
michael@0 2096 kDescription + "compositionend hasn't been handled by input #10");
michael@0 2097 is(inputEventData["compositionend"], "end data",
michael@0 2098 kDescription + "data of compositionend was changed (input) #10");
michael@0 2099 is(inputEventLocale["compositionend"], "end locale",
michael@0 2100 kDescription + "locale of compositionend was changed (input) #10");
michael@0 2101
michael@0 2102 is(input.value, "value of input",
michael@0 2103 kDescription + "input value was changed #10");
michael@0 2104
michael@0 2105 window.removeEventListener("compositionstart",
michael@0 2106 compositionEventHandlerForWindow, true);
michael@0 2107 window.removeEventListener("compositionend",
michael@0 2108 compositionEventHandlerForWindow, true);
michael@0 2109 window.removeEventListener("compositionupdate",
michael@0 2110 compositionEventHandlerForWindow, true);
michael@0 2111 window.removeEventListener("input",
michael@0 2112 formEventHandlerForWindow, true);
michael@0 2113
michael@0 2114 input.removeEventListener("compositionstart",
michael@0 2115 compositionEventHandlerForInput, true);
michael@0 2116 input.removeEventListener("compositionend",
michael@0 2117 compositionEventHandlerForInput, true);
michael@0 2118 input.removeEventListener("compositionupdate",
michael@0 2119 compositionEventHandlerForInput, true);
michael@0 2120 input.removeEventListener("input",
michael@0 2121 formEventHandlerForInput, true);
michael@0 2122 }
michael@0 2123
michael@0 2124 function runCharAtPointTest(aFocusedEditor, aTargetName)
michael@0 2125 {
michael@0 2126 aFocusedEditor.value = "This is a test of the\nContent Events";
michael@0 2127 // 012345678901234567890 12345678901234
michael@0 2128 // 0 1 2 3
michael@0 2129
michael@0 2130 aFocusedEditor.focus();
michael@0 2131
michael@0 2132 const kNone = -1;
michael@0 2133 const kTestingOffset = [ 0, 10, 20, 21 + kLFLen, 34 + kLFLen];
michael@0 2134 const kLeftSideOffset = [ kNone, 9, 19, kNone, 33 + kLFLen];
michael@0 2135 const kRightSideOffset = [ 1, 11, kNone, 22 + kLFLen, kNone];
michael@0 2136
michael@0 2137 var editorRect = synthesizeQueryEditorRect();
michael@0 2138 if (!checkQueryContentResult(editorRect,
michael@0 2139 "runCharAtPointTest (" + aTargetName + "): editorRect")) {
michael@0 2140 return;
michael@0 2141 }
michael@0 2142
michael@0 2143 for (var i = 0; i < kTestingOffset.length; i++) {
michael@0 2144 var textRect = synthesizeQueryTextRect(kTestingOffset[i], 1);
michael@0 2145 if (!checkQueryContentResult(textRect,
michael@0 2146 "runCharAtPointTest (" + aTargetName + "): textRect: i=" + i)) {
michael@0 2147 continue;
michael@0 2148 }
michael@0 2149
michael@0 2150 checkRectContainsRect(textRect, editorRect,
michael@0 2151 "runCharAtPointTest (" + aTargetName +
michael@0 2152 "): the text rect isn't in the editor");
michael@0 2153
michael@0 2154 // Test #1, getting same character rect by the point near the top-left.
michael@0 2155 var charAtPt1 = synthesizeCharAtPoint(textRect.left + 1,
michael@0 2156 textRect.top + 1);
michael@0 2157 if (checkQueryContentResult(charAtPt1,
michael@0 2158 "runCharAtPointTest (" + aTargetName + "): charAtPt1: i=" + i)) {
michael@0 2159 ok(!charAtPt1.notFound,
michael@0 2160 "runCharAtPointTest (" + aTargetName + "): charAtPt1 isn't found: i=" + i);
michael@0 2161 if (!charAtPt1.notFound) {
michael@0 2162 is(charAtPt1.offset, kTestingOffset[i],
michael@0 2163 "runCharAtPointTest (" + aTargetName + "): charAtPt1 offset is wrong: i=" + i);
michael@0 2164 checkRect(charAtPt1, textRect, "runCharAtPointTest (" + aTargetName +
michael@0 2165 "): charAtPt1 left is wrong: i=" + i);
michael@0 2166 }
michael@0 2167 }
michael@0 2168
michael@0 2169 // Test #2, getting same character rect by the point near the bottom-right.
michael@0 2170 var charAtPt2 = synthesizeCharAtPoint(textRect.left + textRect.width - 2,
michael@0 2171 textRect.top + textRect.height - 2);
michael@0 2172 if (checkQueryContentResult(charAtPt2,
michael@0 2173 "runCharAtPointTest (" + aTargetName + "): charAtPt2: i=" + i)) {
michael@0 2174 ok(!charAtPt2.notFound,
michael@0 2175 "runCharAtPointTest (" + aTargetName + "): charAtPt2 isn't found: i=" + i);
michael@0 2176 if (!charAtPt2.notFound) {
michael@0 2177 is(charAtPt2.offset, kTestingOffset[i],
michael@0 2178 "runCharAtPointTest (" + aTargetName + "): charAtPt2 offset is wrong: i=" + i);
michael@0 2179 checkRect(charAtPt2, textRect, "runCharAtPointTest (" + aTargetName +
michael@0 2180 "): charAtPt1 left is wrong: i=" + i);
michael@0 2181 }
michael@0 2182 }
michael@0 2183
michael@0 2184 // Test #3, getting left character offset.
michael@0 2185 var charAtPt3 = synthesizeCharAtPoint(textRect.left - 2,
michael@0 2186 textRect.top + 1);
michael@0 2187 if (checkQueryContentResult(charAtPt3,
michael@0 2188 "runCharAtPointTest (" + aTargetName + "): charAtPt3: i=" + i)) {
michael@0 2189 is(charAtPt3.notFound, kLeftSideOffset[i] == kNone,
michael@0 2190 kLeftSideOffset[i] == kNone ?
michael@0 2191 "runCharAtPointTest (" + aTargetName + "): charAtPt3 is found: i=" + i :
michael@0 2192 "runCharAtPointTest (" + aTargetName + "): charAtPt3 isn't found: i=" + i);
michael@0 2193 if (!charAtPt3.notFound) {
michael@0 2194 is(charAtPt3.offset, kLeftSideOffset[i],
michael@0 2195 "runCharAtPointTest (" + aTargetName + "): charAtPt3 offset is wrong: i=" + i);
michael@0 2196 }
michael@0 2197 }
michael@0 2198
michael@0 2199 // Test #4, getting right character offset.
michael@0 2200 var charAtPt4 = synthesizeCharAtPoint(textRect.left + textRect.width + 1,
michael@0 2201 textRect.top + textRect.height - 2);
michael@0 2202 if (checkQueryContentResult(charAtPt4,
michael@0 2203 "runCharAtPointTest (" + aTargetName + "): charAtPt4: i=" + i)) {
michael@0 2204 is(charAtPt4.notFound, kRightSideOffset[i] == kNone,
michael@0 2205 kRightSideOffset[i] == kNone ?
michael@0 2206 "runCharAtPointTest (" + aTargetName + "): charAtPt4 is found: i=" + i :
michael@0 2207 "runCharAtPointTest (" + aTargetName + "): charAtPt4 isn't found: i=" + i);
michael@0 2208 if (!charAtPt4.notFound) {
michael@0 2209 is(charAtPt4.offset, kRightSideOffset[i],
michael@0 2210 "runCharAtPointTest (" + aTargetName + "): charAtPt4 offset is wrong: i=" + i);
michael@0 2211 }
michael@0 2212 }
michael@0 2213 }
michael@0 2214 }
michael@0 2215
michael@0 2216 function runCharAtPointAtOutsideTest()
michael@0 2217 {
michael@0 2218 textarea.focus();
michael@0 2219 textarea.value = "some text";
michael@0 2220 var editorRect = synthesizeQueryEditorRect();
michael@0 2221 if (!checkQueryContentResult(editorRect,
michael@0 2222 "runCharAtPointAtOutsideTest: editorRect")) {
michael@0 2223 return;
michael@0 2224 }
michael@0 2225 // Check on a text node which is at the outside of editor.
michael@0 2226 var charAtPt = synthesizeCharAtPoint(editorRect.left + 20,
michael@0 2227 editorRect.top - 10);
michael@0 2228 if (checkQueryContentResult(charAtPt,
michael@0 2229 "runCharAtPointAtOutsideTest: charAtPt")) {
michael@0 2230 ok(charAtPt.notFound,
michael@0 2231 "runCharAtPointAtOutsideTest: charAtPt is found on outside of editor");
michael@0 2232 }
michael@0 2233 }
michael@0 2234
michael@0 2235 function runBug722639Test()
michael@0 2236 {
michael@0 2237 textarea.focus();
michael@0 2238 textarea.value = "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n";
michael@0 2239 textarea.value += textarea.value;
michael@0 2240 textarea.value += textarea.value; // 80 characters
michael@0 2241
michael@0 2242 var firstLine = synthesizeQueryTextRect(0, 1);
michael@0 2243 if (!checkQueryContentResult(firstLine,
michael@0 2244 "runBug722639Test: firstLine")) {
michael@0 2245 return;
michael@0 2246 }
michael@0 2247 var secondLine = synthesizeQueryTextRect(kLFLen, 1);
michael@0 2248 if (!checkQueryContentResult(secondLine,
michael@0 2249 "runBug722639Test: secondLine")) {
michael@0 2250 return;
michael@0 2251 }
michael@0 2252 var lineHeight = secondLine.top - firstLine.top;
michael@0 2253 ok(lineHeight > 0,
michael@0 2254 "runBug722639Test: lineHeight must be positive");
michael@0 2255 is(secondLine.left, firstLine.left,
michael@0 2256 "runBug722639Test: the left value must be always same value");
michael@0 2257 var previousTop = secondLine.top;
michael@0 2258 for (var i = 2; i < textarea.value.length; i++) {
michael@0 2259 var currentLine = synthesizeQueryTextRect(kLFLen * i, 1);
michael@0 2260 if (!checkQueryContentResult(currentLine,
michael@0 2261 "runBug722639Test: " + i + "th currentLine")) {
michael@0 2262 return;
michael@0 2263 }
michael@0 2264 // NOTE: the top position may be 1px larger or smaller than other lines
michael@0 2265 // due to sub pixel positioning.
michael@0 2266 if (Math.abs(currentLine.top - (previousTop + lineHeight)) <= 1) {
michael@0 2267 ok(true, "runBug722639Test: " + i + "th line's top is expected");
michael@0 2268 } else {
michael@0 2269 is(currentLine.top, previousTop + lineHeight,
michael@0 2270 "runBug722639Test: " + i + "th line's top is unexpected");
michael@0 2271 }
michael@0 2272 is(currentLine.left, firstLine.left,
michael@0 2273 "runBug722639Test: " + i + "th line's left is unexpected");
michael@0 2274 previousTop = currentLine.top;
michael@0 2275 }
michael@0 2276 }
michael@0 2277
michael@0 2278 function runForceCommitTest()
michael@0 2279 {
michael@0 2280 var events;
michael@0 2281 function eventHandler(aEvent)
michael@0 2282 {
michael@0 2283 events.push(aEvent);
michael@0 2284 }
michael@0 2285 window.addEventListener("compositionstart", eventHandler, true);
michael@0 2286 window.addEventListener("compositionupdate", eventHandler, true);
michael@0 2287 window.addEventListener("compositionend", eventHandler, true);
michael@0 2288 window.addEventListener("input", eventHandler, true);
michael@0 2289 window.addEventListener("text", eventHandler, true);
michael@0 2290
michael@0 2291 // Make the composition in textarea commit by click in the textarea
michael@0 2292 textarea.focus();
michael@0 2293 textarea.value = "";
michael@0 2294
michael@0 2295 events = [];
michael@0 2296 synthesizeComposition({ type: "compositionstart" });
michael@0 2297
michael@0 2298 synthesizeComposition({ type: "compositionupdate", data: "\u306E" });
michael@0 2299 synthesizeText(
michael@0 2300 { "composition":
michael@0 2301 { "string": "\u306E",
michael@0 2302 "clauses":
michael@0 2303 [
michael@0 2304 { "length": 1, "attr": COMPOSITION_ATTR_RAWINPUT }
michael@0 2305 ]
michael@0 2306 },
michael@0 2307 "caret": { "start": 1, "length": 0 }
michael@0 2308 });
michael@0 2309
michael@0 2310 is(events.length, 4,
michael@0 2311 "runForceCommitTest: wrong event count #1");
michael@0 2312 is(events[0].type, "compositionstart",
michael@0 2313 "runForceCommitTest: the 1st event must be compositionstart #1");
michael@0 2314 is(events[1].type, "compositionupdate",
michael@0 2315 "runForceCommitTest: the 2nd event must be compositionupdate #1");
michael@0 2316 is(events[2].type, "text",
michael@0 2317 "runForceCommitTest: the 3rd event must be text #1");
michael@0 2318 is(events[3].type, "input",
michael@0 2319 "runForceCommitTest: the 4th event must be input #1");
michael@0 2320
michael@0 2321 events = [];
michael@0 2322 synthesizeMouseAtCenter(textarea, {});
michael@0 2323
michael@0 2324 is(events.length, 3,
michael@0 2325 "runForceCommitTest: wrong event count #2");
michael@0 2326 is(events[0].type, "text",
michael@0 2327 "runForceCommitTest: the 1st event must be text #2");
michael@0 2328 is(events[1].type, "compositionend",
michael@0 2329 "runForceCommitTest: the 2nd event must be compositionend #2");
michael@0 2330 is(events[2].type, "input",
michael@0 2331 "runForceCommitTest: the 3rd event must be input #2");
michael@0 2332 is(events[1].data, "\u306E",
michael@0 2333 "runForceCommitTest: compositionend has wrong data #2");
michael@0 2334 is(events[0].target, textarea,
michael@0 2335 "runForceCommitTest: The 1st event was fired on wrong event target #2");
michael@0 2336 is(events[1].target, textarea,
michael@0 2337 "runForceCommitTest: The 2nd event was fired on wrong event target #2");
michael@0 2338 is(events[2].target, textarea,
michael@0 2339 "runForceCommitTest: The 3rd event was fired on wrong event target #2");
michael@0 2340 ok(!getEditorIMESupport(textarea).isComposing,
michael@0 2341 "runForceCommitTest: the textarea still has composition #2");
michael@0 2342 is(textarea.value, "\u306E",
michael@0 2343 "runForceCommitTest: the textarea doesn't have the committed text #2");
michael@0 2344
michael@0 2345 // Make the composition in textarea commit by click in another editor (input)
michael@0 2346 textarea.focus();
michael@0 2347 textarea.value = "";
michael@0 2348 input.value = "";
michael@0 2349
michael@0 2350 synthesizeComposition({ type: "compositionstart" });
michael@0 2351
michael@0 2352 synthesizeComposition({ type: "compositionupdate", data: "\u306E" });
michael@0 2353 synthesizeText(
michael@0 2354 { "composition":
michael@0 2355 { "string": "\u306E",
michael@0 2356 "clauses":
michael@0 2357 [
michael@0 2358 { "length": 1, "attr": COMPOSITION_ATTR_RAWINPUT }
michael@0 2359 ]
michael@0 2360 },
michael@0 2361 "caret": { "start": 1, "length": 0 }
michael@0 2362 });
michael@0 2363
michael@0 2364 events = [];
michael@0 2365 synthesizeMouseAtCenter(input, {});
michael@0 2366
michael@0 2367 is(events.length, 3,
michael@0 2368 "runForceCommitTest: wrong event count #3");
michael@0 2369 is(events[0].type, "text",
michael@0 2370 "runForceCommitTest: the 1st event must be text #3");
michael@0 2371 is(events[1].type, "compositionend",
michael@0 2372 "runForceCommitTest: the 2nd event must be compositionend #3");
michael@0 2373 is(events[2].type, "input",
michael@0 2374 "runForceCommitTest: the 3rd event must be input #3");
michael@0 2375 is(events[1].data, "\u306E",
michael@0 2376 "runForceCommitTest: compositionend has wrong data #3");
michael@0 2377 is(events[0].target, textarea,
michael@0 2378 "runForceCommitTest: The 1st event was fired on wrong event target #3");
michael@0 2379 is(events[1].target, textarea,
michael@0 2380 "runForceCommitTest: The 2nd event was fired on wrong event target #3");
michael@0 2381 is(events[2].target, textarea,
michael@0 2382 "runForceCommitTest: The 3rd event was fired on wrong event target #3");
michael@0 2383 ok(!getEditorIMESupport(textarea).isComposing,
michael@0 2384 "runForceCommitTest: the textarea still has composition #3");
michael@0 2385 ok(!getEditorIMESupport(input).isComposing,
michael@0 2386 "runForceCommitTest: the input has composition #3");
michael@0 2387 is(textarea.value, "\u306E",
michael@0 2388 "runForceCommitTest: the textarea doesn't have the committed text #3");
michael@0 2389 is(input.value, "",
michael@0 2390 "runForceCommitTest: the input has the committed text? #3");
michael@0 2391
michael@0 2392 // Make the composition in textarea commit by blur()
michael@0 2393 textarea.focus();
michael@0 2394 textarea.value = "";
michael@0 2395
michael@0 2396 synthesizeComposition({ type: "compositionstart" });
michael@0 2397
michael@0 2398 synthesizeComposition({ type: "compositionupdate", data: "\u306E" });
michael@0 2399 synthesizeText(
michael@0 2400 { "composition":
michael@0 2401 { "string": "\u306E",
michael@0 2402 "clauses":
michael@0 2403 [
michael@0 2404 { "length": 1, "attr": COMPOSITION_ATTR_RAWINPUT }
michael@0 2405 ]
michael@0 2406 },
michael@0 2407 "caret": { "start": 1, "length": 0 }
michael@0 2408 });
michael@0 2409
michael@0 2410 events = [];
michael@0 2411 textarea.blur();
michael@0 2412
michael@0 2413 is(events.length, 3,
michael@0 2414 "runForceCommitTest: wrong event count #4");
michael@0 2415 is(events[0].type, "text",
michael@0 2416 "runForceCommitTest: the 1st event must be text #4");
michael@0 2417 is(events[1].type, "compositionend",
michael@0 2418 "runForceCommitTest: the 2nd event must be compositionend #4");
michael@0 2419 is(events[2].type, "input",
michael@0 2420 "runForceCommitTest: the 3rd event must be input #4");
michael@0 2421 is(events[1].data, "\u306E",
michael@0 2422 "runForceCommitTest: compositionend has wrong data #4");
michael@0 2423 is(events[0].target, textarea,
michael@0 2424 "runForceCommitTest: The 1st event was fired on wrong event target #4");
michael@0 2425 is(events[1].target, textarea,
michael@0 2426 "runForceCommitTest: The 2nd event was fired on wrong event target #4");
michael@0 2427 is(events[2].target, textarea,
michael@0 2428 "runForceCommitTest: The 3rd event was fired on wrong event target #4");
michael@0 2429 ok(!getEditorIMESupport(textarea).isComposing,
michael@0 2430 "runForceCommitTest: the textarea still has composition #4");
michael@0 2431 is(textarea.value, "\u306E",
michael@0 2432 "runForceCommitTest: the textarea doesn't have the committed text #4");
michael@0 2433
michael@0 2434 // Make the composition in textarea commit by input.focus()
michael@0 2435 textarea.focus();
michael@0 2436 textarea.value = "";
michael@0 2437 input.value = "";
michael@0 2438
michael@0 2439 synthesizeComposition({ type: "compositionstart" });
michael@0 2440
michael@0 2441 synthesizeComposition({ type: "compositionupdate", data: "\u306E" });
michael@0 2442 synthesizeText(
michael@0 2443 { "composition":
michael@0 2444 { "string": "\u306E",
michael@0 2445 "clauses":
michael@0 2446 [
michael@0 2447 { "length": 1, "attr": COMPOSITION_ATTR_RAWINPUT }
michael@0 2448 ]
michael@0 2449 },
michael@0 2450 "caret": { "start": 1, "length": 0 }
michael@0 2451 });
michael@0 2452
michael@0 2453 events = [];
michael@0 2454 input.focus();
michael@0 2455
michael@0 2456 is(events.length, 3,
michael@0 2457 "runForceCommitTest: wrong event count #5");
michael@0 2458 is(events[0].type, "text",
michael@0 2459 "runForceCommitTest: the 1st event must be text #5");
michael@0 2460 is(events[1].type, "compositionend",
michael@0 2461 "runForceCommitTest: the 2nd event must be compositionend #5");
michael@0 2462 is(events[2].type, "input",
michael@0 2463 "runForceCommitTest: the 3rd event must be input #5");
michael@0 2464 is(events[1].data, "\u306E",
michael@0 2465 "runForceCommitTest: compositionend has wrong data #5");
michael@0 2466 is(events[0].target, textarea,
michael@0 2467 "runForceCommitTest: The 1st event was fired on wrong event target #5");
michael@0 2468 is(events[1].target, textarea,
michael@0 2469 "runForceCommitTest: The 2nd event was fired on wrong event target #5");
michael@0 2470 is(events[2].target, textarea,
michael@0 2471 "runForceCommitTest: The 3rd event was fired on wrong event target #5");
michael@0 2472 ok(!getEditorIMESupport(textarea).isComposing,
michael@0 2473 "runForceCommitTest: the textarea still has composition #5");
michael@0 2474 ok(!getEditorIMESupport(input).isComposing,
michael@0 2475 "runForceCommitTest: the input has composition #5");
michael@0 2476 is(textarea.value, "\u306E",
michael@0 2477 "runForceCommitTest: the textarea doesn't have the committed text #5");
michael@0 2478 is(input.value, "",
michael@0 2479 "runForceCommitTest: the input has the committed text? #5");
michael@0 2480
michael@0 2481 // Make the composition in textarea commit by click in another document's editor
michael@0 2482 textarea.focus();
michael@0 2483 textarea.value = "";
michael@0 2484 textareaInFrame.value = "";
michael@0 2485
michael@0 2486 synthesizeComposition({ type: "compositionstart" });
michael@0 2487
michael@0 2488 synthesizeComposition({ type: "compositionupdate", data: "\u306E" });
michael@0 2489 synthesizeText(
michael@0 2490 { "composition":
michael@0 2491 { "string": "\u306E",
michael@0 2492 "clauses":
michael@0 2493 [
michael@0 2494 { "length": 1, "attr": COMPOSITION_ATTR_RAWINPUT }
michael@0 2495 ]
michael@0 2496 },
michael@0 2497 "caret": { "start": 1, "length": 0 }
michael@0 2498 });
michael@0 2499
michael@0 2500 events = [];
michael@0 2501 synthesizeMouseAtCenter(textareaInFrame, {}, iframe.contentWindow);
michael@0 2502
michael@0 2503 is(events.length, 3,
michael@0 2504 "runForceCommitTest: wrong event count #6");
michael@0 2505 is(events[0].type, "text",
michael@0 2506 "runForceCommitTest: the 1st event must be text #6");
michael@0 2507 is(events[1].type, "compositionend",
michael@0 2508 "runForceCommitTest: the 2nd event must be compositionend #6");
michael@0 2509 is(events[2].type, "input",
michael@0 2510 "runForceCommitTest: the 3rd event must be input #6");
michael@0 2511 is(events[1].data, "\u306E",
michael@0 2512 "runForceCommitTest: compositionend has wrong data #6");
michael@0 2513 is(events[0].target, textarea,
michael@0 2514 "runForceCommitTest: The 1st event was fired on wrong event target #6");
michael@0 2515 is(events[1].target, textarea,
michael@0 2516 "runForceCommitTest: The 2nd event was fired on wrong event target #6");
michael@0 2517 is(events[2].target, textarea,
michael@0 2518 "runForceCommitTest: The 3rd event was fired on wrong event target #6");
michael@0 2519 ok(!getEditorIMESupport(textarea).isComposing,
michael@0 2520 "runForceCommitTest: the textarea still has composition #6");
michael@0 2521 ok(!getEditorIMESupport(textareaInFrame).isComposing,
michael@0 2522 "runForceCommitTest: the textarea in frame has composition #6");
michael@0 2523 is(textarea.value, "\u306E",
michael@0 2524 "runForceCommitTest: the textarea doesn't have the committed text #6");
michael@0 2525 is(textareaInFrame.value, "",
michael@0 2526 "runForceCommitTest: the textarea in frame has the committed text? #6");
michael@0 2527
michael@0 2528 // Make the composition in textarea commit by another document's editor's focus()
michael@0 2529 textarea.focus();
michael@0 2530 textarea.value = "";
michael@0 2531 textareaInFrame.value = "";
michael@0 2532
michael@0 2533 synthesizeComposition({ type: "compositionstart" });
michael@0 2534
michael@0 2535 synthesizeComposition({ type: "compositionupdate", data: "\u306E" });
michael@0 2536 synthesizeText(
michael@0 2537 { "composition":
michael@0 2538 { "string": "\u306E",
michael@0 2539 "clauses":
michael@0 2540 [
michael@0 2541 { "length": 1, "attr": COMPOSITION_ATTR_RAWINPUT }
michael@0 2542 ]
michael@0 2543 },
michael@0 2544 "caret": { "start": 1, "length": 0 }
michael@0 2545 });
michael@0 2546
michael@0 2547 events = [];
michael@0 2548 textareaInFrame.focus();
michael@0 2549
michael@0 2550 is(events.length, 3,
michael@0 2551 "runForceCommitTest: wrong event count #7");
michael@0 2552 is(events[0].type, "text",
michael@0 2553 "runForceCommitTest: the 1st event must be text #7");
michael@0 2554 is(events[1].type, "compositionend",
michael@0 2555 "runForceCommitTest: the 2nd event must be compositionend #7");
michael@0 2556 is(events[2].type, "input",
michael@0 2557 "runForceCommitTest: the 3rd event must be input #7");
michael@0 2558 is(events[1].data, "\u306E",
michael@0 2559 "runForceCommitTest: compositionend has wrong data #7");
michael@0 2560 is(events[0].target, textarea,
michael@0 2561 "runForceCommitTest: The 1st event was fired on wrong event target #7");
michael@0 2562 is(events[1].target, textarea,
michael@0 2563 "runForceCommitTest: The 2nd event was fired on wrong event target #7");
michael@0 2564 is(events[2].target, textarea,
michael@0 2565 "runForceCommitTest: The 3rd event was fired on wrong event target #7");
michael@0 2566 ok(!getEditorIMESupport(textarea).isComposing,
michael@0 2567 "runForceCommitTest: the textarea still has composition #7");
michael@0 2568 ok(!getEditorIMESupport(textareaInFrame).isComposing,
michael@0 2569 "runForceCommitTest: the textarea in frame has composition #7");
michael@0 2570 is(textarea.value, "\u306E",
michael@0 2571 "runForceCommitTest: the textarea doesn't have the committed text #7");
michael@0 2572 is(textareaInFrame.value, "",
michael@0 2573 "runForceCommitTest: the textarea in frame has the committed text? #7");
michael@0 2574
michael@0 2575 // Make the composition in a textarea commit by click in another editable document
michael@0 2576 textarea.focus();
michael@0 2577 textarea.value = "";
michael@0 2578 iframe2.contentDocument.body.innerHTML = "Text in the Body";
michael@0 2579 var iframe2BodyInnerHTML = iframe2.contentDocument.body.innerHTML;
michael@0 2580
michael@0 2581 synthesizeComposition({ type: "compositionstart" });
michael@0 2582
michael@0 2583 synthesizeComposition({ type: "compositionupdate", data: "\u306E" });
michael@0 2584 synthesizeText(
michael@0 2585 { "composition":
michael@0 2586 { "string": "\u306E",
michael@0 2587 "clauses":
michael@0 2588 [
michael@0 2589 { "length": 1, "attr": COMPOSITION_ATTR_RAWINPUT }
michael@0 2590 ]
michael@0 2591 },
michael@0 2592 "caret": { "start": 1, "length": 0 }
michael@0 2593 });
michael@0 2594
michael@0 2595 events = [];
michael@0 2596 synthesizeMouseAtCenter(iframe2.contentDocument.body, {}, iframe2.contentWindow);
michael@0 2597
michael@0 2598 is(events.length, 3,
michael@0 2599 "runForceCommitTest: wrong event count #8");
michael@0 2600 is(events[0].type, "text",
michael@0 2601 "runForceCommitTest: the 1st event must be text #8");
michael@0 2602 is(events[1].type, "compositionend",
michael@0 2603 "runForceCommitTest: the 2nd event must be compositionend #8");
michael@0 2604 is(events[2].type, "input",
michael@0 2605 "runForceCommitTest: the 3rd event must be input #8");
michael@0 2606 is(events[1].data, "\u306E",
michael@0 2607 "runForceCommitTest: compositionend has wrong data #8");
michael@0 2608 is(events[0].target, textarea,
michael@0 2609 "runForceCommitTest: The 1st event was fired on wrong event target #8");
michael@0 2610 is(events[1].target, textarea,
michael@0 2611 "runForceCommitTest: The 2nd event was fired on wrong event target #8");
michael@0 2612 is(events[2].target, textarea,
michael@0 2613 "runForceCommitTest: The 3rd event was fired on wrong event target #8");
michael@0 2614 ok(!getEditorIMESupport(textarea).isComposing,
michael@0 2615 "runForceCommitTest: the textarea still has composition #8");
michael@0 2616 ok(!getHTMLEditorIMESupport(iframe2.contentWindow).isComposing,
michael@0 2617 "runForceCommitTest: the editable document has composition #8");
michael@0 2618 is(textarea.value, "\u306E",
michael@0 2619 "runForceCommitTest: the textarea doesn't have the committed text #8");
michael@0 2620 is(iframe2.contentDocument.body.innerHTML, iframe2BodyInnerHTML,
michael@0 2621 "runForceCommitTest: the editable document has the committed text? #8");
michael@0 2622
michael@0 2623 // Make the composition in an editable document commit by click in it
michael@0 2624 iframe2.contentWindow.focus();
michael@0 2625 iframe2.contentDocument.body.innerHTML = "Text in the Body";
michael@0 2626 iframe2BodyInnerHTML = iframe2.contentDocument.body.innerHTML;
michael@0 2627
michael@0 2628 synthesizeComposition({ type: "compositionstart" }, iframe2.contentWindow);
michael@0 2629
michael@0 2630 synthesizeComposition({ type: "compositionupdate", data: "\u306E" }, iframe2.contentWindow);
michael@0 2631 synthesizeText(
michael@0 2632 { "composition":
michael@0 2633 { "string": "\u306E",
michael@0 2634 "clauses":
michael@0 2635 [
michael@0 2636 { "length": 1, "attr": COMPOSITION_ATTR_RAWINPUT }
michael@0 2637 ]
michael@0 2638 },
michael@0 2639 "caret": { "start": 1, "length": 0 }
michael@0 2640 }, iframe2.contentWindow);
michael@0 2641
michael@0 2642 events = [];
michael@0 2643 synthesizeMouseAtCenter(iframe2.contentDocument.body, {}, iframe2.contentWindow);
michael@0 2644
michael@0 2645 is(events.length, 3,
michael@0 2646 "runForceCommitTest: wrong event count #9");
michael@0 2647 is(events[0].type, "text",
michael@0 2648 "runForceCommitTest: the 1st event must be text #9");
michael@0 2649 is(events[1].type, "compositionend",
michael@0 2650 "runForceCommitTest: the 2nd event must be compositionend #9");
michael@0 2651 is(events[2].type, "input",
michael@0 2652 "runForceCommitTest: the 3rd event must be input #9");
michael@0 2653 is(events[1].data, "\u306E",
michael@0 2654 "runForceCommitTest: compositionend has wrong data #9");
michael@0 2655 is(events[0].target, iframe2.contentDocument.body,
michael@0 2656 "runForceCommitTest: The 1st event was fired on wrong event target #9");
michael@0 2657 is(events[1].target, iframe2.contentDocument.body,
michael@0 2658 "runForceCommitTest: The 2nd event was fired on wrong event target #9");
michael@0 2659 is(events[2].target, iframe2.contentDocument.body,
michael@0 2660 "runForceCommitTest: The 3rd event was fired on wrong event target #9");
michael@0 2661 ok(!getHTMLEditorIMESupport(iframe2.contentWindow).isComposing,
michael@0 2662 "runForceCommitTest: the editable document still has composition #9");
michael@0 2663 ok(iframe2.contentDocument.body.innerHTML != iframe2BodyInnerHTML &&
michael@0 2664 iframe2.contentDocument.body.innerHTML.indexOf("\u306E") >= 0,
michael@0 2665 "runForceCommitTest: the editable document doesn't have the committed text #9");
michael@0 2666
michael@0 2667 // Make the composition in an editable document commit by click in another document's editor
michael@0 2668 textarea.value = "";
michael@0 2669 iframe2.contentWindow.focus();
michael@0 2670 iframe2.contentDocument.body.innerHTML = "Text in the Body";
michael@0 2671 iframe2BodyInnerHTML = iframe2.contentDocument.body.innerHTML;
michael@0 2672
michael@0 2673 synthesizeComposition({ type: "compositionstart" }, iframe2.contentWindow);
michael@0 2674
michael@0 2675 synthesizeComposition({ type: "compositionupdate", data: "\u306E" }, iframe2.contentWindow);
michael@0 2676 synthesizeText(
michael@0 2677 { "composition":
michael@0 2678 { "string": "\u306E",
michael@0 2679 "clauses":
michael@0 2680 [
michael@0 2681 { "length": 1, "attr": COMPOSITION_ATTR_RAWINPUT }
michael@0 2682 ]
michael@0 2683 },
michael@0 2684 "caret": { "start": 1, "length": 0 }
michael@0 2685 }, iframe2.contentWindow);
michael@0 2686
michael@0 2687 events = [];
michael@0 2688 synthesizeMouseAtCenter(textarea, {});
michael@0 2689
michael@0 2690 is(events.length, 3,
michael@0 2691 "runForceCommitTest: wrong event count #10");
michael@0 2692 is(events[0].type, "text",
michael@0 2693 "runForceCommitTest: the 1st event must be text #10");
michael@0 2694 is(events[1].type, "compositionend",
michael@0 2695 "runForceCommitTest: the 2nd event must be compositionend #10");
michael@0 2696 is(events[2].type, "input",
michael@0 2697 "runForceCommitTest: the 3rd event must be input #10");
michael@0 2698 is(events[1].data, "\u306E",
michael@0 2699 "runForceCommitTest: compositionend has wrong data #10");
michael@0 2700 is(events[0].target, iframe2.contentDocument.body,
michael@0 2701 "runForceCommitTest: The 1st event was fired on wrong event target #10");
michael@0 2702 is(events[1].target, iframe2.contentDocument.body,
michael@0 2703 "runForceCommitTest: The 2nd event was fired on wrong event target #10");
michael@0 2704 is(events[2].target, iframe2.contentDocument.body,
michael@0 2705 "runForceCommitTest: The 3rd event was fired on wrong event target #10");
michael@0 2706 ok(!getHTMLEditorIMESupport(iframe2.contentWindow).isComposing,
michael@0 2707 "runForceCommitTest: the editable document still has composition #10");
michael@0 2708 ok(!getEditorIMESupport(textarea).isComposing,
michael@0 2709 "runForceCommitTest: the textarea has composition #10");
michael@0 2710 ok(iframe2.contentDocument.body.innerHTML != iframe2BodyInnerHTML &&
michael@0 2711 iframe2.contentDocument.body.innerHTML.indexOf("\u306E") >= 0,
michael@0 2712 "runForceCommitTest: the editable document doesn't have the committed text #10");
michael@0 2713 is(textarea.value, "",
michael@0 2714 "runForceCommitTest: the textarea has the committed text? #10");
michael@0 2715
michael@0 2716 // Make the composition in an editable document commit by click in the another editable document
michael@0 2717 iframe2.contentWindow.focus();
michael@0 2718 iframe2.contentDocument.body.innerHTML = "Text in the Body";
michael@0 2719 iframe2BodyInnerHTML = iframe2.contentDocument.body.innerHTML;
michael@0 2720 iframe3.contentDocument.body.innerHTML = "Text in the Body";
michael@0 2721 iframe3BodyInnerHTML = iframe2.contentDocument.body.innerHTML;
michael@0 2722
michael@0 2723 synthesizeComposition({ type: "compositionstart" }, iframe2.contentWindow);
michael@0 2724
michael@0 2725 synthesizeComposition({ type: "compositionupdate", data: "\u306E" }, iframe2.contentWindow);
michael@0 2726 synthesizeText(
michael@0 2727 { "composition":
michael@0 2728 { "string": "\u306E",
michael@0 2729 "clauses":
michael@0 2730 [
michael@0 2731 { "length": 1, "attr": COMPOSITION_ATTR_RAWINPUT }
michael@0 2732 ]
michael@0 2733 },
michael@0 2734 "caret": { "start": 1, "length": 0 }
michael@0 2735 }, iframe2.contentWindow);
michael@0 2736
michael@0 2737 events = [];
michael@0 2738 synthesizeMouseAtCenter(iframe3.contentDocument.body, {}, iframe3.contentWindow);
michael@0 2739
michael@0 2740 is(events.length, 3,
michael@0 2741 "runForceCommitTest: wrong event count #11");
michael@0 2742 is(events[0].type, "text",
michael@0 2743 "runForceCommitTest: the 1st event must be text #11");
michael@0 2744 is(events[1].type, "compositionend",
michael@0 2745 "runForceCommitTest: the 2nd event must be compositionend #11");
michael@0 2746 is(events[2].type, "input",
michael@0 2747 "runForceCommitTest: the 3rd event must be input #11");
michael@0 2748 is(events[1].data, "\u306E",
michael@0 2749 "runForceCommitTest: compositionend has wrong data #11");
michael@0 2750 is(events[0].target, iframe2.contentDocument.body,
michael@0 2751 "runForceCommitTest: The 1st event was fired on wrong event target #11");
michael@0 2752 is(events[1].target, iframe2.contentDocument.body,
michael@0 2753 "runForceCommitTest: The 2nd event was fired on wrong event target #11");
michael@0 2754 is(events[2].target, iframe2.contentDocument.body,
michael@0 2755 "runForceCommitTest: The 3rd event was fired on wrong event target #11");
michael@0 2756 ok(!getHTMLEditorIMESupport(iframe2.contentWindow).isComposing,
michael@0 2757 "runForceCommitTest: the editable document still has composition #11");
michael@0 2758 ok(!getHTMLEditorIMESupport(iframe3.contentWindow).isComposing,
michael@0 2759 "runForceCommitTest: the other editable document has composition #11");
michael@0 2760 ok(iframe2.contentDocument.body.innerHTML != iframe2BodyInnerHTML &&
michael@0 2761 iframe2.contentDocument.body.innerHTML.indexOf("\u306E") >= 0,
michael@0 2762 "runForceCommitTest: the editable document doesn't have the committed text #11");
michael@0 2763 is(iframe3.contentDocument.body.innerHTML, iframe3BodyInnerHTML,
michael@0 2764 "runForceCommitTest: the other editable document has the committed text? #11");
michael@0 2765
michael@0 2766 window.removeEventListener("compositionstart", eventHandler, true);
michael@0 2767 window.removeEventListener("compositionupdate", eventHandler, true);
michael@0 2768 window.removeEventListener("compositionend", eventHandler, true);
michael@0 2769 window.removeEventListener("input", eventHandler, true);
michael@0 2770 window.removeEventListener("text", eventHandler, true);
michael@0 2771 }
michael@0 2772
michael@0 2773 function runBug811755Test()
michael@0 2774 {
michael@0 2775 iframe2.contentDocument.body.innerHTML = "<div>content<br/></div>";
michael@0 2776 iframe2.contentWindow.focus();
michael@0 2777 // Query everything
michael@0 2778 var textContent = synthesizeQueryTextContent(0, 10);
michael@0 2779 if (!checkQueryContentResult(textContent, "runBug811755Test: synthesizeQueryTextContent #1")) {
michael@0 2780 return false;
michael@0 2781 }
michael@0 2782 // Query everything but specify exact end offset, which should be immediately after the <br> node
michael@0 2783 // If PreContentIterator is used, the next node after <br> is the node after </div>.
michael@0 2784 // If ContentIterator is used, the next node is the <div> node itself. In this case, the end
michael@0 2785 // node ends up being before the start node, and an empty string is returned.
michael@0 2786 var queryContent = synthesizeQueryTextContent(0, textContent.text.length);
michael@0 2787 if (!checkQueryContentResult(queryContent, "runBug811755Test: synthesizeQueryTextContent #2")) {
michael@0 2788 return false;
michael@0 2789 }
michael@0 2790 is(queryContent.text, textContent.text, "runBug811755Test: two queried texts don't match");
michael@0 2791 return queryContent.text == textContent.text;
michael@0 2792 }
michael@0 2793
michael@0 2794 function runIsComposingTest()
michael@0 2795 {
michael@0 2796 var expectedIsComposing = false;
michael@0 2797 var descriptionBase = "runIsComposingTest: ";
michael@0 2798 var description = "";
michael@0 2799
michael@0 2800 function eventHandler(aEvent)
michael@0 2801 {
michael@0 2802 if (aEvent.type == "keydown" || aEvent.type == "keyup") {
michael@0 2803 is(aEvent.isComposing, expectedIsComposing,
michael@0 2804 "runIsComposingTest: " + description + " (type=" + aEvent.type + ", key=" + aEvent.key + ")");
michael@0 2805 } else {
michael@0 2806 is(aEvent.isComposing, expectedIsComposing,
michael@0 2807 "runIsComposingTest: " + description + " (type=" + aEvent.type + ")");
michael@0 2808 }
michael@0 2809 }
michael@0 2810
michael@0 2811 textarea.addEventListener("keydown", eventHandler, true);
michael@0 2812 textarea.addEventListener("keypress", eventHandler, true);
michael@0 2813 textarea.addEventListener("keyup", eventHandler, true);
michael@0 2814 textarea.addEventListener("input", eventHandler, true);
michael@0 2815
michael@0 2816 textarea.focus();
michael@0 2817 textarea.value = "";
michael@0 2818
michael@0 2819 // XXX These cases shouldn't occur in actual native key events because we
michael@0 2820 // don't dispatch key events while composition (bug 354358).
michael@0 2821 expectedIsComposing = false;
michael@0 2822 description = "events before dispatching compositionstart";
michael@0 2823 synthesizeKey("VK_LEFT", {});
michael@0 2824
michael@0 2825 synthesizeKey("a", { type: "keydown" });
michael@0 2826 synthesizeComposition({ type: "compositionstart" });
michael@0 2827 expectedIsComposing = true;
michael@0 2828 description = "events after dispatching compositionstart";
michael@0 2829 synthesizeComposition({ type: "compositionupdate", data: "\u3042" });
michael@0 2830 synthesizeText(
michael@0 2831 { "composition":
michael@0 2832 { "string": "\u3042",
michael@0 2833 "clauses":
michael@0 2834 [
michael@0 2835 { "length": 1, "attr": COMPOSITION_ATTR_RAWINPUT }
michael@0 2836 ]
michael@0 2837 },
michael@0 2838 "caret": { "start": 1, "length": 0 }
michael@0 2839 });
michael@0 2840 synthesizeKey("a", { type: "keyup" });
michael@0 2841
michael@0 2842 // Although, firing keypress event during composition is a bug.
michael@0 2843 synthesizeKey("VK_INSERT", {});
michael@0 2844
michael@0 2845 description = "events for committing composition string";
michael@0 2846 synthesizeKey("VK_RETURN", { type: "keydown" });
michael@0 2847 synthesizeText(
michael@0 2848 { "composition":
michael@0 2849 { "string": "\u3042",
michael@0 2850 "clauses":
michael@0 2851 [
michael@0 2852 { "length": 0, "attr": 0 }
michael@0 2853 ]
michael@0 2854 },
michael@0 2855 "caret": { "start": 1, "length": 0 }
michael@0 2856 });
michael@0 2857
michael@0 2858 // input event will be fired by synthesizing compositionend event.
michael@0 2859 // Then, its isComposing should be false.
michael@0 2860 expectedIsComposing = false;
michael@0 2861 description = "events after dispatching compositionend";
michael@0 2862 synthesizeComposition({ type: "compositionend" });
michael@0 2863 synthesizeKey("VK_RETURN", { type: "keyup" });
michael@0 2864
michael@0 2865 textarea.removeEventListener("keydown", eventHandler, true);
michael@0 2866 textarea.removeEventListener("keypress", eventHandler, true);
michael@0 2867 textarea.removeEventListener("keyup", eventHandler, true);
michael@0 2868 textarea.removeEventListener("input", eventHandler, true);
michael@0 2869
michael@0 2870 textarea.value = "";
michael@0 2871 }
michael@0 2872
michael@0 2873 function runRemoveContentTest(aCallback)
michael@0 2874 {
michael@0 2875 var events = [];
michael@0 2876 function eventHandler(aEvent)
michael@0 2877 {
michael@0 2878 events.push(aEvent);
michael@0 2879 }
michael@0 2880 textarea.addEventListener("compositionstart", eventHandler, true);
michael@0 2881 textarea.addEventListener("compositionupdate", eventHandler, true);
michael@0 2882 textarea.addEventListener("compositionend", eventHandler, true);
michael@0 2883 textarea.addEventListener("input", eventHandler, true);
michael@0 2884 textarea.addEventListener("text", eventHandler, true);
michael@0 2885
michael@0 2886 textarea.focus();
michael@0 2887 textarea.value = "";
michael@0 2888
michael@0 2889 synthesizeComposition({ type: "compositionstart" });
michael@0 2890
michael@0 2891 synthesizeComposition({ type: "compositionupdate", data: "\u306E" });
michael@0 2892 synthesizeText(
michael@0 2893 { "composition":
michael@0 2894 { "string": "\u306E",
michael@0 2895 "clauses":
michael@0 2896 [
michael@0 2897 { "length": 1, "attr": COMPOSITION_ATTR_RAWINPUT }
michael@0 2898 ]
michael@0 2899 },
michael@0 2900 "caret": { "start": 1, "length": 0 }
michael@0 2901 });
michael@0 2902
michael@0 2903 var nextSibling = textarea.nextSibling;
michael@0 2904 var parent = textarea.parentElement;
michael@0 2905
michael@0 2906 events = [];
michael@0 2907 parent.removeChild(textarea);
michael@0 2908
michael@0 2909 hitEventLoop(function () {
michael@0 2910 // XXX Currently, "input" event isn't fired on removed content.
michael@0 2911 is(events.length, 3,
michael@0 2912 "runRemoveContentTest: wrong event count #1");
michael@0 2913 is(events[0].type, "compositionupdate",
michael@0 2914 "runRemoveContentTest: the 1st event must be compositionupdate #1");
michael@0 2915 is(events[1].type, "text",
michael@0 2916 "runRemoveContentTest: the 2nd event must be text #1");
michael@0 2917 is(events[2].type, "compositionend",
michael@0 2918 "runRemoveContentTest: the 3rd event must be compositionend #1");
michael@0 2919 is(events[0].data, "",
michael@0 2920 "runRemoveContentTest: compositionupdate has wrong data #1");
michael@0 2921 is(events[2].data, "",
michael@0 2922 "runRemoveContentTest: compositionend has wrong data #1");
michael@0 2923 is(events[0].target, textarea,
michael@0 2924 "runRemoveContentTest: The 1st event was fired on wrong event target #1");
michael@0 2925 is(events[1].target, textarea,
michael@0 2926 "runRemoveContentTest: The 2nd event was fired on wrong event target #1");
michael@0 2927 is(events[2].target, textarea,
michael@0 2928 "runRemoveContentTest: The 3rd event was fired on wrong event target #1");
michael@0 2929 ok(!getEditorIMESupport(textarea).isComposing,
michael@0 2930 "runRemoveContentTest: the textarea still has composition #1");
michael@0 2931 todo_is(textarea.value, "",
michael@0 2932 "runRemoveContentTest: the textarea has the committed text? #1");
michael@0 2933
michael@0 2934 parent.insertBefore(textarea, nextSibling);
michael@0 2935
michael@0 2936 textarea.focus();
michael@0 2937 textarea.value = "";
michael@0 2938
michael@0 2939 synthesizeComposition({ type: "compositionstart" });
michael@0 2940
michael@0 2941 events = [];
michael@0 2942 parent.removeChild(textarea);
michael@0 2943
michael@0 2944 hitEventLoop(function () {
michael@0 2945 // XXX Currently, "input" event isn't fired on removed content.
michael@0 2946 is(events.length, 1,
michael@0 2947 "runRemoveContentTest: wrong event count #2");
michael@0 2948 is(events[0].type, "compositionend",
michael@0 2949 "runRemoveContentTest: the 1st event must be compositionend #2");
michael@0 2950 is(events[0].data, "",
michael@0 2951 "runRemoveContentTest: compositionupdate has wrong data #2");
michael@0 2952 is(events[0].target, textarea,
michael@0 2953 "runRemoveContentTest: The 1st event was fired on wrong event target #2");
michael@0 2954 ok(!getEditorIMESupport(textarea).isComposing,
michael@0 2955 "runRemoveContentTest: the textarea still has composition #2");
michael@0 2956 is(textarea.value, "",
michael@0 2957 "runRemoveContentTest: the textarea has the committed text? #2");
michael@0 2958
michael@0 2959 parent.insertBefore(textarea, nextSibling);
michael@0 2960
michael@0 2961 textarea.removeEventListener("compositionstart", eventHandler, true);
michael@0 2962 textarea.removeEventListener("compositionupdate", eventHandler, true);
michael@0 2963 textarea.removeEventListener("compositionend", eventHandler, true);
michael@0 2964 textarea.removeEventListener("input", eventHandler, true);
michael@0 2965 textarea.removeEventListener("text", eventHandler, true);
michael@0 2966
michael@0 2967 SimpleTest.executeSoon(aCallback);
michael@0 2968 }, 50);
michael@0 2969 }, 50);
michael@0 2970 }
michael@0 2971
michael@0 2972 function runTestOnAnotherContext(aPanelOrFrame, aFocusedEditor, aTestName)
michael@0 2973 {
michael@0 2974 aFocusedEditor.value = "";
michael@0 2975
michael@0 2976 var editorRect = synthesizeQueryEditorRect();
michael@0 2977 if (!checkQueryContentResult(editorRect, aTestName + ": editorRect")) {
michael@0 2978 return;
michael@0 2979 }
michael@0 2980
michael@0 2981 var r = aPanelOrFrame.getBoundingClientRect();
michael@0 2982 var parentRect = { "left": r.left, "top": r.top, "width": r.right - r.left,
michael@0 2983 "height": r.bottom - r.top };
michael@0 2984 checkRectContainsRect(editorRect, parentRect, aTestName +
michael@0 2985 ": the editor rect coordinates are wrong");
michael@0 2986
michael@0 2987 // start composition
michael@0 2988 synthesizeComposition({ type: "compositionstart" });
michael@0 2989
michael@0 2990 // input characters
michael@0 2991 synthesizeComposition({ type: "compositionupdate",
michael@0 2992 data: "\u3078\u3093\u3057\u3093" });
michael@0 2993 synthesizeText(
michael@0 2994 { "composition":
michael@0 2995 { "string": "\u3078\u3093\u3057\u3093",
michael@0 2996 "clauses":
michael@0 2997 [
michael@0 2998 { "length": 4, "attr": COMPOSITION_ATTR_RAWINPUT }
michael@0 2999 ]
michael@0 3000 },
michael@0 3001 "caret": { "start": 4, "length": 0 }
michael@0 3002 });
michael@0 3003
michael@0 3004 if (!checkContent("\u3078\u3093\u3057\u3093", aTestName, "#1-1") ||
michael@0 3005 !checkSelection(4, "", aTestName, "#1-1")) {
michael@0 3006 return;
michael@0 3007 }
michael@0 3008
michael@0 3009 // convert them #1
michael@0 3010 synthesizeComposition({ type: "compositionupdate", data: "\u8FD4\u4FE1" });
michael@0 3011 synthesizeText(
michael@0 3012 { "composition":
michael@0 3013 { "string": "\u8FD4\u4FE1",
michael@0 3014 "clauses":
michael@0 3015 [
michael@0 3016 { "length": 2,
michael@0 3017 "attr": COMPOSITION_ATTR_SELECTEDCONVERTEDTEXT }
michael@0 3018 ]
michael@0 3019 },
michael@0 3020 "caret": { "start": 2, "length": 0 }
michael@0 3021 });
michael@0 3022
michael@0 3023 if (!checkContent("\u8FD4\u4FE1", aTestName, "#1-2") ||
michael@0 3024 !checkSelection(2, "", aTestName, "#1-2")) {
michael@0 3025 return;
michael@0 3026 }
michael@0 3027
michael@0 3028 // convert them #2
michael@0 3029 synthesizeComposition({ type: "compositionupdate", data: "\u5909\u8EAB" });
michael@0 3030 synthesizeText(
michael@0 3031 { "composition":
michael@0 3032 { "string": "\u5909\u8EAB",
michael@0 3033 "clauses":
michael@0 3034 [
michael@0 3035 { "length": 2,
michael@0 3036 "attr": COMPOSITION_ATTR_SELECTEDCONVERTEDTEXT }
michael@0 3037 ]
michael@0 3038 },
michael@0 3039 "caret": { "start": 2, "length": 0 }
michael@0 3040 });
michael@0 3041
michael@0 3042 if (!checkContent("\u5909\u8EAB", aTestName, "#1-3") ||
michael@0 3043 !checkSelection(2, "", aTestName, "#1-3")) {
michael@0 3044 return;
michael@0 3045 }
michael@0 3046
michael@0 3047 // commit them
michael@0 3048 synthesizeText(
michael@0 3049 { "composition":
michael@0 3050 { "string": "\u5909\u8EAB",
michael@0 3051 "clauses":
michael@0 3052 [
michael@0 3053 { "length": 0, "attr": 0 }
michael@0 3054 ]
michael@0 3055 },
michael@0 3056 "caret": { "start": 2, "length": 0 }
michael@0 3057 });
michael@0 3058
michael@0 3059 if (!checkContent("\u5909\u8EAB", aTestName, "#1-4") ||
michael@0 3060 !checkSelection(2, "", aTestName, "#1-4")) {
michael@0 3061 return;
michael@0 3062 }
michael@0 3063
michael@0 3064 synthesizeComposition({ type: "compositionend", data: "\u5909\u8EAB" });
michael@0 3065
michael@0 3066 is(aFocusedEditor.value, "\u5909\u8EAB",
michael@0 3067 aTestName + ": composition isn't in the focused editor");
michael@0 3068 if (aFocusedEditor.value != "\u5909\u8EAB") {
michael@0 3069 return;
michael@0 3070 }
michael@0 3071
michael@0 3072 var textRect = synthesizeQueryTextRect(0, 1);
michael@0 3073 var caretRect = synthesizeQueryCaretRect(2);
michael@0 3074 if (!checkQueryContentResult(textRect,
michael@0 3075 aTestName + ": synthesizeQueryTextRect") ||
michael@0 3076 !checkQueryContentResult(caretRect,
michael@0 3077 aTestName + ": synthesizeQueryCaretRect")) {
michael@0 3078 return;
michael@0 3079 }
michael@0 3080 checkRectContainsRect(textRect, editorRect, aTestName + ":testRect");
michael@0 3081 checkRectContainsRect(caretRect, editorRect, aTestName + ":caretRect");
michael@0 3082 }
michael@0 3083
michael@0 3084 function runFrameTest()
michael@0 3085 {
michael@0 3086 textareaInFrame.focus();
michael@0 3087 runTestOnAnotherContext(iframe, textareaInFrame, "runFrameTest");
michael@0 3088 runCharAtPointTest(textareaInFrame, "textarea in the iframe");
michael@0 3089 }
michael@0 3090
michael@0 3091 var gPanelShown = false;
michael@0 3092 var gPanelFocused = false;
michael@0 3093 function onPanelShown(aEvent)
michael@0 3094 {
michael@0 3095 gPanelShown = true;
michael@0 3096 textbox.focus();
michael@0 3097 setTimeout(doPanelTest, 0);
michael@0 3098 }
michael@0 3099
michael@0 3100 function onFocusPanelTextbox(aEvent)
michael@0 3101 {
michael@0 3102 gPanelFocused = true;
michael@0 3103 setTimeout(doPanelTest, 0);
michael@0 3104 }
michael@0 3105
michael@0 3106 var gIsPanelHiding = false;
michael@0 3107 var gIsRunPanelTestInternal = false;
michael@0 3108 function doPanelTest()
michael@0 3109 {
michael@0 3110 if (!gPanelFocused || !gPanelShown) {
michael@0 3111 return;
michael@0 3112 }
michael@0 3113 if (gIsRunPanelTestInternal) {
michael@0 3114 return;
michael@0 3115 }
michael@0 3116 gIsRunPanelTestInternal = true;
michael@0 3117 runTestOnAnotherContext(panel, textbox, "runPanelTest");
michael@0 3118 runCharAtPointTest(textbox, "textbox in the panel");
michael@0 3119 gIsPanelHiding = true;
michael@0 3120 panel.hidePopup();
michael@0 3121 }
michael@0 3122
michael@0 3123 function onPanelHidden(aEvent)
michael@0 3124 {
michael@0 3125 panel.hidden = true;
michael@0 3126 ok(gIsPanelHiding, "runPanelTest: the panel is hidden unexpectedly");
michael@0 3127 finish();
michael@0 3128 }
michael@0 3129
michael@0 3130 function runPanelTest()
michael@0 3131 {
michael@0 3132 panel.hidden = false;
michael@0 3133 panel.openPopupAtScreen(window.screenX + window.outerWidth, 0, false);
michael@0 3134 }
michael@0 3135
michael@0 3136 function runMaxLengthTest()
michael@0 3137 {
michael@0 3138 input.maxLength = 1;
michael@0 3139 input.value = "";
michael@0 3140 input.focus();
michael@0 3141
michael@0 3142 var kDesc ="runMaxLengthTest";
michael@0 3143
michael@0 3144 // start composition
michael@0 3145 synthesizeComposition({ type: "compositionstart" });
michael@0 3146
michael@0 3147 // input first character
michael@0 3148 synthesizeComposition({ type: "compositionupdate", data: "\u3089" });
michael@0 3149 synthesizeText(
michael@0 3150 { "composition":
michael@0 3151 { "string": "\u3089",
michael@0 3152 "clauses":
michael@0 3153 [
michael@0 3154 { "length": 1, "attr": COMPOSITION_ATTR_RAWINPUT }
michael@0 3155 ]
michael@0 3156 },
michael@0 3157 "caret": { "start": 1, "length": 0 }
michael@0 3158 });
michael@0 3159
michael@0 3160 if (!checkContent("\u3089", kDesc, "#1-1") ||
michael@0 3161 !checkSelection(1, "", kDesc, "#1-1")) {
michael@0 3162 return;
michael@0 3163 }
michael@0 3164
michael@0 3165 // input second character
michael@0 3166 synthesizeComposition({ type: "compositionupdate", data: "\u3089\u30FC" });
michael@0 3167 synthesizeText(
michael@0 3168 { "composition":
michael@0 3169 { "string": "\u3089\u30FC",
michael@0 3170 "clauses":
michael@0 3171 [
michael@0 3172 { "length": 2, "attr": COMPOSITION_ATTR_RAWINPUT }
michael@0 3173 ]
michael@0 3174 },
michael@0 3175 "caret": { "start": 2, "length": 0 }
michael@0 3176 });
michael@0 3177
michael@0 3178 if (!checkContent("\u3089\u30FC", kDesc, "#1-2") ||
michael@0 3179 !checkSelection(2, "", kDesc, "#1-2")) {
michael@0 3180 return;
michael@0 3181 }
michael@0 3182
michael@0 3183 // input third character
michael@0 3184 synthesizeComposition({ type: "compositionupdate",
michael@0 3185 data: "\u3089\u30FC\u3081" });
michael@0 3186 synthesizeText(
michael@0 3187 { "composition":
michael@0 3188 { "string": "\u3089\u30FC\u3081",
michael@0 3189 "clauses":
michael@0 3190 [
michael@0 3191 { "length": 3, "attr": COMPOSITION_ATTR_RAWINPUT }
michael@0 3192 ]
michael@0 3193 },
michael@0 3194 "caret": { "start": 3, "length": 0 }
michael@0 3195 });
michael@0 3196
michael@0 3197 if (!checkContent("\u3089\u30FC\u3081", kDesc, "#1-3") ||
michael@0 3198 !checkSelection(3, "", kDesc, "#1-3")) {
michael@0 3199 return;
michael@0 3200 }
michael@0 3201
michael@0 3202 // input fourth character
michael@0 3203 synthesizeComposition({ type: "compositionupdate",
michael@0 3204 data: "\u3089\u30FC\u3081\u3093" });
michael@0 3205 synthesizeText(
michael@0 3206 { "composition":
michael@0 3207 { "string": "\u3089\u30FC\u3081\u3093",
michael@0 3208 "clauses":
michael@0 3209 [
michael@0 3210 { "length": 4, "attr": COMPOSITION_ATTR_RAWINPUT }
michael@0 3211 ]
michael@0 3212 },
michael@0 3213 "caret": { "start": 4, "length": 0 }
michael@0 3214 });
michael@0 3215
michael@0 3216 if (!checkContent("\u3089\u30FC\u3081\u3093", kDesc, "#1-4") ||
michael@0 3217 !checkSelection(4, "", kDesc, "#1-4")) {
michael@0 3218 return;
michael@0 3219 }
michael@0 3220
michael@0 3221
michael@0 3222 // backspace
michael@0 3223 synthesizeComposition({ type: "compositionupdate",
michael@0 3224 data: "\u3089\u30FC\u3081" });
michael@0 3225 synthesizeText(
michael@0 3226 { "composition":
michael@0 3227 { "string": "\u3089\u30FC\u3081",
michael@0 3228 "clauses":
michael@0 3229 [
michael@0 3230 { "length": 3, "attr": COMPOSITION_ATTR_RAWINPUT }
michael@0 3231 ]
michael@0 3232 },
michael@0 3233 "caret": { "start": 3, "length": 0 }
michael@0 3234 });
michael@0 3235
michael@0 3236 if (!checkContent("\u3089\u30FC\u3081", kDesc, "#1-5") ||
michael@0 3237 !checkSelection(3, "", kDesc, "#1-5")) {
michael@0 3238 return;
michael@0 3239 }
michael@0 3240
michael@0 3241 // re-input
michael@0 3242 synthesizeComposition({ type: "compositionupdate",
michael@0 3243 data: "\u3089\u30FC\u3081\u3093" });
michael@0 3244 synthesizeText(
michael@0 3245 { "composition":
michael@0 3246 { "string": "\u3089\u30FC\u3081\u3093",
michael@0 3247 "clauses":
michael@0 3248 [
michael@0 3249 { "length": 4, "attr": COMPOSITION_ATTR_RAWINPUT }
michael@0 3250 ]
michael@0 3251 },
michael@0 3252 "caret": { "start": 4, "length": 0 }
michael@0 3253 });
michael@0 3254
michael@0 3255 if (!checkContent("\u3089\u30FC\u3081\u3093", kDesc, "#1-6") ||
michael@0 3256 !checkSelection(4, "", kDesc, "#1-6")) {
michael@0 3257 return;
michael@0 3258 }
michael@0 3259
michael@0 3260 synthesizeComposition({ type: "compositionupdate",
michael@0 3261 data: "\u3089\u30FC\u3081\u3093\u3055" });
michael@0 3262 synthesizeText(
michael@0 3263 { "composition":
michael@0 3264 { "string": "\u3089\u30FC\u3081\u3093\u3055",
michael@0 3265 "clauses":
michael@0 3266 [
michael@0 3267 { "length": 5, "attr": COMPOSITION_ATTR_RAWINPUT }
michael@0 3268 ]
michael@0 3269 },
michael@0 3270 "caret": { "start": 5, "length": 0 }
michael@0 3271 });
michael@0 3272
michael@0 3273 if (!checkContent("\u3089\u30FC\u3081\u3093\u3055", kDesc, "#1-7") ||
michael@0 3274 !checkSelection(5, "", kDesc, "#1-7")) {
michael@0 3275 return;
michael@0 3276 }
michael@0 3277
michael@0 3278 synthesizeComposition({ type: "compositionupdate",
michael@0 3279 data: "\u3089\u30FC\u3081\u3093\u3055\u3044" });
michael@0 3280 synthesizeText(
michael@0 3281 { "composition":
michael@0 3282 { "string": "\u3089\u30FC\u3081\u3093\u3055\u3044",
michael@0 3283 "clauses":
michael@0 3284 [
michael@0 3285 { "length": 6, "attr": COMPOSITION_ATTR_RAWINPUT }
michael@0 3286 ]
michael@0 3287 },
michael@0 3288 "caret": { "start": 6, "length": 0 }
michael@0 3289 });
michael@0 3290
michael@0 3291 if (!checkContent("\u3089\u30FC\u3081\u3093\u3055\u3044", kDesc, "#1-8") ||
michael@0 3292 !checkSelection(6, "", kDesc, "#1-8")) {
michael@0 3293 return;
michael@0 3294 }
michael@0 3295
michael@0 3296 synthesizeComposition({ type: "compositionupdate",
michael@0 3297 data: "\u3089\u30FC\u3081\u3093\u3055\u3044\u3053" });
michael@0 3298 synthesizeText(
michael@0 3299 { "composition":
michael@0 3300 { "string": "\u3089\u30FC\u3081\u3093\u3055\u3044\u3053",
michael@0 3301 "clauses":
michael@0 3302 [
michael@0 3303 { "length": 7, "attr": COMPOSITION_ATTR_RAWINPUT }
michael@0 3304 ]
michael@0 3305 },
michael@0 3306 "caret": { "start": 7, "length": 0 }
michael@0 3307 });
michael@0 3308
michael@0 3309 if (!checkContent("\u3089\u30FC\u3081\u3093\u3055\u3044\u3053",
michael@0 3310 kDesc, "#1-8") ||
michael@0 3311 !checkSelection(7, "", kDesc, "#1-8")) {
michael@0 3312 return;
michael@0 3313 }
michael@0 3314
michael@0 3315 synthesizeComposition({ type: "compositionupdate",
michael@0 3316 data: "\u3089\u30FC\u3081\u3093\u3055\u3044\u3053\u3046" });
michael@0 3317 synthesizeText(
michael@0 3318 { "composition":
michael@0 3319 { "string": "\u3089\u30FC\u3081\u3093\u3055\u3044\u3053\u3046",
michael@0 3320 "clauses":
michael@0 3321 [
michael@0 3322 { "length": 8, "attr": COMPOSITION_ATTR_RAWINPUT }
michael@0 3323 ]
michael@0 3324 },
michael@0 3325 "caret": { "start": 8, "length": 0 }
michael@0 3326 });
michael@0 3327
michael@0 3328 if (!checkContent("\u3089\u30FC\u3081\u3093\u3055\u3044\u3053\u3046",
michael@0 3329 kDesc, "#1-9") ||
michael@0 3330 !checkSelection(8, "", kDesc, "#1-9")) {
michael@0 3331 return;
michael@0 3332 }
michael@0 3333
michael@0 3334 // convert
michael@0 3335 synthesizeComposition({ type: "compositionupdate",
michael@0 3336 data: "\u30E9\u30FC\u30E1\u30F3\u6700\u9AD8" });
michael@0 3337 synthesizeText(
michael@0 3338 { "composition":
michael@0 3339 { "string": "\u30E9\u30FC\u30E1\u30F3\u6700\u9AD8",
michael@0 3340 "clauses":
michael@0 3341 [
michael@0 3342 { "length": 4,
michael@0 3343 "attr": COMPOSITION_ATTR_SELECTEDCONVERTEDTEXT },
michael@0 3344 { "length": 2,
michael@0 3345 "attr": COMPOSITION_ATTR_CONVERTEDTEXT }
michael@0 3346 ]
michael@0 3347 },
michael@0 3348 "caret": { "start": 4, "length": 0 }
michael@0 3349 });
michael@0 3350
michael@0 3351 if (!checkContent("\u30E9\u30FC\u30E1\u30F3\u6700\u9AD8", kDesc, "#1-10") ||
michael@0 3352 !checkSelection(4, "", kDesc, "#1-10")) {
michael@0 3353 return;
michael@0 3354 }
michael@0 3355
michael@0 3356 // commit the composition string
michael@0 3357 synthesizeText(
michael@0 3358 { "composition":
michael@0 3359 { "string": "\u30E9\u30FC\u30E1\u30F3\u6700\u9AD8",
michael@0 3360 "clauses":
michael@0 3361 [
michael@0 3362 { "length": 0, "attr": 0 }
michael@0 3363 ]
michael@0 3364 },
michael@0 3365 "caret": { "start": 6, "length": 0 }
michael@0 3366 });
michael@0 3367
michael@0 3368 if (!checkContent("\u30E9", kDesc, "#1-11") ||
michael@0 3369 !checkSelection(1, "", kDesc, "#1-11")) {
michael@0 3370 return;
michael@0 3371 }
michael@0 3372
michael@0 3373 synthesizeComposition({ type: "compositionend",
michael@0 3374 data: "\u30E9\u30FC\u30E1\u30F3\u6700\u9AD8" });
michael@0 3375
michael@0 3376 // restart composition
michael@0 3377 synthesizeComposition({ type: "compositionstart" });
michael@0 3378
michael@0 3379 // input characters
michael@0 3380 synthesizeComposition({ type: "compositionupdate", data: "\u3057" });
michael@0 3381 synthesizeText(
michael@0 3382 { "composition":
michael@0 3383 { "string": "\u3057",
michael@0 3384 "clauses":
michael@0 3385 [
michael@0 3386 { "length": 1, "attr": COMPOSITION_ATTR_RAWINPUT }
michael@0 3387 ]
michael@0 3388 },
michael@0 3389 "caret": { "start": 1, "length": 0 }
michael@0 3390 });
michael@0 3391
michael@0 3392 if (!checkContent("\u30E9\u3057", kDesc, "#2-1") ||
michael@0 3393 !checkSelection(1 + 1, "", kDesc, "#2-1")) {
michael@0 3394 return;
michael@0 3395 }
michael@0 3396
michael@0 3397 // commit the composition string
michael@0 3398 synthesizeComposition({ type: "compositionupdate", data: "\u3058" });
michael@0 3399 synthesizeText(
michael@0 3400 { "composition":
michael@0 3401 { "string": "\u3058",
michael@0 3402 "clauses":
michael@0 3403 [
michael@0 3404 { "length": 0, "attr": 0 }
michael@0 3405 ]
michael@0 3406 },
michael@0 3407 "caret": { "start": 1, "length": 0 }
michael@0 3408 });
michael@0 3409
michael@0 3410 if (!checkContent("\u30E9", kDesc, "#2-2") ||
michael@0 3411 !checkSelection(1 + 0, "", kDesc, "#2-2")) {
michael@0 3412 return;
michael@0 3413 }
michael@0 3414
michael@0 3415 synthesizeComposition({ type: "compositionend", data: "\u3058" });
michael@0 3416
michael@0 3417 // Undo
michael@0 3418 synthesizeKey("Z", {accelKey: true});
michael@0 3419
michael@0 3420 // XXX this is unexpected behavior, see bug 258291
michael@0 3421 if (!checkContent("\u30E9", kDesc, "#3-1") ||
michael@0 3422 !checkSelection(1 + 0, "", kDesc, "#3-1")) {
michael@0 3423 return;
michael@0 3424 }
michael@0 3425
michael@0 3426 // Undo
michael@0 3427 synthesizeKey("Z", {accelKey: true});
michael@0 3428 if (!checkContent("", kDesc, "#3-2") ||
michael@0 3429 !checkSelection(0, "", kDesc, "#3-2")) {
michael@0 3430 return;
michael@0 3431 }
michael@0 3432
michael@0 3433 // Redo
michael@0 3434 synthesizeKey("Z", {accelKey: true, shiftKey: true});
michael@0 3435 if (!checkContent("\u30E9", kDesc, "#3-3") ||
michael@0 3436 !checkSelection(1, "", kDesc, "#3-3")) {
michael@0 3437 return;
michael@0 3438 }
michael@0 3439
michael@0 3440 // Redo
michael@0 3441 synthesizeKey("Z", {accelKey: true, shiftKey: true});
michael@0 3442 if (!checkContent("\u30E9", kDesc, "#3-4") ||
michael@0 3443 !checkSelection(1 + 0, "", kDesc, "#3-4")) {
michael@0 3444 return;
michael@0 3445 }
michael@0 3446 }
michael@0 3447
michael@0 3448 function runTest()
michael@0 3449 {
michael@0 3450 textareaInFrame = iframe.contentDocument.getElementById("textarea");
michael@0 3451
michael@0 3452 runUndoRedoTest();
michael@0 3453 runCompositionTest();
michael@0 3454 runCompositionEventTest();
michael@0 3455 runCharAtPointTest(textarea, "textarea in the document");
michael@0 3456 runCharAtPointAtOutsideTest();
michael@0 3457 runBug722639Test();
michael@0 3458 runForceCommitTest();
michael@0 3459 runBug811755Test();
michael@0 3460 runIsComposingTest();
michael@0 3461 runRemoveContentTest(function () {
michael@0 3462 runFrameTest();
michael@0 3463 runPanelTest();
michael@0 3464 runMaxLengthTest();
michael@0 3465 });
michael@0 3466 }
michael@0 3467
michael@0 3468 ]]>
michael@0 3469 </script>
michael@0 3470
michael@0 3471 </window>

mercurial