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/spellchecker/tests/test_bug1837268.html | |
parent | Initial commit. (diff) | |
download | firefox-esr-upstream.tar.xz firefox-esr-upstream.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/spellchecker/tests/test_bug1837268.html | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/editor/spellchecker/tests/test_bug1837268.html b/editor/spellchecker/tests/test_bug1837268.html new file mode 100644 index 0000000000..1467a328b5 --- /dev/null +++ b/editor/spellchecker/tests/test_bug1837268.html @@ -0,0 +1,79 @@ +<!DOCTYPE html> +<html> +<head> + <title>Mozilla bug 1837268</title> + <link rel=stylesheet href="/tests/SimpleTest/test.css"> + <script src="/tests/SimpleTest/EventUtils.js"></script> + <script src="/tests/SimpleTest/SimpleTest.js"></script> + <script src="/tests/editor/spellchecker/tests/spellcheck.js"></script> +</head> +<body> +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1837268">Mozilla Bug 1837268</a> +<p id="display"></p> +<div id="content" style="display: none;"> + +</div> + +<div id="contenteditable" contenteditable=true>aabbcc</div> + +<script> +const { maybeOnSpellCheck } = SpecialPowers.ChromeUtils.importESModule( + "resource://testing-common/AsyncSpellCheckTestHelper.sys.mjs" +); + +SimpleTest.waitForExplicitFinish(); + +function getEditor() { + return SpecialPowers.wrap(window).docShell.editor; +} + +SimpleTest.waitForFocus(async () => { + let contenteditable = document.getElementById("contenteditable"); + contenteditable.addEventListener("beforeinput", (ev) => { + ev.preventDefault(); + let text = contenteditable.textContent; + const sel = window.getSelection(); + let offset = sel.anchorOffset; + switch (ev.inputType) { + case "insertText": + text = text.substring(0, offset) + ev.data + text.substring(offset); + offset += 1; + break; + case "deleteContentBackward": + text = text.substring(0, offset - 1) + text.substring(offset); + offset -= 1; + break; + default: + return; + } + if (contenteditable.firstChild) { + contenteditable.firstChild.nodeValue = text; + } else { + contenteditable.textContent = text; + } + sel.collapse(contenteditable.firstChild ?? contenteditable, offset); + }); + + let misspelledWords = []; + misspelledWords.push("aabbc"); // One c removed. + + contenteditable.focus(); + window.getSelection().collapse(contenteditable.firstChild, contenteditable.firstChild.length); + + // Run spell checker + await new Promise((resolve) => { maybeOnSpellCheck(contenteditable, resolve); }); + + synthesizeKey("KEY_Backspace"); + synthesizeKey(" "); + + await new Promise((resolve) => { maybeOnSpellCheck(contenteditable, resolve); }); + let editor = getEditor(); + // isSpellingCheckOk is defined in spellcheck.js + // eslint-disable-next-line no-undef + ok(isSpellingCheckOk(editor, misspelledWords), "correct word is selected as misspelled"); + + SimpleTest.finish(); +}); +</script> +</body> +</html> |