Bug 1078797 - Wait for running state before emitting install. r=ochameau
--- a/toolkit/devtools/apps/app-actor-front.js
+++ b/toolkit/devtools/apps/app-actor-front.js
@@ -660,62 +660,65 @@ AppActorFront.prototype = {
let request = {
to: this.actor,
type: "unwatchApps"
};
return this.client.request(request);
},
_clientListener: function (type, message) {
-
let { manifestURL } = message;
// Reset the app object to get a fresh copy when we (re)install the app.
if (type == "appInstall" && this._apps && this._apps.has(manifestURL)) {
this._apps.delete(manifestURL);
}
this._getApp(manifestURL).then((app) => {
switch(type) {
case "appOpen":
app.running = true;
+ this._notifyListeners("appOpen", app);
break;
case "appClose":
app.running = false;
+ this._notifyListeners("appClose", app);
break;
case "appInstall":
// The call to _getApp is going to create App object
// This app may have been running while being installed, so check the list
// of running apps again to get the right answer.
let request = {
to: this.actor,
type: "listRunningApps"
};
this.client.request(request)
.then(res => {
if (res.apps.indexOf(manifestURL) !== -1) {
app.running = true;
+ this._notifyListeners("appInstall", app);
this._notifyListeners("appOpen", app);
+ } else {
+ this._notifyListeners("appInstall", app);
}
});
break;
case "appUninstall":
// Fake a appClose event if we didn't got one before uninstall
if (app.running) {
app.running = false;
this._notifyListeners("appClose", app);
}
this._apps.delete(manifestURL);
+ this._notifyListeners("appUninstall", app);
break;
default:
return;
}
- this._notifyListeners(type, app);
-
});
},
_notifyListeners: function (type, app) {
this._listeners.forEach(f => {
f(type, app);
});
},