Bug 1429131 - Add policy to lock xpinstall.enabled. r=felipe draft
authorMichael Kaply <mozilla@kaply.com>
Tue, 03 Apr 2018 12:58:53 -0500
changeset 776763 b5a76b35562748e14e8fdda609a8f3036d6d6b86
parent 776748 5ec55f7a95f94cf39d57cdf36abecab914ea48eb
push id104987
push usermozilla@kaply.com
push dateTue, 03 Apr 2018 17:59:17 +0000
reviewersfelipe
bugs1429131
milestone61.0a1
Bug 1429131 - Add policy to lock xpinstall.enabled. r=felipe MozReview-Commit-ID: Frt4rMFL42K
browser/components/enterprisepolicies/Policies.jsm
browser/components/enterprisepolicies/schemas/policies-schema.json
browser/components/enterprisepolicies/tests/browser/browser_policies_simple_pref_policies.js
--- a/browser/components/enterprisepolicies/Policies.jsm
+++ b/browser/components/enterprisepolicies/Policies.jsm
@@ -479,17 +479,22 @@ var Policies = {
           Services.prefs.clearUserPref("browser.startup.page");
         });
       }
     }
   },
 
   "InstallAddons": {
     onBeforeUIStartup(manager, param) {
-      addAllowDenyPermissions("install", param.Allow, null);
+      if ("Allow" in param) {
+        addAllowDenyPermissions("install", param.Allow, null);
+      }
+      if ("Default" in param) {
+        setAndLockPref("xpinstall.enabled", param.Default);
+      }
     }
   },
 
   "NoDefaultBookmarks": {
     onProfileAfterChange(manager, param) {
       if (param) {
         manager.disallowFeature("defaultBookmarks");
       }
--- a/browser/components/enterprisepolicies/schemas/policies-schema.json
+++ b/browser/components/enterprisepolicies/schemas/policies-schema.json
@@ -374,16 +374,19 @@
 
       "type": "object",
       "properties": {
         "Allow": {
           "type": "array",
           "items": {
             "type": "origin"
           }
+        },
+        "Default": {
+          "type": "boolean"
         }
       }
     },
 
     "NoDefaultBookmarks": {
       "description": "Don't create the default bookmarks bundled with Firefox, nor the Smart Bookmarks (Most Visited, Recent Tags). Note: this policy is only effective if used before the first run of the profile.",
       "first_available": "60.0",
 
--- a/browser/components/enterprisepolicies/tests/browser/browser_policies_simple_pref_policies.js
+++ b/browser/components/enterprisepolicies/tests/browser/browser_policies_simple_pref_policies.js
@@ -96,16 +96,26 @@ const POLICIES_TESTS = [
       "Certificates": {
         "ImportEnterpriseRoots": true,
       }
     },
     lockedPrefs: {
       "security.enterprise_roots.enabled": true,
     }
   },
+  {
+    policies: {
+      "InstallAddons": {
+        "Default": false,
+      }
+    },
+    lockedPrefs: {
+      "xpinstall.enabled": false,
+    }
+  },
 ];
 
 add_task(async function test_policy_remember_passwords() {
   for (let test of POLICIES_TESTS) {
     await setupPolicyEngineWithJson({
       "policies": test.policies
     });