This is an automated email from the git hooks/post-receive script.
richard pushed a commit to branch base-browser-102.5.0esr-12.0-1 in repository tor-browser.
commit 682d77089460e7c3284c47b28e62f5c0fdd2e49a Author: Mike Kaply mozilla@kaply.com AuthorDate: Fri Oct 7 16:40:42 2022 +0000
Bug 1793742 - Disable autofill prefs when locked by policy. r=tgiles,credential-management-reviewers,sgalich, a=dmeehan
Differential Revision: https://phabricator.services.mozilla.com/D158676 --- .../test/browser/browser_privacyPreferences.js | 34 ++++++++++++++++++++++ toolkit/components/formautofill/FormAutofill.jsm | 14 +++++++++ .../formautofill/FormAutofillPreferences.jsm | 6 ++++ 3 files changed, 54 insertions(+)
diff --git a/browser/extensions/formautofill/test/browser/browser_privacyPreferences.js b/browser/extensions/formautofill/test/browser/browser_privacyPreferences.js index 7289d5a86934..d193f3b3405f 100644 --- a/browser/extensions/formautofill/test/browser/browser_privacyPreferences.js +++ b/browser/extensions/formautofill/test/browser/browser_privacyPreferences.js @@ -434,3 +434,37 @@ add_task(async function test_addressAutofillNotAvailableViaRegion() {
await SpecialPowers.popPrefEnv(); }); + +// Checkboxes should be disabled based on whether or not they are locked. +add_task(async function test_aboutPreferencesPrivacy() { + Services.prefs.lockPref(ENABLED_AUTOFILL_ADDRESSES_PREF); + Services.prefs.lockPref(ENABLED_AUTOFILL_CREDITCARDS_PREF); + registerCleanupFunction(function() { + Services.prefs.unlockPref(ENABLED_AUTOFILL_ADDRESSES_PREF); + Services.prefs.unlockPref(ENABLED_AUTOFILL_CREDITCARDS_PREF); + }); + let finalPrefPaneLoaded = TestUtils.topicObserved( + "sync-pane-loaded", + () => true + ); + await BrowserTestUtils.withNewTab( + { gBrowser, url: PAGE_PRIVACY }, + async function(browser) { + await finalPrefPaneLoaded; + await SpecialPowers.spawn(browser, [SELECTORS], selectors => { + is( + content.document.querySelector(selectors.addressAutofillCheckbox) + .disabled, + true, + "Autofill addresses checkbox should be disabled" + ); + is( + content.document.querySelector(selectors.creditCardAutofillCheckbox) + .disabled, + true, + "Autofill credit cards checkbox should be disabled" + ); + }); + } + ); +}); diff --git a/toolkit/components/formautofill/FormAutofill.jsm b/toolkit/components/formautofill/FormAutofill.jsm index c1a12b92595e..384f379b9447 100644 --- a/toolkit/components/formautofill/FormAutofill.jsm +++ b/toolkit/components/formautofill/FormAutofill.jsm @@ -146,6 +146,13 @@ var FormAutofill = { FormAutofill._isAutofillCreditCardsEnabled ); }, + /** + * Determines if credit card autofill is locked by policy. + * @returns {boolean} `true` if credit card autofill is locked + */ + get isAutofillCreditCardsLocked() { + return Services.prefs.prefIsLocked(ENABLED_AUTOFILL_CREDITCARDS_PREF); + }, /** * Determines if the user has enabled or disabled address autofill. * @returns {boolean} `true` if address autofill is enabled @@ -156,6 +163,13 @@ var FormAutofill = { FormAutofill._isAutofillAddressesEnabled ); }, + /** + * Determines if address autofill is locked by policy. + * @returns {boolean} `true` if address autofill is locked + */ + get isAutofillAddressesLocked() { + return Services.prefs.prefIsLocked(ENABLED_AUTOFILL_ADDRESSES_PREF); + },
defineLazyLogGetter(scope, logPrefix) { scope.debug = debug; diff --git a/toolkit/components/formautofill/FormAutofillPreferences.jsm b/toolkit/components/formautofill/FormAutofillPreferences.jsm index 1b007b29038a..e006e98f6c10 100644 --- a/toolkit/components/formautofill/FormAutofillPreferences.jsm +++ b/toolkit/components/formautofill/FormAutofillPreferences.jsm @@ -163,6 +163,9 @@ FormAutofillPreferences.prototype = { if (FormAutofill.isAutofillAddressesEnabled) { addressAutofillCheckbox.setAttribute("checked", true); } + if (FormAutofill.isAutofillAddressesLocked) { + addressAutofillCheckbox.disabled = true; + }
addressAutofillCheckboxGroup.setAttribute("align", "center"); addressAutofillCheckboxGroup.flex = 1; @@ -233,6 +236,9 @@ FormAutofillPreferences.prototype = { if (FormAutofill.isAutofillCreditCardsEnabled) { creditCardAutofillCheckbox.setAttribute("checked", true); } + if (FormAutofill.isAutofillCreditCardsLocked) { + creditCardAutofillCheckbox.disabled = true; + }
creditCardAutofillCheckboxGroup.setAttribute("align", "center"); creditCardAutofillCheckboxGroup.flex = 1;