|
1 <!DOCTYPE> |
|
2 <html> |
|
3 <!-- |
|
4 https://bugzilla.mozilla.org/show_bug.cgi?id=697842 |
|
5 --> |
|
6 <head> |
|
7 <title>Test for Bug 697842</title> |
|
8 <script type="application/javascript" src="/MochiKit/packed.js"></script> |
|
9 <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
|
10 <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script> |
|
11 <link rel="stylesheet" type="text/css" |
|
12 href="chrome://mochikit/content/tests/SimpleTest/test.css" /> |
|
13 </head> |
|
14 <body> |
|
15 <div id="display"> |
|
16 <p id="editor" contenteditable style="min-height: 1.5em;"></p> |
|
17 </div> |
|
18 <div id="content" style="display: none"> |
|
19 |
|
20 </div> |
|
21 <pre id="test"> |
|
22 </pre> |
|
23 |
|
24 <script class="testbody" type="application/javascript"> |
|
25 |
|
26 /** Test for Bug 697842 **/ |
|
27 SimpleTest.waitForExplicitFinish(); |
|
28 SimpleTest.waitForFocus(runTests); |
|
29 |
|
30 function runTests() |
|
31 { |
|
32 var editor = document.getElementById("editor"); |
|
33 editor.focus(); |
|
34 |
|
35 SimpleTest.executeSoon(function() { |
|
36 var composingString = ""; |
|
37 |
|
38 function handler(aEvent) { |
|
39 if (aEvent.type != "text") { |
|
40 is(aEvent.data, composingString, "mismatch composition string"); |
|
41 } |
|
42 aEvent.stopPropagation(); |
|
43 aEvent.preventDefault(); |
|
44 } |
|
45 |
|
46 editor.addEventListener("compositionstart", handler, true); |
|
47 editor.addEventListener("compositionend", handler, true); |
|
48 editor.addEventListener("compositionupdate", handler, true); |
|
49 editor.addEventListener("text", handler, true); |
|
50 |
|
51 // start composition |
|
52 synthesizeComposition({ type: "compositionstart" }); |
|
53 |
|
54 // input first character |
|
55 composingString = "\u306B"; |
|
56 synthesizeComposition({ type: "compositionupdate", data: composingString }); |
|
57 synthesizeText( |
|
58 { "composition": |
|
59 { "string": composingString, |
|
60 "clauses": |
|
61 [ |
|
62 { "length": 1, "attr": COMPOSITION_ATTR_RAWINPUT } |
|
63 ] |
|
64 }, |
|
65 "caret": { "start": 1, "length": 0 } |
|
66 }); |
|
67 |
|
68 // input second character |
|
69 composingString = "\u306B\u3085"; |
|
70 synthesizeComposition({ type: "compositionupdate", data: composingString }); |
|
71 synthesizeText( |
|
72 { "composition": |
|
73 { "string": composingString, |
|
74 "clauses": |
|
75 [ |
|
76 { "length": 2, "attr": COMPOSITION_ATTR_RAWINPUT } |
|
77 ] |
|
78 }, |
|
79 "caret": { "start": 2, "length": 0 } |
|
80 }); |
|
81 |
|
82 // convert them |
|
83 synthesizeText( |
|
84 { "composition": |
|
85 { "string": composingString, |
|
86 "clauses": |
|
87 [ |
|
88 { "length": 2, |
|
89 "attr": COMPOSITION_ATTR_SELECTEDCONVERTEDTEXT } |
|
90 ] |
|
91 }, |
|
92 "caret": { "start": 2, "length": 0 } |
|
93 }); |
|
94 |
|
95 // commit |
|
96 synthesizeText( |
|
97 { "composition": |
|
98 { "string": composingString, |
|
99 "clauses": |
|
100 [ |
|
101 { "length": 0, "attr": 0 } |
|
102 ] |
|
103 }, |
|
104 "caret": { "start": 2, "length": 0 } |
|
105 }); |
|
106 |
|
107 synthesizeComposition({ type: "compositionend", data: composingString }); |
|
108 |
|
109 is(editor.innerHTML, composingString, |
|
110 "editor has unexpected result"); |
|
111 |
|
112 editor.removeEventListener("compositionstart", handler, true); |
|
113 editor.removeEventListener("compositionend", handler, true); |
|
114 editor.removeEventListener("compositionupdate", handler, true); |
|
115 editor.removeEventListener("text", handler, true); |
|
116 |
|
117 SimpleTest.finish(); |
|
118 }); |
|
119 } |
|
120 |
|
121 |
|
122 </script> |
|
123 </body> |
|
124 |
|
125 </html> |