Bug 1392653: Remove redundant LegacyExtensionUtils shutdown blocker. r?aswan
The base Extension class now handles adding shutdown blockers and waiting for
extension startup before beginning shutdown, so the redundant logic only
causes problems.
MozReview-Commit-ID: 2gBWlmIs1KQ
--- a/toolkit/components/extensions/LegacyExtensionsUtils.jsm
+++ b/toolkit/components/extensions/LegacyExtensionsUtils.jsm
@@ -12,18 +12,16 @@ this.EXPORTED_SYMBOLS = ["LegacyExtensio
* This file exports helpers for Legacy Extensions that want to embed a webextensions
* and exchange messages with the embedded WebExtension.
*/
const {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components;
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
-XPCOMUtils.defineLazyModuleGetter(this, "AsyncShutdown",
- "resource://gre/modules/AsyncShutdown.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "Extension",
"resource://gre/modules/Extension.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "ExtensionChild",
"resource://gre/modules/ExtensionChild.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "Services",
"resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/ExtensionCommon.jsm");
@@ -197,38 +195,26 @@ class EmbeddedExtension {
return this.startupPromise;
}
/**
* Shuts down the embedded webextension.
*
* @returns {Promise<void>} a promise that is resolved when the shutdown has been done
*/
- shutdown() {
+ async shutdown() {
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();
- });
-
- AsyncShutdown.profileChangeTeardown.addBlocker(
- `Legacy Extension Shutdown: ${this.addonId}`,
- promise.catch(() => {}));
+ if (this.extension && !this.extension.hasShutdown) {
+ let {extension} = this;
+ this.extension = null;
- return promise;
+ await extension.shutdown();
}
-
- // Run shutdown now if the embedded webextension has been correctly started
- if (this.extension && this.started && !this.extension.hasShutdown) {
- this.extension.shutdown();
- }
-
- return Promise.resolve();
+ return undefined;
}
}
// Keep track on the created EmbeddedExtension instances and destroy
// them when their container addon is going to be disabled or uninstalled.
EmbeddedExtensionManager = {
// Map of the existent EmbeddedExtensions instances by addon id.
embeddedExtensionsByAddonId: new Map(),