Bug 1385630 fix extension sidebar restore after app update, r?Gijs draft
authorShane Caraveo <scaraveo@mozilla.com>
Sun, 10 Sep 2017 13:36:54 -0700
changeset 662056 2042567f90485ceb6dc4b343692cb169009893c5
parent 661689 ea7b55d65d76214f97aaae502d65cb26fc6f5659
child 730734 566e814880e2a2780e6538fbebea8a34764e6c98
push id78939
push usermixedpuppy@gmail.com
push dateSun, 10 Sep 2017 20:37:16 +0000
reviewersGijs
bugs1385630
milestone57.0a1
Bug 1385630 fix extension sidebar restore after app update, r?Gijs MozReview-Commit-ID: IR0UDJgrp58
browser/base/content/browser-sidebar.js
browser/components/extensions/ext-sidebarAction.js
--- a/browser/base/content/browser-sidebar.js
+++ b/browser/base/content/browser-sidebar.js
@@ -230,16 +230,23 @@ var SidebarUI = {
 
     if (document.getElementById(commandID)) {
       this.showInitially(commandID);
     } else {
       // Remove the |sidebarcommand| attribute, because the element it
       // refers to no longer exists, so we should assume this sidebar
       // panel has been uninstalled. (249883)
       this._box.removeAttribute("sidebarcommand");
+      // On a startup in which the startup cache was invalidated (e.g. app update)
+      // extensions will not be started prior to delayedLoad, thus the
+      // sidebarcommand element will not exist yet.  Store the commandID so
+      // extensions may reopen if necessary.  A startup cache invalidation
+      // can be forced (for testing) by deleting compatibility.ini from the
+      // profile.
+      this.lastOpenedId = commandID;
     }
   },
 
   /**
    * Fire a "SidebarShown" event on the sidebar to give any interested parties
    * a chance to update the button or whatever.
    */
   _fireShowEvent() {
--- a/browser/components/extensions/ext-sidebarAction.js
+++ b/browser/components/extensions/ext-sidebarAction.js
@@ -129,21 +129,20 @@ this.sidebarAction = class extends Exten
     windowTracker.removeCloseListener(this.windowCloseListener);
   }
 
   build() {
     this.tabContext.on("tab-select", // eslint-disable-line mozilla/balanced-listeners
                        (evt, tab) => { this.updateWindow(tab.ownerGlobal); });
 
     let install = this.extension.startupReason === "ADDON_INSTALL";
-    let upgrade = ["ADDON_UPGRADE", "ADDON_DOWNGRADE"].includes(this.extension.startupReason);
     for (let window of windowTracker.browserWindows()) {
       this.updateWindow(window);
       let {SidebarUI} = window;
-      if (install || (upgrade && SidebarUI.lastOpenedId == this.id)) {
+      if (install || SidebarUI.lastOpenedId == this.id) {
         SidebarUI.show(this.id);
       }
     }
 
     if (install && !Services.prefs.prefHasUserValue("extensions.sidebar-button.shown")) {
       Services.prefs.setBoolPref("extensions.sidebar-button.shown", true);
       // If the sidebar button has never been moved to the toolbar, move it now
       // so the user can see/access the sidebars.