summaryrefslogtreecommitdiffstats
path: root/browser/components/tests
diff options
context:
space:
mode:
Diffstat (limited to 'browser/components/tests')
-rw-r--r--browser/components/tests/browser/browser.toml3
-rw-r--r--browser/components/tests/browser/browser_browserGlue_os_auth.js25
-rw-r--r--browser/components/tests/browser/browser_browserGlue_upgradeDialog_trigger.js80
-rw-r--r--browser/components/tests/unit/test_browserGlue_migration_osauth.js159
-rw-r--r--browser/components/tests/unit/xpcshell.toml3
5 files changed, 190 insertions, 80 deletions
diff --git a/browser/components/tests/browser/browser.toml b/browser/components/tests/browser/browser.toml
index c754191b8b..366842b04d 100644
--- a/browser/components/tests/browser/browser.toml
+++ b/browser/components/tests/browser/browser.toml
@@ -4,6 +4,9 @@ support-files = [
"../../../../dom/security/test/csp/dummy.pdf",
]
+["browser_browserGlue_os_auth.js"]
+skip-if = ["os == 'linux'"]
+
["browser_browserGlue_showModal_trigger.js"]
["browser_browserGlue_telemetry.js"]
diff --git a/browser/components/tests/browser/browser_browserGlue_os_auth.js b/browser/components/tests/browser/browser_browserGlue_os_auth.js
new file mode 100644
index 0000000000..9f17a00d03
--- /dev/null
+++ b/browser/components/tests/browser/browser_browserGlue_os_auth.js
@@ -0,0 +1,25 @@
+/* Any copyright is dedicated to the Public Domain.
+ http://creativecommons.org/publicdomain/zero/1.0/ */
+
+"use strict";
+
+const { FormAutofillUtils } = ChromeUtils.importESModule(
+ "resource://gre/modules/shared/FormAutofillUtils.sys.mjs"
+);
+
+// Check whether os auth is disabled by default on a new profile in Beta and Release.
+add_task(async function test_creditCards_os_auth_disabled_for_new_profile() {
+ Assert.equal(
+ FormAutofillUtils.getOSAuthEnabled(
+ FormAutofillUtils.AUTOFILL_CREDITCARDS_REAUTH_PREF
+ ),
+ AppConstants.NIGHTLY_BUILD,
+ "OS Auth should be disabled for credit cards by default for a new profile."
+ );
+
+ Assert.equal(
+ LoginHelper.getOSAuthEnabled(LoginHelper.OS_AUTH_FOR_PASSWORDS_PREF),
+ AppConstants.NIGHTLY_BUILD,
+ "OS Auth should be disabled for passwords by default for a new profile."
+ );
+});
diff --git a/browser/components/tests/browser/browser_browserGlue_upgradeDialog_trigger.js b/browser/components/tests/browser/browser_browserGlue_upgradeDialog_trigger.js
index 88004525c8..f7b3e4c06f 100644
--- a/browser/components/tests/browser/browser_browserGlue_upgradeDialog_trigger.js
+++ b/browser/components/tests/browser/browser_browserGlue_upgradeDialog_trigger.js
@@ -122,83 +122,3 @@ add_task(async function show_major_upgrade() {
defaultPrefs.setBoolPref(pref, orig);
await cleanupUpgrade();
});
-
-add_task(async function test_mr2022_upgradeDialogEnabled() {
- const FALLBACK_PREF = "browser.startup.upgradeDialog.enabled";
-
- async function runMajorReleaseTest(
- { onboarding = undefined, enabled = undefined, fallbackPref = undefined },
- expected
- ) {
- info("Testing upgradeDialog with:");
- info(` majorRelease2022.onboarding=${onboarding}`);
- info(` upgradeDialog.enabled=${enabled}`);
- info(` ${FALLBACK_PREF}=${fallbackPref}`);
-
- let mr2022Cleanup = async () => {};
- let upgradeDialogCleanup = async () => {};
-
- if (typeof onboarding !== "undefined") {
- mr2022Cleanup = await ExperimentFakes.enrollWithFeatureConfig({
- featureId: "majorRelease2022",
- value: { onboarding },
- });
- }
-
- if (typeof enabled !== "undefined") {
- upgradeDialogCleanup = await ExperimentFakes.enrollWithFeatureConfig({
- featureId: "upgradeDialog",
- value: { enabled },
- });
- }
-
- if (typeof fallbackPref !== "undefined") {
- await SpecialPowers.pushPrefEnv({
- set: [[FALLBACK_PREF, fallbackPref]],
- });
- }
-
- const cleanupForcedUpgrade = await forceMajorUpgrade();
-
- try {
- await BROWSER_GLUE._maybeShowDefaultBrowserPrompt();
- AssertEvents(`Upgrade dialog ${expected ? "shown" : "not shown"}`, [
- "trigger",
- "reason",
- expected ? "satisfied" : "disabled",
- ]);
-
- if (expected) {
- const [win] = await TestUtils.topicObserved("subdialog-loaded");
- win.close();
- await BrowserTestUtils.removeTab(gBrowser.selectedTab);
- }
- } finally {
- await cleanupForcedUpgrade();
- if (typeof fallbackPref !== "undefined") {
- await SpecialPowers.popPrefEnv();
- }
- await upgradeDialogCleanup();
- await mr2022Cleanup();
- }
- }
-
- await runMajorReleaseTest({ onboarding: true }, true);
- await runMajorReleaseTest({ onboarding: true, enabled: false }, true);
- await runMajorReleaseTest({ onboarding: true, fallbackPref: false }, true);
-
- await runMajorReleaseTest({ onboarding: false }, false);
- await runMajorReleaseTest({ onboarding: false, enabled: true }, false);
- await runMajorReleaseTest({ onboarding: false, fallbackPref: true }, false);
-
- await runMajorReleaseTest({ enabled: true }, true);
- await runMajorReleaseTest({ enabled: true, fallbackPref: false }, true);
- await runMajorReleaseTest({ fallbackPref: true }, true);
-
- await runMajorReleaseTest({ enabled: false }, false);
- await runMajorReleaseTest({ enabled: false, fallbackPref: true }, false);
- await runMajorReleaseTest({ fallbackPref: false }, false);
-
- // Test the default configuration.
- await runMajorReleaseTest({}, false);
-});
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"]