diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /editor/libeditor/tests/test_composition_event_created_in_chrome.html | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | editor/libeditor/tests/test_composition_event_created_in_chrome.html | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/editor/libeditor/tests/test_composition_event_created_in_chrome.html b/editor/libeditor/tests/test_composition_event_created_in_chrome.html new file mode 100644 index 0000000000..11b24d3bc1 --- /dev/null +++ b/editor/libeditor/tests/test_composition_event_created_in_chrome.html @@ -0,0 +1,76 @@ +<!doctype html> +<html> + +<head> + <link rel="stylesheet" href="/tests/SimpleTest/test.css"> + + <script src="/tests/SimpleTest/SimpleTest.js"></script> + <script src="/tests/SimpleTest/EventUtils.js"></script> +</head> + +<body> + +<input id="input"> + +<script type="application/javascript"> + +// In nsEditorEventListener, when listening event is not created with proper +// event interface, it asserts the fact. +SimpleTest.waitForExplicitFinish(); + +var gInputElement = document.getElementById("input"); + +function getEditor(aInputElement) { + var editableElement = SpecialPowers.wrap(aInputElement); + ok(editableElement.editor, "There is no editor for the input element"); + return editableElement.editor; +} + +var gEditor; + +function testNotGenerateCompositionByCreatedEvents(aEventInterface) { + var compositionEvent = document.createEvent(aEventInterface); + if (compositionEvent.initCompositionEvent) { + compositionEvent.initCompositionEvent("compositionstart", true, true, window, "", ""); + } else if (compositionEvent.initMouseEvent) { + compositionEvent.initMouseEvent("compositionstart", true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null); + } + gInputElement.dispatchEvent(compositionEvent); + ok(!gEditor.composing, "Composition shouldn't be started with a created compositionstart event (" + aEventInterface + ")"); + + compositionEvent = document.createEvent(aEventInterface); + if (compositionEvent.initCompositionEvent) { + compositionEvent.initCompositionEvent("compositionupdate", true, false, window, "abc", ""); + } else if (compositionEvent.initMouseEvent) { + compositionEvent.initMouseEvent("compositionupdate", true, false, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null); + } + gInputElement.dispatchEvent(compositionEvent); + ok(!gEditor.composing, "Composition shouldn't be started with a created compositionupdate event (" + aEventInterface + ")"); + is(gInputElement.value, "", "Input element shouldn't be modified with a created compositionupdate event (" + aEventInterface + ")"); + + compositionEvent = document.createEvent(aEventInterface); + if (compositionEvent.initCompositionEvent) { + compositionEvent.initCompositionEvent("compositionend", true, false, window, "abc", ""); + } else if (compositionEvent.initMouseEvent) { + compositionEvent.initMouseEvent("compositionend", true, false, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null); + } + gInputElement.dispatchEvent(compositionEvent); + ok(!gEditor.composing, "Composition shouldn't be committed with a created compositionend event (" + aEventInterface + ")"); + is(gInputElement.value, "", "Input element shouldn't be committed with a created compositionend event (" + aEventInterface + ")"); +} + +function doTests() { + gInputElement.focus(); + gEditor = getEditor(gInputElement); + + testNotGenerateCompositionByCreatedEvents("CompositionEvent"); + testNotGenerateCompositionByCreatedEvents("MouseEvent"); + + SimpleTest.finish(); +} + +SimpleTest.waitForFocus(doTests); + +</script> +</body> +</html> |