summaryrefslogtreecommitdiffstats
path: root/browser/components/migration/InternalTestingProfileMigrator.sys.mjs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 17:32:43 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 17:32:43 +0000
commit6bf0a5cb5034a7e684dcc3500e841785237ce2dd (patch)
treea68f146d7fa01f0134297619fbe7e33db084e0aa /browser/components/migration/InternalTestingProfileMigrator.sys.mjs
parentInitial commit. (diff)
downloadthunderbird-upstream.tar.xz
thunderbird-upstream.zip
Adding upstream version 1:115.7.0.upstream/1%115.7.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'browser/components/migration/InternalTestingProfileMigrator.sys.mjs')
-rw-r--r--browser/components/migration/InternalTestingProfileMigrator.sys.mjs63
1 files changed, 63 insertions, 0 deletions
diff --git a/browser/components/migration/InternalTestingProfileMigrator.sys.mjs b/browser/components/migration/InternalTestingProfileMigrator.sys.mjs
new file mode 100644
index 0000000000..e14b72607f
--- /dev/null
+++ b/browser/components/migration/InternalTestingProfileMigrator.sys.mjs
@@ -0,0 +1,63 @@
+/* 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";
+
+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";
+ }
+
+ 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 => {
+ 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" };
+ }
+}