diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /browser/extensions/formautofill/test/unit/test_isAddressAutofillAvailable.js | |
parent | Initial commit. (diff) | |
download | firefox-esr-upstream.tar.xz firefox-esr-upstream.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'browser/extensions/formautofill/test/unit/test_isAddressAutofillAvailable.js')
-rw-r--r-- | browser/extensions/formautofill/test/unit/test_isAddressAutofillAvailable.js | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/browser/extensions/formautofill/test/unit/test_isAddressAutofillAvailable.js b/browser/extensions/formautofill/test/unit/test_isAddressAutofillAvailable.js new file mode 100644 index 0000000000..2d2940c33e --- /dev/null +++ b/browser/extensions/formautofill/test/unit/test_isAddressAutofillAvailable.js @@ -0,0 +1,74 @@ +/* Any copyright is dedicated to the Public Domain. +http://creativecommons.org/publicdomain/zero/1.0/ */ + +/** + * Test enabling address autofill in specific locales and regions. + */ + +"use strict"; + +const { FormAutofill } = ChromeUtils.importESModule( + "resource://autofill/FormAutofill.sys.mjs" +); + +add_task(async function test_defaultTestEnvironment() { + Assert.equal( + Services.prefs.getCharPref("extensions.formautofill.addresses.supported"), + "on" + ); +}); + +add_task(async function test_default_supported_module_and_autofill_region() { + Services.prefs.setCharPref("browser.search.region", "US"); + registerCleanupFunction(function cleanupRegion() { + Services.prefs.clearUserPref("browser.search.region"); + }); + + let addon = await AddonManager.getAddonByID(EXTENSION_ID); + await addon.reload(); + + Assert.equal(FormAutofill.isAutofillAddressesAvailable, true); + Assert.equal(FormAutofill.isAutofillAddressesEnabled, true); +}); + +add_task( + async function test_supported_creditCard_region_unsupported_address_region() { + Services.prefs.setCharPref( + "extensions.formautofill.addresses.supported", + "detect" + ); + Services.prefs.setCharPref( + "extensions.formautofill.creditCards.supported", + "detect" + ); + Services.prefs.setCharPref("browser.search.region", "FR"); + Services.prefs.setCharPref( + "extensions.formautofill.addresses.supportedCountries", + "US,CA" + ); + Services.prefs.setCharPref( + "extensions.formautofill.creditCards.supportedCountries", + "US,CA,FR" + ); + registerCleanupFunction(function cleanupPrefs() { + Services.prefs.clearUserPref("browser.search.region"); + Services.prefs.clearUserPref( + "extensions.formautofill.addresses.supportedCountries" + ); + Services.prefs.clearUserPref( + "extensions.formautofill.addresses.supported" + ); + Services.prefs.clearUserPref( + "extensions.formautofill.creditCards.supported" + ); + }); + + let addon = await AddonManager.getAddonByID(EXTENSION_ID); + await addon.reload(); + Assert.ok( + Services.prefs.getBoolPref("extensions.formautofill.creditCards.enabled") + ); + Assert.equal(FormAutofill.isAutofillAddressesAvailable, false); + Assert.equal(FormAutofill.isAutofillAddressesEnabled, false); + } +); |