Backed out changeset 3bd9591627ce (bug 1442694)

This commit is contained in:
Dão Gottwald 2019-03-07 11:31:48 +01:00
Родитель 14505d9bf1
Коммит 9d4207731e
4 изменённых файлов: 6 добавлений и 149 удалений

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

@ -249,8 +249,8 @@ var SessionStore = {
return SessionStoreInternal.getWindowState(aWindow); return SessionStoreInternal.getWindowState(aWindow);
}, },
setWindowState: function ss_setWindowState(aWindow, aState, aOverwrite, aFirstWindow) { setWindowState: function ss_setWindowState(aWindow, aState, aOverwrite) {
SessionStoreInternal.setWindowState(aWindow, aState, aOverwrite, aFirstWindow); SessionStoreInternal.setWindowState(aWindow, aState, aOverwrite);
}, },
getTabState: function ss_getTabState(aTab) { getTabState: function ss_getTabState(aTab) {
@ -2500,15 +2500,12 @@ var SessionStoreInternal = {
throw Components.Exception("Window is not tracked", Cr.NS_ERROR_INVALID_ARG); throw Components.Exception("Window is not tracked", Cr.NS_ERROR_INVALID_ARG);
}, },
setWindowState: function ssi_setWindowState(aWindow, aState, aOverwrite, aFirstWindow) { setWindowState: function ssi_setWindowState(aWindow, aState, aOverwrite) {
if (!aWindow.__SSi) { if (!aWindow.__SSi) {
throw Components.Exception("Window is not tracked", Cr.NS_ERROR_INVALID_ARG); throw Components.Exception("Window is not tracked", Cr.NS_ERROR_INVALID_ARG);
} }
this.restoreWindows(aWindow, aState, { this.restoreWindows(aWindow, aState, {overwriteTabs: aOverwrite});
overwriteTabs: aOverwrite,
firstWindow: aFirstWindow,
});
// Notify of changes to closed objects. // Notify of changes to closed objects.
this._notifyOfClosedObjectsChange(); this._notifyOfClosedObjectsChange();

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

@ -113,7 +113,6 @@ skip-if = (verify && (os == 'win' || os == 'mac'))
[browser_old_favicon.js] [browser_old_favicon.js]
[browser_page_title.js] [browser_page_title.js]
[browser_pending_tabs.js] [browser_pending_tabs.js]
[browser_preopened_apptabs.js]
[browser_privatetabs.js] [browser_privatetabs.js]
[browser_purge_shistory.js] [browser_purge_shistory.js]
skip-if = e10s # Bug 1271024 skip-if = e10s # Bug 1271024

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

@ -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);
});

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

@ -190,9 +190,8 @@ async function setBrowserState(state, win = window) {
await promiseWindowRestored(win); await promiseWindowRestored(win);
} }
async function setWindowState(win, state, overwrite = false, firstWindow = false) { async function setWindowState(win, state, overwrite = false) {
ss.setWindowState(win, typeof state != "string" ? JSON.stringify(state) : state, ss.setWindowState(win, typeof state != "string" ? JSON.stringify(state) : state, overwrite);
overwrite, firstWindow);
await promiseWindowRestored(win); await promiseWindowRestored(win);
} }