From 6bf0a5cb5034a7e684dcc3500e841785237ce2dd Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 19:32:43 +0200 Subject: Adding upstream version 1:115.7.0. Signed-off-by: Daniel Baumann --- .../unit/test_isCreditCardAutofillAvailable.js | 84 ++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 browser/extensions/formautofill/test/unit/test_isCreditCardAutofillAvailable.js (limited to 'browser/extensions/formautofill/test/unit/test_isCreditCardAutofillAvailable.js') diff --git a/browser/extensions/formautofill/test/unit/test_isCreditCardAutofillAvailable.js b/browser/extensions/formautofill/test/unit/test_isCreditCardAutofillAvailable.js new file mode 100644 index 0000000000..5be5101ee6 --- /dev/null +++ b/browser/extensions/formautofill/test/unit/test_isCreditCardAutofillAvailable.js @@ -0,0 +1,84 @@ +/** + * Test enabling the feature in specific locales and regions. + */ + +"use strict"; + +const { FormAutofill } = ChromeUtils.importESModule( + "resource://autofill/FormAutofill.sys.mjs" +); + +add_task(async function test_defaultTestEnvironment() { + Assert.ok(Services.prefs.getBoolPref("dom.forms.autocomplete.formautofill")); +}); + +add_task(async function test_detect_unsupportedRegion() { + Services.prefs.setCharPref( + "extensions.formautofill.creditCards.supported", + "detect" + ); + Services.prefs.setCharPref( + "extensions.formautofill.creditCards.supportedCountries", + "US,CA" + ); + Services.prefs.setCharPref("browser.search.region", "ZZ"); + registerCleanupFunction(function cleanupRegion() { + Services.prefs.clearUserPref("browser.search.region"); + Services.prefs.clearUserPref( + "extensions.formautofill.creditCards.supported" + ); + Services.prefs.clearUserPref("extensions.formautofill.addresses.supported"); + Services.prefs.clearUserPref( + "extensions.formautofill.creditCards.supportedCountries" + ); + }); + + let addon = await AddonManager.getAddonByID(EXTENSION_ID); + await addon.reload(); + + Assert.equal( + FormAutofill.isAutofillCreditCardsAvailable, + false, + "Credit card autofill should not be available" + ); + Assert.equal( + FormAutofill.isAutofillCreditCardsEnabled, + false, + "Credit card autofill should not be enabled" + ); +}); + +add_task(async function test_detect_supportedRegion() { + Services.prefs.setCharPref( + "extensions.formautofill.creditCards.supported", + "detect" + ); + Services.prefs.setCharPref( + "extensions.formautofill.creditCards.supportedCountries", + "US,CA" + ); + Services.prefs.setCharPref("browser.search.region", "US"); + registerCleanupFunction(function cleanupRegion() { + Services.prefs.clearUserPref("browser.search.region"); + Services.prefs.clearUserPref( + "extensions.formautofill.creditCards.supported" + ); + Services.prefs.clearUserPref( + "extensions.formautofill.creditCards.supportedCountries" + ); + }); + + let addon = await AddonManager.getAddonByID(EXTENSION_ID); + await addon.reload(); + + Assert.equal( + FormAutofill.isAutofillCreditCardsAvailable, + true, + "Credit card autofill should be available" + ); + Assert.equal( + FormAutofill.isAutofillCreditCardsEnabled, + true, + "Credit card autofill should be enabled" + ); +}); -- cgit v1.2.3