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 --- .../tests/browser/browser_aboutwelcome_behavior.js | 100 +++++++++++++++++++++ 1 file changed, 100 insertions(+) create mode 100644 browser/components/migration/tests/browser/browser_aboutwelcome_behavior.js (limited to 'browser/components/migration/tests/browser/browser_aboutwelcome_behavior.js') diff --git a/browser/components/migration/tests/browser/browser_aboutwelcome_behavior.js b/browser/components/migration/tests/browser/browser_aboutwelcome_behavior.js new file mode 100644 index 0000000000..72c90851e2 --- /dev/null +++ b/browser/components/migration/tests/browser/browser_aboutwelcome_behavior.js @@ -0,0 +1,100 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +"use strict"; + +/** + * Tests that if browser.migrate.content-modal.about-welcome-behavior + * is "autoclose", that closing the migration dialog when opened with the + * NEWTAB entrypoint (which currently only occurs from about:welcome), + * will result in the about:preferences tab closing too. + */ +add_task(async function test_autoclose_from_welcome() { + await BrowserTestUtils.openNewForegroundTab(gBrowser, "about:blank"); + + await SpecialPowers.pushPrefEnv({ + set: [ + ["browser.migrate.content-modal.about-welcome-behavior", "autoclose"], + ], + }); + + let migrationDialogPromise = waitForMigrationWizardDialogTab(); + MigrationUtils.showMigrationWizard(window, { + entrypoint: MigrationUtils.MIGRATION_ENTRYPOINTS.NEWTAB, + }); + + let prefsBrowser = await migrationDialogPromise; + let prefsTab = gBrowser.getTabForBrowser(prefsBrowser); + + let tabClosed = BrowserTestUtils.waitForTabClosing(prefsTab); + + let dialog = prefsBrowser.contentDocument.querySelector( + "#migrationWizardDialog" + ); + + let dialogClosed = BrowserTestUtils.waitForEvent(dialog, "close"); + await BrowserTestUtils.synthesizeKey("VK_ESCAPE", {}, prefsBrowser); + await dialogClosed; + await tabClosed; + Assert.ok(true, "Preferences tab closed with autoclose behavior."); +}); + +/** + * Tests that if browser.migrate.content-modal.about-welcome-behavior + * is "default", that closing the migration dialog when opened with the + * NEWTAB entrypoint (which currently only occurs from about:welcome), + * will result in the about:preferences tab still staying open. + */ +add_task(async function test_no_autoclose_from_welcome() { + // Create a new blank tab which about:preferences will open into. + await BrowserTestUtils.openNewForegroundTab(gBrowser, "about:blank"); + + await SpecialPowers.pushPrefEnv({ + set: [["browser.migrate.content-modal.about-welcome-behavior", "default"]], + }); + + let migrationDialogPromise = waitForMigrationWizardDialogTab(); + MigrationUtils.showMigrationWizard(window, { + entrypoint: MigrationUtils.MIGRATION_ENTRYPOINTS.NEWTAB, + }); + + let prefsBrowser = await migrationDialogPromise; + let prefsTab = gBrowser.getTabForBrowser(prefsBrowser); + + let dialog = prefsBrowser.contentDocument.querySelector( + "#migrationWizardDialog" + ); + + let dialogClosed = BrowserTestUtils.waitForEvent(dialog, "close"); + await BrowserTestUtils.synthesizeKey("VK_ESCAPE", {}, prefsBrowser); + await dialogClosed; + Assert.ok(!prefsTab.closing, "about:preferences tab is not closing."); + + BrowserTestUtils.removeTab(prefsTab); +}); + +/** + * Tests that if browser.migrate.content-modal.about-welcome-behavior + * is "standalone", that opening the migration wizard from the NEWTAB + * entrypoint opens the migration wizard in a standalone top-level + * window. + */ +add_task(async function test_no_autoclose_from_welcome() { + await SpecialPowers.pushPrefEnv({ + set: [ + ["browser.migrate.content-modal.about-welcome-behavior", "standalone"], + ], + }); + + let windowOpened = BrowserTestUtils.domWindowOpened(); + MigrationUtils.showMigrationWizard(window, { + entrypoint: MigrationUtils.MIGRATION_ENTRYPOINTS.NEWTAB, + }); + let dialogWin = await windowOpened; + Assert.ok(dialogWin, "Top-level dialog window opened for the migrator."); + await BrowserTestUtils.waitForEvent(dialogWin, "MigrationWizard:Ready"); + + let dialogClosed = BrowserTestUtils.domWindowClosed(dialogWin); + dialogWin.close(); + await dialogClosed; +}); -- cgit v1.2.3