Bug 1429148 - Policy: Enforce choice for the Remember Passwords setting. r=MattN
authorFelipe Gomes <felipc@gmail.com>
Wed, 14 Feb 2018 23:50:36 -0200
changeset 404681 0c3184f918f0da21aa730d0577c2bdd8810ce2dc
parent 404680 c79437be5a27e3b34bee47d1b3351968a409b3d7
child 404682 ffe15fb2541cc5999f6fcee6c13e6075e4f0feb7
push id33487
push userncsoregi@mozilla.com
push dateWed, 21 Feb 2018 21:49:39 +0000
treeherdermozilla-central@4da181c6e053 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersMattN
bugs1429148
milestone60.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 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
@@ -148,16 +148,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
@@ -138,16 +138,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
@@ -18,9 +18,10 @@ support-files =
 [browser_policy_block_about_support.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");
+});