blob: 7174757b9628d82ab8d1e679c19eac323b936ef6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
/* 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/. */
import { MigratorBase } from "resource:///modules/MigratorBase.sys.mjs";
import { MigrationWizardConstants } from "chrome://browser/content/migration/migration-wizard-constants.mjs";
const lazy = {};
ChromeUtils.defineESModuleGetters(lazy, {
MigrationUtils: "resource:///modules/MigrationUtils.sys.mjs",
});
/**
* A stub of a migrator used for automated testing only.
*/
export class InternalTestingProfileMigrator extends MigratorBase {
static get key() {
return "internal-testing";
}
static get displayNameL10nID() {
return "Internal Testing Migrator";
}
static get sourceID() {
return 1;
}
getSourceProfiles() {
return Promise.resolve([InternalTestingProfileMigrator.testProfile]);
}
// We will create a single MigratorResource for each resource type that
// just immediately reports a successful migration.
getResources(aProfile) {
if (
!aProfile ||
aProfile.id != InternalTestingProfileMigrator.testProfile.id
) {
throw new Error(
"InternalTestingProfileMigrator.getResources expects test profile."
);
}
return Object.values(lazy.MigrationUtils.resourceTypes).map(type => {
return {
type,
migrate: callback => {
if (type == lazy.MigrationUtils.resourceTypes.EXTENSIONS) {
callback(true, {
progressValue: MigrationWizardConstants.PROGRESS_VALUE.SUCCESS,
totalExtensions: [],
importedExtensions: [],
});
} else {
callback(true /* success */);
}
},
};
});
}
/**
* Clears the MigratorResources that are normally cached by the
* MigratorBase parent class after a call to getResources. This
* allows our automated tests to try different resource availability
* scenarios between tests.
*/
flushResourceCache() {
this._resourcesByProfile = null;
}
static get testProfile() {
return { id: "test-profile", name: "Some test profile" };
}
}
|