Prepare callsites of clearUserPref so it can go back to throwing. r=gavin
authorGijs Kruitbosch <gijskruitbosch@gmail.com>
Wed, 28 Oct 2009 22:44:15 +0100
changeset 34257 d0b7ef28c23a54acf61e723f24dbaaf9cd8631a5
parent 34256 8a86b4dbd991046315dd55621335924e9fa7d081
child 34258 c03e4d80991ed4259563c55f0f91e01b48b8a76b
push idunknown
push userunknown
push dateunknown
reviewersgavin
milestone1.9.3a1pre
Prepare callsites of clearUserPref so it can go back to throwing. r=gavin
browser/base/content/openLocationLastURL.jsm
browser/components/privatebrowsing/test/browser/browser_privatebrowsing_opendir.js
toolkit/mozapps/downloads/src/DownloadLastDir.jsm
toolkit/mozapps/extensions/content/extensions.js
toolkit/mozapps/extensions/src/nsExtensionManager.js.in
--- a/browser/base/content/openLocationLastURL.jsm
+++ b/browser/base/content/openLocationLastURL.jsm
@@ -83,12 +83,13 @@ let gOpenLocationLastURL = {
     else {
       let str = Components.classes["@mozilla.org/supports-string;1"]
                           .createInstance(Components.interfaces.nsISupportsString);
       str.data = val;
       prefSvc.setComplexValue(LAST_URL_PREF, nsISupportsString, str);
     }
   },
   reset: function() {
-    prefSvc.clearUserPref(LAST_URL_PREF);
+    if (prefSvc.prefHasUserValue(LAST_URL_PREF))
+        prefSvc.clearUserPref(LAST_URL_PREF);
     gOpenLocationLastURLData = "";
   }
 };
--- a/browser/components/privatebrowsing/test/browser/browser_privatebrowsing_opendir.js
+++ b/browser/components/privatebrowsing/test/browser/browser_privatebrowsing_opendir.js
@@ -49,17 +49,18 @@ function test() {
   let file = dir2.clone();
   file.append("pbtest.file");
   file.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, 0600);
 
   const kPrefName = "browser.open.lastDir";
 
   function setupCleanSlate() {
     gLastOpenDirectory.reset();
-    gPrefService.clearUserPref(kPrefName);
+    if (gPrefService.prefHasUserValue(kPrefName))
+        gPrefService.clearUserPref(kPrefName);
   }
 
   setupCleanSlate();
 
   // Test 1: general workflow test
 
   // initial checks
   ok(!gLastOpenDirectory.path,
--- a/toolkit/mozapps/downloads/src/DownloadLastDir.jsm
+++ b/toolkit/mozapps/downloads/src/DownloadLastDir.jsm
@@ -92,13 +92,13 @@ let gDownloadLastDir = {
     if (pbSvc && pbSvc.privateBrowsingEnabled) {
       if (val instanceof Components.interfaces.nsIFile)
         gDownloadLastDirFile = val.clone();
       else
         gDownloadLastDirFile = null;
     } else {
       if (val instanceof Components.interfaces.nsIFile)
         prefSvc.setComplexValue(LAST_DIR_PREF, nsILocalFile, val);
-      else
+      else if (prefSvc.prefHasUserValue(LAST_DIR_PREF))
         prefSvc.clearUserPref(LAST_DIR_PREF);
     }
   }
 };
--- a/toolkit/mozapps/extensions/content/extensions.js
+++ b/toolkit/mozapps/extensions/content/extensions.js
@@ -2233,17 +2233,18 @@ const gPluginObserver = {
 
 const gLWThemeObserver = {
   observe: function (aSubject, aTopic, aData) {
     if (aTopic == "lightweight-theme-list-changed") {
       rebuildLWThemeDS();
     }
     else if (aTopic == "lightweight-theme-changed") {
       gLWThemeToSelect = LightweightThemeManager.currentTheme;
-      gPref.clearUserPref(PREF_LWTHEME_TO_SELECT);
+      if (gPref.prefHasUserValue(PREF_LWTHEME_TO_SELECT))
+          gPref.clearUserPref(PREF_LWTHEME_TO_SELECT);
     }
   }
 };
 
 function isXPInstallEnabled() {
   var enabled = false;
   var locked = false;
   try {
--- a/toolkit/mozapps/extensions/src/nsExtensionManager.js.in
+++ b/toolkit/mozapps/extensions/src/nsExtensionManager.js.in
@@ -2311,17 +2311,18 @@ ExtensionManager.prototype = {
         var toSelect = gPref.getCharPref(PREF_DSS_SKIN_TO_SELECT);
         gPref.setCharPref(PREF_GENERAL_SKINS_SELECTEDSKIN, toSelect);
         gPref.clearUserPref(PREF_DSS_SWITCHPENDING);
         gPref.clearUserPref(PREF_DSS_SKIN_TO_SELECT);
 
         // If we've changed to a non-default theme make sure there is no
         // lightweight theme selected
         if (toSelect != gDefaultTheme) {
-          gPref.clearUserPref(PREF_LWTHEME_TO_SELECT);
+          if (gPref.prefHasUserValue(PREF_LWTHEME_TO_SELECT))
+            gPref.clearUserPref(PREF_LWTHEME_TO_SELECT);
           LightweightThemeManager.currentTheme = null;
         }
       }
 
       if (gPref.prefHasUserValue(PREF_LWTHEME_TO_SELECT)) {
         var id = gPref.getCharPref(PREF_LWTHEME_TO_SELECT);
         if (id)
           LightweightThemeManager.currentTheme = LightweightThemeManager.getUsedTheme(id);
@@ -3306,18 +3307,18 @@ ExtensionManager.prototype = {
       // Should we show a UI or just pass the list via a pref?
       if (getPref("getBoolPref", PREF_EM_SHOW_MISMATCH_UI, true)) {
         this._showMismatchWindow(inactiveItemIDs);
       }
       else {
         // Remember the list of add-ons that were disabled this time around
         gPref.setCharPref(PREF_EM_DISABLED_ADDONS_LIST, disabledAddons.join(","));
       }
-    } else {
-      // Clear the disabled addons list
+    } else if (gPref.prefHasUserValue(PREF_EM_DISABLED_ADDONS_LIST)) {
+      // Clear the disabled addons list if necessary
       gPref.clearUserPref(PREF_EM_DISABLED_ADDONS_LIST);
     }
 
     // Finish any pending upgrades from the compatibility update to avoid an
     // additional restart.
     if (PendingOperations.size != 0)
       this._finishOperations();