Bug 1399517 - remove CustomizableUI placements for old buttons to avoid saved state corruption, r=mikedeboer
authorGijs Kruitbosch <gijskruitbosch@gmail.com>
Mon, 18 Sep 2017 17:34:50 +0100
changeset 381648 685c28b080b39f5877a4773a245e1f10d8c5f63d
parent 381647 83b48abc843353c5e981a1f6afb0069326e62f19
child 381649 f0ac15bbbc50f718ad2ed53dcb22da31af9ad596
push id32535
push userkwierso@gmail.com
push dateTue, 19 Sep 2017 21:06:08 +0000
treeherdermozilla-central@c0d1f9eb2a40 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmikedeboer
bugs1399517
milestone57.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1399517 - remove CustomizableUI placements for old buttons to avoid saved state corruption, r=mikedeboer MozReview-Commit-ID: 3XKPuz9KwlD
browser/components/customizableui/CustomizableUI.jsm
--- a/browser/components/customizableui/CustomizableUI.jsm
+++ b/browser/components/customizableui/CustomizableUI.jsm
@@ -54,17 +54,17 @@ const kSubviewEvents = [
   "ViewShowing",
   "ViewHiding"
 ];
 
 /**
  * The current version. We can use this to auto-add new default widgets as necessary.
  * (would be const but isn't because of testing purposes)
  */
-var kVersion = 11;
+var kVersion = 12;
 
 /**
  * Buttons removed from built-ins by version they were removed. kVersion must be
  * bumped any time a new id is added to this. Use the button id as key, and
  * version the button is removed in as the value.  e.g. "pocket-button": 5
  */
 var ObsoleteBuiltinButtons = {
 };
@@ -306,25 +306,16 @@ var CustomizableUIInternal = {
           }
           if (shouldSetPref) {
             Services.prefs.setBoolPref(prefId, true);
           }
         }
       }
     }
 
-    if (currentVersion < 2) {
-      // Nuke the old 'loop-call-button' out of orbit.
-      CustomizableUI.removeWidgetFromArea("loop-call-button");
-    }
-
-    if (currentVersion < 4) {
-      CustomizableUI.removeWidgetFromArea("loop-button-throttled");
-    }
-
     if (currentVersion < 7 && gSavedState.placements &&
         gSavedState.placements[CustomizableUI.AREA_NAVBAR]) {
       let placements = gSavedState.placements[CustomizableUI.AREA_NAVBAR];
       let newPlacements = ["back-button", "forward-button", "stop-reload-button", "home-button"];
       for (let button of placements) {
         if (!newPlacements.includes(button)) {
           newPlacements.push(button);
         }
@@ -444,16 +435,28 @@ var CustomizableUIInternal = {
             break;
           }
         }
         // We either found the right spot, or reached the end of the
         // placements, so insert here:
         navbarPlacements.splice(insertionPoint, 0, "downloads-button");
       }
     }
+
+    if (currentVersion < 12 && gSavedState.placements) {
+      const removedButtons = ["loop-call-button", "loop-button-throttled", "pocket-button"];
+      for (let placements of Object.values(gSavedState.placements)) {
+        for (let button of removedButtons) {
+          let buttonIndex = placements.indexOf(button);
+          if (buttonIndex != -1) {
+            placements.splice(buttonIndex, 1);
+          }
+        }
+      }
+    }
   },
 
   /**
    * _markObsoleteBuiltinButtonsSeen
    * when upgrading, ensure obsoleted buttons are in seen state.
    */
   _markObsoleteBuiltinButtonsSeen() {
     if (!gSavedState)