Bug 1474131: Don't load ContentRestore.jsm before it's needed. r?mconley
MozReview-Commit-ID: 6ftGscrrdRb
--- a/browser/base/content/test/performance/browser_startup_content.js
+++ b/browser/base/content/test/performance/browser_startup_content.js
@@ -40,17 +40,16 @@ const whitelist = {
"resource://gre/modules/Services.jsm", // bug 1464542
"resource://gre/modules/Timer.jsm",
"resource://gre/modules/XPCOMUtils.jsm",
// Logging related
"resource://gre/modules/Log.jsm",
// Session store
- "resource:///modules/sessionstore/ContentRestore.jsm",
"resource://gre/modules/sessionstore/SessionHistory.jsm",
// Forms and passwords
"resource://formautofill/FormAutofillContent.jsm",
"resource://formautofill/FormAutofillUtils.jsm",
// Browser front-end
"resource:///modules/ContentLinkHandler.jsm",
--- a/browser/components/sessionstore/content/content-sessionStore.js
+++ b/browser/components/sessionstore/content/content-sessionStore.js
@@ -15,28 +15,34 @@ ChromeUtils.defineModuleGetter(this, "Te
function debug(msg) {
Services.console.logStringMessage("SessionStoreContent: " + msg);
}
ChromeUtils.defineModuleGetter(this, "FormData",
"resource://gre/modules/FormData.jsm");
+ChromeUtils.defineModuleGetter(this, "ContentRestore",
+ "resource:///modules/sessionstore/ContentRestore.jsm");
ChromeUtils.defineModuleGetter(this, "DocShellCapabilities",
"resource:///modules/sessionstore/DocShellCapabilities.jsm");
ChromeUtils.defineModuleGetter(this, "ScrollPosition",
"resource://gre/modules/ScrollPosition.jsm");
ChromeUtils.defineModuleGetter(this, "SessionHistory",
"resource://gre/modules/sessionstore/SessionHistory.jsm");
ChromeUtils.defineModuleGetter(this, "SessionStorage",
"resource:///modules/sessionstore/SessionStorage.jsm");
-ChromeUtils.import("resource:///modules/sessionstore/ContentRestore.jsm", this);
+var contentRestoreInitialized = false;
+
XPCOMUtils.defineLazyGetter(this, "gContentRestore",
- () => { return new ContentRestore(this); });
+ () => {
+ contentRestoreInitialized = true;
+ return new ContentRestore(this);
+ });
ChromeUtils.defineModuleGetter(this, "Utils",
"resource://gre/modules/sessionstore/Utils.jsm");
const ssu = Cc["@mozilla.org/browser/sessionstore/utils;1"]
.getService(Ci.nsISessionStoreUtils);
// The current epoch.
var gCurrentEpoch = 0;
@@ -154,19 +160,21 @@ var EventListener = {
// point; listen for the custom event dispatched from AboutReader.jsm.
content.addEventListener("AboutReaderContentReady", this);
return;
}
content.removeEventListener("AboutReaderContentReady", this);
}
- // Restore the form data and scroll position. If we're not currently
- // restoring a tab state then this call will simply be a noop.
- gContentRestore.restoreDocument();
+ if (contentRestoreInitialized) {
+ // Restore the form data and scroll position. If we're not currently
+ // restoring a tab state then this call will simply be a noop.
+ gContentRestore.restoreDocument();
+ }
}
};
/**
* Listens for and handles messages sent by the session store service.
*/
var MessageListener = {
@@ -957,15 +965,17 @@ addEventListener("unload", () => {
// event to be fired.
handleRevivedTab();
// Remove all registered nsIObservers.
SessionStorageListener.uninit();
SessionHistoryListener.uninit();
MessageQueue.uninit();
- // Remove progress listeners.
- gContentRestore.resetRestore();
+ if (contentRestoreInitialized) {
+ // Remove progress listeners.
+ gContentRestore.resetRestore();
+ }
// We don't need to take care of any StateChangeNotifier observers as they
// will die with the content script. The same goes for the privacy transition
// observer that will die with the docShell when the tab is closed.
});