diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /editor/composer/test/test_async_UpdateCurrentDictionary.html | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'editor/composer/test/test_async_UpdateCurrentDictionary.html')
-rw-r--r-- | editor/composer/test/test_async_UpdateCurrentDictionary.html | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/editor/composer/test/test_async_UpdateCurrentDictionary.html b/editor/composer/test/test_async_UpdateCurrentDictionary.html new file mode 100644 index 000000000..53d9ff307 --- /dev/null +++ b/editor/composer/test/test_async_UpdateCurrentDictionary.html @@ -0,0 +1,75 @@ +<!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;version=1.8"> + +SimpleTest.waitForExplicitFinish(); +addLoadEvent(start); + +function start() { + var textarea = document.getElementById("editor"); + textarea.focus(); + + SpecialPowers.Cu.import("resource://gre/modules/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; + isnot(sc.GetCurrentDictionary(), lang, + "Current dictionary should not be set yet."); + + // 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 () { + is(sc.GetCurrentDictionary(), lang, + "UpdateCurrentDictionary should set the current dictionary."); + + // Second, make some Update calls, but then do a Set. The Set should + // effectively cancel the Updates, but the Updates' callbacks should be + // called nonetheless. + var numCalls = 3; + for (var i = 0; i < numCalls; i++) { + sc.UpdateCurrentDictionary(function () { + is(sc.GetCurrentDictionary(), "", + "No dictionary should be active after Update."); + if (--numCalls == 0) { + // This will clear the content preferences and reset "spellchecker.dictionary". + sc.SetCurrentDictionary(""); + SimpleTest.finish(); + } + }); + } + try { + sc.SetCurrentDictionary("testing-XX"); + } + catch (err) { + // Set throws NS_ERROR_NOT_AVAILABLE because "testing-XX" isn't really + // an available dictionary. + } + is(sc.GetCurrentDictionary(), "", + "No dictionary should be active after Set."); + }); + }); +} + +</script> +</pre> +</body> +</html> + |