Bug 1379721: Add separate AsyncShutdown blocker for embedded extension shutdown. r?rhelmer
MozReview-Commit-ID: CognGxT3BGp
--- a/toolkit/components/extensions/LegacyExtensionsUtils.jsm
+++ b/toolkit/components/extensions/LegacyExtensionsUtils.jsm
@@ -12,16 +12,18 @@ 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");
@@ -200,19 +202,25 @@ class EmbeddedExtension {
*
* @returns {Promise<void>} a promise that is resolved when the shutdown has been done
*/
shutdown() {
EmbeddedExtensionManager.untrackEmbeddedExtension(this);
// If there is a pending startup, wait to be completed and then shutdown.
if (this.startupPromise) {
- return this.startupPromise.then(() => {
- this.extension.shutdown();
+ let promise = this.startupPromise.then(() => {
+ return this.extension.shutdown();
});
+
+ 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();
}
return Promise.resolve();