summaryrefslogtreecommitdiffstats
path: root/editor/spellchecker/tests/test_async_UpdateCurrentDictionary.html
diff options
context:
space:
mode:
Diffstat (limited to 'editor/spellchecker/tests/test_async_UpdateCurrentDictionary.html')
-rw-r--r--editor/spellchecker/tests/test_async_UpdateCurrentDictionary.html60
1 files changed, 60 insertions, 0 deletions
diff --git a/editor/spellchecker/tests/test_async_UpdateCurrentDictionary.html b/editor/spellchecker/tests/test_async_UpdateCurrentDictionary.html
new file mode 100644
index 0000000000..6f8371d2cd
--- /dev/null
+++ b/editor/spellchecker/tests/test_async_UpdateCurrentDictionary.html
@@ -0,0 +1,60 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=856270
+-->
+<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.import(
+ "resource://testing-common/AsyncSpellCheckTestHelper.jsm"
+ )
+ 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>