Bug 1874684 - Part 17: Fix uninitialised variable warnings from clang-tidy. r=allstarschh
[gecko.git] / editor / libeditor / tests / test_composition_event_created_in_chrome.html
blob11b24d3bc1fa473a4921db55e290b2fb7d6f8cf9
1 <!doctype html>
2 <html>
4 <head>
5 <link rel="stylesheet" href="/tests/SimpleTest/test.css">
7 <script src="/tests/SimpleTest/SimpleTest.js"></script>
8 <script src="/tests/SimpleTest/EventUtils.js"></script>
9 </head>
11 <body>
13 <input id="input">
15 <script type="application/javascript">
17 // In nsEditorEventListener, when listening event is not created with proper
18 // event interface, it asserts the fact.
19 SimpleTest.waitForExplicitFinish();
21 var gInputElement = document.getElementById("input");
23 function getEditor(aInputElement) {
24 var editableElement = SpecialPowers.wrap(aInputElement);
25 ok(editableElement.editor, "There is no editor for the input element");
26 return editableElement.editor;
29 var gEditor;
31 function testNotGenerateCompositionByCreatedEvents(aEventInterface) {
32 var compositionEvent = document.createEvent(aEventInterface);
33 if (compositionEvent.initCompositionEvent) {
34 compositionEvent.initCompositionEvent("compositionstart", true, true, window, "", "");
35 } else if (compositionEvent.initMouseEvent) {
36 compositionEvent.initMouseEvent("compositionstart", true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
38 gInputElement.dispatchEvent(compositionEvent);
39 ok(!gEditor.composing, "Composition shouldn't be started with a created compositionstart event (" + aEventInterface + ")");
41 compositionEvent = document.createEvent(aEventInterface);
42 if (compositionEvent.initCompositionEvent) {
43 compositionEvent.initCompositionEvent("compositionupdate", true, false, window, "abc", "");
44 } else if (compositionEvent.initMouseEvent) {
45 compositionEvent.initMouseEvent("compositionupdate", true, false, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
47 gInputElement.dispatchEvent(compositionEvent);
48 ok(!gEditor.composing, "Composition shouldn't be started with a created compositionupdate event (" + aEventInterface + ")");
49 is(gInputElement.value, "", "Input element shouldn't be modified with a created compositionupdate event (" + aEventInterface + ")");
51 compositionEvent = document.createEvent(aEventInterface);
52 if (compositionEvent.initCompositionEvent) {
53 compositionEvent.initCompositionEvent("compositionend", true, false, window, "abc", "");
54 } else if (compositionEvent.initMouseEvent) {
55 compositionEvent.initMouseEvent("compositionend", true, false, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
57 gInputElement.dispatchEvent(compositionEvent);
58 ok(!gEditor.composing, "Composition shouldn't be committed with a created compositionend event (" + aEventInterface + ")");
59 is(gInputElement.value, "", "Input element shouldn't be committed with a created compositionend event (" + aEventInterface + ")");
62 function doTests() {
63 gInputElement.focus();
64 gEditor = getEditor(gInputElement);
66 testNotGenerateCompositionByCreatedEvents("CompositionEvent");
67 testNotGenerateCompositionByCreatedEvents("MouseEvent");
69 SimpleTest.finish();
72 SimpleTest.waitForFocus(doTests);
74 </script>
75 </body>
76 </html>