Bug 1846570 - Convert more jsm style imports to ES modules (services). r=markh,sync-reviewers

Differential Revision: https://phabricator.services.mozilla.com/D185070
This commit is contained in:
Mark Banner 2023-08-02 13:43:07 +00:00
Родитель 6948e36567
Коммит 674bbb9d67
6 изменённых файлов: 48 добавлений и 49 удалений

Просмотреть файл

@ -6,19 +6,24 @@ const { AppConstants } = ChromeUtils.importESModule(
);
const MODULE_BASE = "resource://services-common/";
const shared_modules = ["async.js", "logmanager.js", "rest.js", "utils.js"];
const shared_modules = [
"async.sys.mjs",
"logmanager.sys.mjs",
"rest.sys.mjs",
"utils.sys.mjs",
];
const non_android_modules = ["tokenserverclient.js"];
const non_android_modules = ["tokenserverclient.sys.mjs"];
const TEST_BASE = "resource://testing-common/services/common/";
const shared_test_modules = ["logging.js"];
const shared_test_modules = ["logging.sys.mjs"];
function expectImportsToSucceed(mm, base = MODULE_BASE) {
for (let m of mm) {
let resource = base + m;
let succeeded = false;
try {
ChromeUtils.import(resource);
ChromeUtils.importESModule(resource);
succeeded = true;
} catch (e) {}
@ -33,7 +38,7 @@ function expectImportsToFail(mm, base = MODULE_BASE) {
let resource = base + m;
let succeeded = false;
try {
ChromeUtils.import(resource);
ChromeUtils.importESModule(resource);
succeeded = true;
} catch (e) {}

Просмотреть файл

@ -1,12 +1,12 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
const modules = ["utils.js", "WeaveCrypto.js"];
const modules = ["utils.sys.mjs", "WeaveCrypto.sys.mjs"];
function run_test() {
for (let m of modules) {
let resource = "resource://services-crypto/" + m;
_("Attempting to import: " + resource);
ChromeUtils.import(resource);
ChromeUtils.importESModule(resource);
}
}

Просмотреть файл

@ -9,19 +9,16 @@ import {
log,
} from "resource://gre/modules/FxAccountsCommon.sys.mjs";
const lazy = {};
ChromeUtils.defineModuleGetter(
lazy,
"PushCrypto",
"resource://gre/modules/PushCrypto.jsm"
);
import { XPCOMUtils } from "resource://gre/modules/XPCOMUtils.sys.mjs";
import { Observers } from "resource://services-common/observers.sys.mjs";
const lazy = {};
ChromeUtils.defineESModuleGetters(lazy, {
BulkKeyBundle: "resource://services-sync/keys.sys.mjs",
CryptoWrapper: "resource://services-sync/record.sys.mjs",
PushCrypto: "resource://gre/modules/PushCrypto.sys.mjs",
});
XPCOMUtils.defineLazyPreferenceGetter(

Просмотреть файл

@ -11,6 +11,7 @@ ChromeUtils.defineESModuleGetters(lazy, {
Database: "resource://services-settings/Database.sys.mjs",
FilterExpressions:
"resource://gre/modules/components-utils/FilterExpressions.sys.mjs",
pushBroadcastService: "resource://gre/modules/PushBroadcastService.sys.mjs",
RemoteSettingsClient:
"resource://services-settings/RemoteSettingsClient.sys.mjs",
SyncHistory: "resource://services-settings/SyncHistory.sys.mjs",
@ -18,10 +19,6 @@ ChromeUtils.defineESModuleGetters(lazy, {
Utils: "resource://services-settings/Utils.sys.mjs",
});
XPCOMUtils.defineLazyModuleGetters(lazy, {
pushBroadcastService: "resource://gre/modules/PushBroadcastService.jsm",
});
const PREF_SETTINGS_BRANCH = "services.settings.";
const PREF_SETTINGS_SERVER_BACKOFF = "server.backoff";
const PREF_SETTINGS_LAST_UPDATE = "last_update_seconds";

Просмотреть файл

@ -13,8 +13,8 @@ const { UptakeTelemetry, Policy } = ChromeUtils.importESModule(
const { RemoteSettingsClient } = ChromeUtils.importESModule(
"resource://services-settings/RemoteSettingsClient.sys.mjs"
);
const { pushBroadcastService } = ChromeUtils.import(
"resource://gre/modules/PushBroadcastService.jsm"
const { pushBroadcastService } = ChromeUtils.importESModule(
"resource://gre/modules/PushBroadcastService.sys.mjs"
);
const { SyncHistory } = ChromeUtils.importESModule(
"resource://services-settings/SyncHistory.sys.mjs"

Просмотреть файл

@ -6,54 +6,54 @@ const { AppConstants } = ChromeUtils.importESModule(
);
const modules = [
"addonutils.js",
"addonsreconciler.js",
"constants.js",
"engines/addons.js",
"engines/clients.js",
"engines/extension-storage.js",
"engines/passwords.js",
"engines/prefs.js",
"engines.js",
"keys.js",
"main.js",
"policies.js",
"record.js",
"resource.js",
"service.js",
"stages/declined.js",
"stages/enginesync.js",
"status.js",
"sync_auth.js",
"util.js",
"addonutils.sys.mjs",
"addonsreconciler.sys.mjs",
"constants.sys.mjs",
"engines/addons.sys.mjs",
"engines/clients.sys.mjs",
"engines/extension-storage.sys.mjs",
"engines/passwords.sys.mjs",
"engines/prefs.sys.mjs",
"engines.sys.mjs",
"keys.sys.mjs",
"main.sys.mjs",
"policies.sys.mjs",
"record.sys.mjs",
"resource.sys.mjs",
"service.sys.mjs",
"stages/declined.sys.mjs",
"stages/enginesync.sys.mjs",
"status.sys.mjs",
"sync_auth.sys.mjs",
"util.sys.mjs",
];
if (AppConstants.MOZ_APP_NAME != "thunderbird") {
modules.push(
"engines/bookmarks.js",
"engines/forms.js",
"engines/history.js",
"engines/tabs.js"
"engines/bookmarks.sys.mjs",
"engines/forms.sys.mjs",
"engines/history.sys.mjs",
"engines/tabs.sys.mjs"
);
}
const testingModules = [
"fakeservices.js",
"rotaryengine.js",
"utils.js",
"fxa_utils.js",
"fakeservices.sys.mjs",
"rotaryengine.sys.mjs",
"utils.sys.mjs",
"fxa_utils.sys.mjs",
];
function run_test() {
for (let m of modules) {
let res = "resource://services-sync/" + m;
_("Attempting to load " + res);
ChromeUtils.import(res);
ChromeUtils.importESModule(res);
}
for (let m of testingModules) {
let res = "resource://testing-common/services/sync/" + m;
_("Attempting to load " + res);
ChromeUtils.import(res);
ChromeUtils.importESModule(res);
}
}