Bug 802675 - Fixing mozApp.checkForUpdate for packaged apps. r=fabrice
authorEtienne Segonzac <etienne@segonzac.info>
Thu, 18 Oct 2012 11:32:03 +0100
changeset 110781 06f60c3d1f86cb05c64fe51e661b7074ccaf734d
parent 110780 9d5f464dc1c011439ef075789c6b3df2c7ceb257
child 110782 89ff8e55638111c977538dbd22edf00b82f013ee
push id93
push usernmatsakis@mozilla.com
push dateWed, 31 Oct 2012 21:26:57 +0000
reviewersfabrice
bugs802675
milestone19.0a1
Bug 802675 - Fixing mozApp.checkForUpdate for packaged apps. r=fabrice
dom/apps/src/Webapps.jsm
--- a/dom/apps/src/Webapps.jsm
+++ b/dom/apps/src/Webapps.jsm
@@ -746,16 +746,18 @@ let DOMApplicationRegistry = {
       if (aOfflineCacheObserver) {
         cacheUpdate.addObserver(aOfflineCacheObserver, false);
       }
     }
   },
 
   checkForUpdate: function(aData, aMm) {
     let app = this.getAppByManifestURL(aData.manifestURL);
+    let installOrigin = app.installOrigin;
+
     if (!app) {
       aData.error = "NO_SUCH_APP";
       aMm.sendAsyncMessage("Webapps:CheckForUpdate:Return:KO", aData);
       return;
     }
 
     function sendError(aError) {
       aData.error = aError;
@@ -845,17 +847,17 @@ let DOMApplicationRegistry = {
     if (aData.etag) {
       xhr.setRequestHeader("If-None-Match", aData.etag);
     }
 
     xhr.addEventListener("load", (function() {
       if (xhr.status == 200) {
         let manifest;
         try {
-          JSON.parse(xhr.responseText, installOrigin);
+          manifest = JSON.parse(xhr.responseText);
         } catch(e) {
           sendError("MANIFEST_PARSE_ERROR");
           return;
         }
         if (!AppsUtils.checkManifest(manifest, installOrigin)) {
           sendError("INVALID_MANIFEST");
         } else {
           app.etag = xhr.getResponseHeader("Etag");