Backed out 9 changesets (bug 1800917, bug 718280) for causing xpc failures in browser/components/migration/tests/unit/test_Edge_db_migration.js CLOSED TREE

Backed out changeset d55b95d9d14f (bug 1800917)
Backed out changeset 8427f1e65df4 (bug 1800917)
Backed out changeset 2d0f77d324f2 (bug 718280)
Backed out changeset eba58fd1ed1c (bug 718280)
Backed out changeset 33027a0f9ce9 (bug 718280)
Backed out changeset 237be1f62d01 (bug 718280)
Backed out changeset 007afe158ae5 (bug 718280)
Backed out changeset f1dea7abdfb7 (bug 718280)
Backed out changeset 47e2cccd33c7 (bug 718280)
This commit is contained in:
Sandor Molnar
2022-12-13 00:50:16 +02:00
parent 9b29d12bde
commit c46a05c875
26 changed files with 627 additions and 312 deletions

View File

@@ -30,8 +30,8 @@
<command id="cmd_pageSetup" oncommand="PrintUtils.showPageSetup();"/>
<command id="cmd_print" oncommand="PrintUtils.startPrintWindow(gBrowser.selectedBrowser.browsingContext);"/>
<command id="cmd_printPreviewToggle" oncommand="PrintUtils.togglePrintPreview(gBrowser.selectedBrowser.browsingContext);"/>
<command id="cmd_file_importFromAnotherBrowser" oncommand="MigrationUtils.showMigrationWizard(window, { entrypoint: MigrationUtils.MIGRATION_ENTRYPOINTS.FILE_MENU });"/>
<command id="cmd_help_importFromAnotherBrowser" oncommand="MigrationUtils.showMigrationWizard(window, { entrypoint: MigrationUtils.MIGRATION_ENTRYPOINTS.HELP_MENU });"/>
<command id="cmd_file_importFromAnotherBrowser" oncommand="MigrationUtils.showMigrationWizard(window, [MigrationUtils.MIGRATION_ENTRYPOINTS.FILE_MENU]);"/>
<command id="cmd_help_importFromAnotherBrowser" oncommand="MigrationUtils.showMigrationWizard(window, [MigrationUtils.MIGRATION_ENTRYPOINTS.HELP_MENU]);"/>
<command id="cmd_close" oncommand="BrowserCloseTabOrWindow(event);"/>
<command id="cmd_closeWindow" oncommand="BrowserTryToCloseWindow(event)"/>
<command id="cmd_toggleMute" oncommand="gBrowser.toggleMuteAudioOnMultiSelectedTabs(gBrowser.selectedTab)"/>

View File

@@ -562,7 +562,7 @@
<html:template id="BrowserToolbarPalette">
<toolbarbutton id="import-button"
class="toolbarbutton-1 chromeclass-toolbar-additional"
oncommand="MigrationUtils.showMigrationWizard(window, { entrypoint: MigrationUtils.MIGRATION_ENTRYPOINTS.BOOKMARKS_TOOLBAR });"
oncommand="MigrationUtils.showMigrationWizard(window, [MigrationUtils.MIGRATION_ENTRYPOINTS.BOOKMARKS_TOOLBAR]);"
data-l10n-id="browser-import-button2"/>
<toolbarbutton id="new-window-button" class="toolbarbutton-1 chromeclass-toolbar-additional"

View File

@@ -234,9 +234,9 @@ class AboutLoginsParent extends JSWindowActorParent {
#importFromBrowser() {
try {
lazy.MigrationUtils.showMigrationWizard(this.#ownerGlobal, {
entrypoint: lazy.MigrationUtils.MIGRATION_ENTRYPOINTS.PASSWORDS,
});
lazy.MigrationUtils.showMigrationWizard(this.#ownerGlobal, [
lazy.MigrationUtils.MIGRATION_ENTRYPOINTS.PASSWORDS,
]);
} catch (ex) {
console.error(ex);
}

View File

