Bug 1574483 - Updated Policies.jsm to use PermissionManager principal methods. r=mkaply
authorPaul Zuehlcke <pzuhlcke@mozilla.com>
Mon, 19 Aug 2019 16:28:26 +0000
changeset 488902 2c949f8b0d63153639fa72bcb66aac3ae0d41233
parent 488901 eab2f870a742d82d240f9b3738911c0936cdfb42
child 488903 44918721e54f895158d50c0150763e15d78ec095
push id93016
push userpzuhlcke@mozilla.com
push dateTue, 20 Aug 2019 08:20:04 +0000
treeherderautoland@2c949f8b0d63 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmkaply
bugs1574483
milestone70.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1574483 - Updated Policies.jsm to use PermissionManager principal methods. r=mkaply Differential Revision: https://phabricator.services.mozilla.com/D42523
browser/components/enterprisepolicies/Policies.jsm
--- a/browser/components/enterprisepolicies/Policies.jsm
+++ b/browser/components/enterprisepolicies/Policies.jsm
@@ -1431,47 +1431,47 @@ function setDefaultPermission(policyName
       setDefaultPref(prefName, 0, policyParam.Locked);
     }
   }
 }
 
 /**
  * addAllowDenyPermissions
  *
- * Helper function to call the permissions manager (Services.perms.add)
+ * Helper function to call the permissions manager (Services.perms.addFromPrincipal)
  * for two arrays of URLs.
  *
  * @param {string} permissionName
  *        The name of the permission to change
  * @param {array} allowList
  *        The list of URLs to be set as ALLOW_ACTION for the chosen permission.
  * @param {array} blockList
  *        The list of URLs to be set as DENY_ACTION for the chosen permission.
  */
 function addAllowDenyPermissions(permissionName, allowList, blockList) {
   allowList = allowList || [];
   blockList = blockList || [];
 
   for (let origin of allowList) {
     try {
-      Services.perms.add(
-        Services.io.newURI(origin.href),
+      Services.perms.addFromPrincipal(
+        Services.scriptSecurityManager.createContentPrincipalFromOrigin(origin),
         permissionName,
         Ci.nsIPermissionManager.ALLOW_ACTION,
         Ci.nsIPermissionManager.EXPIRE_POLICY
       );
     } catch (ex) {
       log.error(`Added by default for ${permissionName} permission in the permission
       manager - ${origin.href}`);
     }
   }
 
   for (let origin of blockList) {
-    Services.perms.add(
-      Services.io.newURI(origin.href),
+    Services.perms.addFromPrincipal(
+      Services.scriptSecurityManager.createContentPrincipalFromOrigin(origin),
       permissionName,
       Ci.nsIPermissionManager.DENY_ACTION,
       Ci.nsIPermissionManager.EXPIRE_POLICY
     );
   }
 }
 
 /**