Bug 1394207 - Export a function to show the sidebar without firing focus for session restore;r=Gijs
authorBrian Grinstead <bgrinstead@mozilla.com>
Wed, 06 Sep 2017 08:58:10 -0700
changeset 428702 5edfd440c97f26c484add1826c985d05c4cdb5cc
parent 428701 9435660523cb463d22b032c2f0d88b7565a7ab89
child 428703 8d4b1890f7cf73a8ca194e2852cff9c5916b30b6
push id7761
push userjlund@mozilla.com
push dateFri, 15 Sep 2017 00:19:52 +0000
treeherdermozilla-beta@c38455951db4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersGijs
bugs1394207
milestone57.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1394207 - Export a function to show the sidebar without firing focus for session restore;r=Gijs MozReview-Commit-ID: uHrShpl2xJ
browser/base/content/browser-sidebar.js
browser/components/sessionstore/SessionStore.jsm
--- 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.