зеркало из https://github.com/mozilla/gecko-dev.git
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:
Родитель
18753bfe42
Коммит
a24dca9645
|
@ -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"
|
||||
);
|
||||
|
||||
/**
|
||||
|
|
Загрузка…
Ссылка в новой задаче