forked from mirrors/gecko-dev
Bug 1793742 - Disable autofill prefs when locked by policy. r=tgiles,credential-management-reviewers,sgalich
Differential Revision: https://phabricator.services.mozilla.com/D158676
This commit is contained in:
parent
39288a2957
commit
b94d158f96
3 changed files with 54 additions and 0 deletions
|
|
@ -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"
|
||||
);
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -147,6 +147,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
|
||||
|
|
@ -157,6 +164,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);
|
||||
},
|
||||
|
||||
defineLogGetter(scope, logPrefix) {
|
||||
scope.debug = debug;
|
||||
|
|
|
|||
|
|
@ -164,6 +164,9 @@ FormAutofillPreferences.prototype = {
|
|||
if (FormAutofill.isAutofillAddressesEnabled) {
|
||||
addressAutofillCheckbox.setAttribute("checked", true);
|
||||
}
|
||||
if (FormAutofill.isAutofillAddressesLocked) {
|
||||
addressAutofillCheckbox.disabled = true;
|
||||
}
|
||||
|
||||
addressAutofillCheckboxGroup.setAttribute("align", "center");
|
||||
addressAutofillCheckboxGroup.setAttribute("flex", "1");
|
||||
|
|
@ -229,6 +232,9 @@ FormAutofillPreferences.prototype = {
|
|||
if (FormAutofill.isAutofillCreditCardsEnabled) {
|
||||
creditCardAutofillCheckbox.setAttribute("checked", true);
|
||||
}
|
||||
if (FormAutofill.isAutofillCreditCardsLocked) {
|
||||
creditCardAutofillCheckbox.disabled = true;
|
||||
}
|
||||
|
||||
creditCardAutofillCheckboxGroup.setAttribute("align", "center");
|
||||
creditCardAutofillCheckboxGroup.setAttribute("flex", "1");
|
||||
|
|
|
|||
Loading…
Reference in a new issue