Bug 1455888 - Added a check to Policies.jsm addAllowDenyPermissions to to throw a warning when the user tries to add built-in sites to the permission manager r?Felipe Gomes draft
authorkanika <kanika16047@iiitd.ac.in>
Wed, 16 May 2018 21:36:25 +0530
changeset 796239 e446ef34fc4a68dfa8cc4e5c9278e9d189018da2
parent 796087 1800b8895c08bc0c60302775dc0a4b5ea4deb310
push id110190
push userbmo:kanika16047@iiitd.ac.in
push dateThu, 17 May 2018 10:02:18 +0000
reviewersFelipe
bugs1455888
milestone62.0a1
Bug 1455888 - Added a check to Policies.jsm addAllowDenyPermissions to to throw a warning when the user tries to add built-in sites to the permission manager r?Felipe Gomes MozReview-Commit-ID: 7msLqHQiJL5
browser/components/enterprisepolicies/Policies.jsm
--- a/browser/components/enterprisepolicies/Policies.jsm
+++ b/browser/components/enterprisepolicies/Policies.jsm
@@ -774,20 +774,24 @@ function setDefaultPref(prefName, prefVa
  * @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) {
-    Services.perms.add(origin,
-                       permissionName,
-                       Ci.nsIPermissionManager.ALLOW_ACTION,
-                       Ci.nsIPermissionManager.EXPIRE_POLICY);
+    try {
+      Services.perms.add(origin,
+                         permissionName,
+                         Ci.nsIPermissionManager.ALLOW_ACTION,
+                         Ci.nsIPermissionManager.EXPIRE_POLICY);
+  	} catch (ex) {
+  		log.warn(`Added by default in the permission manager - ${origin.spec}`);
+  	}
   }
 
   for (let origin of blockList) {
     Services.perms.add(origin,
                        permissionName,
                        Ci.nsIPermissionManager.DENY_ACTION,
                        Ci.nsIPermissionManager.EXPIRE_POLICY);
   }