Bug 1392872 - Fix missing startup/shutdown reason in LegacyExtensionsUtils.
MozReview-Commit-ID: K8pyxR7Vhpl
--- a/toolkit/components/extensions/LegacyExtensionsUtils.jsm
+++ b/toolkit/components/extensions/LegacyExtensionsUtils.jsm
@@ -123,20 +123,23 @@ class EmbeddedExtension {
// Setup status flag.
this.started = false;
}
/**
* Start the embedded webextension.
*
+ * @param {number} reason
+ * The add-on startup bootstrap reason received from the XPIProvider.
+ *
* @returns {Promise<LegacyContextAPI>} A promise which resolve to the API exposed to the
* legacy context.
*/
- startup() {
+ startup(reason) {
if (this.started) {
return Promise.reject(new Error("This embedded extension has already been started"));
}
// Setup the startup promise.
this.startupPromise = new Promise((resolve, reject) => {
let embeddedExtensionURI = Services.io.newURI("webextension/", null, this.resourceURI);
@@ -180,52 +183,55 @@ class EmbeddedExtension {
// chained to it.
resolve(this.context.api);
};
this.extension.on("startup", onBeforeStarted);
// Run ambedded extension startup and catch any error during embedded extension
// startup.
- this.extension.startup().catch((err) => {
+ this.extension.startup(reason).catch((err) => {
this.started = false;
this.startupPromise = null;
this.extension.off("startup", onBeforeStarted);
reject(err);
});
});
return this.startupPromise;
}
/**
* Shuts down the embedded webextension.
*
+ * @param {number} reason
+ * The add-on shutdown bootstrap reason received from the XPIProvider.
+ *
* @returns {Promise<void>} a promise that is resolved when the shutdown has been done
*/
- shutdown() {
+ shutdown(reason) {
EmbeddedExtensionManager.untrackEmbeddedExtension(this);
// If there is a pending startup, wait to be completed and then shutdown.
if (this.startupPromise) {
let promise = this.startupPromise.then(() => {
- return this.extension.shutdown();
+ return this.extension.shutdown(reason);
});
AsyncShutdown.profileChangeTeardown.addBlocker(
`Legacy Extension Shutdown: ${this.addonId}`,
promise.catch(() => {}));
return promise;
}
// Run shutdown now if the embedded webextension has been correctly started
if (this.extension && this.started && !this.extension.hasShutdown) {
- this.extension.shutdown();
+ this.extension.shutdown(reason);
}
return Promise.resolve();
}
}
// Keep track on the created EmbeddedExtension instances and destroy
// them when their container addon is going to be disabled or uninstalled.