Source code
Revision control
Copy as Markdown
Other Tools
Test Info: Warnings
- This test gets skipped with pattern: os == 'android'
- Manifest: editor/spellchecker/tests/mochitest.toml
<!doctype html>
<html>
<!--
-->
<head>
<meta charset="utf-8">
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<script src="/tests/SimpleTest/EventUtils.js"></script>
<link rel="stylesheet" href="/tests/SimpleTest/test.css">
</head>
<body>
<textarea rows="20" cols="50">That undfgdfg seems OK.</textarea>
<script>
let { maybeOnSpellCheck } = SpecialPowers.ChromeUtils.importESModule(
);
function waitForTick() {
return new Promise(resolve => SimpleTest.executeSoon(resolve));
}
function waitForOnSpellCheck(aTextArea) {
info("Waiting for onSpellCheck...");
return new Promise(resolve => maybeOnSpellCheck(aTextArea, resolve));
}
SimpleTest.waitForExplicitFinish();
SimpleTest.waitForFocus(async () => {
const textarea = document.querySelector("textarea");
textarea.focus();
textarea.selectionStart = textarea.selectionEnd = "That undfgdfg".length;
const editor = SpecialPowers.wrap(textarea).editor;
const nsISelectionController = SpecialPowers.Ci.nsISelectionController;
const selection = editor.selectionController.getSelection(nsISelectionController.SELECTION_SPELLCHECK);
const spellChecker = SpecialPowers.Cu.createSpellChecker();
spellChecker.InitSpellChecker(editor, false);
info("Waiting for current dictionary update...");
await new Promise(resolve => spellChecker.UpdateCurrentDictionary(resolve));
if (selection.rangeCount === 0) {
await waitForOnSpellCheck(textarea);
}
if (selection.rangeCount == 1) {
is(
selection.getRangeAt(0).toString(),
"undfgdfg",
"\"undfgdfg\" should be marked as misspelled word at start"
);
} else {
is(selection.rangeCount, 1, "We should have a misspelled word at start");
}
synthesizeKey(" ");
synthesizeKey("KEY_Backspace");
textarea.addEventListener("keydown", event => {
event.stopImmediatePropagation(); // This shouldn't block spellchecker to handle it.
}, {once: true});
synthesizeKey("KEY_End");
await waitForTick();
if (selection.rangeCount === 0) {
await waitForOnSpellCheck(textarea);
}
if (selection.rangeCount == 1) {
is(
selection.getRangeAt(0).toString(),
"undfgdfg",
"\"undfgdfg\" should be marked as misspelled word at end"
);
} else {
is(selection.rangeCount, 1, "We should have a misspelled word at end");
}
SimpleTest.finish();
});
</script>
</body>
</html>