Bug 1295151 - Install add-on should not show as a permission in the control center; r?MattN draft
authorFred Lin <gasolin@mozilla.com>
Mon, 19 Sep 2016 15:03:46 +0800
changeset 415009 f7048a999e24a7c2a0b2289a7feb32ea62e4fb39
parent 415008 520980c5d845fa81c96019c8321108688549f7d7
child 531524 1858535eecb8678da39fceaa2b31dbb104825371
push id29773
push userbmo:gasolin@mozilla.com
push dateMon, 19 Sep 2016 07:09:42 +0000
reviewersMattN
bugs1295151
milestone51.0a1
Bug 1295151 - Install add-on should not show as a permission in the control center; r?MattN MozReview-Commit-ID: ChkG0AU743W
browser/modules/SitePermissions.jsm
browser/modules/test/xpcshell/test_SitePermissions.js
--- a/browser/modules/SitePermissions.jsm
+++ b/browser/modules/SitePermissions.jsm
@@ -19,29 +19,35 @@ this.SitePermissions = {
   /* Returns all custom permissions for a given URI, the return
    * type is a list of objects with the keys:
    * - id: the permissionId of the permission
    * - state: a constant representing the current permission state
    *   (e.g. SitePermissions.ALLOW)
    *
    * To receive a more detailed, albeit less performant listing see
    * SitePermissions.getPermissionDetailsByURI().
+   *
+   * install addon permission is excluded, check bug 1303108
    */
   getAllByURI: function (aURI) {
     let result = [];
     if (!this.isSupportedURI(aURI)) {
       return result;
     }
 
     let permissions = Services.perms.getAllForURI(aURI);
     while (permissions.hasMoreElements()) {
       let permission = permissions.getNext();
 
       // filter out unknown permissions
       if (gPermissionObject[permission.type]) {
+        // XXX Bug 1303108 - Control Center should only show non-default permissions
+        if (permission.type == "install") {
+          continue;
+        }
         result.push({
           id: permission.type,
           state: permission.capability,
         });
       }
     }
 
     return result;
--- a/browser/modules/test/xpcshell/test_SitePermissions.js
+++ b/browser/modules/test/xpcshell/test_SitePermissions.js
@@ -40,16 +40,21 @@ add_task(function* testGetAllByURI() {
   Assert.deepEqual(SitePermissions.getAllByURI(uri), [
       { id: "camera", state: SitePermissions.ALLOW },
       { id: "desktop-notification", state: SitePermissions.BLOCK }
   ]);
 
   SitePermissions.remove(uri, "camera");
   SitePermissions.remove(uri, "desktop-notification");
   Assert.deepEqual(SitePermissions.getAllByURI(uri), []);
+
+  // XXX Bug 1303108 - Control Center should only show non-default permissions
+  SitePermissions.set(uri, "addon", SitePermissions.BLOCK);
+  Assert.deepEqual(SitePermissions.getAllByURI(uri), []);
+  SitePermissions.remove(uri, "addon");
 });
 
 add_task(function* testGetPermissionDetailsByURI() {
   // check that it returns an empty array on an invalid URI
   // like a file URI, which doesn't support site permissions
   let wrongURI = Services.io.newURI("file:///example.js", null, null)
   Assert.deepEqual(SitePermissions.getPermissionDetailsByURI(wrongURI), []);