Bug 1772588 [wpt PR 34302] - [wpt] Add test for block-in-inline offsetParent., a...
[gecko.git] / editor / libeditor / tests / test_bug697842.html
blob5b39abbace364fa71b73f9174333f919ef09193f
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 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" />
12 </head>
13 <body>
14 <div id="display">
15 <p id="editor" contenteditable style="min-height: 1.5em;"></p>
16 </div>
17 <div id="content" style="display: none">
19 </div>
20 <pre id="test">
21 </pre>
23 <script class="testbody" type="application/javascript">
25 /** Test for Bug 697842 **/
26 SimpleTest.waitForExplicitFinish();
27 SimpleTest.waitForFocus(runTests);
29 function runTests() {
30 var editor = document.getElementById("editor");
31 editor.focus();
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");
41 break;
42 case "compositionupdate":
43 case "compositionend":
44 is(aEvent.data, composingString, "mismatch composition string");
45 break;
46 default:
47 break;
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(
60 { "composition":
61 { "string": composingString,
62 "clauses":
64 { "length": 1, "attr": COMPOSITION_ATTR_RAW_CLAUSE },
67 "caret": { "start": 1, "length": 0 },
68 });
70 // input second character
71 composingString = "\u306B\u3085";
72 synthesizeCompositionChange(
73 { "composition":
74 { "string": composingString,
75 "clauses":
77 { "length": 2, "attr": COMPOSITION_ATTR_RAW_CLAUSE },
80 "caret": { "start": 2, "length": 0 },
81 });
83 // convert them
84 synthesizeCompositionChange(
85 { "composition":
86 { "string": composingString,
87 "clauses":
89 { "length": 2,
90 "attr": COMPOSITION_ATTR_SELECTED_CLAUSE },
93 "caret": { "start": 2, "length": 0 },
94 });
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);
106 SimpleTest.finish();
111 </script>
112 </body>
114 </html>