diff --git a/editor/AsyncSpellCheckTestHelper.jsm b/editor/AsyncSpellCheckTestHelper.jsm index 77bfee17b162..78d5f2993f8e 100644 --- a/editor/AsyncSpellCheckTestHelper.jsm +++ b/editor/AsyncSpellCheckTestHelper.jsm @@ -2,11 +2,19 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -var EXPORTED_SYMBOLS = ["maybeOnSpellCheck", "onSpellCheck"]; +var EXPORTED_SYMBOLS = [ + "maybeOnSpellCheck", + "onSpellCheck", + "getDictionaryContentPref", +]; const SPELL_CHECK_ENDED_TOPIC = "inlineSpellChecker-spellCheck-ended"; const SPELL_CHECK_STARTED_TOPIC = "inlineSpellChecker-spellCheck-started"; +const CP = Cc["@mozilla.org/content-pref/service;1"].getService( + Ci.nsIContentPrefService2 +); + /** * Waits until spell checking has stopped on the given element. * @@ -105,3 +113,19 @@ function onSpellCheck(editableElement, callback) { callback ); } + +async function getDictionaryContentPref() { + let dictionaries = await new Promise(resolve => { + let value = ""; + CP.getByDomainAndName("mochi.test", "spellcheck.lang", null, { + handleResult(pref) { + value = pref.value; + }, + handleCompletion() { + resolve(value); + }, + }); + }); + + return dictionaries; +} diff --git a/editor/spellchecker/EditorSpellCheck.cpp b/editor/spellchecker/EditorSpellCheck.cpp index bf5cc7dbbaf6..77855dcd04eb 100644 --- a/editor/spellchecker/EditorSpellCheck.cpp +++ b/editor/spellchecker/EditorSpellCheck.cpp @@ -603,10 +603,9 @@ EditorSpellCheck::SetCurrentDictionaries( mEditor->GetFlags(&flags); if (!(flags & nsIEditor::eEditorMailMask)) { if (!aDictionaries.IsEmpty() && - (mPreferredLang.IsEmpty() || - (aDictionaries.Length() == 1 && - !mPreferredLang.Equals(aDictionaries[0], - nsCaseInsensitiveCStringComparator)))) { + (mPreferredLang.IsEmpty() || aDictionaries.Length() > 1 || + !mPreferredLang.Equals(aDictionaries[0], + nsCaseInsensitiveCStringComparator))) { // When user sets dictionary manually, we store this value associated // with editor url, if it doesn't match the document language exactly. // For example on "en" sites, we need to store "en-GB", otherwise diff --git a/editor/spellchecker/tests/mochitest.ini b/editor/spellchecker/tests/mochitest.ini index 448950c71cff..c7d611585855 100644 --- a/editor/spellchecker/tests/mochitest.ini +++ b/editor/spellchecker/tests/mochitest.ini @@ -41,6 +41,7 @@ skip-if = e10s [test_bug1418629.html] [test_bug1497480.html] [test_bug1602526.html] +[test_bug1761273.html] [test_spellcheck_after_edit.html] [test_spellcheck_after_pressing_navigation_key.html] [test_suggest.html] diff --git a/editor/spellchecker/tests/test_bug1402822.html b/editor/spellchecker/tests/test_bug1402822.html index e091d9611f8d..ba43d49a82c1 100644 --- a/editor/spellchecker/tests/test_bug1402822.html +++ b/editor/spellchecker/tests/test_bug1402822.html @@ -4,13 +4,13 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1402822 --> - Test for Bug 1209414 + Test for Bug 1402822 -Mozilla Bug 1209414 +Mozilla Bug 1402822

diff --git a/editor/spellchecker/tests/test_bug1761273.html b/editor/spellchecker/tests/test_bug1761273.html new file mode 100644 index 000000000000..a1e01fbdba25 --- /dev/null +++ b/editor/spellchecker/tests/test_bug1761273.html @@ -0,0 +1,92 @@ + + + + + Test for Bug 1761273 + + + + + +Mozilla Bug 1761273 +

+ + + + +
+
+
+ +