Bug 1465537 Move browser startup promises to ExtensionParent.jsm
Creating these promises from ext-toolkit.js was always dicey since that
script is loaded asynchronously during startup. This should ensure that
the startup promises are reliably created early enough in startup.
MozReview-Commit-ID: A0V7iCOFNI8
--- a/toolkit/components/extensions/ExtensionParent.jsm
+++ b/toolkit/components/extensions/ExtensionParent.jsm
@@ -1724,24 +1724,36 @@ class CacheStore {
StartupCache.save();
}
}
for (let name of StartupCache.STORE_NAMES) {
StartupCache[name] = new CacheStore(name);
}
+function makeStartupPromise(event) {
+ return ExtensionUtils.promiseObserved(event).then(() => {});
+}
+
+// browserPaintedPromise and browserStartupPromise are promises that
+// resolve after the first browser window is painted and after browser
+// windows have been restored, respectively.
+let browserPaintedPromise = makeStartupPromise("browser-delayed-startup-finished");
+let browserStartupPromise = makeStartupPromise("sessionstore-windows-restored");
+
var ExtensionParent = {
GlobalManager,
HiddenExtensionPage,
IconDetails,
ParentAPIManager,
StartupCache,
WebExtensionPolicy,
apiManager,
+ browserPaintedPromise,
+ browserStartupPromise,
promiseExtensionViewLoaded,
watchExtensionProxyContextLoad,
DebugUtils,
};
XPCOMUtils.defineLazyGetter(ExtensionParent, "PlatformInfo", () => {
return Object.freeze({
os: (function() {
--- a/toolkit/components/extensions/parent/.eslintrc.js
+++ b/toolkit/components/extensions/parent/.eslintrc.js
@@ -9,18 +9,16 @@ module.exports = {
"InputEventManager": true,
"PRIVATE_STORE": true,
"TabBase": true,
"TabManagerBase": true,
"TabTrackerBase": true,
"WindowBase": true,
"WindowManagerBase": true,
"WindowTrackerBase": true,
- "browserPaintedPromise": true,
- "browserStartupPromise": true,
"getContainerForCookieStoreId": true,
"getCookieStoreIdForContainer": true,
"getCookieStoreIdForTab": true,
"isContainerCookieStoreId": true,
"isDefaultCookieStoreId": true,
"isPrivateCookieStoreId": true,
"isValidCookieStoreId": true,
},
--- a/toolkit/components/extensions/parent/ext-backgroundPage.js
+++ b/toolkit/components/extensions/parent/ext-backgroundPage.js
@@ -1,16 +1,18 @@
"use strict";
ChromeUtils.defineModuleGetter(this, "TelemetryStopwatch",
"resource://gre/modules/TelemetryStopwatch.jsm");
ChromeUtils.import("resource://gre/modules/ExtensionParent.jsm");
var {
HiddenExtensionPage,
+ browserPaintedPromise,
+ browserStartupPromise,
promiseExtensionViewLoaded,
} = ExtensionParent;
XPCOMUtils.defineLazyPreferenceGetter(this, "DELAYED_STARTUP",
"extensions.webextensions.background-delayed-startup");
// Responsible for the background_page section of the manifest.
class BackgroundPage extends HiddenExtensionPage {
--- a/toolkit/components/extensions/parent/ext-toolkit.js
+++ b/toolkit/components/extensions/parent/ext-toolkit.js
@@ -69,18 +69,8 @@ global.getContainerForCookieStoreId = fu
return null;
};
global.isValidCookieStoreId = function(storeId) {
return isDefaultCookieStoreId(storeId) ||
isPrivateCookieStoreId(storeId) ||
isContainerCookieStoreId(storeId);
};
-
-function makeStartupPromise(event) {
- return ExtensionUtils.promiseObserved(event).then(() => {});
-}
-
-// browserPaintedPromise and browserStartupPromise are promises that
-// resolve after the first browser window is painted and after browser
-// windows have been restored, respectively.
-global.browserPaintedPromise = makeStartupPromise("browser-delayed-startup-finished");
-global.browserStartupPromise = makeStartupPromise("sessionstore-windows-restored");