4 https://bugzilla.mozilla.org/show_bug.cgi?id=856270
7 <title>Test for Bug
856270 - Async UpdateCurrentDictionary
</title>
8 <script src=
"/tests/SimpleTest/SimpleTest.js"></script>
9 <link rel=
"stylesheet" href=
"/tests/SimpleTest/test.css">
12 <a target=
"_blank" href=
"https://bugzilla.mozilla.org/show_bug.cgi?id=856270">Mozilla Bug
856270</a>
15 <textarea id=
"editor" spellcheck=
"true"></textarea>
18 <script class=
"testbody" type=
"text/javascript">
20 SimpleTest.waitForExplicitFinish();
24 var textarea = document.getElementById(
"editor");
27 const { onSpellCheck } = SpecialPowers.ChromeUtils.importESModule(
28 "resource://testing-common/AsyncSpellCheckTestHelper.sys.mjs"
30 onSpellCheck(textarea, function() {
31 var isc = SpecialPowers.wrap(textarea).editor.getInlineSpellChecker(false);
32 ok(isc,
"Inline spell checker should exist after focus and spell check");
33 var sc = isc.spellChecker;
35 sc.setCurrentDictionaries([
"testing-XX"]).then(() =
> {
36 is(true, false,
"Setting a non-existent dictionary should fail");
38 let currentDictionaries = sc.getCurrentDictionaries();
40 is(currentDictionaries.length,
0,
"expected no dictionaries");
41 // First, set the lang attribute on the textarea, call Update, and make
42 // sure the spell checker's language was updated appropriately.
44 textarea.setAttribute(
"lang", lang);
45 sc.UpdateCurrentDictionary(function() {
46 currentDictionaries = sc.getCurrentDictionaries();
47 is(currentDictionaries.length,
1,
"expected one dictionary");
48 is(sc.getCurrentDictionaries()[
0], lang,
49 "UpdateCurrentDictionary should set the current dictionary.");
50 sc.setCurrentDictionaries([]).then(() =
> {