<div contenteditable id="de-DE" lang="de-DE" onfocus="deFocus()">German heute ist ein guter Tag</div>
<textarea id="en-US" lang="en-US" onfocus="enFocus()">Nogoodword today is a nice day</textarea>
function deFocus() {
elem_de = document.getElementById("de-DE");
maybeOnSpellCheck(elem_de, function() { var editingSession = SpecialPowers.wrap(window).docShell.editingSession;
editor_de = editingSession.getEditorForWindow(window);
selcon_de = editor_de.selectionController; var sel = selcon_de.getSelection(selcon_de.SELECTION_SPELLCHECK);
// Check that we spelled in German, so there is only one misspelled word.
is(sel.toString(), "German", "one misspelled word expected: German");
// Now focus the textarea, which requires English spelling.
document.getElementById("en-US").focus();
});
}
function enFocus() { var elem_en = document.getElementById("en-US"); var editor_en =
SpecialPowers.wrap(elem_en)
.editor;
editor_en.setSpellcheckUserOverride(true); var inlineSpellChecker = editor_en.getInlineSpellChecker(true);
maybeOnSpellCheck(elem_en, async function() { var spellchecker = inlineSpellChecker.spellChecker;
let currentDictionaries = spellchecker.getCurrentDictionaries();
is(currentDictionaries.length, 1, "expected one dictionary");
let currentDictionary = currentDictionaries[0];
// Check that the English dictionary is loaded and that the spell check has worked.
is(currentDictionary, "en-US", "expected en-US");
is(getMisspelledWords(editor_en), "Nogoodword", "one misspelled word expected: Nogoodword");
// So far all was boring. The important thing is whether the spell check result
// in the de-DE editor is still the same. After losing focus, no spell check
// updates should take place there. var sel = selcon_de.getSelection(selcon_de.SELECTION_SPELLCHECK);
is(sel.toString(), "German", "one misspelled word expected: German");
// Remove the fake de_DE dictionary again.
await script.sendQuery("destroy");
// Focus again, so the spelling gets updated, but before we need to kill the focus handler.
elem_de.onfocus = null;
elem_de.blur();
elem_de.focus();
// After removal, the de_DE editor should refresh the spelling with en-US.
maybeOnSpellCheck(elem_de, function() { var endSel = selcon_de.getSelection(selcon_de.SELECTION_SPELLCHECK);
// eslint-disable-next-line no-useless-concat
is(endSel.toString(), "heute" + "ist" + "ein" + "guter", "some misspelled words expected: heute ist ein guter");
// If we don't reset this, we cause massive leaks.
selcon_de = null;
editor_de = null;
SimpleTest.finish();
});
});
}
</script>
</pre>
</body>
</html>
Messung V0.5
¤ Dauer der Verarbeitung: 0.24 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.