Source code

Revision control

Copy as Markdown

Other Tools

Test Info: Warnings

<!DOCTYPE HTML>
<html>
<!--
-->
<head>
<title>Test for Bug 856270 - Async UpdateCurrentDictionary</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" href="/tests/SimpleTest/test.css">
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=856270">Mozilla Bug 856270</a>
<p id="display"></p>
<div id="content">
<textarea id="editor" spellcheck="true"></textarea>
</div>
<pre id="test">
<script class="testbody" type="text/javascript">
SimpleTest.waitForExplicitFinish();
addLoadEvent(start);
function start() {
var textarea = document.getElementById("editor");
textarea.focus();
const { onSpellCheck } = SpecialPowers.ChromeUtils.importESModule(
)
onSpellCheck(textarea, function() {
var isc = SpecialPowers.wrap(textarea).editor.getInlineSpellChecker(false);
ok(isc, "Inline spell checker should exist after focus and spell check");
var sc = isc.spellChecker;
sc.setCurrentDictionaries(["testing-XX"]).then(() => {
is(true, false, "Setting a non-existent dictionary should fail");
}, () => {
let currentDictionaries = sc.getCurrentDictionaries();
is(currentDictionaries.length, 0, "expected no dictionaries");
// First, set the lang attribute on the textarea, call Update, and make
// sure the spell checker's language was updated appropriately.
var lang = "en-US";
textarea.setAttribute("lang", lang);
sc.UpdateCurrentDictionary(function() {
currentDictionaries = sc.getCurrentDictionaries();
is(currentDictionaries.length, 1, "expected one dictionary");
is(sc.getCurrentDictionaries()[0], lang,
"UpdateCurrentDictionary should set the current dictionary.");
sc.setCurrentDictionaries([]).then(() => {
SimpleTest.finish();
});
});
});
});
}
</script>
</pre>
</body>
</html>