diff options
author | JustOff <Off.Just.Off@gmail.com> | 2018-09-18 00:13:21 +0300 |
---|---|---|
committer | Moonchild <mcwerewolf@gmail.com> | 2018-09-17 23:13:21 +0200 |
commit | ab47a3a9a6c1d05d74e4f5bd00fbd8ea94f90e1a (patch) | |
tree | d0200d851180144fc853e96f95e3337c60b0e23e | |
parent | 5bcd1cc228e73d47bdecc38086aff77b15f5ecbc (diff) | |
download | UXP-ab47a3a9a6c1d05d74e4f5bd00fbd8ea94f90e1a.tar UXP-ab47a3a9a6c1d05d74e4f5bd00fbd8ea94f90e1a.tar.gz UXP-ab47a3a9a6c1d05d74e4f5bd00fbd8ea94f90e1a.tar.lz UXP-ab47a3a9a6c1d05d74e4f5bd00fbd8ea94f90e1a.tar.xz UXP-ab47a3a9a6c1d05d74e4f5bd00fbd8ea94f90e1a.zip |
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]
-rw-r--r-- | application/palemoon/base/content/browser.js | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/application/palemoon/base/content/browser.js b/application/palemoon/base/content/browser.js index 5cf43850a..4167f186c 100644 --- a/application/palemoon/base/content/browser.js +++ b/application/palemoon/base/content/browser.js @@ -2421,11 +2421,18 @@ function BrowserOnAboutPageLoad(doc) { /* === about:home === */ if (doc.documentURI.toLowerCase() == "about:home") { - let ss = Components.classes["@mozilla.org/browser/sessionstore;1"]. - getService(Components.interfaces.nsISessionStore); - if (ss.canRestoreLastSession && - !PrivateBrowsingUtils.isWindowPrivate(window)) - doc.getElementById("launcher").setAttribute("session", "true"); + if (!PrivateBrowsingUtils.isWindowPrivate(window)) { + let wrapper = {}; + Cu.import("resource:///modules/sessionstore/SessionStore.jsm", wrapper); + let ss = wrapper.SessionStore; + 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. let docElt = doc.documentElement; |