Bug 1014238 - Don't break on invalid customization state. r=jaws, a=lsblakk
authorGijs Kruitbosch <gijskruitbosch@gmail.com>
Thu, 22 May 2014 00:35:57 +0100
changeset 192403 e6e4abc426a0c7600aab110b8b3325ef5110d156
parent 192402 23cc851c112bd94b92e26e47beb0c69397cef796
child 192404 5ac65440631d09f53c2434d6616977529b51ef06
push id3604
push userryanvm@gmail.com
push dateWed, 28 May 2014 16:22:57 +0000
treeherdermozilla-beta@5ac65440631d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjaws, lsblakk
bugs1014238
milestone30.0
Bug 1014238 - Don't break on invalid customization state. r=jaws, a=lsblakk
browser/components/customizableui/src/CustomizableUI.jsm
--- a/browser/components/customizableui/src/CustomizableUI.jsm
+++ b/browser/components/customizableui/src/CustomizableUI.jsm
@@ -1671,17 +1671,22 @@ let CustomizableUIInternal = {
       // the defaults.
     }
 
     if (!state) {
       return;
     }
     try {
       gSavedState = JSON.parse(state);
+      if (typeof gSavedState != "object" || gSavedState === null) {
+        throw "Invalid saved state";
+      }
     } catch(e) {
+      Services.prefs.clearUserPref(kPrefCustomizationState);
+      gSavedState = {};
       LOG("Error loading saved UI customization state, falling back to defaults.");
     }
 
     if (!("placements" in gSavedState)) {
       gSavedState.placements = {};
     }
 
     gSeenWidgets = new Set(gSavedState.seen || []);