From 08b7f8eebb5e71ff3e3638b9adde311c3f5ad658 Mon Sep 17 00:00:00 2001 From: shindli Date: Tue, 26 Feb 2019 18:32:20 +0200 Subject: [PATCH] Backed out 2 changesets (bug 1442694) for breaking session restores on update a=backout Backed out changeset f100f8631f78 (bug 1442694) Backed out changeset 7a20c79a0e12 (bug 1442694) --- browser/base/content/tabbrowser.css | 5 - browser/base/content/tabbrowser.js | 78 ++-------- browser/base/content/tabbrowser.xml | 4 +- .../components/sessionstore/SessionStore.jsm | 49 ++----- .../components/sessionstore/test/browser.ini | 1 - .../test/browser_preopened_apptabs.js | 138 ------------------ browser/components/sessionstore/test/head.js | 5 +- browser/modules/BrowserWindowTracker.jsm | 6 - 8 files changed, 28 insertions(+), 258 deletions(-) delete mode 100644 browser/components/sessionstore/test/browser_preopened_apptabs.js diff --git a/browser/base/content/tabbrowser.css b/browser/base/content/tabbrowser.css index dabb5315397b..86b6564e7ce2 100644 --- a/browser/base/content/tabbrowser.css +++ b/browser/base/content/tabbrowser.css @@ -22,11 +22,6 @@ display: none; } -.tab-icon-pending[preopened], -.tab-icon-image[preopened] { - visibility: hidden; -} - .tab-sharing-icon-overlay[sharing]:not([selected]), .tab-icon-overlay[soundplaying][pinned], .tab-icon-overlay[muted][pinned], diff --git a/browser/base/content/tabbrowser.js b/browser/base/content/tabbrowser.js index 233b955b1714..0aff03b7ce6b 100644 --- a/browser/base/content/tabbrowser.js +++ b/browser/base/content/tabbrowser.js @@ -32,7 +32,6 @@ window._gBrowser = { window.addEventListener("occlusionstatechange", this); this._setupInitialBrowserAndTab(); - this._preopenPinnedTabs(); if (Services.prefs.getBoolPref("browser.display.use_system_colors")) { this.tabpanels.style.backgroundColor = "-moz-default-background-color"; @@ -384,29 +383,6 @@ window._gBrowser = { 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); - } - - for (let i = 0; i < numPinnedTabs; i++) { - let tab = this.addTrustedTab("about:blank", { - skipAnimation: true, - noInitialLabel: true, - skipBackgroundNotify: true, - createLazyBrowser: true, - pinned: true, - isForFirstWindowRestore: true, - }); - - tab.setAttribute("preopened", "true"); - } - }, - /** * BEGIN FORWARDED BROWSER PROPERTIES. IF YOU ADD A PROPERTY TO THE BROWSER ELEMENT * MAKE SURE TO ADD IT HERE AS WELL. @@ -617,32 +593,14 @@ window._gBrowser = { this.tabContainer._updateCloseButtons(); }, - _sendPinnedTabContentMessage(aTab) { + _notifyPinnedStatus(aTab) { this.getBrowserForTab(aTab).messageManager.sendAsyncMessage("Browser:AppTab", { isAppTab: aTab.pinned }); - }, - - _notifyPinnedStatus(aTab, aDeferContentMessage = false) { - if (!aDeferContentMessage) { - this._sendPinnedTabContentMessage(aTab); - } let event = document.createEvent("Events"); event.initEvent(aTab.pinned ? "TabPinned" : "TabUnpinned", true, false); aTab.dispatchEvent(event); }, - _maybeUpdateNumPinnedTabsPref() { - if (BrowserWindowTracker.getTopWindow() == window) { - Services.prefs.setIntPref("browser.tabs.firstWindowRestore.numPinnedTabs", - this._numPinnedTabs); - } - }, - - activatePreopenedPinnedTab(aTab) { - this._insertBrowser(aTab); - this._sendPinnedTabContentMessage(aTab); - }, - pinTab(aTab) { if (aTab.pinned) return; @@ -654,7 +612,6 @@ window._gBrowser = { aTab.setAttribute("pinned", "true"); this._updateTabBarForPinnedTabs(); this._notifyPinnedStatus(aTab); - this._maybeUpdateNumPinnedTabsPref(); }, unpinTab(aTab) { @@ -666,7 +623,6 @@ window._gBrowser = { aTab.style.marginInlineStart = ""; this._updateTabBarForPinnedTabs(); this._notifyPinnedStatus(aTab); - this._maybeUpdateNumPinnedTabsPref(); }, previewTab(aTab, aCallback) { @@ -2340,7 +2296,6 @@ window._gBrowser = { forceNotRemote, fromExternal, index, - isForFirstWindowRestore, lazyTabTitle, name, nextTabParentId, @@ -2524,9 +2479,6 @@ window._gBrowser = { if (pinned) { this._updateTabBarForPinnedTabs(); - if (!isForFirstWindowRestore) { - this._maybeUpdateNumPinnedTabsPref(); - } } this.tabContainer._setPositionalAttributes(); @@ -2606,15 +2558,13 @@ window._gBrowser = { userContextId); b.registeredOpenURI = lazyBrowserURI; } - if (!isForFirstWindowRestore) { - SessionStore.setTabState(t, { - entries: [{ - url: lazyBrowserURI ? lazyBrowserURI.spec : "about:blank", - title: lazyTabTitle, - triggeringPrincipal_base64: E10SUtils.serializePrincipal(triggeringPrincipal), - }], - }); - } + SessionStore.setTabState(t, { + entries: [{ + url: lazyBrowserURI ? lazyBrowserURI.spec : "about:blank", + title: lazyTabTitle, + triggeringPrincipal_base64: E10SUtils.serializePrincipal(triggeringPrincipal), + }], + }); } else { this._insertBrowser(t, true); } @@ -2652,9 +2602,7 @@ window._gBrowser = { // If we didn't swap docShells with a preloaded browser // then let's just continue loading the page normally. - if (!usingPreloadedContent && - !createLazyBrowser && - (!uriIsAboutBlank || !allowInheritPrincipal)) { + if (!usingPreloadedContent && (!uriIsAboutBlank || !allowInheritPrincipal)) { // pretend the user typed this so it'll be available till // the document successfully loads if (aURI && !gInitialPages.includes(aURI)) { @@ -2707,7 +2655,7 @@ window._gBrowser = { // Additionally send pinned tab events if (pinned) { - this._notifyPinnedStatus(t, isForFirstWindowRestore); + this._notifyPinnedStatus(t); } return t; @@ -3205,10 +3153,8 @@ window._gBrowser = { this.tabs[i]._tPos = i; if (!this._windowIsClosing) { - if (wasPinned) { + if (wasPinned) this.tabContainer._positionPinnedTabs(); - this._maybeUpdateNumPinnedTabsPref(); - } // update tab close buttons state this.tabContainer._updateCloseButtons(); @@ -3893,6 +3839,7 @@ window._gBrowser = { skipAnimation: true, index: aIndex, createLazyBrowser, + allowInheritPrincipal: createLazyBrowser, }; let numPinned = this._numPinnedTabs; @@ -5069,7 +5016,6 @@ class TabProgressListener { this.mTab.removeAttribute("crashed"); } - this.mTab.removeAttribute("preopened"); if (this._shouldShowProgress(aRequest)) { if (!(aStateFlags & Ci.nsIWebProgressListener.STATE_RESTORING) && aWebProgress && aWebProgress.isTopLevel) { diff --git a/browser/base/content/tabbrowser.xml b/browser/base/content/tabbrowser.xml index ea46a23b5585..97c1566afbbd 100644 --- a/browser/base/content/tabbrowser.xml +++ b/browser/base/content/tabbrowser.xml @@ -1937,10 +1937,10 @@ anonid="tab-throbber" class="tab-throbber" layer="true"/> - - = 0; i--) { - if (!tabbrowser.tabs[i].selected && - !tabbrowser.tabs[i].hasAttribute("preopened")) { + if (!tabbrowser.tabs[i].selected) { tabbrowser.removeTab(tabbrowser.tabs[i]); - } else if (tabbrowser.tabs[i].hasAttribute("preopened")) { - initialTabs.push(tabbrowser.tabs[i]); } } } @@ -3686,24 +3678,13 @@ var SessionStoreInternal = { if (select && tabbrowser.selectedTab.userContextId == userContextId) { tab = tabbrowser.selectedTab; - if (tab.pinned && !tabData.pinned) { + if (!tabData.pinned) { tabbrowser.unpinTab(tab); - } else if (!tab.pinned && tabData.pinned) { - tabbrowser.removeTab(tabbrowser.tabs[t]); - tabbrowser.pinTab(tab); - tabbrowser.moveTabTo(tab, t); } - tabbrowser.moveTabToEnd(); if (aWindow.gMultiProcessBrowser && !tab.linkedBrowser.isRemoteBrowser) { tabbrowser.updateBrowserRemoteness(tab.linkedBrowser, true); } - } else if (tabData.pinned && - tabbrowser.tabs[t] && - tabbrowser.tabs[t].pinned && - !tabbrowser.tabs[t].linkedPanel) { - tab = tabbrowser.tabs[t]; - tabbrowser.activatePreopenedPinnedTab(tab); } // Add a new tab if needed. @@ -3752,14 +3733,11 @@ var SessionStoreInternal = { } // Move the originally open tabs to the end. - let endPosition = tabbrowser.tabs.length - 1; - for (let tab of initialTabs) { - if (tab.hasAttribute("preopened") && - !tab.linkedPanel) { - tabbrowser.removeTab(tab); - } else if (!tab.hasAttribute("preopened")) { - tabbrowser.unpinTab(tab); - tabbrowser.moveTabTo(tab, endPosition); + if (initialTabs) { + let endPosition = tabbrowser.tabs.length - 1; + for (let i = 0; i < initialTabs.length; i++) { + tabbrowser.unpinTab(initialTabs[i]); + tabbrowser.moveTabTo(initialTabs[i], endPosition); } } @@ -4020,9 +3998,6 @@ var SessionStoreInternal = { for (let t = 0; t < aTabs.length; t++) { if (t != selectedIndex) { this.restoreTab(aTabs[t], aTabData[t]); - if (this._restore_pinned_tabs_on_demand) { - aTabs[t].removeAttribute("preopened"); - } } } }, diff --git a/browser/components/sessionstore/test/browser.ini b/browser/components/sessionstore/test/browser.ini index 750dc839c9de..ab1cdeb69984 100644 --- a/browser/components/sessionstore/test/browser.ini +++ b/browser/components/sessionstore/test/browser.ini @@ -113,7 +113,6 @@ skip-if = (verify && (os == 'win' || os == 'mac')) [browser_old_favicon.js] [browser_page_title.js] [browser_pending_tabs.js] -[browser_preopened_apptabs.js] [browser_privatetabs.js] [browser_purge_shistory.js] skip-if = e10s # Bug 1271024 diff --git a/browser/components/sessionstore/test/browser_preopened_apptabs.js b/browser/components/sessionstore/test/browser_preopened_apptabs.js deleted file mode 100644 index 45de47891d3a..000000000000 --- a/browser/components/sessionstore/test/browser_preopened_apptabs.js +++ /dev/null @@ -1,138 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - * http://creativecommons.org/publicdomain/zero/1.0/ */ - -"use strict"; - -const PREF_RESTORE_ON_DEMAND = "browser.sessionstore.restore_on_demand"; -const PREF_NUM_PINNED_TABS = "browser.tabs.firstWindowRestore.numPinnedTabs"; - -function muffleMainWindowType() { - let oldWinType = document.documentElement.getAttribute("windowtype"); - // Check if we've already done this to allow calling multiple times: - if (oldWinType != "navigator:testrunner") { - // Make the main test window not count as a browser window any longer - document.documentElement.setAttribute("windowtype", "navigator:testrunner"); - - registerCleanupFunction(() => { - document.documentElement.setAttribute("windowtype", oldWinType); - }); - } -} - -registerCleanupFunction(function() { - Services.prefs.clearUserPref(PREF_NUM_PINNED_TABS); -}); - -add_task(async function testPrefSynced() { - Services.prefs.setIntPref(PREF_NUM_PINNED_TABS, 3); - - let state = { windows: [{ tabs: [ - { entries: [{ url: "http://example.org/#1", triggeringPrincipal_base64 }], pinned: true }, - { entries: [{ url: "http://example.org/#2", triggeringPrincipal_base64 }], pinned: true }, - { entries: [{ url: "http://example.org/#3", triggeringPrincipal_base64 }], pinned: true }, - ], selected: 3 }] }; - - muffleMainWindowType(); - let win = await BrowserTestUtils.openNewBrowserWindow(); - Assert.equal([...win.gBrowser.tabs].filter(t => t.pinned).length, 3); - Assert.equal([...win.gBrowser.tabs].filter(t => !!t.linkedPanel).length, 1); - await setWindowState(win, state, false, true); - Assert.equal([...win.gBrowser.tabs].filter(t => t.pinned).length, 3); - Assert.equal([...win.gBrowser.tabs].filter(t => !!t.linkedPanel).length, 4); - await BrowserTestUtils.closeWindow(win); -}); - -add_task(async function testPrefSyncedSelected() { - Services.prefs.setIntPref(PREF_NUM_PINNED_TABS, 3); - - let state = { windows: [{ tabs: [ - { entries: [{ url: "http://example.org/#1", triggeringPrincipal_base64 }], pinned: true }, - { entries: [{ url: "http://example.org/#2", triggeringPrincipal_base64 }], pinned: true }, - { entries: [{ url: "http://example.org/#3", triggeringPrincipal_base64 }], pinned: true }, - ], selected: 1 }] }; - - muffleMainWindowType(); - let win = await BrowserTestUtils.openNewBrowserWindow(); - Assert.equal([...win.gBrowser.tabs].filter(t => t.pinned).length, 3); - Assert.equal([...win.gBrowser.tabs].filter(t => !!t.linkedPanel).length, 1); - await setWindowState(win, state, false, true); - Assert.equal([...win.gBrowser.tabs].filter(t => t.pinned).length, 3); - Assert.equal([...win.gBrowser.tabs].filter(t => !!t.linkedPanel).length, 4); - await BrowserTestUtils.closeWindow(win); -}); - -add_task(async function testPrefTooHigh() { - Services.prefs.setIntPref(PREF_NUM_PINNED_TABS, 5); - - let state = { windows: [{ tabs: [ - { entries: [{ url: "http://example.org/#1", triggeringPrincipal_base64 }], pinned: true }, - { entries: [{ url: "http://example.org/#2", triggeringPrincipal_base64 }], pinned: true }, - { entries: [{ url: "http://example.org/#3", triggeringPrincipal_base64 }], pinned: true }, - ], selected: 3 }] }; - - muffleMainWindowType(); - let win = await BrowserTestUtils.openNewBrowserWindow(); - Assert.equal([...win.gBrowser.tabs].filter(t => t.pinned).length, 5); - Assert.equal([...win.gBrowser.tabs].filter(t => !!t.linkedPanel).length, 1); - await setWindowState(win, state, false, true); - Assert.equal([...win.gBrowser.tabs].filter(t => t.pinned).length, 3); - Assert.equal([...win.gBrowser.tabs].filter(t => !!t.linkedPanel).length, 4); - await BrowserTestUtils.closeWindow(win); -}); - -add_task(async function testPrefTooLow() { - Services.prefs.setIntPref(PREF_NUM_PINNED_TABS, 1); - - let state = { windows: [{ tabs: [ - { entries: [{ url: "http://example.org/#1", triggeringPrincipal_base64 }], pinned: true }, - { entries: [{ url: "http://example.org/#2", triggeringPrincipal_base64 }], pinned: true }, - { entries: [{ url: "http://example.org/#3", triggeringPrincipal_base64 }], pinned: true }, - ], selected: 3 }] }; - - muffleMainWindowType(); - let win = await BrowserTestUtils.openNewBrowserWindow(); - Assert.equal([...win.gBrowser.tabs].filter(t => t.pinned).length, 1); - Assert.equal([...win.gBrowser.tabs].filter(t => !!t.linkedPanel).length, 1); - await setWindowState(win, state, false, true); - Assert.equal([...win.gBrowser.tabs].filter(t => t.pinned).length, 3); - Assert.equal([...win.gBrowser.tabs].filter(t => !!t.linkedPanel).length, 4); - await BrowserTestUtils.closeWindow(win); -}); - -add_task(async function testPrefTooHighSelected() { - Services.prefs.setIntPref(PREF_NUM_PINNED_TABS, 5); - - let state = { windows: [{ tabs: [ - { entries: [{ url: "http://example.org/#1", triggeringPrincipal_base64 }], pinned: true }, - { entries: [{ url: "http://example.org/#2", triggeringPrincipal_base64 }], pinned: true }, - { entries: [{ url: "http://example.org/#3", triggeringPrincipal_base64 }], pinned: true }, - ], selected: 1 }] }; - - muffleMainWindowType(); - let win = await BrowserTestUtils.openNewBrowserWindow(); - Assert.equal([...win.gBrowser.tabs].filter(t => t.pinned).length, 5); - Assert.equal([...win.gBrowser.tabs].filter(t => !!t.linkedPanel).length, 1); - await setWindowState(win, state, false, true); - Assert.equal([...win.gBrowser.tabs].filter(t => t.pinned).length, 3); - Assert.equal([...win.gBrowser.tabs].filter(t => !!t.linkedPanel).length, 4); - await BrowserTestUtils.closeWindow(win); -}); - -add_task(async function testPrefTooLowSelected() { - Services.prefs.setIntPref(PREF_NUM_PINNED_TABS, 1); - - let state = { windows: [{ tabs: [ - { entries: [{ url: "http://example.org/#1", triggeringPrincipal_base64 }], pinned: true }, - { entries: [{ url: "http://example.org/#2", triggeringPrincipal_base64 }], pinned: true }, - { entries: [{ url: "http://example.org/#3", triggeringPrincipal_base64 }], pinned: true }, - ], selected: 1 }] }; - - muffleMainWindowType(); - let win = await BrowserTestUtils.openNewBrowserWindow(); - Assert.equal([...win.gBrowser.tabs].filter(t => t.pinned).length, 1); - Assert.equal([...win.gBrowser.tabs].filter(t => !!t.linkedPanel).length, 1); - await setWindowState(win, state, false, true); - Assert.equal([...win.gBrowser.tabs].filter(t => t.pinned).length, 3); - Assert.equal([...win.gBrowser.tabs].filter(t => !!t.linkedPanel).length, 4); - await BrowserTestUtils.closeWindow(win); -}); diff --git a/browser/components/sessionstore/test/head.js b/browser/components/sessionstore/test/head.js index ffe8fba51f3c..909e83da1cbb 100644 --- a/browser/components/sessionstore/test/head.js +++ b/browser/components/sessionstore/test/head.js @@ -190,9 +190,8 @@ async function setBrowserState(state, win = window) { await promiseWindowRestored(win); } -async function setWindowState(win, state, overwrite = false, firstWindow = false) { - ss.setWindowState(win, typeof state != "string" ? JSON.stringify(state) : state, - overwrite, firstWindow); +async function setWindowState(win, state, overwrite = false) { + ss.setWindowState(win, typeof state != "string" ? JSON.stringify(state) : state, overwrite); await promiseWindowRestored(win); } diff --git a/browser/modules/BrowserWindowTracker.jsm b/browser/modules/BrowserWindowTracker.jsm index a3b1eb9e868c..03ee9d11c2aa 100644 --- a/browser/modules/BrowserWindowTracker.jsm +++ b/browser/modules/BrowserWindowTracker.jsm @@ -96,11 +96,6 @@ function _untrackWindowOrder(window) { _trackedWindows.splice(idx, 1); } -function _trackPinnedTabs(window) { - Services.prefs.setIntPref("browser.tabs.firstWindowRestore.numPinnedTabs", - window.gBrowser._numPinnedTabs); -} - // Methods that impact a window. Put into single object for organization. var WindowHelper = { addWindow(window) { @@ -143,7 +138,6 @@ var WindowHelper = { _untrackWindowOrder(window); _trackWindowOrder(window); - _trackPinnedTabs(window); _updateCurrentContentOuterWindowID(window.gBrowser.selectedBrowser); },