Bug 1389525 - Add async version of nsISessionStartup::willOverrideHomepage. r?mikedeboer
MozReview-Commit-ID: 7zVR8H8cpB3
--- a/browser/components/sessionstore/nsISessionStartup.idl
+++ b/browser/components/sessionstore/nsISessionStartup.idl
@@ -43,16 +43,24 @@ interface nsISessionStartup: nsISupports
* This is meant to be an optimization for the average case that loading the
* session file finishes before we may want to start loading the default
* homepage. Should this be called before the session file has been read it
* will just return false.
*/
readonly attribute bool willOverrideHomepage;
/**
+ * Returns a promise that resolves to a boolean indicating whether we will
+ * restore a session that ends up replacing the homepage. The browser uses
+ * this to not start loading the homepage if we're going to stop its load
+ * anyway shortly after.
+ */
+ readonly attribute jsval willOverrideHomepagePromise;
+
+ /**
* What type of session we're restoring.
* NO_SESSION There is no data available from the previous session
* RECOVER_SESSION The last session crashed. It will either be restored or
* about:sessionrestore will be shown.
* RESUME_SESSION The previous session should be restored at startup
* DEFER_SESSION The previous session is fine, but it shouldn't be restored
* without explicit action (with the exception of pinned tabs)
*/
--- a/browser/components/sessionstore/nsSessionStartup.js
+++ b/browser/components/sessionstore/nsSessionStartup.js
@@ -329,16 +329,28 @@ SessionStartup.prototype = {
// If there are valid windows with not only pinned tabs, signal that we
// will override the default homepage by restoring a session.
return windows && windows.some(w => w.tabs.some(t => !t.pinned));
}
return false;
},
/**
+ * Returns a promise that resolves to a boolean indicating whether we will
+ * restore a session that ends up replacing the homepage. The browser uses
+ * this to not start loading the homepage if we're going to stop its load
+ * anyway shortly after.
+ */
+ get willOverrideHomepagePromise() {
+ return new Promise(resolve => {
+ resolve(this.willOverrideHomepage);
+ });
+ },
+
+ /**
* Get the type of pending session store, if any.
*/
get sessionType() {
return this._sessionType;
},
/**
* Get whether the previous session crashed.