Bug 1385630 fix extension sidebar restore after app update, r?Gijs
MozReview-Commit-ID: IR0UDJgrp58
--- 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.