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
Родитель 25e942f2a0
Коммит d0d41ac35f
15 изменённых файлов: 49 добавлений и 119 удалений

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

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

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

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

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

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

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

@ -2,15 +2,9 @@
* 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/. */
"use strict";
import { GeckoViewModule } from "resource://gre/modules/GeckoViewModule.sys.mjs";
var EXPORTED_SYMBOLS = ["GeckoViewContent"];
const { GeckoViewModule } = ChromeUtils.importESModule(
"resource://gre/modules/GeckoViewModule.sys.mjs"
);
class GeckoViewContent extends GeckoViewModule {
export class GeckoViewContent extends GeckoViewModule {
onInit() {
this.registerListener([
"GeckoViewContent:ExitFullScreen",

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

@ -2,15 +2,9 @@
* 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/. */
"use strict";
import { GeckoViewModule } from "resource://gre/modules/GeckoViewModule.sys.mjs";
var EXPORTED_SYMBOLS = ["GeckoViewContentBlocking"];
const { GeckoViewModule } = ChromeUtils.importESModule(
"resource://gre/modules/GeckoViewModule.sys.mjs"
);
class GeckoViewContentBlocking extends GeckoViewModule {
export class GeckoViewContentBlocking extends GeckoViewModule {
onEnable() {
const flags = Ci.nsIWebProgress.NOTIFY_CONTENT_BLOCKING;
this.progressFilter = Cc[

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

@ -2,15 +2,9 @@
* 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/. */
"use strict";
import { GeckoViewModule } from "resource://gre/modules/GeckoViewModule.sys.mjs";
var EXPORTED_SYMBOLS = ["GeckoViewMediaControl"];
const { GeckoViewModule } = ChromeUtils.importESModule(
"resource://gre/modules/GeckoViewModule.sys.mjs"
);
class GeckoViewMediaControl extends GeckoViewModule {
export class GeckoViewMediaControl extends GeckoViewModule {
onInit() {
debug`onInit`;
}

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

@ -2,16 +2,8 @@
* 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/. */
"use strict";
var EXPORTED_SYMBOLS = ["GeckoViewNavigation"];
const { GeckoViewModule } = ChromeUtils.importESModule(
"resource://gre/modules/GeckoViewModule.sys.mjs"
);
const { XPCOMUtils } = ChromeUtils.importESModule(
"resource://gre/modules/XPCOMUtils.sys.mjs"
);
import { GeckoViewModule } from "resource://gre/modules/GeckoViewModule.sys.mjs";
import { XPCOMUtils } from "resource://gre/modules/XPCOMUtils.sys.mjs";
const lazy = {};
@ -44,6 +36,7 @@ const FORBIDDEN_HEADER_CHARACTERS = ["\n", "\r"];
// Keep in sync with GeckoSession.java
const HEADER_FILTER_CORS_SAFELISTED = 1;
// eslint-disable-next-line no-unused-vars
const HEADER_FILTER_UNRESTRICTED_UNSAFE = 2;
// 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
// active.
// Implements nsIBrowserDOMWindow.
class GeckoViewNavigation extends GeckoViewModule {
export class GeckoViewNavigation extends GeckoViewModule {
onInitBrowser() {
this.window.browserDOMWindow = this;

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

@ -2,15 +2,9 @@
* 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/. */
"use strict";
import { GeckoViewModule } from "resource://gre/modules/GeckoViewModule.sys.mjs";
var EXPORTED_SYMBOLS = ["GeckoViewProcessHangMonitor"];
const { GeckoViewModule } = ChromeUtils.importESModule(
"resource://gre/modules/GeckoViewModule.sys.mjs"
);
class GeckoViewProcessHangMonitor extends GeckoViewModule {
export class GeckoViewProcessHangMonitor extends GeckoViewModule {
constructor(aModuleInfo) {
super(aModuleInfo);

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

@ -2,16 +2,8 @@
* 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/. */
"use strict";
var EXPORTED_SYMBOLS = ["GeckoViewProgress"];
const { GeckoViewModule } = ChromeUtils.importESModule(
"resource://gre/modules/GeckoViewModule.sys.mjs"
);
const { XPCOMUtils } = ChromeUtils.importESModule(
"resource://gre/modules/XPCOMUtils.sys.mjs"
);
import { GeckoViewModule } from "resource://gre/modules/GeckoViewModule.sys.mjs";
import { XPCOMUtils } from "resource://gre/modules/XPCOMUtils.sys.mjs";
const lazy = {};
@ -506,7 +498,7 @@ class SecurityTracker extends Tracker {
}
}
class GeckoViewProgress extends GeckoViewModule {
export class GeckoViewProgress extends GeckoViewModule {
onEnable() {
debug`onEnable`;

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

@ -2,15 +2,9 @@
* 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/. */
"use strict";
import { GeckoViewModule } from "resource://gre/modules/GeckoViewModule.sys.mjs";
var EXPORTED_SYMBOLS = ["GeckoViewSelectionAction"];
const { GeckoViewModule } = ChromeUtils.importESModule(
"resource://gre/modules/GeckoViewModule.sys.mjs"
);
class GeckoViewSelectionAction extends GeckoViewModule {
export class GeckoViewSelectionAction extends GeckoViewModule {
onEnable() {
debug`onEnable`;
this.registerListener(["GeckoView:ExecuteSelectionAction"]);

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

@ -2,17 +2,8 @@
* 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/. */
"use strict";
var EXPORTED_SYMBOLS = ["GeckoViewSettings"];
const { GeckoViewModule } = ChromeUtils.importESModule(
"resource://gre/modules/GeckoViewModule.sys.mjs"
);
const { XPCOMUtils } = ChromeUtils.importESModule(
"resource://gre/modules/XPCOMUtils.sys.mjs"
);
import { GeckoViewModule } from "resource://gre/modules/GeckoViewModule.sys.mjs";
import { XPCOMUtils } from "resource://gre/modules/XPCOMUtils.sys.mjs";
const lazy = {};
@ -45,11 +36,12 @@ const DISPLAY_MODE_STANDALONE = 2;
const DISPLAY_MODE_FULLSCREEN = 3;
// This needs to match GeckoSessionSettings.java
// eslint-disable-next-line no-unused-vars
const VIEWPORT_MODE_MOBILE = 0;
const VIEWPORT_MODE_DESKTOP = 1;
// Handles GeckoSession settings.
class GeckoViewSettings extends GeckoViewModule {
export class GeckoViewSettings extends GeckoViewModule {
onInit() {
debug`onInit`;
this._userAgentMode = USER_AGENT_MODE_MOBILE;

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

@ -2,16 +2,9 @@
* 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/. */
"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(
"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.
const TAB_ID_BASE = 10000;
const GeckoViewTabBridge = {
export const GeckoViewTabBridge = {
/**
* 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() {
const { window } = this;
if (!window.tab) {

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

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

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

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

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

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