Bug 1394207 - Export a function to show the sidebar without firing focus for session restore;r=Gijs
MozReview-Commit-ID: uHrShpl2xJ
--- a/browser/base/content/browser-sidebar.js
+++ b/browser/base/content/browser-sidebar.js
@@ -189,17 +189,17 @@ var SidebarUI = {
// dynamically generated sidebars will fail this check, but we still
// consider it adopted.
if (!document.getElementById(commandID)) {
return true;
}
this._box.setAttribute("width", sourceUI._box.boxObject.width);
- this._show(commandID);
+ this.showInitially(commandID);
return true;
},
windowPrivacyMatches(w1, w2) {
return PrivateBrowsingUtils.isWindowPrivate(w1) === PrivateBrowsingUtils.isWindowPrivate(w2);
},
@@ -224,17 +224,17 @@ var SidebarUI = {
// If we're not adopting settings from a parent window, set them now.
let commandID = this._box.getAttribute("sidebarcommand");
if (!commandID) {
return;
}
if (document.getElementById(commandID)) {
- this._show(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");
}
},
@@ -331,16 +331,27 @@ var SidebarUI = {
}
this._fireFocusedEvent();
BrowserUITelemetry.countSidebarEvent(commandID, "show");
});
},
/**
+ * Show the sidebar, without firing the focused event or logging telemetry.
+ * This is intended to be used when the sidebar is opened automatically
+ * when a window opens (not triggered by user interaction).
+ *
+ * @param {string} commandID ID of the xul:broadcaster element to use.
+ */
+ showInitially(commandID) {
+ return this._show(commandID);
+ },
+
+ /**
* Implementation for show. Also used internally for sidebars that are shown
* when a window is opened and we don't want to ping telemetry.
*
* @param {string} commandID ID of the xul:broadcaster element to use.
*/
_show(commandID) {
return new Promise((resolve, reject) => {
let sidebarBroadcaster = this.getBroadcasterById(commandID);
--- a/browser/components/sessionstore/SessionStore.jsm
+++ b/browser/components/sessionstore/SessionStore.jsm
@@ -4082,17 +4082,17 @@ var SessionStoreInternal = {
break;
case "normal":
aWindow.restore();
break;
}
}
var sidebar = aWindow.document.getElementById("sidebar-box");
if (sidebar.getAttribute("sidebarcommand") != aSidebar) {
- aWindow.SidebarUI.show(aSidebar);
+ aWindow.SidebarUI.showInitially(aSidebar);
}
// since resizing/moving a window brings it to the foreground,
// we might want to re-focus the last focused window
if (this.windowToFocus) {
this.windowToFocus.focus();
}
} finally {
// Enable animations.