Bug 1350597 fix reload/upgrade of sidebar addon, r=kmag
authorShane Caraveo <scaraveo@mozilla.com>
Fri, 14 Apr 2017 17:01:23 -0700
changeset 563311 45f5b5a65b7fffa5d68931d427f547ac4443a10e
parent 563310 3ccf70e977bd7bc5b2c0b3b1890c34b226afee57
child 563312 fc91bd1a27a72e451c435acede23ecff374e56e7
push id54258
push usercpeterson@mozilla.com
push dateSun, 16 Apr 2017 05:52:14 +0000
reviewerskmag
bugs1350597
milestone55.0a1
Bug 1350597 fix reload/upgrade of sidebar addon, r=kmag MozReview-Commit-ID: FcC7zJn1ka5
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
@@ -218,16 +218,17 @@ var SidebarUI = {
           sidebarBroadcaster.setAttribute("checked", "true");
         }
       }
 
       this._box.hidden = false;
       this._splitter.hidden = false;
 
       this._box.setAttribute("sidebarcommand", sidebarBroadcaster.id);
+      this.lastOpenedId = sidebarBroadcaster.id;
 
       let title = sidebarBroadcaster.getAttribute("sidebartitle");
       if (!title) {
         title = sidebarBroadcaster.getAttribute("label");
       }
       this._title.value = title;
 
       let url = sidebarBroadcaster.getAttribute("sidebarurl");
--- a/browser/components/extensions/ext-sidebarAction.js
+++ b/browser/components/extensions/ext-sidebarAction.js
@@ -96,20 +96,21 @@ this.sidebarAction = class extends Exten
     windowTracker.removeOpenListener(this.windowOpenListener);
   }
 
   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);
-      if (install) {
-        let {SidebarUI} = window;
+      let {SidebarUI} = window;
+      if (install || (upgrade && 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.