Bug 1096013 - Give selected tabs highest priority during restoration. r?mikedeboer draft
authorMike Conley <mconley@mozilla.com>
Thu, 23 Mar 2017 01:59:51 -0400
changeset 551450 93f2b536601b063b98fa947d60d2ff00e367b500
parent 551449 a7398555b44beb3675164d00c2658abc5e1c8312
child 551451 567c803e1b30155a021b5f4836524db9c74736c4
push id51045
push usermconley@mozilla.com
push dateSun, 26 Mar 2017 03:38:12 +0000
reviewersmikedeboer
bugs1096013
milestone55.0a1
Bug 1096013 - Give selected tabs highest priority during restoration. r?mikedeboer MozReview-Commit-ID: EtApFsDyB50
browser/components/sessionstore/SessionStore.jsm
--- a/browser/components/sessionstore/SessionStore.jsm
+++ b/browser/components/sessionstore/SessionStore.jsm
@@ -3487,19 +3487,27 @@ var SessionStoreInternal = {
     // If provided, set the selected tab.
     if (aSelectTab > 0 && aSelectTab <= aTabs.length) {
       tabbrowser.selectedTab = aTabs[aSelectTab - 1];
 
       // Update the window state in case we shut down without being notified.
       this._windows[aWindow.__SSi].selected = aSelectTab;
     }
 
+    // If we restore the selected tab, make sure it goes first.
+    let selectedIndex = aTabs.indexOf(tabbrowser.selectedTab);
+    if (selectedIndex > -1) {
+      this.restoreTab(tabbrowser.selectedTab, aTabData[selectedIndex]);
+    }
+
     // Restore all tabs.
     for (let t = 0; t < aTabs.length; t++) {
-      this.restoreTab(aTabs[t], aTabData[t]);
+      if (t != selectedIndex) {
+        this.restoreTab(aTabs[t], aTabData[t]);
+      }
     }
   },
 
   // Restores the given tab state for a given tab.
   restoreTab(tab, tabData, options = {}) {
     NS_ASSERT(!tab.linkedBrowser.__SS_restoreState,
               "must reset tab before calling restoreTab()");