Use SessionStore.promiseInitialized() to avoid race condition in "about:home" (#774)

* Use SessionStore.promiseInitialized() to avoid race condition in "about:home"

* Improve code style of [d6c3adb91c9f29786f8ed8d93baa14c076494017]
This commit is contained in:
JustOff 2018-09-18 00:13:21 +03:00 • committed by Roy Tam
commit 0c0d82689f

View file

@ -2421,11 +2421,18 @@ function BrowserOnAboutPageLoad(doc) {
/* === about:home === */ /* === about:home === */
if (doc.documentURI.toLowerCase() == "about:home") { if (doc.documentURI.toLowerCase() == "about:home") {
let ss = Components.classes["@mozilla.org/browser/sessionstore;1"]. if (!PrivateBrowsingUtils.isWindowPrivate(window)) {
getService(Components.interfaces.nsISessionStore); let wrapper = {};
if (ss.canRestoreLastSession && Cu.import("resource:///modules/sessionstore/SessionStore.jsm", wrapper);
!PrivateBrowsingUtils.isWindowPrivate(window)) let ss = wrapper.SessionStore;
doc.getElementById("launcher").setAttribute("session", "true"); ss.promiseInitialized.then(function() {
if (ss.canRestoreLastSession) {
doc.getElementById("launcher").setAttribute("session", "true");
}
}).then(null, function onError(x) {
Cu.reportError("Error in SessionStore init while processing 'about:home': " + x);
});
}
// Inject search engine and snippets URL. // Inject search engine and snippets URL.
let docElt = doc.documentElement; let docElt = doc.documentElement;