Backed out changeset b821fc0de45c (bug 1543684) for failing browser_354894_perwindowpb.js on a CLOSED TREE

This commit is contained in:
Andreea Pavel 2019-05-06 19:52:40 +03:00
Родитель e9c2024ba3
Коммит afb105189c
2 изменённых файлов: 63 добавлений и 53 удалений

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

@ -54,10 +54,9 @@ const TYPE_DEFER_SESSION = 3;
// 'browser.startup.page' preference value to resume the previous session.
const BROWSER_STARTUP_RESUME_SESSION = 3;
function warning(msg, exception) {
function warning(aMsg, aException) {
let consoleMsg = Cc["@mozilla.org/scripterror;1"].createInstance(Ci.nsIScriptError);
consoleMsg.init(msg, exception.fileName, null, exception.lineNumber, 0, Ci.nsIScriptError.warningFlag,
"component javascript");
consoleMsg.init(aMsg, aException.fileName, null, aException.lineNumber, 0, Ci.nsIScriptError.warningFlag, "component javascript");
Services.console.logMessage(consoleMsg);
}
@ -80,7 +79,7 @@ var SessionStartup = {
RESUME_SESSION: TYPE_RESUME_SESSION,
DEFER_SESSION: TYPE_DEFER_SESSION,
// The state to restore at startup.
// the state to restore at startup
_initialState: null,
_sessionType: TYPE_NO_SESSION,
_initialized: false,
@ -95,7 +94,7 @@ var SessionStartup = {
/**
* Initialize the component
*/
init() {
init: function sss_init() {
Services.obs.notifyObservers(null, "sessionstore-init-started");
StartupPerformance.init();
@ -117,22 +116,26 @@ var SessionStartup = {
Services.prefs.setBoolPref("browser.sessionstore.resuming_after_os_restart", false);
}
this._resumeSessionEnabled =
Services.prefs.getBoolPref("browser.sessionstore.resume_session_once") ||
Services.prefs.getIntPref("browser.startup.page") == BROWSER_STARTUP_RESUME_SESSION;
SessionFile.read().then(
this._onSessionFileRead.bind(this),
console.error
);
},
// Wrap a string as a nsISupports.
_createSupportsString(data) {
// Wrap a string as a nsISupports
_createSupportsString: function ssfi_createSupportsString(aData) {
let string = Cc["@mozilla.org/supports-string;1"]
.createInstance(Ci.nsISupportsString);
string.data = data;
string.data = aData;
return string;
},
/**
* Complete initialization once the Session File has been read.
* Complete initialization once the Session File has been read
*
* @param source The Session State string read from disk.
* @param parsed The object obtained by parsing |source| as JSON.
@ -177,8 +180,8 @@ var SessionStartup = {
Services.telemetry.scalarSet("browser.engagement.restored_pinned_tabs_count", pinnedTabCount);
}, 60000);
// If this is a normal restore then throw away any previous session.
if (!this.isAutomaticRestoreEnabled() && this._initialState) {
// If this is a normal restore then throw away any previous session
if (!this._resumeSessionEnabled && this._initialState) {
delete this._initialState.lastSessionState;
}
@ -195,7 +198,7 @@ var SessionStartup = {
// a version including the Crash Monitor, or if the checkpoints file
// was removed, or on first startup with this profile, or after Firefox Reset.
// There was no checkpoints file and no sessionstore.js or its backups,
// There was no checkpoints file and no sessionstore.js or its backups
// so we will assume that this was a fresh profile.
this._previousSessionCrashed = false;
} else {
@ -220,16 +223,15 @@ var SessionStartup = {
// session restore was written, etc.
Services.telemetry.getHistogramById("SHUTDOWN_OK").add(!this._previousSessionCrashed);
// Set the startup type.
if (this.isAutomaticRestoreEnabled()) {
this._sessionType = this.RESUME_SESSION;
} else if (this._previousSessionCrashed && resumeFromCrash) {
// set the startup type
if (this._previousSessionCrashed && resumeFromCrash)
this._sessionType = this.RECOVER_SESSION;
} else if (this._initialState) {
else if (!this._previousSessionCrashed && this._resumeSessionEnabled)
this._sessionType = this.RESUME_SESSION;
else if (this._initialState)
this._sessionType = this.DEFER_SESSION;
} else {
this._initialState = null; // Reset the state.
}
else
this._initialState = null; // reset the state
Services.obs.addObserver(this, "sessionstore-windows-restored", true);
if (this._sessionType != this.NO_SESSION)
@ -245,19 +247,19 @@ var SessionStartup = {
/**
* Handle notifications
*/
observe(subject, topic, data) {
switch (topic) {
case "sessionstore-windows-restored":
Services.obs.removeObserver(this, "sessionstore-windows-restored");
// Free _initialState after nsSessionStore is done with it.
this._initialState = null;
this._didRestore = true;
break;
case "browser:purge-session-history":
Services.obs.removeObserver(this, "browser:purge-session-history");
// Reset all state on sanitization.
this._sessionType = this.NO_SESSION;
break;
observe: function sss_observe(aSubject, aTopic, aData) {
switch (aTopic) {
case "sessionstore-windows-restored":
Services.obs.removeObserver(this, "sessionstore-windows-restored");
// free _initialState after nsSessionStore is done with it
this._initialState = null;
this._didRestore = true;
break;
case "browser:purge-session-history":
Services.obs.removeObserver(this, "browser:purge-session-history");
// reset all state on sanitization
this._sessionType = this.NO_SESSION;
break;
}
},
@ -274,6 +276,15 @@ var SessionStartup = {
return this._initialState;
},
/**
* Determines whether there is a pending session restore. Should only be
* called after initialization has completed.
* @returns bool
*/
doRestore: function sss_doRestore() {
return this._willRestore();
},
/**
* Determines whether automatic session restoration is enabled for this
* launch of the browser. This does not include crash restoration. In
@ -282,33 +293,23 @@ var SessionStartup = {
* @returns bool
*/
isAutomaticRestoreEnabled() {
if (this._resumeSessionEnabled === null) {
this._resumeSessionEnabled = !PrivateBrowsingUtils.permanentPrivateBrowsing &&
(Services.prefs.getBoolPref("browser.sessionstore.resume_session_once") ||
Services.prefs.getIntPref("browser.startup.page") == BROWSER_STARTUP_RESUME_SESSION);
if (PrivateBrowsingUtils.permanentPrivateBrowsing) {
return false;
}
return this._resumeSessionEnabled;
return Services.prefs.getBoolPref("browser.sessionstore.resume_session_once") ||
Services.prefs.getIntPref("browser.startup.page") == BROWSER_STARTUP_RESUME_SESSION;
},
/**
* Determines whether there is a pending session restore.
* @returns bool
*/
willRestore() {
_willRestore() {
return this._sessionType == this.RECOVER_SESSION ||
this._sessionType == this.RESUME_SESSION;
},
/**
* Determines whether there is a pending session restore and if that will refer
* back to a crash.
* @returns bool
*/
willRestoreAsCrashed() {
return this._sessionType == this.RECOVER_SESSION;
},
/**
* Returns a boolean or a promise that resolves to a boolean, indicating
* whether we will restore a session that ends up replacing the homepage.
@ -323,7 +324,7 @@ var SessionStartup = {
// it when recovering from a crash, which we'll only know after reading the
// session file, but waiting for that would delay loading the homepage in
// the non-crash case.
if (!this._initialState && !this.isAutomaticRestoreEnabled()) {
if (!this._initialState && !this._resumeSessionEnabled) {
return false;
}
// If we've already restored the session, we won't override again.
@ -335,7 +336,7 @@ var SessionStartup = {
this.onceInitialized.then(() => {
// If there are valid windows with not only pinned tabs, signal that we
// will override the default homepage by restoring a session.
resolve(this.willRestore() &&
resolve(this._willRestore() &&
this._initialState &&
this._initialState.windows &&
this._initialState.windows.some(w => w.tabs.some(t => !t.pinned)));

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

@ -643,7 +643,7 @@ var SessionStoreInternal = {
let state;
let ss = SessionStartup;
if (ss.willRestore() ||
if (ss.doRestore() ||
ss.sessionType == ss.DEFER_SESSION) {
state = ss.state;
}
@ -674,7 +674,7 @@ var SessionStoreInternal = {
// restore it
LastSession.setState(state.lastSessionState);
if (ss.willRestoreAsCrashed()) {
if (ss.previousSessionCrashed) {
this._recentCrashes = (state.session &&
state.session.recentCrashes || 0) + 1;
@ -1224,7 +1224,7 @@ var SessionStoreInternal = {
if (closedWindowState) {
let newWindowState;
if (AppConstants.platform == "macosx" || !SessionStartup.willRestore()) {
if (AppConstants.platform == "macosx" || !this._doResumeSession()) {
// We want to split the window up into pinned tabs and unpinned tabs.
// Pinned tabs should be restored. If there are any remaining tabs,
// they should be added back to _closedWindows.
@ -4669,6 +4669,15 @@ var SessionStoreInternal = {
return window;
},
/**
* Whether or not to resume session, if not recovering from a crash.
* @returns bool
*/
_doResumeSession: function ssi_doResumeSession() {
return this._prefBranch.getIntPref("startup.page") == 3 ||
this._prefBranch.getBoolPref("sessionstore.resume_session_once");
},
/**
* whether the user wants to load any other page at startup
* (except the homepage) - needed for determining whether to overwrite the current tabs