Bug 893848 - Manifest properties aren't updated when installing apps multiple times. r=fabrice
authorAlexandre Poirot <poirot.alex@gmail.com>
Tue, 10 Sep 2013 12:52:56 -0400
changeset 146370 511d7aa49409a6f18f5199d20d6036947b9b3b3d
parent 146369 6a8d3277faaf0a7dcc073075e8b3a14e9651153d
child 146371 ae47eb6c9114d1fd1d9bfc77dd5ad837fc61757f
push id872
push userryanvm@gmail.com
push dateTue, 10 Sep 2013 16:53:21 +0000
treeherderb2g-inbound@511d7aa49409 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfabrice
bugs893848
milestone26.0a1
Bug 893848 - Manifest properties aren't updated when installing apps multiple times. r=fabrice
toolkit/devtools/server/actors/webapps.js
--- a/toolkit/devtools/server/actors/webapps.js
+++ b/toolkit/devtools/server/actors/webapps.js
@@ -144,16 +144,21 @@ WebappsActor.prototype = {
     this.conn = null;
   },
 
   _registerApp: function wa_actorRegisterApp(aApp, aId, aDir) {
     debug("registerApp");
     let reg = DOMApplicationRegistry;
     let self = this;
 
+    // Clean up the deprecated manifest cache if needed.
+    if (aId in reg._manifestCache) {
+      delete reg._manifestCache[aId];
+    }
+
     aApp.installTime = Date.now();
     aApp.installState = "installed";
     aApp.removable = true;
     aApp.id = aId;
     aApp.basePath = reg.getWebAppsBasePath();
     aApp.localId = (aId in reg.webapps) ? reg.webapps[aId].localId
                                         : reg._nextLocalId();
 
@@ -162,22 +167,34 @@ WebappsActor.prototype = {
 
     reg._readManifests([{ id: aId }], function(aResult) {
       let manifest = aResult[0].manifest;
       aApp.name = manifest.name;
       reg.updateAppHandlers(null, manifest, aApp);
 
       reg._saveApps(function() {
         aApp.manifest = manifest;
+
+        // Needed to evict manifest cache on content side
+        // (has to be dispatched first, otherwise other messages like
+        // Install:Return:OK are going to use old manifest version)
+        reg.broadcastMessage("Webapps:PackageEvent",
+                             { type: "installed",
+                               manifestURL: aApp.manifestURL,
+                               app: aApp,
+                               manifest: manifest
+                             });
+
         reg.broadcastMessage("Webapps:AddApp", { id: aId, app: aApp });
         reg.broadcastMessage("Webapps:Install:Return:OK",
                              { app: aApp,
                                oid: "foo",
                                requestID: "bar"
                              });
+
         delete aApp.manifest;
         self.conn.send({ from: self.actorID,
                          type: "webappsEvent",
                          appId: aId
                        });
 
         // We can't have appcache for packaged apps.
         if (!aApp.origin.startsWith("app://")) {