Bug 1392872 - Fix missing startup/shutdown reason in LegacyExtensionsUtils. r=aswan

MozReview-Commit-ID: K8pyxR7Vhpl

--HG--
extra : rebase_source : 80d5a5b820969226fd7d297991ef76b1037b6e11
This commit is contained in:
Luca Greco 2017-08-23 15:43:09 +02:00
parent d5df18da33
commit 40aec4e04a

View File

@ -131,7 +131,7 @@ class EmbeddedExtension {
* @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"));
}
@ -185,7 +185,7 @@ class EmbeddedExtension {
// 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);
@ -202,13 +202,13 @@ class EmbeddedExtension {
*
* @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(
@ -220,7 +220,7 @@ class EmbeddedExtension {
// 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();