Bug 1838507 - Default the about:welcome migration behaviour to the legacy XUL dialog. r=Mardak

This adds a new behaviour that opens the legacy migration wizard from about:welcome,
and sets the pref to default to that behaviour.

This also adds the behaviour to the FeatureManifest.yaml file so that it can be
instrumented remotely via Nimbus.

Differential Revision: https://phabricator.services.mozilla.com/D181105
This commit is contained in:
Mike Conley
2023-06-15 16:33:43 +00:00
parent 667509aeb7
commit fededa4b9c
6 changed files with 101 additions and 38 deletions

View File

@@ -2165,8 +2165,8 @@ pref("browser.migrate.vivaldi.enabled", true);
pref("browser.migrate.content-modal.enabled", true);
pref("browser.migrate.content-modal.import-all.enabled", true);
// Values can be: "default", "autoclose", "standalone".
pref("browser.migrate.content-modal.about-welcome-behavior", "default");
// Values can be: "default", "autoclose", "standalone", "legacy".
pref("browser.migrate.content-modal.about-welcome-behavior", "legacy");
// The maximum age of history entries we'll import, in days.
pref("browser.migrate.history.maxAgeInDays", 180);

View File

@@ -589,8 +589,43 @@ class MigrationUtils {
* just after opening the dialog window.
*/
showMigrationWizard(aOpener, aOptions) {
// When migration is kicked off from about:welcome, there are
// a few different behaviors that we want to test, controlled
// by a preference that is instrumented for Nimbus. The pref
// has the following possible states:
//
// "autoclose":
// The user will be directed to the migration wizard in
// about:preferences, but once the wizard is dismissed,
// the tab will close.
//
// "standalone":
// The migration wizard will open in a new top-level content
// window.
//
// "legacy":
// The legacy migration wizard will open, even if the new migration
// wizard is enabled by default.
//
// "default" / other
// The user will be directed to the migration wizard in
// about:preferences. The tab will not close once the
// user closes the wizard.
let aboutWelcomeBehavior = Services.prefs.getCharPref(
"browser.migrate.content-modal.about-welcome-behavior",
"default"
);
let aboutWelcomeLegacyBehavior =
aboutWelcomeBehavior == "legacy" &&
aOptions.entrypoint == this.MIGRATION_ENTRYPOINTS.NEWTAB;
if (
Services.prefs.getBoolPref("browser.migrate.content-modal.enabled", false)
Services.prefs.getBoolPref(
"browser.migrate.content-modal.enabled",
false
) &&
!aboutWelcomeLegacyBehavior
) {
let entrypoint =
aOptions.entrypoint || this.MIGRATION_ENTRYPOINTS.UNKNOWN;
@@ -633,29 +668,6 @@ class MigrationUtils {
if (aOpener?.openPreferences) {
if (aOptions.entrypoint == this.MIGRATION_ENTRYPOINTS.NEWTAB) {
// When migration is kicked off from about:welcome, there are
// a few different behaviors that we want to test, controlled
// by a preference that is instrumented for Nimbus. The pref
// has the following possible states:
//
// "autoclose":
// The user will be directed to the migration wizard in
// about:preferences, but once the wizard is dismissed,
// the tab will close.
//
// "standalone":
// The migration wizard will open in a new top-level content
// window.
//
// "default" / other
// The user will be directed to the migration wizard in
// about:preferences. The tab will not close once the
// user closes the wizard.
let aboutWelcomeBehavior = Services.prefs.getCharPref(
"browser.migrate.content-modal.about-welcome-behavior",
"default"
);
if (aboutWelcomeBehavior == "autoclose") {
return aOpener.openPreferences("general-migrate-autoclose");
} else if (aboutWelcomeBehavior == "standalone") {

View File

@@ -15,6 +15,12 @@ const IMPORT_SCREEN = {
},
};
const FORCE_LEGACY =
Services.prefs.getCharPref(
"browser.migrate.content-modal.about-welcome-behavior",
"default"
) === "legacy";
add_task(async function test_wait_import_modal() {
await setAboutWelcomeMultiStage(
JSON.stringify([IMPORT_SCREEN, { id: "AW_NEXT", content: {} }])
@@ -32,7 +38,10 @@ add_task(async function test_wait_import_modal() {
["main.AW_NEXT"]
);
const wizardPromise = BrowserTestUtils.waitForMigrationWizard(window);
const wizardPromise = BrowserTestUtils.waitForMigrationWizard(
window,
FORCE_LEGACY
);
const prefsTab = await BrowserTestUtils.openNewForegroundTab(
gBrowser,
"about:preferences"
@@ -50,7 +59,7 @@ add_task(async function test_wait_import_modal() {
["main.AW_NEXT"]
);
await BrowserTestUtils.closeMigrationWizard(wizard);
await BrowserTestUtils.closeMigrationWizard(wizard, FORCE_LEGACY);
await test_screen_content(
browser,
@@ -77,7 +86,10 @@ add_task(async function test_wait_import_spotlight() {
});
const [win] = await spotlightPromise;
const wizardPromise = BrowserTestUtils.waitForMigrationWizard(window);
const wizardPromise = BrowserTestUtils.waitForMigrationWizard(
window,
FORCE_LEGACY
);
const prefsTab = await BrowserTestUtils.openNewForegroundTab(
gBrowser,
"about:preferences"
@@ -87,7 +99,7 @@ add_task(async function test_wait_import_spotlight() {
.click();
const wizard = await wizardPromise;
await BrowserTestUtils.closeMigrationWizard(wizard);
await BrowserTestUtils.closeMigrationWizard(wizard, FORCE_LEGACY);
// cleanup
BrowserTestUtils.removeTab(prefsTab);

View File

@@ -2802,12 +2802,15 @@ export var BrowserTestUtils = {
* @param {DOMWindow} window
* The top-level window that the about:preferences tab is likely to open
* in if the new migration wizard is enabled.
* @param {boolean} forceLegacy
* True if, despite the browser.migrate.content-modal.enabled pref value,
* the legacy XUL migration wizard is expected.
* @returns {Promise<Element>}
* Resolves to the dialog window in the legacy case, and the
* about:preferences tab otherwise.
*/
async waitForMigrationWizard(window) {
if (!this._usingNewMigrationWizard) {
async waitForMigrationWizard(window, forceLegacy = false) {
if (!this._usingNewMigrationWizard || forceLegacy) {
return this.waitForCondition(() => {
let win = Services.wm.getMostRecentWindow("Browser:MigrationWizard");
if (win?.document?.readyState == "complete") {
@@ -2834,10 +2837,13 @@ export var BrowserTestUtils = {
* the about:preferences tab otherwise. In general, it's probably best to
* just pass whatever BrowserTestUtils.waitForMigrationWizard resolved to
* into this in order to handle both the old and new migration wizard.
* @param {boolean} forceLegacy
* True if, despite the browser.migrate.content-modal.enabled pref value,
* the legacy XUL migration wizard is expected.
* @returns {Promise<undefined>}
*/
closeMigrationWizard(wizardWindowOrTab) {
if (!this._usingNewMigrationWizard) {
closeMigrationWizard(wizardWindowOrTab, forceLegacy = false) {
if (!this._usingNewMigrationWizard || forceLegacy) {
return BrowserTestUtils.closeWindow(wizardWindowOrTab);
}

View File

@@ -3,6 +3,12 @@
"use strict";
const FORCE_LEGACY =
Services.prefs.getCharPref(
"browser.migrate.content-modal.about-welcome-behavior",
"default"
) == "legacy";
add_setup(async () => {
// Load the initial tab at example.com. This makes it so that if
// we're using the new migration wizard, we'll load the about:preferences
@@ -15,7 +21,10 @@ add_setup(async () => {
});
add_task(async function test_SHOW_MIGRATION_WIZARD() {
let wizardOpened = BrowserTestUtils.waitForMigrationWizard(window);
let wizardOpened = BrowserTestUtils.waitForMigrationWizard(
window,
FORCE_LEGACY
);
await SMATestUtils.executeAndValidateAction({
type: "SHOW_MIGRATION_WIZARD",
@@ -23,11 +32,14 @@ add_task(async function test_SHOW_MIGRATION_WIZARD() {
let wizard = await wizardOpened;
ok(wizard, "Migration wizard opened");
await BrowserTestUtils.closeMigrationWizard(wizard);
await BrowserTestUtils.closeMigrationWizard(wizard, FORCE_LEGACY);
});
add_task(async function test_SHOW_MIGRATION_WIZARD_WITH_SOURCE() {
let wizardOpened = BrowserTestUtils.waitForMigrationWizard(window);
let wizardOpened = BrowserTestUtils.waitForMigrationWizard(
window,
FORCE_LEGACY
);
await SMATestUtils.executeAndValidateAction({
type: "SHOW_MIGRATION_WIZARD",
@@ -36,5 +48,22 @@ add_task(async function test_SHOW_MIGRATION_WIZARD_WITH_SOURCE() {
let wizard = await wizardOpened;
ok(wizard, "Migrator window opened when source param specified");
await BrowserTestUtils.closeMigrationWizard(wizard);
await BrowserTestUtils.closeMigrationWizard(wizard, FORCE_LEGACY);
});
add_task(async function test_SHOW_MIGRATION_WIZARD_forcing_legacy() {
await SpecialPowers.pushPrefEnv({
set: [["browser.migrate.content-modal.about-welcome-behavior", "legacy"]],
});
let wizardOpened = BrowserTestUtils.waitForMigrationWizard(window, true);
await SMATestUtils.executeAndValidateAction({
type: "SHOW_MIGRATION_WIZARD",
data: { source: "chrome" },
});
let wizard = await wizardOpened;
ok(wizard, "Legacy migrator window opened");
await BrowserTestUtils.closeMigrationWizard(wizard, true);
});

View File

@@ -1457,6 +1457,10 @@ migrationWizard:
The migration wizard will open in a new top-level content
window.
"legacy":
The legacy wizard will be opened from about:welcome, even if
the new wizard is enabled by default.
"default" / other
The user will be directed to the migration wizard in
about:preferences. The tab will not close once the