Bug 1532841 - Don't preopen pinned tabs for private browser window r=Gijs
authorDoug Thayer <dothayer@mozilla.com>
Wed, 06 Mar 2019 11:51:55 +0000
changeset 520462 447f88307c1c
parent 520461 764939fcdaf3
child 520463 61db2b186d69
push id10862
push userffxbld-merge
push dateMon, 11 Mar 2019 13:01:11 +0000
treeherdermozilla-beta@a2e7f5c935da [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersGijs
bugs1532841
milestone67.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 1532841 - Don't preopen pinned tabs for private browser window r=Gijs If we're opening a private browsing window on startup, we won't run the session restore code, and thus we won't end up cleaning up the preopened tabs. This raises the question: are there other scenarios where we won't run restoreWindow at all? Eyeballing the code I think not, but I'm not sure. Depends on D22195 Differential Revision: https://phabricator.services.mozilla.com/D22216
browser/base/content/tabbrowser.js
--- a/browser/base/content/tabbrowser.js
+++ b/browser/base/content/tabbrowser.js
@@ -381,21 +381,23 @@ window._gBrowser = {
     filter.addProgressListener(tabListener, Ci.nsIWebProgress.NOTIFY_ALL);
     this._tabListeners.set(tab, tabListener);
     this._tabFilters.set(tab, filter);
     browser.webProgress.addProgressListener(filter, Ci.nsIWebProgress.NOTIFY_ALL);
   },
 
   _preopenPinnedTabs() {
     let numPinnedTabs = 0;
-    let windows = browserWindows();
-    windows.getNext();
-    let isOnlyWindow = !windows.hasMoreElements();
-    if (isOnlyWindow) {
-      numPinnedTabs = Services.prefs.getIntPref("browser.tabs.firstWindowRestore.numPinnedTabs", 0);
+    if (!PrivateBrowsingUtils.isWindowPrivate(window)) {
+      let windows = browserWindows();
+      windows.getNext();
+      let isOnlyWindow = !windows.hasMoreElements();
+      if (isOnlyWindow) {
+        numPinnedTabs = Services.prefs.getIntPref("browser.tabs.firstWindowRestore.numPinnedTabs", 0);
+      }
     }
 
     for (let i = 0; i < numPinnedTabs; i++) {
       let tab = this.addTrustedTab("about:blank", {
         skipAnimation: true,
         noInitialLabel: true,
         skipBackgroundNotify: true,
         createLazyBrowser: true,
@@ -627,17 +629,18 @@ window._gBrowser = {
     }
 
     let event = document.createEvent("Events");
     event.initEvent(aTab.pinned ? "TabPinned" : "TabUnpinned", true, false);
     aTab.dispatchEvent(event);
   },
 
   _maybeUpdateNumPinnedTabsPref() {
-    if (BrowserWindowTracker.getTopWindow() == window) {
+    if (!PrivateBrowsingUtils.isWindowPrivate(window) &&
+        BrowserWindowTracker.getTopWindow() == window) {
       Services.prefs.setIntPref("browser.tabs.firstWindowRestore.numPinnedTabs",
                                 this._numPinnedTabs);
     }
   },
 
   activatePreopenedPinnedTab(aTab) {
     this._insertBrowser(aTab);
     this._sendPinnedTabContentMessage(aTab);