@@ -296,11 +296,11 @@ export var ChromeMigrationUtils = {
"Chrome Beta": ["google-chrome-beta"],
"Chrome Dev": ["google-chrome-unstable"],
Chromium: ["chromium"],
// Opera GX is not available on Linux.
"Opera GX": ["Opera-GX"],
// Canary is not available on Linux.
// Edge is not available on Linux.
Opera: ["opera"],
Vivaldi: ["vivaldi"],
Opera: ["Opera"],
Vivaldi: ["Vivaldi"],
},
};
let subfolders = SUB_DIRECTORIES[AppConstants.platform][chromeProjectName];
@@ -432,7 +432,7 @@ export var ChromeMigrationUtils = {
}
// Check each profile for logins.
const dataPath = await migrator._getChromeUserDataPathIfExists();
const dataPath = await migrator.wrappedJSObject._getChromeUserDataPathIfExists();
for (const profile of await migrator.getSourceProfiles()) {
const path = PathUtils.join(dataPath, profile.id, "Login Data");
// Skip if login data is missing.

View File

@@ -73,8 +73,16 @@ function convertBookmarks(items, errorAccumulator) {
* migrators for browsers that are variants of Chrome.
*/
export class ChromeProfileMigrator extends MigratorBase {
static get key() {
return "chrome";
get classDescription() {
return "Chrome Profile Migrator";
}
get contractID() {
return "@mozilla.org/profile/migrator;1?app=browser&type=chrome";
}
get classID() {
return Components.ID("{4cec1de4-1671-4fc3-a53e-6c539dc77a26}");
}
get _chromeUserDataPathSuffix() {
@@ -110,7 +118,7 @@ export class ChromeProfileMigrator extends MigratorBase {
}
if (await IOUtils.exists(profileFolder)) {
let possibleResourcePromises = [
GetBookmarksResource(profileFolder, this.constructor.key),
GetBookmarksResource(profileFolder, this.getBrowserKey()),
GetHistoryResource(profileFolder),
GetCookiesResource(profileFolder),
];
@@ -611,8 +619,16 @@ async function GetCookiesResource(aProfileFolder) {
* Chromium migrator
*/
export class ChromiumProfileMigrator extends ChromeProfileMigrator {
static get key() {
return "chromium";
get classDescription() {
return "Chromium Profile Migrator";
}
get contractID() {
return "@mozilla.org/profile/migrator;1?app=browser&type=chromium";
}
get classID() {
return Components.ID("{8cece922-9720-42de-b7db-7cef88cb07ca}");
}
_chromeUserDataPathSuffix = "Chromium";
@@ -625,8 +641,16 @@ export class ChromiumProfileMigrator extends ChromeProfileMigrator {
* Not available on Linux
*/
export class CanaryProfileMigrator extends ChromeProfileMigrator {
static get key() {
return "canary";
get classDescription() {
return "Chrome Canary Profile Migrator";
}
get contractID() {
return "@mozilla.org/profile/migrator;1?app=browser&type=canary";
}
get classID() {
return Components.ID("{4bf85aa5-4e21-46ca-825f-f9c51a5e8c76}");
}
get _chromeUserDataPathSuffix() {
@@ -646,8 +670,16 @@ export class CanaryProfileMigrator extends ChromeProfileMigrator {
* Chrome Dev - Linux only (not available in Mac and Windows)
*/
export class ChromeDevMigrator extends ChromeProfileMigrator {
static get key() {
return "chrome-dev";
get classDescription() {
return "Chrome Dev Profile Migrator";
}
get contractID() {
return "@mozilla.org/profile/migrator;1?app=browser&type=chrome-dev";
}
get classID() {
return Components.ID("{7370a02a-4886-42c3-a4ec-d48c726ec30a}");
}
_chromeUserDataPathSuffix = "Chrome Dev";
@@ -659,8 +691,16 @@ export class ChromeDevMigrator extends ChromeProfileMigrator {
* Chrome Beta migrator
*/
export class ChromeBetaMigrator extends ChromeProfileMigrator {
static get key() {
return "chrome-beta";
get classDescription() {
return "Chrome Beta Profile Migrator";
}
get contractID() {
return "@mozilla.org/profile/migrator;1?app=browser&type=chrome-beta";
}
get classID() {
return Components.ID("{47f75963-840b-4950-a1f0-d9c1864f8b8e}");
}
_chromeUserDataPathSuffix = "Chrome Beta";
@@ -672,8 +712,16 @@ export class ChromeBetaMigrator extends ChromeProfileMigrator {
* Brave migrator
*/
export class BraveProfileMigrator extends ChromeProfileMigrator {
static get key() {
return "brave";
get classDescription() {
return "Brave Browser Migrator";
}
get contractID() {
return "@mozilla.org/profile/migrator;1?app=browser&type=brave";
}
get classID() {
return Components.ID("{4071880a-69e4-4c83-88b4-6c589a62801d}");
}
_chromeUserDataPathSuffix = "Brave";
@@ -685,8 +733,16 @@ export class BraveProfileMigrator extends ChromeProfileMigrator {
* Edge (Chromium-based) migrator
*/
export class ChromiumEdgeMigrator extends ChromeProfileMigrator {
static get key() {
return "chromium-edge";
get classDescription() {
return "Chromium Edge Profile Migrator";
}
get contractID() {
return "@mozilla.org/profile/migrator;1?app=browser&type=chromium-edge";
}
get classID() {
return Components.ID("{3c7f6b7c-baa9-4338-acfa-04bf79f1dcf1}");
}
_chromeUserDataPathSuffix = "Edge";
@@ -698,8 +754,16 @@ export class ChromiumEdgeMigrator extends ChromeProfileMigrator {
* Edge Beta (Chromium-based) migrator
*/
export class ChromiumEdgeBetaMigrator extends ChromeProfileMigrator {
static get key() {
return "chromium-edge-beta";
get classDescription() {
return "Chromium Edge Beta Profile Migrator";
}
get contractID() {
return "@mozilla.org/profile/migrator;1?app=browser&type=chromium-edge-beta";
}
get classID() {
return Components.ID("{0fc3d48a-c1c3-4871-b58f-a8b47d1555fb}");
}
_chromeUserDataPathSuffix = "Edge Beta";
@@ -711,8 +775,16 @@ export class ChromiumEdgeBetaMigrator extends ChromeProfileMigrator {
* Chromium 360 migrator
*/
export class Chromium360seMigrator extends ChromeProfileMigrator {
static get key() {
return "chromium-360se";
get classDescription() {
return "Chromium 360 Secure Browser Profile Migrator";
}
get contractID() {
return "@mozilla.org/profile/migrator;1?app=browser&type=chromium-360se";
}
get classID() {
return Components.ID("{2e1a182e-ce4f-4dc9-a22c-d4125b931552}");
}
_chromeUserDataPathSuffix = "360 SE";
@@ -724,8 +796,16 @@ export class Chromium360seMigrator extends ChromeProfileMigrator {
* Opera migrator
*/
export class OperaProfileMigrator extends ChromeProfileMigrator {
static get key() {
return "opera";
get classDescription() {
return "Opera Browser Migrator";
}
get contractID() {
return "@mozilla.org/profile/migrator;1?app=browser&type=opera";
}
get classID() {
return Components.ID("{16c5d501-e411-41eb-93f2-af6c9ba64dee}");
}
_chromeUserDataPathSuffix = "Opera";
@@ -741,8 +821,16 @@ export class OperaProfileMigrator extends ChromeProfileMigrator {
* Opera GX migrator
*/
export class OperaGXProfileMigrator extends ChromeProfileMigrator {
static get key() {
return "opera-gx";
get classDescription() {
return "Opera GX Browser Migrator";
}
get contractID() {
return "@mozilla.org/profile/migrator;1?app=browser&type=opera-gx";
}
get classID() {
return Components.ID("{26F4E0A0-B533-4FDA-B344-6FF5DA45D6DC}");
}
_chromeUserDataPathSuffix = "Opera GX";
@@ -758,8 +846,16 @@ export class OperaGXProfileMigrator extends ChromeProfileMigrator {
* Vivaldi migrator
*/
export class VivaldiProfileMigrator extends ChromeProfileMigrator {
static get key() {
return "vivaldi";
get classDescription() {
return "Vivaldi Migrator";
}
get contractID() {
return "@mozilla.org/profile/migrator;1?app=browser&type=vivaldi";
}
get classID() {
return Components.ID("{54a6a025-e70d-49dd-ba95-0f7e45d728d3}");
}
_chromeUserDataPathSuffix = "Vivaldi";

View File

@@ -468,8 +468,21 @@ EdgeBookmarksMigrator.prototype = {
* Edge (EdgeHTML) profile migrator
*/
export class EdgeProfileMigrator extends MigratorBase {
static get key() {
return "edge";
constructor() {
super();
this.wrappedJSObject = this;
}
get classDescription() {
return "Edge Profile Migrator";
}
get contractID() {
return "@mozilla.org/profile/migrator;1?app=browser&type=edge";
}
get classID() {
return Components.ID("{62e8834b-2d17-49f5-96ff-56344903a2ae}");
}
getBookmarksMigratorForTesting(dbOverride) {

View File

@@ -33,8 +33,21 @@ ChromeUtils.defineESModuleGetters(lazy, {
* This migrator is what powers the "Profile Refresh" mechanism.
*/
export class FirefoxProfileMigrator extends MigratorBase {
static get key() {
return "firefox";
constructor() {
super();
this.wrappedJSObject = this; // for testing...
}
get classDescription() {
return "Firefox Profile Migrator";
}
get contractID() {
return "@mozilla.org/profile/migrator;1?app=browser&type=firefox";
}
get classID() {
return Components.ID("{91185366-ba97-4438-acba-48deaca63386}");
}
_getAllProfiles() {

View File

@@ -353,8 +353,21 @@ IE7FormPasswords.prototype = {
* Internet Explorer profile migrator
*/
export class IEProfileMigrator extends MigratorBase {
static get key() {
return "ie";
constructor() {
super();
this.wrappedJSObject = this; // export this to be able to use it in the unittest.
}
get classDescription() {
return "IE Profile Migrator";
}
get contractID() {
return "@mozilla.org/profile/migrator;1?app=browser&type=ie";
}
get classID() {
return Components.ID("{3d2532e3-4932-4774-b7ba-968f5899d3a4}");
}
getResources() {

View File

@@ -35,76 +35,6 @@ function getL10n() {
return gL10n;
}
const MIGRATOR_MODULES = Object.freeze({
EdgeProfileMigrator: {
moduleURI: "resource:///modules/EdgeProfileMigrator.sys.mjs",
platforms: ["win"],
},
FirefoxProfileMigrator: {
moduleURI: "resource:///modules/FirefoxProfileMigrator.sys.mjs",
platforms: ["linux", "macosx", "win"],
},
IEProfileMigrator: {
moduleURI: "resource:///modules/IEProfileMigrator.sys.mjs",
platforms: ["win"],
},
SafariProfileMigrator: {
moduleURI: "resource:///modules/SafariProfileMigrator.sys.mjs",
platforms: ["macosx"],
},
// The following migrators are all variants of the ChromeProfileMigrator
BraveProfileMigrator: {
moduleURI: "resource:///modules/ChromeProfileMigrator.sys.mjs",
platforms: ["linux", "macosx", "win"],
},
CanaryProfileMigrator: {
moduleURI: "resource:///modules/ChromeProfileMigrator.sys.mjs",
platforms: ["macosx", "win"],
},
ChromeProfileMigrator: {
moduleURI: "resource:///modules/ChromeProfileMigrator.sys.mjs",
platforms: ["linux", "macosx", "win"],
},
ChromeBetaMigrator: {
moduleURI: "resource:///modules/ChromeProfileMigrator.sys.mjs",
platforms: ["linux", "win"],
},
ChromeDevMigrator: {
moduleURI: "resource:///modules/ChromeProfileMigrator.sys.mjs",
platforms: ["linux"],
},
ChromiumProfileMigrator: {
moduleURI: "resource:///modules/ChromeProfileMigrator.sys.mjs",
platforms: ["linux", "macosx", "win"],
},
Chromium360seMigrator: {
moduleURI: "resource:///modules/ChromeProfileMigrator.sys.mjs",
platforms: ["win"],
},
ChromiumEdgeMigrator: {
moduleURI: "resource:///modules/ChromeProfileMigrator.sys.mjs",
platforms: ["macosx", "win"],
},
ChromiumEdgeBetaMigrator: {
moduleURI: "resource:///modules/ChromeProfileMigrator.sys.mjs",
platforms: ["macosx", "win"],
},
OperaProfileMigrator: {
moduleURI: "resource:///modules/ChromeProfileMigrator.sys.mjs",
platforms: ["linux", "macosx", "win"],
},
VivaldiProfileMigrator: {
moduleURI: "resource:///modules/ChromeProfileMigrator.sys.mjs",
platforms: ["linux", "macosx", "win"],
},
OperaGXProfileMigrator: {
moduleURI: "resource:///modules/ChromeProfileMigrator.sys.mjs",
platforms: ["macosx", "win"],
},
});
/**
* The singleton MigrationUtils service. This service is the primary mechanism
* by which migrations from other browsers to this browser occur. The singleton
@@ -112,15 +42,13 @@ const MIGRATOR_MODULES = Object.freeze({
*/
class MigrationUtils {
resourceTypes = Object.freeze({
ALL: 0x0000,
/* 0x01 used to be used for settings, but was removed. */
COOKIES: 0x0002,
HISTORY: 0x0004,
FORMDATA: 0x0008,
PASSWORDS: 0x0010,
BOOKMARKS: 0x0020,
OTHERDATA: 0x0040,
SESSION: 0x0080,
COOKIES: Ci.nsIBrowserProfileMigrator.COOKIES,
HISTORY: Ci.nsIBrowserProfileMigrator.HISTORY,
FORMDATA: Ci.nsIBrowserProfileMigrator.FORMDATA,
PASSWORDS: Ci.nsIBrowserProfileMigrator.PASSWORDS,
BOOKMARKS: Ci.nsIBrowserProfileMigrator.BOOKMARKS,
OTHERDATA: Ci.nsIBrowserProfileMigrator.OTHERDATA,
SESSION: Ci.nsIBrowserProfileMigrator.SESSION,
});
/**
@@ -260,23 +188,6 @@ class MigrationUtils {
get #migrators() {
if (!gMigrators) {
gMigrators = new Map();
for (let [symbol, { moduleURI, platforms }] of Object.entries(
MIGRATOR_MODULES
)) {
if (platforms.includes(AppConstants.platform)) {
let { [symbol]: migratorClass } = ChromeUtils.importESModule(
moduleURI
);
if (gMigrators.has(migratorClass.key)) {
console.error(
"A pre-existing migrator exists with key " +
`${migratorClass.key}. Not registering.`
);
continue;
}
gMigrators.set(migratorClass.key, new migratorClass());
}
}
}
return gMigrators;
}
@@ -333,10 +244,18 @@ class MigrationUtils {
* import any data, null otherwise.
*/
async getMigrator(aKey) {
let migrator = this.#migrators.get(aKey);
if (!migrator) {
console.error(`Could not find a migrator class for key ${aKey}`);
return null;
let migrator = null;
if (this.#migrators.has(aKey)) {
migrator = this.#migrators.get(aKey);
} else {
try {
migrator = Cc[
"@mozilla.org/profile/migrator;1?app=browser&type=" + aKey
].createInstance(Ci.nsIBrowserProfileMigrator);
} catch (ex) {
Cu.reportError(ex);
}
this.#migrators.set(aKey, migrator);
}
try {
@@ -347,19 +266,6 @@ class MigrationUtils {
}
}
/**
* Returns true if a migrator is registered with key aKey. No check is made
* to determine if a profile exists that the migrator can migrate from.
*
* @param {string} aKey
* Internal name of the migration source. See `availableMigratorKeys`
* for supported values by OS.
* @returns {boolean}
*/
migratorExists(aKey) {
return this.#migrators.has(aKey);
}
/**
* Figure out what is the default browser, and if there is a migrator
* for it, return that migrator's internal name.
@@ -475,31 +381,26 @@ class MigrationUtils {
/**
* Show the migration wizard. On mac, this may just focus the wizard if it's
* already running, in which case aOpener and aOptions are ignored.
*
* NB: If you add new consumers, please add a migration entry point constant to
* MIGRATION_ENTRYPOINTS and supply that entrypoint with the entrypoint property
* in the aOptions argument.
* already running, in which case aOpener and aParams are ignored.
*
* @param {Window} [aOpener=null]
* optional; the window that asks to open the wizard.
* @param {object} [aOptions=null]
* optional named arguments for the migration wizard.
* @param {number} [aOptions.entrypoint=undefined]
* migration entry point constant. See MIGRATION_ENTRYPOINTS.
* @param {string} [aOptions.migratorKey=undefined]
* The key for which migrator to use automatically. This is the key that is exposed
* as a static getter on the migrator class.
* @param {MigratorBase} [aOptions.migrator=undefined]
* A migrator instance to use automatically.
* @param {boolean} [aOptions.isStartupMigration=undefined]
* True if this is a startup migration.
* @param {boolean} [aOptions.skipSourceSelection=undefined]
* True if the source selection page of the wizard should be skipped.
* @param {string} [aOptions.profileId]
* An identifier for the profile to use when migrating.
* @param {Array} [aParams=null]
* optional arguments for the migration wizard, in the form of an array
* This is passed as-is for the params argument of
* nsIWindowWatcher.openWindow. The array elements we expect are, in
* order:
* - {Number} migration entry point constant (see below)
* - {String} source browser identifier
* - {nsIBrowserProfileMigrator} actual migrator object
* - {Boolean} whether this is a startup migration
* - {Boolean} whether to skip the 'source' page
* - {String} an identifier for the profile to use when migrating
* NB: If you add new consumers, please add a migration entry point
* constant below, and specify at least the first element of the array
* (the migration entry point for purposes of telemetry).
*/
showMigrationWizard(aOpener, aOptions) {
showMigrationWizard(aOpener, aParams) {
const DIALOG_URL = "chrome://browser/content/migration/migration.xhtml";
let features = "chrome,dialog,modal,centerscreen,titlebar,resizable=no";
if (AppConstants.platform == "macosx" && !this.isStartupMigration) {
@@ -513,6 +414,55 @@ class MigrationUtils {
features = "centerscreen,chrome,resizable=no";
}
// nsIWindowWatcher doesn't deal with raw arrays, so we convert the input
let params;
if (Array.isArray(aParams)) {
params = Cc["@mozilla.org/array;1"].createInstance(Ci.nsIMutableArray);
for (let item of aParams) {
let comtaminatedVal;
if (item && item instanceof Ci.nsISupports) {
comtaminatedVal = item;
} else {
switch (typeof item) {
case "boolean":
comtaminatedVal = Cc[
"@mozilla.org/supports-PRBool;1"
].createInstance(Ci.nsISupportsPRBool);
comtaminatedVal.data = item;
break;
case "number":
comtaminatedVal = Cc[
"@mozilla.org/supports-PRUint32;1"
].createInstance(Ci.nsISupportsPRUint32);
comtaminatedVal.data = item;
break;
case "string":
comtaminatedVal = Cc[
"@mozilla.org/supports-cstring;1"
].createInstance(Ci.nsISupportsCString);
comtaminatedVal.data = item;
break;
case "undefined":
case "object":
if (!item) {
comtaminatedVal = null;
break;
}
/* intentionally falling through to error out here for
non-null/undefined things: */
default:
throw new Error(
"Unexpected parameter type " + typeof item + ": " + item
);
}
}
params.appendElement(comtaminatedVal);
}
} else {
params = aParams;
}
if (
Services.prefs.getBoolPref(
"browser.migrate.content-modal.enabled",
@@ -523,9 +473,9 @@ class MigrationUtils {
) {
const { gBrowser } = aOpener;
const { selectedBrowser } = gBrowser;
gBrowser.getTabDialogBox(selectedBrowser).open(DIALOG_URL, aOptions);
gBrowser.getTabDialogBox(selectedBrowser).open(DIALOG_URL, params);
} else {
Services.ww.openWindow(aOpener, DIALOG_URL, "_blank", features, aOptions);
Services.ww.openWindow(aOpener, DIALOG_URL, "_blank", features, params);
}
}
@@ -573,7 +523,7 @@ class MigrationUtils {
}
gProfileStartup = aProfileStartup;
let skipSourceSelection = false,
let skipSourcePage = false,
migrator = null,
migratorKey = "";
if (aMigratorKey) {
@@ -589,7 +539,7 @@ class MigrationUtils {
);
}
migratorKey = aMigratorKey;
skipSourceSelection = true;
skipSourcePage = true;
} else {
let defaultBrowserKey = this.getMigratorKeyForDefaultBrowser();
if (defaultBrowserKey) {
@@ -616,23 +566,22 @@ class MigrationUtils {
}
let isRefresh =
migrator &&
skipSourceSelection &&
migratorKey == AppConstants.MOZ_APP_NAME;
migrator && skipSourcePage && migratorKey == AppConstants.MOZ_APP_NAME;
let entrypoint = this.MIGRATION_ENTRYPOINTS.FIRSTRUN;
let migrationEntryPoint = this.MIGRATION_ENTRYPOINTS.FIRSTRUN;
if (isRefresh) {
entrypoint = this.MIGRATION_ENTRYPOINTS.FXREFRESH;
migrationEntryPoint = this.MIGRATION_ENTRYPOINTS.FXREFRESH;
}
this.showMigrationWizard(null, {
entrypoint,
let params = [
migrationEntryPoint,
migratorKey,
migrator,
isStartupMigration: !!aProfileStartup,
skipSourceSelection,
profileId: aProfileToMigrate,
});
aProfileStartup,
skipSourcePage,
aProfileToMigrate,
];
this.showMigrationWizard(null, params);
}
/**
@@ -867,7 +816,53 @@ class MigrationUtils {
}
get availableMigratorKeys() {
return [...this.#migrators.keys()];
if (AppConstants.platform == "win") {
return [
"firefox",
"edge",
"ie",
"opera",
"opera-gx",
"vivaldi",
"brave",
"chrome",
"chromium-edge",
"chromium-edge-beta",
"chrome-beta",
"chromium",
"chromium-360se",
"canary",
];
}
if (AppConstants.platform == "macosx") {
return [
"firefox",
"safari",
"opera",
"opera-gx",
"vivaldi",
"brave",
"chrome",
"chromium-edge",
"chromium-edge-beta",
"chromium",
"canary",
];
}
if (AppConstants.XP_UNIX) {
return [
"firefox",
"opera",
"vivaldi",
"brave",
"chrome",
"chrome-beta",
"chrome-dev",
"chromium",
"opera-gx",
];
}
return [];
}
/**

View File

@@ -23,7 +23,7 @@ ChromeUtils.defineESModuleGetters(lazy, {
* A resource returned by a subclass of MigratorBase that can migrate
* data to this browser.
* @property {number} type
* A bitfield with bits from MigrationUtils.resourceTypes flipped to indicate
* A bitfield with bits from nsIBrowserProfileMigrator flipped to indicate
* what this resource represents. A resource can represent one or more types
* of data, for example HISTORY and FORMDATA.
* @property {Function} migrate
@@ -32,30 +32,20 @@ ChromeUtils.defineESModuleGetters(lazy, {
*/
/**
* Shared prototype for migrators.
* Shared prototype for migrators, implementing nsIBrowserProfileMigrator.
*
* To implement a migrator:
* 1. Import this module.
* 2. Create a subclass of MigratorBase for your new migrator.
* 3. Override the `key` static getter with a unique identifier for the browser
* that this migrator migrates from.
* 2. Create the prototype for the migrator, extending MigratorBase.
* 3. Set classDescription, contractID and classID for your migrator, and update
* components.conf to register the migrator as an XPCOM component.
* 4. If the migrator supports multiple profiles, override the sourceProfiles
* Here we default for single-profile migrator.
* 5. Implement getResources(aProfile) (see below).
* 6. For startup-only migrators, override |startupOnlyMigrator|.
* 7. Add the migrator to the MIGRATOR_MODULES structure in MigrationUtils.sys.mjs.
*/
export class MigratorBase {
/**
* This must be overridden to return a simple string identifier for the
* migrator, for example "firefox", "chrome", "opera-gx". This key is what
* is used as an identifier when calling MigrationUtils.getMigrator.
*
* @type {boolean}
*/
static get key() {
throw new Error("MigratorBase must be overridden.");
}
QueryInterface = ChromeUtils.generateQI(["nsIBrowserProfileMigrator"]);
/**
* OVERRIDE IF AND ONLY IF the source supports multiple profiles.
@@ -86,8 +76,8 @@ export class MigratorBase {
* profiles.
*
* Each migration resource should provide:
* - a |type| getter, returning any of the migration resource types (see
* MigrationUtils.resourceTypes).
* - a |type| getter, returning any of the migration types (see
* nsIBrowserProfileMigrator).
*
* - a |migrate| method, taking a single argument, aCallback(bool success),
* for migrating the data for this resource. It may do its job
@@ -98,7 +88,7 @@ export class MigratorBase {
* Note: In the case of a simple asynchronous implementation, you may find
* MigrationUtils.wrapMigrateFunction handy for handling aCallback easily.
*
* For each migration type listed in MigrationUtils.resourceTypes, multiple
* For each migration type listed in nsIBrowserProfileMigrator, multiple
* migration resources may be provided. This practice is useful when the
* data for a certain migration type is independently stored in few
* locations. For example, the mac version of Safari stores its "reading list"
@@ -171,19 +161,20 @@ export class MigratorBase {
* true if the migrator should be shown in the migration wizard.
*/
get enabled() {
let key = this.constructor.key;
let key = this.getBrowserKey();
return Services.prefs.getBoolPref(`browser.migrate.${key}.enabled`, false);
}
/**
* This method returns a number that is the bitwise OR of all resource
* types that are available in aProfile. See MigrationUtils.resourceTypes
* for each resource type.
* DO NOT OVERRIDE - After deCOMing migration, the UI will just call
* getResources.
*
* See nsIBrowserProfileMigrator.
*
* @param {object|string} aProfile
* The profile from which data may be imported, or an empty string
* in the case of a single-profile migrator.
* @returns {number}
* @returns {MigratorResource[]}
*/
async getMigrateData(aProfile) {
let resources = await this.#getMaybeCachedResources(aProfile);
@@ -197,11 +188,18 @@ export class MigratorBase {
}, 0);
}
getBrowserKey() {
return this.contractID.match(/\=([^\=]+)$/)[1];
}
/**
* @see MigrationUtils
* DO NOT OVERRIDE - After deCOMing migration, the UI will just call
* migrate for each resource.
*
* See nsIBrowserProfileMigrator.
*
* @param {number} aItems
* A bitfield with bits from MigrationUtils.resourceTypes flipped to indicate
* A bitfield with bits from nsIBrowserProfileMigrator flipped to indicate
* what types of resources should be migrated.
* @param {boolean} aStartup
* True if this migration is occurring during startup.
@@ -214,7 +212,7 @@ export class MigratorBase {
throw new Error("migrate called for a non-existent source");
}
if (aItems != lazy.MigrationUtils.resourceTypes.ALL) {
if (aItems != Ci.nsIBrowserProfileMigrator.ALL) {
resources = resources.filter(r => aItems & r.type);
}
@@ -238,7 +236,7 @@ export class MigratorBase {
return null;
};
let browserKey = this.constructor.key;
let browserKey = this.getBrowserKey();
let maybeStartTelemetryStopwatch = resourceType => {
let histogramId = getHistogramIdForResourceType(
@@ -436,12 +434,10 @@ export class MigratorBase {
}
/**
* Checks to see if one or more profiles exist for the browser that this
* migrator migrates from.
* DO NOT OVERRIDE - After deCOMing migration, this code
* won't be part of the migrator itself.
*
* @returns {Promise<boolean>}
* True if one or more profiles exists that this migrator can migrate
* resources from.
* See nsIBrowserProfileMigrator.
*/
async isSourceAvailable() {
if (this.startupOnlyMigrator && !lazy.MigrationUtils.isStartupMigration) {

View File

@@ -346,8 +346,16 @@ SearchStrings.prototype = {
* Safari migrator
*/
export class SafariProfileMigrator extends MigratorBase {
static get key() {
return "safari";
get classDescription() {
return "Safari Profile Migrator";
}
get contractID() {
return "@mozilla.org/profile/migrator;1?app=browser&type=safari";
}
get classID() {
return Components.ID("{4b609ecf-60b2-4655-9df4-dc149e474da1}");
}
getResources() {

View File

@@ -14,20 +14,127 @@ Classes = [
'esModule': 'resource:///modules/ProfileMigrator.sys.mjs',
'constructor': 'ProfileMigrator',
},
{
'cid': '{16c5d501-e411-41eb-93f2-af6c9ba64dee}',
'contract_ids': ['@mozilla.org/profile/migrator;1?app=browser&type=opera'],
'esModule': 'resource:///modules/ChromeProfileMigrator.sys.mjs',
'constructor': 'OperaProfileMigrator',
},
{
'cid': '{4071880a-69e4-4c83-88b4-6c589a62801d}',
'contract_ids': ['@mozilla.org/profile/migrator;1?app=browser&type=brave'],
'esModule': 'resource:///modules/ChromeProfileMigrator.sys.mjs',
'constructor': 'BraveProfileMigrator',
},
{
'cid': '{4cec1de4-1671-4fc3-a53e-6c539dc77a26}',
'contract_ids': ['@mozilla.org/profile/migrator;1?app=browser&type=chrome'],
'esModule': 'resource:///modules/ChromeProfileMigrator.sys.mjs',
'constructor': 'ChromeProfileMigrator',
},
{
'cid': '{8cece922-9720-42de-b7db-7cef88cb07ca}',
'contract_ids': ['@mozilla.org/profile/migrator;1?app=browser&type=chromium'],
'esModule': 'resource:///modules/ChromeProfileMigrator.sys.mjs',
'constructor': 'ChromiumProfileMigrator',
},
{
'cid': '{91185366-ba97-4438-acba-48deaca63386}',
'contract_ids': ['@mozilla.org/profile/migrator;1?app=browser&type=firefox'],
'esModule': 'resource:///modules/FirefoxProfileMigrator.sys.mjs',
'constructor': 'FirefoxProfileMigrator',
},
{
'cid': '{26F4E0A0-B533-4FDA-B344-6FF5DA45D6DC}',
'contract_ids': ['@mozilla.org/profile/migrator;1?app=browser&type=opera-gx'],
'esModule': 'resource:///modules/ChromeProfileMigrator.sys.mjs',
'constructor': 'OperaGXProfileMigrator',
},
{
'cid': '{54a6a025-e70d-49dd-ba95-0f7e45d728d3}',
'contract_ids': ['@mozilla.org/profile/migrator;1?app=browser&type=vivaldi'],
'esModule': 'resource:///modules/ChromeProfileMigrator.sys.mjs',
'constructor': 'VivaldiProfileMigrator',
},
]
if not XP_MACOSX:
Classes += [
{
'cid': '{47f75963-840b-4950-a1f0-d9c1864f8b8e}',
'contract_ids': ['@mozilla.org/profile/migrator;1?app=browser&type=chrome-beta'],
'esModule': 'resource:///modules/ChromeProfileMigrator.sys.mjs',
'constructor': 'ChromeBetaMigrator',
},
]
if XP_WIN or XP_MACOSX:
Classes += [
{
'cid': '{4bf85aa5-4e21-46ca-825f-f9c51a5e8c76}',
'contract_ids': ['@mozilla.org/profile/migrator;1?app=browser&type=canary'],
'esModule': 'resource:///modules/ChromeProfileMigrator.sys.mjs',
'constructor': 'CanaryProfileMigrator',
},
{
'cid': '{3c7f6b7c-baa9-4338-acfa-04bf79f1dcf1}',
'contract_ids': ['@mozilla.org/profile/migrator;1?app=browser&type=chromium-edge'],
'esModule': 'resource:///modules/ChromeProfileMigrator.sys.mjs',
'constructor': 'ChromiumEdgeMigrator',
},
{
'cid': '{0fc3d48a-c1c3-4871-b58f-a8b47d1555fb}',
'contract_ids': ['@mozilla.org/profile/migrator;1?app=browser&type=chromium-edge-beta'],
'esModule': 'resource:///modules/ChromeProfileMigrator.sys.mjs',
'constructor': 'ChromiumEdgeBetaMigrator',
},
]
else:
Classes += [
{
'cid': '{7370a02a-4886-42c3-a4ec-d48c726ec30a}',
'contract_ids': ['@mozilla.org/profile/migrator;1?app=browser&type=chrome-dev'],
'esModule': 'resource:///modules/ChromeProfileMigrator.sys.mjs',
'constructor': 'ChromeDevMigrator',
},
]
if XP_WIN:
Classes += [
{
'cid': '{3d2532e3-4932-4774-b7ba-968f5899d3a4}',
'contract_ids': ['@mozilla.org/profile/migrator;1?app=browser&type=ie'],
'esModule': 'resource:///modules/IEProfileMigrator.sys.mjs',
'constructor': 'IEProfileMigrator',
},
{
'cid': '{62e8834b-2d17-49f5-96ff-56344903a2ae}',
'contract_ids': ['@mozilla.org/profile/migrator;1?app=browser&type=edge'],
'esModule': 'resource:///modules/EdgeProfileMigrator.sys.mjs',
'constructor': 'EdgeProfileMigrator',
},
{
'cid': '{2e1a182e-ce4f-4dc9-a22c-d4125b931552}',
'contract_ids': ['@mozilla.org/profile/migrator;1?app=browser&type=chromium-360se'],
'esModule': 'resource:///modules/ChromeProfileMigrator.sys.mjs',
'constructor': 'Chromium360seMigrator',
},
{
'cid': '{c214cadc-2033-445e-8800-3fe25ee8d368}',
'contract_ids': ['@mozilla.org/profile/migrator/edgemigrationutils;1'],
'type': 'mozilla::nsEdgeMigrationUtils',
'headers': ['nsEdgeMigrationUtils.h'],
},
}
]
if XP_MACOSX:
Classes += [
{
'cid': '{4b609ecf-60b2-4655-9df4-dc149e474da1}',
'contract_ids': ['@mozilla.org/profile/migrator;1?app=browser&type=safari'],
'esModule': 'resource:///modules/SafariProfileMigrator.sys.mjs',
'constructor': 'SafariProfileMigrator',
},
{
'cid': '{647bf80c-cd35-4ce6-b904-fd586b97ae48}',
'contract_ids': ['@mozilla.org/profile/migrator/keychainmigrationutils;1'],

View File

@@ -4,15 +4,15 @@
"use strict";
const kIMig = Ci.nsIBrowserProfileMigrator;
const kIPStartup = Ci.nsIProfileStartup;
const { AppConstants } = ChromeUtils.importESModule(
"resource://gre/modules/AppConstants.sys.mjs"
);
const { MigrationUtils } = ChromeUtils.importESModule(
"resource:///modules/MigrationUtils.sys.mjs"
);
const { MigratorBase } = ChromeUtils.importESModule(
"resource:///modules/MigratorBase.sys.mjs"
);
/**
* Map from data types that match Ci.nsIBrowserProfileMigrator's types to
@@ -34,7 +34,7 @@ const kDataToStringMap = new Map([
var MigrationWizard = {
/* exported MigrationWizard */
_source: "", // Source Profile Migrator ContractID suffix
_itemsFlags: MigrationUtils.resourceTypes.ALL, // Selected Import Data Sources (16-bit bitfield)
_itemsFlags: kIMig.ALL, // Selected Import Data Sources (16-bit bitfield)
_selectedProfile: null, // Selected Profile name to import from
_wiz: null,
_migrator: null,
@@ -51,9 +51,8 @@ var MigrationWizard = {
this._wiz = document.querySelector("wizard");
let args = window.arguments[0]?.wrappedJSObject || {};
let entryPointId =
args.entrypoint || MigrationUtils.MIGRATION_ENTRYPOINTS.UNKNOWN;
let args = window.arguments;
let entryPointId = args[0] || MigrationUtils.MIGRATION_ENTRYPOINTS.UNKNOWN;
Services.telemetry
.getHistogramById("FX_MIGRATION_ENTRY_POINT")
.add(entryPointId);
@@ -69,25 +68,28 @@ var MigrationWizard = {
);
}
this._source = args.migratorKey;
this._migrator =
args.migrator instanceof MigratorBase ? args.migrator : null;
this._autoMigrate = !!args.isStartupMigration;
this._skipImportSourcePage = !!args.skipSourceSelection;
if (args.length == 2) {
this._source = args[1];
} else if (args.length > 2) {
this._source = args[1];
this._migrator = args[2] instanceof kIMig ? args[2] : null;
this._autoMigrate = args[3].QueryInterface(kIPStartup);
this._skipImportSourcePage = args[4];
if (this._migrator && args[5]) {
let sourceProfiles = this.spinResolve(
this._migrator.getSourceProfiles()
);
this._selectedProfile = sourceProfiles.find(
profile => profile.id == args[5]
);
}
if (this._migrator && args.profileId) {
let sourceProfiles = this.spinResolve(this._migrator.getSourceProfiles());
this._selectedProfile = sourceProfiles.find(
profile => profile.id == args.profileId
);
if (this._autoMigrate) {
// Show the "nothing" option in the automigrate case to provide an
// easily identifiable way to avoid migration and create a new profile.
document.getElementById("nothing").hidden = false;
}
}
if (this._autoMigrate) {
// Show the "nothing" option in the automigrate case to provide an
// easily identifiable way to avoid migration and create a new profile.
document.getElementById("nothing").hidden = false;
}
this._setSourceForDataLocalization();
document.addEventListener("wizardcancel", function() {
@@ -263,7 +265,7 @@ var MigrationWizard = {
// Create the migrator for the selected source.
this._migrator = this.spinResolve(MigrationUtils.getMigrator(newSource));
this._itemsFlags = MigrationUtils.resourceTypes.ALL;
this._itemsFlags = kIMig.ALL;
this._selectedProfile = null;
}
this._source = newSource;
@@ -353,7 +355,7 @@ var MigrationWizard = {
);
for (let itemType of kDataToStringMap.keys()) {
let itemValue = MigrationUtils.resourceTypes[itemType.toUpperCase()];
let itemValue = Ci.nsIBrowserProfileMigrator[itemType.toUpperCase()];
if (items & itemValue) {
let checkbox = document.createXULElement("checkbox");
checkbox.id = itemValue;
@@ -420,10 +422,11 @@ var MigrationWizard = {
if (
this._source == "safari" &&
AppConstants.isPlatformAndVersionAtLeast("macosx", "18") &&
(this._itemsFlags & MigrationUtils.resourceTypes.BOOKMARKS ||
this._itemsFlags == MigrationUtils.resourceTypes.ALL)
(this._itemsFlags & Ci.nsIBrowserProfileMigrator.BOOKMARKS ||
this._itemsFlags == Ci.nsIBrowserProfileMigrator.ALL)
) {
let havePermissions = this.spinResolve(this._migrator.hasPermissions());
let migrator = this._migrator.wrappedJSObject;
let havePermissions = this.spinResolve(migrator.hasPermissions());
if (!havePermissions) {
this._wiz.currentPage.next = "importPermissions";
@@ -442,8 +445,9 @@ var MigrationWizard = {
// worked.
event.preventDefault();
await this._migrator.getPermissions(window);
if (await this._migrator.hasPermissions()) {
let migrator = this._migrator.wrappedJSObject;
await migrator.getPermissions(window);
if (await migrator.hasPermissions()) {
this._receivedPermissions.add(this._source);
// Re-enter (we'll then allow the advancement through the early return above)
this._wiz.advance();
@@ -501,7 +505,7 @@ var MigrationWizard = {
}
for (let itemType of kDataToStringMap.keys()) {
let itemValue = MigrationUtils.resourceTypes[itemType.toUpperCase()];
let itemValue = Ci.nsIBrowserProfileMigrator[itemType.toUpperCase()];
if (this._itemsFlags & itemValue) {
var label = document.createXULElement("label");
label.id = itemValue + "_migrated";
@@ -563,22 +567,22 @@ var MigrationWizard = {
let type = "undefined";
let numericType = parseInt(aData);
switch (numericType) {
case MigrationUtils.resourceTypes.COOKIES:
case Ci.nsIBrowserProfileMigrator.COOKIES:
type = "cookies";
break;
case MigrationUtils.resourceTypes.HISTORY:
case Ci.nsIBrowserProfileMigrator.HISTORY:
type = "history";
break;
case MigrationUtils.resourceTypes.FORMDATA:
case Ci.nsIBrowserProfileMigrator.FORMDATA:
type = "form data";
break;
case MigrationUtils.resourceTypes.PASSWORDS:
case Ci.nsIBrowserProfileMigrator.PASSWORDS:
type = "passwords";
break;
case MigrationUtils.resourceTypes.BOOKMARKS:
case Ci.nsIBrowserProfileMigrator.BOOKMARKS:
type = "bookmarks";
break;
case MigrationUtils.resourceTypes.OTHERDATA:
case Ci.nsIBrowserProfileMigrator.OTHERDATA:
type = "misc. data";
break;
}

View File

@@ -15,6 +15,7 @@ SPHINX_TREES["docs"] = "docs"
JAR_MANIFESTS += ["jar.mn"]
XPIDL_SOURCES += [
"nsIBrowserProfileMigrator.idl",
"nsIEdgeMigrationUtils.idl",
]

View File

@@ -0,0 +1,73 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "nsISupports.idl"
interface nsIArray;
interface nsIProfileStartup;
[scriptable, uuid(22b56ffc-3149-43c5-b5a9-b3a6b678de93)]
interface nsIBrowserProfileMigrator : nsISupports
{
/**
* profile items to migrate. use with migrate().
*/
const unsigned short ALL = 0x0000;
/* 0x01 used to be used for settings, but was removed. */
const unsigned short COOKIES = 0x0002;
const unsigned short HISTORY = 0x0004;
const unsigned short FORMDATA = 0x0008;
const unsigned short PASSWORDS = 0x0010;
const unsigned short BOOKMARKS = 0x0020;
const unsigned short OTHERDATA = 0x0040;
const unsigned short SESSION = 0x0080;
/**
* Copy user profile information to the current active profile.
* @param aItems list of data items to migrate. see above for values.
* @param aStartup helper interface which is non-null if called during startup.
* @param aProfile profile to migrate from, if there is more than one.
*/
void migrate(in unsigned short aItems, in nsIProfileStartup aStartup, in jsval aProfile);
/**
* A bit field containing profile items that this migrator
* offers for import.
* @param aProfile the profile that we are looking for available data
* to import
* @return Promise containing a bit field containing profile items (see above)
* @note a return value of 0 represents no items rather than ALL.
*/
jsval getMigrateData(in jsval aProfile);
/**
* Get the last time data from this browser was modified
* @return a promise that resolves to a JS Date object
*/
jsval getLastUsedDate();
/**
* Get whether or not there is any data that can be imported from this
* browser (i.e. whether or not it is installed, and there exists
* a user profile)
* @return a promise that resolves with a boolean.
*/
jsval isSourceAvailable();
/**
* An enumeration of available profiles. If the import source does
* not support profiles, this attribute is null.
* @return a promise that resolves with an array of profiles or null.
*/
jsval getSourceProfiles();
/**
* Returns true if the migrator is configured to be enabled. This is
* controlled via the `browser.migrate.<BROWSER_KEY>.enabled` boolean
* preference, and defaults to false if the preference is not set.
*/
readonly attribute boolean enabled;
};

View File

@@ -264,7 +264,7 @@ add_task(async function setup() {
if (AppConstants.platform == "macosx") {
let migrator = await MigrationUtils.getMigrator("chrome");
Object.assign(migrator, {
Object.assign(migrator.wrappedJSObject, {
_keychainServiceName: mockMacOSKeychain.serviceName,
_keychainAccountName: mockMacOSKeychain.accountName,
_keychainMockPassphrase: mockMacOSKeychain.passphrase,

View File

@@ -41,7 +41,7 @@ add_task(async function setup() {
if (AppConstants.platform == "macosx") {
let migrator = await MigrationUtils.getMigrator("chrome");
Object.assign(migrator, {
Object.assign(migrator.wrappedJSObject, {
_keychainServiceName: mockMacOSKeychain.serviceName,
_keychainAccountName: mockMacOSKeychain.accountName,
// No `_keychainMockPassphrase` as we don't want to mock the OS dialog as

View File

@@ -535,8 +535,12 @@ add_task(async function() {
])
);
let migrator = await MigrationUtils.getMigrator("edge");
let bookmarksMigrator = migrator.getBookmarksMigratorForTesting(db);
let migrator = Cc[
"@mozilla.org/profile/migrator;1?app=browser&type=edge"
].createInstance(Ci.nsIBrowserProfileMigrator);
let bookmarksMigrator = migrator.wrappedJSObject.getBookmarksMigratorForTesting(
db
);
Assert.ok(bookmarksMigrator.exists, "Should recognize db we just created");
let seenBookmarks = [];
@@ -721,7 +725,9 @@ add_task(async function() {
};
PlacesUtils.observers.addListener(["bookmark-added"], listener);
let readingListMigrator = migrator.getReadingListMigratorForTesting(db);
let readingListMigrator = migrator.wrappedJSObject.getReadingListMigratorForTesting(
db
);
Assert.ok(readingListMigrator.exists, "Should recognize db we just created");
migrateResult = await new Promise(resolve =>
readingListMigrator.migrate(resolve)

View File

@@ -1212,8 +1212,10 @@ function createRegistryPath(path) {
}
}
async function getFirstResourceOfType(type) {
let migrator = await MigrationUtils.getMigrator("ie");
function getFirstResourceOfType(type) {
let migrator = Cc[
"@mozilla.org/profile/migrator;1?app=browser&type=ie"
].createInstance(Ci.nsISupports).wrappedJSObject;
let migrators = migrator.getResources();
for (let m of migrators) {
if (m.name == IE7_FORM_PASSWORDS_MIGRATOR_NAME && m.type == type) {
@@ -1229,8 +1231,8 @@ function makeURI(aURL) {
add_task(async function setup() {
if (AppConstants.isPlatformAndVersionAtLeast("win", "6.2")) {
await Assert.rejects(
getFirstResourceOfType(MigrationUtils.resourceTypes.PASSWORDS),
Assert.throws(
() => getFirstResourceOfType(MigrationUtils.resourceTypes.PASSWORDS),
/failed to find/,
"The migrator doesn't exist for win8+"
);
@@ -1258,9 +1260,7 @@ add_task(async function test_passwordsNotAvailable() {
return;
}
let migrator = await getFirstResourceOfType(
MigrationUtils.resourceTypes.PASSWORDS
);
let migrator = getFirstResourceOfType(MigrationUtils.resourceTypes.PASSWORDS);
Assert.ok(migrator.exists, "The migrator has to exist");
let logins = Services.logins.getAllLogins();
Assert.equal(
@@ -1309,9 +1309,7 @@ add_task(async function test_passwordsAvailable() {
crypto.finalize();
});
let migrator = await getFirstResourceOfType(
MigrationUtils.resourceTypes.PASSWORDS
);
let migrator = getFirstResourceOfType(MigrationUtils.resourceTypes.PASSWORDS);
Assert.ok(migrator.exists, "The migrator has to exist");
let logins = Services.logins.getAllLogins();
Assert.equal(

View File

@@ -2,9 +2,6 @@
* http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
const { FirefoxProfileMigrator } = ChromeUtils.importESModule(
"resource:///modules/FirefoxProfileMigrator.sys.mjs"
);
function readFile(file) {
let stream = Cc["@mozilla.org/network/file-input-stream;1"].createInstance(
@@ -83,11 +80,10 @@ function createSubDir(dir, subDirName) {
return subDir;
}
async function promiseMigrator(name, srcDir, targetDir) {
// As the FirefoxProfileMigrator is a startup-only migrator, we import its
// module and instantiate it directly rather than going through MigrationUtils,
// to bypass that availability check.
let migrator = new FirefoxProfileMigrator();
function promiseMigrator(name, srcDir, targetDir) {
let migrator = Cc[
"@mozilla.org/profile/migrator;1?app=browser&type=firefox"
].createInstance(Ci.nsISupports).wrappedJSObject;
let migrators = migrator._getResourcesInternal(srcDir, targetDir);
for (let m of migrators) {
if (m.name == name) {

View File

@@ -1870,7 +1870,7 @@ export var PlacesUIUtils = {
// Otherwise, wait for a successful migration:
let obs = (subject, topic, data) => {
if (
data == lazy.MigrationUtils.resourceTypes.BOOKMARKS &&
data == Ci.nsIBrowserProfileMigrator.BOOKMARKS &&
lazy.MigrationUtils.getImportedCount("bookmarks") > 0
) {
lazy.CustomizableUI.removeWidgetFromArea("import-button");

View File

@@ -467,9 +467,9 @@ var PlacesOrganizer = {
*/
importFromBrowser: function PO_importFromBrowser() {
// We pass in the type of source we're using for use in telemetry:
MigrationUtils.showMigrationWizard(window, {
entrypoint: MigrationUtils.MIGRATION_ENTRYPOINTS.PLACES,
});
MigrationUtils.showMigrationWizard(window, [
MigrationUtils.MIGRATION_ENTRYPOINTS.PLACES,
]);
},
/**

View File

@@ -80,7 +80,7 @@ add_task(async function test_bookmark_import_button_removal() {
Services.obs.notifyObservers(
null,
"Migration:ItemAfterMigrate",
MigrationUtils.resourceTypes.BOOKMARKS
Ci.nsIBrowserProfileMigrator.BOOKMARKS
);
is(
@@ -95,7 +95,7 @@ add_task(async function test_bookmark_import_button_removal() {
Services.obs.notifyObservers(
null,
"Migration:ItemAfterMigrate",
MigrationUtils.resourceTypes.BOOKMARKS
Ci.nsIBrowserProfileMigrator.BOOKMARKS
);
is(Services.prefs.prefHasUserValue(kPref), false, "Pref should be removed.");
@@ -159,7 +159,7 @@ add_task(async function test_bookmark_import_button_errors() {
Services.obs.notifyObservers(
null,
"Migration:ItemError",
MigrationUtils.resourceTypes.BOOKMARKS
Ci.nsIBrowserProfileMigrator.BOOKMARKS
);
is(
@@ -174,7 +174,7 @@ add_task(async function test_bookmark_import_button_errors() {
Services.obs.notifyObservers(
null,
"Migration:ItemError",
MigrationUtils.resourceTypes.BOOKMARKS
Ci.nsIBrowserProfileMigrator.BOOKMARKS
);
is(Services.prefs.prefHasUserValue(kPref), false, "Pref should be removed.");

View File

@@ -232,10 +232,10 @@ const SpecialMessageActions = {
switch (action.type) {
case "SHOW_MIGRATION_WIZARD":
Services.tm.dispatchToMainThread(() =>
lazy.MigrationUtils.showMigrationWizard(window, {
entrypoint: lazy.MigrationUtils.MIGRATION_ENTRYPOINTS.NEWTAB,
migratorKey: action.data?.source,
})
lazy.MigrationUtils.showMigrationWizard(window, [
lazy.MigrationUtils.MIGRATION_ENTRYPOINTS.NEWTAB,
action.data?.source,
])
);
break;
case "OPEN_PRIVATE_BROWSER_WINDOW":

View File

@@ -445,10 +445,7 @@ class LoginManagerParent extends JSWindowActorParent {
// Open the migration wizard pre-selecting the appropriate browser.
lazy.MigrationUtils.showMigrationWizard(
this.getRootBrowser().ownerGlobal,
{
entrypoint: lazy.MigrationUtils.MIGRATION_ENTRYPOINTS.PASSWORDS,
migratorKey: browserId,
}
[lazy.MigrationUtils.MIGRATION_ENTRYPOINTS.PASSWORDS, browserId]
);
}
}

View File

@@ -4,13 +4,8 @@
import { AppConstants } from "resource://gre/modules/AppConstants.sys.mjs";
const lazy = {};
ChromeUtils.defineESModuleGetters(lazy, {
MigrationUtils: "resource:///modules/MigrationUtils.sys.mjs",
});
const MOZ_APP_NAME = AppConstants.MOZ_APP_NAME;
const MOZ_BUILD_APP = AppConstants.MOZ_BUILD_APP;
export var ResetProfile = {
/**
@@ -23,10 +18,14 @@ export var ResetProfile = {
return false;
}
// Reset is only supported if the self-migrator used for reset exists.
if (!lazy.MigrationUtils.migratorExists(MOZ_APP_NAME)) {
let migrator =
"@mozilla.org/profile/migrator;1?app=" +
MOZ_BUILD_APP +
"&type=" +
MOZ_APP_NAME;
if (!(migrator in Cc)) {
return false;
}
// We also need to be using a profile the profile manager knows about.
let profileService = Cc[
"@mozilla.org/toolkit/profile-service;1"