Bug 1821163 - Convert browser/actors/Plugin* JSMs to ESMs r=kpatenio

Differential Revision: https://phabricator.services.mozilla.com/D172895
This commit is contained in:
Abhishek Tiwari 2023-03-20 23:01:20 +00:00
parent 2c69c06d89
commit 99be4fc359
6 changed files with 20 additions and 34 deletions

View File

@ -2,12 +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 = ["PluginChild"];
// Handle GMP crashes
class PluginChild extends JSWindowActorChild {
export class PluginChild extends JSWindowActorChild {
handleEvent(event) {
// Ignore events for other frames.
let eventDoc = event.target.ownerDocument || event.target.document;

View File

@ -3,16 +3,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 = ["PluginParent", "PluginManager"];
const { AppConstants } = ChromeUtils.importESModule(
"resource://gre/modules/AppConstants.sys.mjs"
);
const { XPCOMUtils } = ChromeUtils.importESModule(
"resource://gre/modules/XPCOMUtils.sys.mjs"
);
import { AppConstants } from "resource://gre/modules/AppConstants.sys.mjs";
import { XPCOMUtils } from "resource://gre/modules/XPCOMUtils.sys.mjs";
const lazy = {};
@ -25,7 +17,7 @@ XPCOMUtils.defineLazyGetter(lazy, "gNavigatorBundle", function() {
return Services.strings.createBundle(url);
});
const PluginManager = {
export const PluginManager = {
gmpCrashes: new Map(),
observe(subject, topic, data) {
@ -108,7 +100,7 @@ const PluginManager = {
},
};
class PluginParent extends JSWindowActorParent {
export class PluginParent extends JSWindowActorParent {
receiveMessage(msg) {
let browser = this.manager.rootFrameLoader.ownerElement;
switch (msg.name) {

View File

@ -22,7 +22,7 @@ with Files("PageInfoChild.sys.mjs"):
with Files("PageStyleChild.sys.mjs"):
BUG_COMPONENT = ("Firefox", "Menus")
with Files("PluginChild.jsm"):
with Files("PluginChild.sys.mjs"):
BUG_COMPONENT = ("Core", "Audio/Video: GMP")
with Files("ScreenshotsComponentChild.sys.mjs"):
@ -70,8 +70,8 @@ FINAL_TARGET_FILES.actors += [
"PageInfoChild.sys.mjs",
"PageStyleChild.sys.mjs",
"PageStyleParent.sys.mjs",
"PluginChild.jsm",
"PluginParent.jsm",
"PluginChild.sys.mjs",
"PluginParent.sys.mjs",
"PointerLockChild.sys.mjs",
"PointerLockParent.sys.mjs",
"PromptParent.sys.mjs",

View File

@ -1,7 +1,7 @@
"use strict";
let { PluginManager } = ChromeUtils.import(
"resource:///actors/PluginParent.jsm"
let { PluginManager } = ChromeUtils.importESModule(
"resource:///actors/PluginParent.sys.mjs"
);
/**

View File

@ -7,6 +7,8 @@ import { XPCOMUtils } from "resource://gre/modules/XPCOMUtils.sys.mjs";
const lazy = {};
// Ignore unused lazy property for PluginManager.
// eslint-disable-next-line mozilla/valid-lazy
ChromeUtils.defineESModuleGetters(lazy, {
ActorManagerParent: "resource://gre/modules/ActorManagerParent.sys.mjs",
AppMenuNotifications: "resource://gre/modules/AppMenuNotifications.sys.mjs",
@ -42,6 +44,7 @@ ChromeUtils.defineESModuleGetters(lazy, {
PlacesDBUtils: "resource://gre/modules/PlacesDBUtils.sys.mjs",
PlacesUIUtils: "resource:///modules/PlacesUIUtils.sys.mjs",
PlacesUtils: "resource://gre/modules/PlacesUtils.sys.mjs",
PluginManager: "resource:///actors/PluginParent.sys.mjs",
PrivateBrowsingUtils: "resource://gre/modules/PrivateBrowsingUtils.sys.mjs",
ProvenanceData: "resource:///modules/ProvenanceData.sys.mjs",
PublicSuffixList:
@ -118,11 +121,6 @@ if (AppConstants.MOZ_UPDATE_AGENT) {
}
// PluginManager is used in the listeners object below.
// eslint-disable-next-line mozilla/valid-lazy
XPCOMUtils.defineLazyModuleGetters(lazy, {
PluginManager: "resource:///actors/PluginParent.jsm",
});
XPCOMUtils.defineLazyServiceGetters(lazy, {
BrowserHandler: ["@mozilla.org/browser/clh;1", "nsIBrowserHandler"],
PushService: ["@mozilla.org/push/Service;1", "nsIPushService"],
@ -658,10 +656,10 @@ let JSWINDOWACTORS = {
// GMP crash reporting
Plugin: {
parent: {
moduleURI: "resource:///actors/PluginParent.jsm",
esModuleURI: "resource:///actors/PluginParent.sys.mjs",
},
child: {
moduleURI: "resource:///actors/PluginChild.jsm",
esModuleURI: "resource:///actors/PluginChild.sys.mjs",
events: {
PluginCrashed: { capture: true },
},

View File

@ -393,10 +393,10 @@ Here's an example ``JSWindowActor`` registration pulled from ``BrowserGlue.sys.m
Plugin: {
kind: "JSWindowActor",
parent: {
moduleURI: "resource:///actors/PluginParent.jsm",
esModuleURI: "resource:///actors/PluginParent.sys.mjs",
},
child: {
moduleURI: "resource:///actors/PluginChild.jsm",
esModuleURI: "resource:///actors/PluginChild.sys.mjs",
events: {
PluginCrashed: { capture: true },
},
@ -414,10 +414,10 @@ Let's examine parent registration:
.. code-block:: javascript
parent: {
moduleURI: "resource:///actors/PluginParent.jsm",
esModuleURI: "resource:///actors/PluginParent.sys.mjs",
},
Here, we're declaring that class ``PluginParent`` (here, a subclass of ``JSWindowActorParent``) is defined and exported from module ``PluginParent.jsm``. That's all we have to say for the parent (main process) side of things.
Here, we're declaring that class ``PluginParent`` (here, a subclass of ``JSWindowActorParent``) is defined and exported from module ``PluginParent.sys.mjs``. That's all we have to say for the parent (main process) side of things.
.. note::
It's not sufficient to just add a new .jsm file to the actors subdirectories. You also need to update the ``moz.build`` files in the same directory to get the ``resource://`` linkages set up correctly.
@ -427,7 +427,7 @@ Let's look at the second chunk:
.. code-block:: javascript
child: {
moduleURI: "resource:///actors/PluginChild.jsm",
esModuleURI: "resource:///actors/PluginChild.sys.mjs",
events: {
PluginCrashed: { capture: true },
},