Bug 805934 - Ignore unknown permissions during install and don't throw. r=fabrice
authorGregor Wagner <gwagner@mozilla.com>
Fri, 26 Oct 2012 20:45:25 -0700
changeset 111733 485735473745d9f51e1a4c8014e6945856bf7f6d
parent 111732 ba9fb2ed910cf0e8a899d689eb8c898994a4e060
child 111734 7a2f469390e2eb4e6a21ca07b2538f32a9ff4f8b
push id93
push usernmatsakis@mozilla.com
push dateWed, 31 Oct 2012 21:26:57 +0000
reviewersfabrice
bugs805934
milestone19.0a1
Bug 805934 - Ignore unknown permissions during install and don't throw. r=fabrice
dom/apps/src/PermissionsInstaller.jsm
--- a/dom/apps/src/PermissionsInstaller.jsm
+++ b/dom/apps/src/PermissionsInstaller.jsm
@@ -265,20 +265,20 @@ for (let permName in PermissionsTable) {
  *   ['contacts-read', 'contacts-create', contacts-write']
  * @param string aPermName
  * @param string aAccess
  * @returns Array
  **/
 function expandPermissions(aPermName, aAccess) {
   if (!PermissionsTable[aPermName]) {
     Cu.reportError("PermissionsTable.jsm: expandPermissions: Unknown Permission: " + aPermName);
-    throw new Error("PermissionsTable.jsm: expandPermissions: Unknown Permission: " + aPermName);
+    return [];
   }
 
-/* 
+/*
 Temporarily disabled in order to add access fields to gaia: See Bug 805646
   if (!aAccess && PermissionsTable[aPermName].access ||
       aAccess && !PermissionsTable[aPermName].access) {
     Cu.reportError("PermissionsTable.jsm: expandPermissions: Invalid Manifest : " +
                    aPermName + " " + aAccess + "\n");
     throw new Error("PermissionsTable.jsm: expandPermissions: Invalid Manifest");
   }
 */
@@ -382,19 +382,19 @@ let PermissionsInstaller = {
         break;
       default:
         // Cannot determine app type, abort install by throwing an error
         throw new Error("PermissionsInstaller.jsm: Cannot determine app type, install cancelled");
       }
 
       for (let permName in newManifest.permissions) {
         if (!PermissionsTable[permName]) {
-          throw new Error("PermissionsInstaller.jsm: '" + permName + "'" +
-                         " is not a valid Webapps permission type. Aborting Webapp installation");
-          return;
+          Cu.reportError("PermissionsInstaller.jsm: '" + permName + "'" +
+                         " is not a valid Webapps permission type.");
+          continue;
         }
 
         let perms = expandPermissions(permName,
                                       newManifest.permissions[permName].access);
         for (let idx in perms) {
           let perm = PermissionsTable[permName][installPermType];
           let permValue = PERM_TO_STRING[perm];
           this._setPermission(perms[idx], permValue, aApp);