Bug 1385630 - Fix extension sidebar restore after app update. r=Gijs, a=lizzard
authorShane Caraveo <scaraveo@mozilla.com>
Sun, 10 Sep 2017 13:36:54 -0700
changeset 421689 bb89faa93b22a12c442275cb1ec0d2d6a1f0d800
parent 421688 aa3740564226ff05000c83f7b07a919334bd7ac1
child 421690 bd8b51b807381ceef0dd12aa0534b65bf6e12f3d
push id7748
push userryanvm@gmail.com
push dateWed, 13 Sep 2017 00:59:04 +0000
treeherdermozilla-beta@867b9e3b4f92 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersGijs, lizzard
bugs1385630
milestone56.0
Bug 1385630 - Fix extension sidebar restore after app update. r=Gijs, a=lizzard 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
@@ -221,16 +221,23 @@ var SidebarUI = {
 
     if (document.getElementById(commandID)) {
       this._show(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 "SidebarFocused" event on the sidebar's |window| to give the sidebar
    * a chance to adjust focus as needed. An additional event is needed, because
    * we don't want to focus the sidebar when it's opened on startup or in a new
    * window, only when the user opens the sidebar.
--- a/browser/components/extensions/ext-sidebarAction.js
+++ b/browser/components/extensions/ext-sidebarAction.js
@@ -111,21 +111,20 @@ 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);
       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.