Bug 1429148 - Policy: Enforce choice for the Remember Passwords setting. r=MattN draft
authorFelipe Gomes <felipc@gmail.com>
Wed, 14 Feb 2018 23:50:36 -0200
changeset 755242 0c548848eaa0b90be5deec112122b840e8c2d21d
parent 754572 e43f2f6ea111c2d059d95fa9a71516b869a69698
child 755243 83e39ea03b3c3cc93d8b12738e1a03e0eeddc372
child 757639 17372be75d6722fe92582087d7297e91e6de3ceb
push id99131
push userfelipc@gmail.com
push dateThu, 15 Feb 2018 01:51:32 +0000
reviewersMattN
bugs1429148
milestone60.0a1
Bug 1429148 - Policy: Enforce choice for the Remember Passwords setting. r=MattN MozReview-Commit-ID: 3acY4QwQWGb
browser/components/enterprisepolicies/Policies.jsm
browser/components/enterprisepolicies/schemas/policies-schema.json
browser/components/enterprisepolicies/tests/browser/browser.ini
browser/components/enterprisepolicies/tests/browser/browser_policy_remember_passwords.js
--- a/browser/components/enterprisepolicies/Policies.jsm
+++ b/browser/components/enterprisepolicies/Policies.jsm
@@ -116,16 +116,22 @@ this.Policies = {
   },
 
   "popups": {
     onBeforeUIStartup(manager, param) {
       addAllowDenyPermissions("popup", param.allow, param.block);
     }
   },
 
+  "RememberPasswords": {
+    onBeforeUIStartup(manager, param) {
+      setAndLockPref("signon.rememberSignons", param);
+    }
+  },
+
   "install_addons": {
     onBeforeUIStartup(manager, param) {
       addAllowDenyPermissions("install", param.allow, param.block);
     }
   },
 
   "cookies": {
     onBeforeUIStartup(manager, param) {
--- a/browser/components/enterprisepolicies/schemas/policies-schema.json
+++ b/browser/components/enterprisepolicies/schemas/policies-schema.json
@@ -105,16 +105,23 @@
           "type": "array",
           "items": {
             "type": "origin"
           }
         }
       }
     },
 
+    "RememberPasswords": {
+      "description": "Enforces the setting to allow Firefox to remember saved logins and passwords. Both true and false values are accepted.",
+      "first_available": "60.0",
+
+      "type": "boolean"
+    },
+
     "install_addons": {
       "description": "Allow or deny popup websites to install webextensions.",
       "first_available": "60.0",
 
       "type": "object",
       "properties": {
         "allow": {
           "type": "array",
--- a/browser/components/enterprisepolicies/tests/browser/browser.ini
+++ b/browser/components/enterprisepolicies/tests/browser/browser.ini
@@ -13,9 +13,10 @@ support-files =
 [browser_policies_validate_and_parse_API.js]
 [browser_policy_block_set_desktop_background.js]
 [browser_policy_default_browser_check.js]
 [browser_policy_disable_fxscreenshots.js]
 [browser_policy_display_bookmarks.js]
 [browser_policy_disable_formhistory.js]
 [browser_policy_display_menu.js]
 [browser_policy_disable_shield.js]
+[browser_policy_remember_passwords.js]
 
new file mode 100644
--- /dev/null
+++ b/browser/components/enterprisepolicies/tests/browser/browser_policy_remember_passwords.js
@@ -0,0 +1,25 @@
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/ */
+
+"use strict";
+
+add_task(async function test_policy_remember_passwords() {
+  await setupPolicyEngineWithJson({
+    "policies": {
+      "RememberPasswords": false
+    }
+  });
+
+  is(Services.prefs.getBoolPref("signon.rememberSignons"), false, "Logins & Passwords have been disabled");
+  is(Services.prefs.prefIsLocked("signon.rememberSignons"), true, "Logins & Passwords pref has been locked");
+
+
+  await setupPolicyEngineWithJson({
+    "policies": {
+      "RememberPasswords": true
+    }
+  });
+
+  is(Services.prefs.getBoolPref("signon.rememberSignons"), true, "Logins & Passwords have been enabled");
+  is(Services.prefs.prefIsLocked("signon.rememberSignons"), true, "Logins & Passwords pref has been locked");
+});