Bug 1176602 - Make sure that the dictionary stored in spellchecker.dictionary is valid (Adapt Thunderbird Bug 1175908) r=Neil a=IanN for comm-aurora comm-beta and comm-release CLOSED TREE
authorPhilip Chee <philip.chee@gmail.com>
Fri, 18 Sep 2015 23:30:52 +0800
changeset 26367 59f5f2f3a783a26a1b0f30cf6451d877cc7ec660
parent 26366 53f8ab1d339dd9bf442c29fb3192c663f527fba5
child 26368 0e6fd3bedbfbc09ab4c76375d7dd8f5e9c595a14
push id1850
push userclokep@gmail.com
push dateWed, 08 Mar 2017 19:29:12 +0000
treeherdercomm-esr52@028df196b2d9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersNeil, IanN
bugs1176602, 1175908
Bug 1176602 - Make sure that the dictionary stored in spellchecker.dictionary is valid (Adapt Thunderbird Bug 1175908) r=Neil a=IanN for comm-aurora comm-beta and comm-release CLOSED TREE
suite/common/src/nsSuiteGlue.js
--- a/suite/common/src/nsSuiteGlue.js
+++ b/suite/common/src/nsSuiteGlue.js
@@ -331,16 +331,17 @@ SuiteGlue.prototype = {
                              "_blank", "chrome,centerscreen,modal,resizable=no", null);
     }
   },
 
   // profile startup handler (contains profile initialization routines)
   _onProfileStartup: function()
   {
     this._updatePrefs();
+    this._migrateDownloadPrefs();
     migrateMailnews(); // mailnewsMigrator.js
 
     Sanitizer.checkSettings();
     Sanitizer.doPendingSanitize();
 
     if (Services.prefs.prefHasUserValue("privacy.sanitize.didShutdownSanitize")) {
       Services.prefs.clearUserPref("privacy.sanitize.didShutdownSanitize");
       // We need to persist this preference change, since we want to
@@ -942,16 +943,36 @@ SuiteGlue.prototype = {
     // tri-state; 0=always but not accessibility themes, 1=always, 2=never
     try {
       if (!Services.prefs.getBoolPref("browser.display.use_document_colors")) {
         Services.prefs.setIntPref("browser.display.document_color_use", 2);
         Services.prefs.clearUserPref("browser.display.use_document_colors");
       }
     } catch (ex) {}
 
+    // Ensure that this preference is set to a valid dictionary.
+    var prefName = "spellchecker.dictionary";
+    var prefValue = Services.prefs.getCharPref(prefName);
+    if (/_/.test(prefValue)) {
+      prefValue = prefValue.replace(/_/g, "-");
+      Services.prefs.setCharPref(prefName, prefValue);
+    }
+    var spellChecker = Components.classes["@mozilla.org/spellchecker/engine;1"]
+                                 .getService(Components.interfaces.mozISpellCheckingEngine);
+    var o1 = {};
+    spellChecker.getDictionaryList(o1, {});
+    var dictList = o1.value;
+    // If the preference contains an invalid dictionary, set it to a valid
+    // dictionary, any dictionary will do.
+    if (dictList.length && dictList.indexOf(prefValue) < 0)
+      Services.prefs.setCharPref(prefName, dictList[0]);
+  },
+
+  _migrateDownloadPrefs: function()
+  {
     // Migration of download-manager preferences
     if (Services.prefs.getPrefType("browser.download.dir") == Services.prefs.PREF_INVALID ||
         Services.prefs.getPrefType("browser.download.lastDir") != Services.prefs.PREF_INVALID)
       return; //Do nothing if .dir does not exist, or if it exists and lastDir does not
 
     try {
       Services.prefs.setComplexValue("browser.download.lastDir",
                                      Components.interfaces.nsILocalFile,