Bug 1033453 - Fix the composed permission check on app updates. r=fabrice, a=2.0+
authorAntonio M. Amaya <amac@tid.es>
Tue, 08 Jul 2014 05:45:00 -0400
changeset 208851 8b04bdcbd916266f99a3b51150e4d5a62c8c176d
parent 208850 63f8f9ace2341c0bd8a7ff86108da14bd54a6c35
child 208852 756a66aa8ee75cfd15607119185161b793a0a6fc
push id494
push userraliiev@mozilla.com
push dateMon, 25 Aug 2014 18:42:16 +0000
treeherdermozilla-release@a3cc3e46b571 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfabrice, 2
bugs1033453
milestone32.0a2
Bug 1033453 - Fix the composed permission check on app updates. r=fabrice, a=2.0+
dom/apps/src/PermissionsInstaller.jsm
dom/apps/src/PermissionsTable.jsm
dom/apps/tests/file_packaged_app.template.webapp
dom/apps/tests/test_packaged_app_update.html
--- a/dom/apps/src/PermissionsInstaller.jsm
+++ b/dom/apps/src/PermissionsInstaller.jsm
@@ -162,17 +162,17 @@ this.PermissionsInstaller = {
                 ? PermissionsTable[permName]["certified"]
                 : PermissionsTable[permName][appStatus];
 
           let permValue = PERM_TO_STRING[permission];
           if (!aIsSystemUpdate && isPromptPermission) {
             // If it's not a system update, then we should keep the prompt
             // permissions that have been granted or denied previously.
             permValue =
-              PermissionSettingsModule.getPermission(permName,
+              PermissionSettingsModule.getPermission(expandedPermNames[idx],
                                                      aApp.manifestURL,
                                                      aApp.origin,
                                                      false);
             if (permValue === "unknown") {
               permValue = PERM_TO_STRING[permission];
             }
           }
 
--- a/dom/apps/src/PermissionsTable.jsm
+++ b/dom/apps/src/PermissionsTable.jsm
@@ -348,16 +348,25 @@ this.PermissionsTable =  { geolocation: 
                              app: DENY_ACTION,
                              privileged: ALLOW_ACTION,
                              certified: ALLOW_ACTION
                            },
                            "mobileid": {
                              app: DENY_ACTION,
                              privileged: PROMPT_ACTION,
                              certified: PROMPT_ACTION
+                           },
+                           // This permission doesn't actually grant access to
+                           // anything. It exists only to check the correctness
+                           // of web prompt composed permissions in tests.
+                           "test-permission": {
+                             app: PROMPT_ACTION,
+                             privileged: PROMPT_ACTION,
+                             certified: ALLOW_ACTION,
+                             access: ["read", "write", "create"]
                            }
                          };
 
 /**
  * Append access modes to the permission name as suffixes.
  *   e.g. permission name 'contacts' with ['read', 'write'] =
  *   ['contacts-read', contacts-write']
  * @param string aPermName
--- a/dom/apps/tests/file_packaged_app.template.webapp
+++ b/dom/apps/tests/file_packaged_app.template.webapp
@@ -3,16 +3,17 @@
   "version" : "VERSIONTOKEN",
   "size" : PACKAGESIZETOKEN,
   "package_path": "PACKAGEPATHTOKEN",
   "description": "Updated even faster than Firefox, just to annoy slashdotters",
   "permissions": {
      "geolocation": {},
      "audio-capture": {},
      "video-capture": {},
+     "test-permission": {"access": "readonly"},
      "downloads": {}
    },
   "launch_path": "tests/dom/apps/tests/file_packaged_app.sjs",
   "developer": {
     "name": "DEVELOPERTOKEN",
     "url": "DEVELOPERURLTOKEN"
   },
   "default_locale": "en-US"
--- a/dom/apps/tests/test_packaged_app_update.html
+++ b/dom/apps/tests/test_packaged_app_update.html
@@ -90,28 +90,31 @@ function updateApp(aExpectedReady, aPrev
                    true);
 
 }
 
 var initialPermissionState = {
   "geolocation": "prompt",
   "audio-capture": "prompt",
   "video-capture": "prompt",
+  "test-permission-read": "prompt",
   "downloads": "deny"
 }
 
 var permissionsToSet = {
   "geolocation": "allow",
+  "test-permission-read": "allow",
   "audio-capture": "deny"
 }
 
 var permissionsToCheck = {
   "geolocation": "allow",
   "audio-capture": "deny",
   "video-capture": "prompt",
+  "test-permission-read": "allow",
   "downloads": "deny"
 }
 
 function validatePermissions(aList, aDontFail) {
   var gApp = PackagedTestHelper.gApp;
   var mozPermissions = window.navigator.mozPermissionSettings;
   var permission;
   for (permission in aList) {