4 https://bugzilla.mozilla.org/show_bug.cgi?id=697842
7 <title>Test for Bug
697842</title>
8 <script src=
"/tests/SimpleTest/SimpleTest.js"></script>
9 <script src=
"/tests/SimpleTest/EventUtils.js"></script>
10 <link rel=
"stylesheet" type=
"text/css"
11 href=
"chrome://mochikit/content/tests/SimpleTest/test.css" />
15 <p id=
"editor" contenteditable
style=
"min-height: 1.5em;"></p>
17 <div id=
"content" style=
"display: none">
23 <script class=
"testbody" type=
"application/javascript">
25 /** Test for Bug
697842 **/
26 SimpleTest.waitForExplicitFinish();
27 SimpleTest.waitForFocus(runTests);
30 var editor = document.getElementById(
"editor");
33 SimpleTest.executeSoon(function() {
34 var composingString =
"";
36 function handler(aEvent) {
37 switch (aEvent.type) {
38 case
"compositionstart":
39 // Selected string at starting composition must be empty in this test.
40 is(aEvent.data,
"",
"mismatch selected string");
42 case
"compositionupdate":
43 case
"compositionend":
44 is(aEvent.data, composingString,
"mismatch composition string");
49 aEvent.stopPropagation();
50 aEvent.preventDefault();
53 editor.addEventListener(
"compositionstart", handler, true);
54 editor.addEventListener(
"compositionend", handler, true);
55 editor.addEventListener(
"compositionupdate", handler, true);
57 // input first character
58 composingString =
"\u306B";
59 synthesizeCompositionChange(
61 {
"string": composingString,
64 {
"length":
1,
"attr": COMPOSITION_ATTR_RAW_CLAUSE },
67 "caret": {
"start":
1,
"length":
0 },
70 // input second character
71 composingString =
"\u306B\u3085";
72 synthesizeCompositionChange(
74 {
"string": composingString,
77 {
"length":
2,
"attr": COMPOSITION_ATTR_RAW_CLAUSE },
80 "caret": {
"start":
2,
"length":
0 },
84 synthesizeCompositionChange(
86 {
"string": composingString,
90 "attr": COMPOSITION_ATTR_SELECTED_CLAUSE },
93 "caret": {
"start":
2,
"length":
0 },
96 synthesizeComposition({ type:
"compositioncommitasis" });
98 is(editor.innerHTML, composingString,
99 "editor has unexpected result");
101 editor.removeEventListener(
"compositionstart", handler, true);
102 editor.removeEventListener(
"compositionend", handler, true);
103 editor.removeEventListener(
"compositionupdate", handler, true);
104 editor.removeEventListener(
"text", handler, true);