Bug 1822792 - Convert ModuleManager's resouces to ESM. r=geckoview-reviewers,extension-reviewers,owlish

Differential Revision: https://phabricator.services.mozilla.com/D172781
This commit is contained in:
Makoto Kato 2023-03-17 06:34:35 +00:00
parent 25e942f2a0
commit d0d41ac35f
15 changed files with 49 additions and 119 deletions

View file

@ -15,6 +15,7 @@ ChromeUtils.defineESModuleGetters(this, {
E10SUtils: "resource://gre/modules/E10SUtils.sys.mjs", E10SUtils: "resource://gre/modules/E10SUtils.sys.mjs",
EventDispatcher: "resource://gre/modules/Messaging.sys.mjs", EventDispatcher: "resource://gre/modules/Messaging.sys.mjs",
GeckoViewActorManager: "resource://gre/modules/GeckoViewActorManager.sys.mjs", GeckoViewActorManager: "resource://gre/modules/GeckoViewActorManager.sys.mjs",
GeckoViewSettings: "resource://gre/modules/GeckoViewSettings.sys.mjs",
GeckoViewUtils: "resource://gre/modules/GeckoViewUtils.sys.mjs", GeckoViewUtils: "resource://gre/modules/GeckoViewUtils.sys.mjs",
RemoteSecuritySettings: RemoteSecuritySettings:
"resource://gre/modules/psm/RemoteSecuritySettings.sys.mjs", "resource://gre/modules/psm/RemoteSecuritySettings.sys.mjs",
@ -22,7 +23,6 @@ ChromeUtils.defineESModuleGetters(this, {
XPCOMUtils.defineLazyModuleGetters(this, { XPCOMUtils.defineLazyModuleGetters(this, {
Blocklist: "resource://gre/modules/Blocklist.jsm", Blocklist: "resource://gre/modules/Blocklist.jsm",
GeckoViewSettings: "resource://gre/modules/GeckoViewSettings.jsm",
HistogramStopwatch: "resource://gre/modules/GeckoViewTelemetry.jsm", HistogramStopwatch: "resource://gre/modules/GeckoViewTelemetry.jsm",
InitializationTracker: "resource://gre/modules/GeckoViewTelemetry.jsm", InitializationTracker: "resource://gre/modules/GeckoViewTelemetry.jsm",
SafeBrowsing: "resource://gre/modules/SafeBrowsing.jsm", SafeBrowsing: "resource://gre/modules/SafeBrowsing.jsm",
@ -425,7 +425,7 @@ class ModuleInfo {
return; return;
} }
const exports = ChromeUtils.import(aPhase.resource); const exports = ChromeUtils.importESModule(aPhase.resource);
this._impl = new exports[this._name](this); this._impl = new exports[this._name](this);
} }
@ -565,7 +565,7 @@ function startup() {
{ {
name: "GeckoViewContent", name: "GeckoViewContent",
onInit: { onInit: {
resource: "resource://gre/modules/GeckoViewContent.jsm", resource: "resource://gre/modules/GeckoViewContent.sys.mjs",
actors: { actors: {
GeckoViewContent: { GeckoViewContent: {
parent: { parent: {
@ -612,19 +612,19 @@ function startup() {
{ {
name: "GeckoViewNavigation", name: "GeckoViewNavigation",
onInit: { onInit: {
resource: "resource://gre/modules/GeckoViewNavigation.jsm", resource: "resource://gre/modules/GeckoViewNavigation.sys.mjs",
}, },
}, },
{ {
name: "GeckoViewProcessHangMonitor", name: "GeckoViewProcessHangMonitor",
onInit: { onInit: {
resource: "resource://gre/modules/GeckoViewProcessHangMonitor.jsm", resource: "resource://gre/modules/GeckoViewProcessHangMonitor.sys.mjs",
}, },
}, },
{ {
name: "GeckoViewProgress", name: "GeckoViewProgress",
onEnable: { onEnable: {
resource: "resource://gre/modules/GeckoViewProgress.jsm", resource: "resource://gre/modules/GeckoViewProgress.sys.mjs",
actors: { actors: {
ProgressDelegate: { ProgressDelegate: {
parent: { parent: {
@ -665,7 +665,7 @@ function startup() {
{ {
name: "GeckoViewSelectionAction", name: "GeckoViewSelectionAction",
onEnable: { onEnable: {
resource: "resource://gre/modules/GeckoViewSelectionAction.jsm", resource: "resource://gre/modules/GeckoViewSelectionAction.sys.mjs",
actors: { actors: {
SelectionActionDelegate: { SelectionActionDelegate: {
parent: { parent: {
@ -688,7 +688,7 @@ function startup() {
{ {
name: "GeckoViewSettings", name: "GeckoViewSettings",
onInit: { onInit: {
resource: "resource://gre/modules/GeckoViewSettings.jsm", resource: "resource://gre/modules/GeckoViewSettings.sys.mjs",
actors: { actors: {
GeckoViewSettings: { GeckoViewSettings: {
child: { child: {
@ -701,13 +701,13 @@ function startup() {
{ {
name: "GeckoViewTab", name: "GeckoViewTab",
onInit: { onInit: {
resource: "resource://gre/modules/GeckoViewTab.jsm", resource: "resource://gre/modules/GeckoViewTab.sys.mjs",
}, },
}, },
{ {
name: "GeckoViewContentBlocking", name: "GeckoViewContentBlocking",
onInit: { onInit: {
resource: "resource://gre/modules/GeckoViewContentBlocking.jsm", resource: "resource://gre/modules/GeckoViewContentBlocking.sys.mjs",
}, },
}, },
{ {
@ -763,7 +763,7 @@ function startup() {
{ {
name: "GeckoViewMediaControl", name: "GeckoViewMediaControl",
onEnable: { onEnable: {
resource: "resource://gre/modules/GeckoViewMediaControl.jsm", resource: "resource://gre/modules/GeckoViewMediaControl.sys.mjs",
actors: { actors: {
MediaControlDelegate: { MediaControlDelegate: {
parent: { parent: {

View file

@ -4,15 +4,10 @@
"use strict"; "use strict";
ChromeUtils.defineESModuleGetters(this, { ChromeUtils.defineESModuleGetters(this, {
GeckoViewTabBridge: "resource://gre/modules/GeckoViewTab.sys.mjs",
PrivateBrowsingUtils: "resource://gre/modules/PrivateBrowsingUtils.sys.mjs", PrivateBrowsingUtils: "resource://gre/modules/PrivateBrowsingUtils.sys.mjs",
}); });
ChromeUtils.defineModuleGetter(
this,
"GeckoViewTabBridge",
"resource://gre/modules/GeckoViewTab.jsm"
);
ChromeUtils.defineModuleGetter( ChromeUtils.defineModuleGetter(
this, this,
"mobileWindowTracker", "mobileWindowTracker",

View file

@ -7,15 +7,10 @@
"use strict"; "use strict";
ChromeUtils.defineESModuleGetters(this, { ChromeUtils.defineESModuleGetters(this, {
GeckoViewTabBridge: "resource://gre/modules/GeckoViewTab.sys.mjs",
PromiseUtils: "resource://gre/modules/PromiseUtils.sys.mjs", PromiseUtils: "resource://gre/modules/PromiseUtils.sys.mjs",
}); });
ChromeUtils.defineModuleGetter(
this,
"GeckoViewTabBridge",
"resource://gre/modules/GeckoViewTab.jsm"
);
ChromeUtils.defineModuleGetter( ChromeUtils.defineModuleGetter(
this, this,
"mobileWindowTracker", "mobileWindowTracker",

View file

@ -2,15 +2,9 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this file, * 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/. */ * You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict"; import { GeckoViewModule } from "resource://gre/modules/GeckoViewModule.sys.mjs";
var EXPORTED_SYMBOLS = ["GeckoViewContent"]; export class GeckoViewContent extends GeckoViewModule {
const { GeckoViewModule } = ChromeUtils.importESModule(
"resource://gre/modules/GeckoViewModule.sys.mjs"
);
class GeckoViewContent extends GeckoViewModule {
onInit() { onInit() {
this.registerListener([ this.registerListener([
"GeckoViewContent:ExitFullScreen", "GeckoViewContent:ExitFullScreen",

View file

@ -2,15 +2,9 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this file, * 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/. */ * You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict"; import { GeckoViewModule } from "resource://gre/modules/GeckoViewModule.sys.mjs";
var EXPORTED_SYMBOLS = ["GeckoViewContentBlocking"]; export class GeckoViewContentBlocking extends GeckoViewModule {
const { GeckoViewModule } = ChromeUtils.importESModule(
"resource://gre/modules/GeckoViewModule.sys.mjs"
);
class GeckoViewContentBlocking extends GeckoViewModule {
onEnable() { onEnable() {
const flags = Ci.nsIWebProgress.NOTIFY_CONTENT_BLOCKING; const flags = Ci.nsIWebProgress.NOTIFY_CONTENT_BLOCKING;
this.progressFilter = Cc[ this.progressFilter = Cc[

View file

@ -2,15 +2,9 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this file, * 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/. */ * You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict"; import { GeckoViewModule } from "resource://gre/modules/GeckoViewModule.sys.mjs";
var EXPORTED_SYMBOLS = ["GeckoViewMediaControl"]; export class GeckoViewMediaControl extends GeckoViewModule {
const { GeckoViewModule } = ChromeUtils.importESModule(
"resource://gre/modules/GeckoViewModule.sys.mjs"
);
class GeckoViewMediaControl extends GeckoViewModule {
onInit() { onInit() {
debug`onInit`; debug`onInit`;
} }

View file

@ -2,16 +2,8 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this file, * 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/. */ * You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict"; import { GeckoViewModule } from "resource://gre/modules/GeckoViewModule.sys.mjs";
import { XPCOMUtils } from "resource://gre/modules/XPCOMUtils.sys.mjs";
var EXPORTED_SYMBOLS = ["GeckoViewNavigation"];
const { GeckoViewModule } = ChromeUtils.importESModule(
"resource://gre/modules/GeckoViewModule.sys.mjs"
);
const { XPCOMUtils } = ChromeUtils.importESModule(
"resource://gre/modules/XPCOMUtils.sys.mjs"
);
const lazy = {}; const lazy = {};
@ -44,6 +36,7 @@ const FORBIDDEN_HEADER_CHARACTERS = ["\n", "\r"];
// Keep in sync with GeckoSession.java // Keep in sync with GeckoSession.java
const HEADER_FILTER_CORS_SAFELISTED = 1; const HEADER_FILTER_CORS_SAFELISTED = 1;
// eslint-disable-next-line no-unused-vars
const HEADER_FILTER_UNRESTRICTED_UNSAFE = 2; const HEADER_FILTER_UNRESTRICTED_UNSAFE = 2;
// Create default ReferrerInfo instance for the given referrer URI string. // Create default ReferrerInfo instance for the given referrer URI string.
@ -95,7 +88,7 @@ function convertFlags(aFlags) {
// Dispatches GeckoView:LocationChange to the GeckoView on location change when // Dispatches GeckoView:LocationChange to the GeckoView on location change when
// active. // active.
// Implements nsIBrowserDOMWindow. // Implements nsIBrowserDOMWindow.
class GeckoViewNavigation extends GeckoViewModule { export class GeckoViewNavigation extends GeckoViewModule {
onInitBrowser() { onInitBrowser() {
this.window.browserDOMWindow = this; this.window.browserDOMWindow = this;

View file

@ -2,15 +2,9 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this * 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/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict"; import { GeckoViewModule } from "resource://gre/modules/GeckoViewModule.sys.mjs";
var EXPORTED_SYMBOLS = ["GeckoViewProcessHangMonitor"]; export class GeckoViewProcessHangMonitor extends GeckoViewModule {
const { GeckoViewModule } = ChromeUtils.importESModule(
"resource://gre/modules/GeckoViewModule.sys.mjs"
);
class GeckoViewProcessHangMonitor extends GeckoViewModule {
constructor(aModuleInfo) { constructor(aModuleInfo) {
super(aModuleInfo); super(aModuleInfo);

View file

@ -2,16 +2,8 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this file, * 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/. */ * You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict"; import { GeckoViewModule } from "resource://gre/modules/GeckoViewModule.sys.mjs";
import { XPCOMUtils } from "resource://gre/modules/XPCOMUtils.sys.mjs";
var EXPORTED_SYMBOLS = ["GeckoViewProgress"];
const { GeckoViewModule } = ChromeUtils.importESModule(
"resource://gre/modules/GeckoViewModule.sys.mjs"
);
const { XPCOMUtils } = ChromeUtils.importESModule(
"resource://gre/modules/XPCOMUtils.sys.mjs"
);
const lazy = {}; const lazy = {};
@ -506,7 +498,7 @@ class SecurityTracker extends Tracker {
} }
} }
class GeckoViewProgress extends GeckoViewModule { export class GeckoViewProgress extends GeckoViewModule {
onEnable() { onEnable() {
debug`onEnable`; debug`onEnable`;

View file

@ -2,15 +2,9 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this * 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/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict"; import { GeckoViewModule } from "resource://gre/modules/GeckoViewModule.sys.mjs";
var EXPORTED_SYMBOLS = ["GeckoViewSelectionAction"]; export class GeckoViewSelectionAction extends GeckoViewModule {
const { GeckoViewModule } = ChromeUtils.importESModule(
"resource://gre/modules/GeckoViewModule.sys.mjs"
);
class GeckoViewSelectionAction extends GeckoViewModule {
onEnable() { onEnable() {
debug`onEnable`; debug`onEnable`;
this.registerListener(["GeckoView:ExecuteSelectionAction"]); this.registerListener(["GeckoView:ExecuteSelectionAction"]);

View file

@ -2,17 +2,8 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this file, * 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/. */ * You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict"; import { GeckoViewModule } from "resource://gre/modules/GeckoViewModule.sys.mjs";
import { XPCOMUtils } from "resource://gre/modules/XPCOMUtils.sys.mjs";
var EXPORTED_SYMBOLS = ["GeckoViewSettings"];
const { GeckoViewModule } = ChromeUtils.importESModule(
"resource://gre/modules/GeckoViewModule.sys.mjs"
);
const { XPCOMUtils } = ChromeUtils.importESModule(
"resource://gre/modules/XPCOMUtils.sys.mjs"
);
const lazy = {}; const lazy = {};
@ -45,11 +36,12 @@ const DISPLAY_MODE_STANDALONE = 2;
const DISPLAY_MODE_FULLSCREEN = 3; const DISPLAY_MODE_FULLSCREEN = 3;
// This needs to match GeckoSessionSettings.java // This needs to match GeckoSessionSettings.java
// eslint-disable-next-line no-unused-vars
const VIEWPORT_MODE_MOBILE = 0; const VIEWPORT_MODE_MOBILE = 0;
const VIEWPORT_MODE_DESKTOP = 1; const VIEWPORT_MODE_DESKTOP = 1;
// Handles GeckoSession settings. // Handles GeckoSession settings.
class GeckoViewSettings extends GeckoViewModule { export class GeckoViewSettings extends GeckoViewModule {
onInit() { onInit() {
debug`onInit`; debug`onInit`;
this._userAgentMode = USER_AGENT_MODE_MOBILE; this._userAgentMode = USER_AGENT_MODE_MOBILE;

View file

@ -2,16 +2,9 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this file, * 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/. */ * You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict"; import { GeckoViewModule } from "resource://gre/modules/GeckoViewModule.sys.mjs";
import { XPCOMUtils } from "resource://gre/modules/XPCOMUtils.sys.mjs";
var EXPORTED_SYMBOLS = ["GeckoViewTab", "GeckoViewTabBridge"];
const { GeckoViewModule } = ChromeUtils.importESModule(
"resource://gre/modules/GeckoViewModule.sys.mjs"
);
const { XPCOMUtils } = ChromeUtils.importESModule(
"resource://gre/modules/XPCOMUtils.sys.mjs"
);
const { ExtensionUtils } = ChromeUtils.import( const { ExtensionUtils } = ChromeUtils.import(
"resource://gre/modules/ExtensionUtils.jsm" "resource://gre/modules/ExtensionUtils.jsm"
); );
@ -53,7 +46,7 @@ class Tab {
// we choose a value that is unlikely to overlap with Fennec's tab IDs. // we choose a value that is unlikely to overlap with Fennec's tab IDs.
const TAB_ID_BASE = 10000; const TAB_ID_BASE = 10000;
const GeckoViewTabBridge = { export const GeckoViewTabBridge = {
/** /**
* Converts windowId to tabId as in GeckoView every browser window has exactly one tab. * Converts windowId to tabId as in GeckoView every browser window has exactly one tab.
* *
@ -206,7 +199,7 @@ const GeckoViewTabBridge = {
}, },
}; };
class GeckoViewTab extends GeckoViewModule { export class GeckoViewTab extends GeckoViewModule {
onInit() { onInit() {
const { window } = this; const { window } = this;
if (!window.tab) { if (!window.tab) {

View file

@ -31,6 +31,7 @@ const lazy = {};
ChromeUtils.defineESModuleGetters(lazy, { ChromeUtils.defineESModuleGetters(lazy, {
EventDispatcher: "resource://gre/modules/Messaging.sys.mjs", EventDispatcher: "resource://gre/modules/Messaging.sys.mjs",
GeckoViewTabBridge: "resource://gre/modules/GeckoViewTab.sys.mjs",
PrivateBrowsingUtils: "resource://gre/modules/PrivateBrowsingUtils.sys.mjs", PrivateBrowsingUtils: "resource://gre/modules/PrivateBrowsingUtils.sys.mjs",
}); });
@ -39,7 +40,6 @@ XPCOMUtils.defineLazyModuleGetters(lazy, {
Extension: "resource://gre/modules/Extension.jsm", Extension: "resource://gre/modules/Extension.jsm",
ExtensionData: "resource://gre/modules/Extension.jsm", ExtensionData: "resource://gre/modules/Extension.jsm",
ExtensionPermissions: "resource://gre/modules/ExtensionPermissions.jsm", ExtensionPermissions: "resource://gre/modules/ExtensionPermissions.jsm",
GeckoViewTabBridge: "resource://gre/modules/GeckoViewTab.jsm",
Management: "resource://gre/modules/Extension.jsm", Management: "resource://gre/modules/Extension.jsm",
}); });

View file

@ -16,20 +16,20 @@ EXTRA_JS_MODULES += [
"GeckoViewAutofill.jsm", "GeckoViewAutofill.jsm",
"GeckoViewChildModule.jsm", "GeckoViewChildModule.jsm",
"GeckoViewConsole.jsm", "GeckoViewConsole.jsm",
"GeckoViewContent.jsm", "GeckoViewContent.sys.mjs",
"GeckoViewContentBlocking.jsm", "GeckoViewContentBlocking.sys.mjs",
"GeckoViewMediaControl.jsm", "GeckoViewMediaControl.sys.mjs",
"GeckoViewModule.sys.mjs", "GeckoViewModule.sys.mjs",
"GeckoViewNavigation.jsm", "GeckoViewNavigation.sys.mjs",
"GeckoViewProcessHangMonitor.jsm", "GeckoViewProcessHangMonitor.sys.mjs",
"GeckoViewProgress.jsm", "GeckoViewProgress.sys.mjs",
"GeckoViewPushController.jsm", "GeckoViewPushController.jsm",
"GeckoViewRemoteDebugger.jsm", "GeckoViewRemoteDebugger.jsm",
"GeckoViewSelectionAction.jsm", "GeckoViewSelectionAction.sys.mjs",
"GeckoViewSessionStore.jsm", "GeckoViewSessionStore.jsm",
"GeckoViewSettings.jsm", "GeckoViewSettings.sys.mjs",
"GeckoViewStorageController.jsm", "GeckoViewStorageController.jsm",
"GeckoViewTab.jsm", "GeckoViewTab.sys.mjs",
"GeckoViewTelemetry.jsm", "GeckoViewTelemetry.jsm",
"GeckoViewTestUtils.jsm", "GeckoViewTestUtils.jsm",
"GeckoViewUtils.sys.mjs", "GeckoViewUtils.sys.mjs",

View file

@ -14,11 +14,11 @@ const lazy = {};
ChromeUtils.defineESModuleGetters(lazy, { ChromeUtils.defineESModuleGetters(lazy, {
EventDispatcher: "resource://gre/modules/Messaging.sys.mjs", EventDispatcher: "resource://gre/modules/Messaging.sys.mjs",
GeckoViewTabBridge: "resource://gre/modules/GeckoViewTab.sys.mjs",
}); });
XPCOMUtils.defineLazyModuleGetters(lazy, { XPCOMUtils.defineLazyModuleGetters(lazy, {
mobileWindowTracker: "resource://gre/modules/GeckoViewWebExtension.jsm", mobileWindowTracker: "resource://gre/modules/GeckoViewWebExtension.jsm",
GeckoViewTabBridge: "resource://gre/modules/GeckoViewTab.jsm",
}); });
const TEST_SUPPORT_EXTENSION_ID = "test-runner-support@tests.mozilla.org"; const TEST_SUPPORT_EXTENSION_ID = "test-runner-support@tests.mozilla.org";