summaryrefslogtreecommitdiffstats
path: root/browser/components/tests/unit
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-12 05:35:37 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-12 05:35:37 +0000
commita90a5cba08fdf6c0ceb95101c275108a152a3aed (patch)
tree532507288f3defd7f4dcf1af49698bcb76034855 /browser/components/tests/unit
parentAdding debian version 126.0.1-1. (diff)
downloadfirefox-a90a5cba08fdf6c0ceb95101c275108a152a3aed.tar.xz
firefox-a90a5cba08fdf6c0ceb95101c275108a152a3aed.zip
Merging upstream version 127.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'browser/components/tests/unit')
-rw-r--r--browser/components/tests/unit/test_browserGlue_migration_osauth.js159
-rw-r--r--browser/components/tests/unit/xpcshell.toml3
2 files changed, 162 insertions, 0 deletions
diff --git a/browser/components/tests/unit/test_browserGlue_migration_osauth.js b/browser/components/tests/unit/test_browserGlue_migration_osauth.js
new file mode 100644
index 0000000000..5676ea2fa9
--- /dev/null
+++ b/browser/components/tests/unit/test_browserGlue_migration_osauth.js
@@ -0,0 +1,159 @@
+/* Any copyright is dedicated to the Public Domain.
+ http://creativecommons.org/publicdomain/zero/1.0/ */
+
+"use strict";
+
+const TOPIC_BROWSERGLUE_TEST = "browser-glue-test";
+const TOPICDATA_BROWSERGLUE_TEST = "force-ui-migration";
+const gBrowserGlue = Cc["@mozilla.org/browser/browserglue;1"].getService(
+ Ci.nsIObserver
+);
+const UI_VERSION = 147;
+
+const { LoginHelper } = ChromeUtils.importESModule(
+ "resource://gre/modules/LoginHelper.sys.mjs"
+);
+const { FormAutofillUtils } = ChromeUtils.importESModule(
+ "resource://gre/modules/shared/FormAutofillUtils.sys.mjs"
+);
+
+const CC_OLD_PREF = "extensions.formautofill.reauth.enabled";
+const CC_TYPO_PREF = "extensions.formautofill.creditcards.reauth.optout";
+const CC_NEW_PREF = FormAutofillUtils.AUTOFILL_CREDITCARDS_REAUTH_PREF;
+
+const PASSWORDS_OLD_PREF = "signon.management.page.os-auth.enabled";
+const PASSWORDS_NEW_PREF = LoginHelper.OS_AUTH_FOR_PASSWORDS_PREF;
+
+function clearPrefs() {
+ Services.prefs.clearUserPref("browser.migration.version");
+ Services.prefs.clearUserPref(CC_OLD_PREF);
+ Services.prefs.clearUserPref(CC_TYPO_PREF);
+ Services.prefs.clearUserPref(CC_NEW_PREF);
+ Services.prefs.clearUserPref(PASSWORDS_OLD_PREF);
+ Services.prefs.clearUserPref(PASSWORDS_NEW_PREF);
+ Services.prefs.clearUserPref("browser.startup.homepage_override.mstone");
+}
+
+function simulateUIMigration() {
+ gBrowserGlue.observe(
+ null,
+ TOPIC_BROWSERGLUE_TEST,
+ TOPICDATA_BROWSERGLUE_TEST
+ );
+}
+
+add_task(async function setup() {
+ registerCleanupFunction(clearPrefs);
+});
+
+add_task(async function test_pref_migration_old_pref_os_auth_disabled() {
+ Services.prefs.setIntPref("browser.migration.version", UI_VERSION - 1);
+ Services.prefs.setBoolPref(CC_OLD_PREF, false);
+ Services.prefs.setBoolPref(PASSWORDS_OLD_PREF, false);
+
+ simulateUIMigration();
+
+ Assert.ok(
+ !FormAutofillUtils.getOSAuthEnabled(CC_NEW_PREF),
+ "OS Auth should be disabled for credit cards since it was disabled before migration."
+ );
+ Assert.ok(
+ !LoginHelper.getOSAuthEnabled(PASSWORDS_NEW_PREF),
+ "OS Auth should be disabled for passwords since it was disabled before migration."
+ );
+ clearPrefs();
+});
+
+add_task(async function test_pref_migration_old_pref_os_auth_enabled() {
+ Services.prefs.setIntPref("browser.migration.version", UI_VERSION - 1);
+ Services.prefs.setBoolPref(CC_OLD_PREF, true);
+ Services.prefs.setBoolPref(PASSWORDS_OLD_PREF, true);
+
+ simulateUIMigration();
+
+ Assert.ok(
+ FormAutofillUtils.getOSAuthEnabled(CC_NEW_PREF),
+ "OS Auth should be enabled for credit cards since it was enabled before migration."
+ );
+ Assert.ok(
+ LoginHelper.getOSAuthEnabled(PASSWORDS_NEW_PREF),
+ "OS Auth should be enabled for passwords since it was enabled before migration."
+ );
+ clearPrefs();
+});
+
+add_task(
+ async function test_creditCards_pref_migration_typo_pref_os_auth_disabled() {
+ Services.prefs.setIntPref("browser.migration.version", UI_VERSION - 1);
+ Services.prefs.setCharPref(
+ "browser.startup.homepage_override.mstone",
+ "127.0"
+ );
+ FormAutofillUtils.setOSAuthEnabled(CC_TYPO_PREF, false);
+
+ simulateUIMigration();
+
+ Assert.ok(
+ !FormAutofillUtils.getOSAuthEnabled(CC_NEW_PREF),
+ "OS Auth should be disabled for credit cards since it was disabled before migration."
+ );
+ clearPrefs();
+ }
+);
+
+add_task(
+ async function test_creditCards_pref_migration_typo_pref_os_auth_enabled() {
+ Services.prefs.setIntPref("browser.migration.version", UI_VERSION - 1);
+ Services.prefs.setCharPref(
+ "browser.startup.homepage_override.mstone",
+ "127.0"
+ );
+ FormAutofillUtils.setOSAuthEnabled(CC_TYPO_PREF, true);
+
+ simulateUIMigration();
+
+ Assert.ok(
+ FormAutofillUtils.getOSAuthEnabled(CC_NEW_PREF),
+ "OS Auth should be enabled for credit cards since it was enabled before migration."
+ );
+ clearPrefs();
+ }
+);
+
+add_task(
+ async function test_creditCards_pref_migration_real_pref_os_auth_disabled() {
+ Services.prefs.setIntPref("browser.migration.version", UI_VERSION - 1);
+ Services.prefs.setCharPref(
+ "browser.startup.homepage_override.mstone",
+ "127.0"
+ );
+ FormAutofillUtils.setOSAuthEnabled(CC_NEW_PREF, false);
+
+ simulateUIMigration();
+
+ Assert.ok(
+ !FormAutofillUtils.getOSAuthEnabled(CC_NEW_PREF),
+ "OS Auth should be disabled for credit cards since it was disabled before migration."
+ );
+ clearPrefs();
+ }
+);
+
+add_task(
+ async function test_creditCards_pref_migration_real_pref_os_auth_enabled() {
+ Services.prefs.setIntPref("browser.migration.version", UI_VERSION - 1);
+ Services.prefs.setCharPref(
+ "browser.startup.homepage_override.mstone",
+ "127.0"
+ );
+ FormAutofillUtils.setOSAuthEnabled(CC_NEW_PREF, true);
+
+ simulateUIMigration();
+
+ Assert.ok(
+ FormAutofillUtils.getOSAuthEnabled(CC_NEW_PREF),
+ "OS Auth should be enabled for credit cards since it was enabled before migration."
+ );
+ clearPrefs();
+ }
+);
diff --git a/browser/components/tests/unit/xpcshell.toml b/browser/components/tests/unit/xpcshell.toml
index 1b566698ee..b552fd2fa8 100644
--- a/browser/components/tests/unit/xpcshell.toml
+++ b/browser/components/tests/unit/xpcshell.toml
@@ -10,6 +10,9 @@ support-files = ["distribution.ini"]
["test_browserGlue_migration_no_errors.js"]
+["test_browserGlue_migration_osauth.js"]
+skip-if = ["nightly_build", "os == 'linux'"]
+
["test_browserGlue_migration_places_xulstore.js"]
["test_browserGlue_migration_remove_pref.js"]