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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Doug Thayer 2019-03-06 11:51:55 +00:00
Родитель 965b1cacf3
Коммит 61cadb5fd3
1 изменённых файлов: 9 добавлений и 6 удалений

Просмотреть файл

@ -386,11 +386,13 @@ window._gBrowser = {
_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++) {
@ -632,7 +634,8 @@ window._gBrowser = {
},
_maybeUpdateNumPinnedTabsPref() {
if (BrowserWindowTracker.getTopWindow() == window) {
if (!PrivateBrowsingUtils.isWindowPrivate(window) &&
BrowserWindowTracker.getTopWindow() == window) {
Services.prefs.setIntPref("browser.tabs.firstWindowRestore.numPinnedTabs",
this._numPinnedTabs);
}