Bug 1798212 - Replace defineModuleGetter in Integration.sys.mjs with a ES version. r=settings-reviewers,mossop

Differential Revision: https://phabricator.services.mozilla.com/D161014
This commit is contained in:
Mark Banner 2022-11-07 17:56:10 +00:00
Родитель 18753bfe42
Коммит a24dca9645
15 изменённых файлов: 34 добавлений и 45 удалений

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

@ -39,10 +39,10 @@ XPCOMUtils.defineLazyServiceGetter(
import { Integration } from "resource://gre/modules/Integration.sys.mjs";
Integration.downloads.defineModuleGetter(
Integration.downloads.defineESModuleGetter(
lazy,
"DownloadIntegration",
"resource://gre/modules/DownloadIntegration.jsm"
"resource://gre/modules/DownloadIntegration.sys.mjs"
);
const HTML_NS = "http://www.w3.org/1999/xhtml";

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

@ -51,10 +51,10 @@ const { Integration } = ChromeUtils.importESModule(
);
/* global DownloadIntegration */
Integration.downloads.defineModuleGetter(
Integration.downloads.defineESModuleGetter(
this,
"DownloadIntegration",
"resource://gre/modules/DownloadIntegration.jsm"
"resource://gre/modules/DownloadIntegration.sys.mjs"
);
// DownloadsPanel

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

@ -25,10 +25,10 @@ const {
);
/* global DownloadIntegration */
Integration.downloads.defineModuleGetter(
Integration.downloads.defineESModuleGetter(
this,
"DownloadIntegration",
"resource://gre/modules/DownloadIntegration.jsm"
"resource://gre/modules/DownloadIntegration.sys.mjs"
);
const HandlerService = Cc[

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

@ -28,10 +28,10 @@ var { Integration } = ChromeUtils.importESModule(
"resource://gre/modules/Integration.sys.mjs"
);
/* global DownloadIntegration */
Integration.downloads.defineModuleGetter(
Integration.downloads.defineESModuleGetter(
this,
"DownloadIntegration",
"resource://gre/modules/DownloadIntegration.jsm"
"resource://gre/modules/DownloadIntegration.sys.mjs"
);
var { PrivateBrowsingUtils } = ChromeUtils.importESModule(

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

@ -39,10 +39,10 @@ XPCOMUtils.defineLazyServiceGetter(
Ci.nsIExternalHelperAppService
);
Integration.downloads.defineModuleGetter(
Integration.downloads.defineESModuleGetter(
lazy,
"DownloadIntegration",
"resource://gre/modules/DownloadIntegration.jsm"
"resource://gre/modules/DownloadIntegration.sys.mjs"
);
const BackgroundFileSaverStreamListener = Components.Constructor(

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

@ -74,10 +74,10 @@ XPCOMUtils.defineLazyServiceGetter(
Ci.nsIApplicationReputationService
);
Integration.downloads.defineModuleGetter(
Integration.downloads.defineESModuleGetter(
lazy,
"DownloadIntegration",
"resource://gre/modules/DownloadIntegration.jsm"
"resource://gre/modules/DownloadIntegration.sys.mjs"
);
XPCOMUtils.defineLazyGetter(lazy, "gCombinedDownloadIntegration", () => {
return lazy.DownloadIntegration;

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

@ -21,10 +21,10 @@ ChromeUtils.defineESModuleGetters(lazy, {
DownloadSummary: "resource://gre/modules/DownloadList.sys.mjs",
});
Integration.downloads.defineModuleGetter(
Integration.downloads.defineESModuleGetter(
lazy,
"DownloadIntegration",
"resource://gre/modules/DownloadIntegration.jsm"
"resource://gre/modules/DownloadIntegration.sys.mjs"
);
/**

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

@ -46,10 +46,10 @@ XPCOMUtils.defineLazyServiceGetter(
);
/* global DownloadIntegration */
Integration.downloads.defineModuleGetter(
Integration.downloads.defineESModuleGetter(
this,
"DownloadIntegration",
"resource://gre/modules/DownloadIntegration.jsm"
"resource://gre/modules/DownloadIntegration.sys.mjs"
);
const ServerSocket = Components.Constructor(

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

@ -104,8 +104,6 @@
* reference changes when new integration overrides are registered.
*/
import { XPCOMUtils } from "resource://gre/modules/XPCOMUtils.sys.mjs";
/**
* Maps integration point names to IntegrationPoint objects.
*/
@ -253,7 +251,7 @@ IntegrationPoint.prototype = {
/**
* Defines a getter to retrieve the dynamically generated object implementing
* the integration methods, loading the root implementation lazily from the
* specified JSM module. For example:
* specified sys.mjs module. For example:
*
* Integration.test.defineModuleGetter(this, "TestIntegration",
* "resource://testing-common/TestIntegration.sys.mjs");
@ -264,13 +262,13 @@ IntegrationPoint.prototype = {
* The name of the getter to define.
* @param moduleUrl
* The URL used to obtain the module.
* @param symbol [optional]
* The name of the symbol exported by the module. This can be omitted
* if the name of the exported symbol is equal to the getter name.
*/
defineModuleGetter(targetObject, name, moduleUrl, symbol) {
defineESModuleGetter(targetObject, name, moduleUrl) {
let moduleHolder = {};
XPCOMUtils.defineLazyModuleGetter(moduleHolder, name, moduleUrl, symbol);
// eslint-disable-next-line mozilla/lazy-getter-object-name
ChromeUtils.defineESModuleGetters(moduleHolder, {
[name]: moduleUrl,
});
Object.defineProperty(targetObject, name, {
get: () => this.getCombined(moduleHolder[name]),
configurable: true,

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

@ -218,30 +218,21 @@ add_task(async function test_xpcom_throws() {
});
/**
* Checks that getters defined by defineModuleGetter are able to retrieve the
* Checks that getters defined by defineESModuleGetter are able to retrieve the
* latest version of the combined integration object.
*/
add_task(async function test_defineModuleGetter() {
add_task(async function test_defineESModuleGetter() {
let objectForGetters = {};
// Test with and without the optional "symbol" parameter.
Integration.testModule.defineModuleGetter(
Integration.testModule.defineESModuleGetter(
objectForGetters,
"TestIntegration",
"resource://testing-common/TestIntegration.jsm"
);
Integration.testModule.defineModuleGetter(
objectForGetters,
"integration",
"resource://testing-common/TestIntegration.jsm",
"TestIntegration"
"resource://testing-common/TestIntegration.sys.mjs"
);
Integration.testModule.register(overrideFn);
await assertCombinedResults(objectForGetters.integration, 1);
await assertCombinedResults(objectForGetters.TestIntegration, 1);
Integration.testModule.unregister(overrideFn);
await assertCombinedResults(objectForGetters.integration, 0);
await assertCombinedResults(objectForGetters.TestIntegration, 0);
});

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

@ -25,10 +25,10 @@ XPCOMUtils.defineLazyServiceGetter(
const { Integration } = ChromeUtils.importESModule(
"resource://gre/modules/Integration.sys.mjs"
);
Integration.downloads.defineModuleGetter(
Integration.downloads.defineESModuleGetter(
lazy,
"DownloadIntegration",
"resource://gre/modules/DownloadIntegration.jsm"
"resource://gre/modules/DownloadIntegration.sys.mjs"
);
// /////////////////////////////////////////////////////////////////////////////

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

@ -25,7 +25,7 @@ const callExpressionDefinitions = [
/^loader\.lazyServiceGetter\(lazy, "(\w+)"/,
/^loader\.lazyRequireGetter\(lazy, "(\w+)"/,
/^XPCOMUtils\.defineLazyGetter\(lazy, "(\w+)"/,
/^Integration\.downloads\.defineModuleGetter\(lazy, "(\w+)"/,
/^Integration\.downloads\.defineESModuleGetter\(lazy, "(\w+)"/,
/^XPCOMUtils\.defineLazyModuleGetter\(lazy, "(\w+)"/,
/^ChromeUtils\.defineModuleGetter\(lazy, "(\w+)"/,
/^XPCOMUtils\.defineLazyPreferenceGetter\(lazy, "(\w+)"/,

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

@ -45,7 +45,7 @@ ruleTester.run("valid-lazy", rule, {
`,
`
const lazy = {};
Integration.downloads.defineModuleGetter(lazy, "foo", "foo.jsm");
Integration.downloads.defineESModuleGetter(lazy, "foo", "foo.sys.mjs");
if (x) { lazy.foo.bar(); }
`,
`

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

@ -25,10 +25,10 @@ ChromeUtils.defineESModuleGetters(lazy, {
});
import { Integration } from "resource://gre/modules/Integration.sys.mjs";
Integration.downloads.defineModuleGetter(
Integration.downloads.defineESModuleGetter(
lazy,
"DownloadIntegration",
"resource://gre/modules/DownloadIntegration.jsm"
"resource://gre/modules/DownloadIntegration.sys.mjs"
);
XPCOMUtils.defineLazyServiceGetter(

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

@ -13,10 +13,10 @@ const { Integration } = ChromeUtils.importESModule(
);
/* global DownloadIntegration */
Integration.downloads.defineModuleGetter(
Integration.downloads.defineESModuleGetter(
this,
"DownloadIntegration",
"resource://gre/modules/DownloadIntegration.jsm"
"resource://gre/modules/DownloadIntegration.sys.mjs"
);
/**