Source code

Revision control

Other Tools

/* vim: set ts=2 sw=2 sts=2 et tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* 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";
/**
* This module handles JavaScript-implemented JSWindowActors, registered through DOM IPC
* infrastructure, and are fission-compatible.
*/
var EXPORTED_SYMBOLS = ["ActorManagerParent"];
const { XPCOMUtils } = ChromeUtils.import(
);
/**
* Fission-compatible JSProcess implementations.
* Each actor options object takes the form of a ProcessActorOptions dictionary.
* Detailed documentation of these options is in dom/docs/ipc/jsactors.rst,
*/
let JSPROCESSACTORS = {
AsyncPrefs: {
parent: {
},
child: {
},
},
ContentPrefs: {
},
},
},
ExtensionContent: {
},
includeParent: true,
},
};
/**
* Fission-compatible JSWindowActor implementations.
* Each actor options object takes the form of a WindowActorOptions dictionary.
* Detailed documentation of these options is in dom/docs/ipc/jsactors.rst,
*/
let JSWINDOWACTORS = {
AboutCertViewer: {
},
child: {
events: {
DOMWindowCreated: { capture: true },
},
},
matches: ["about:certificate"],
},
AboutHttpsOnlyError: {
},
child: {
events: {
DOMWindowCreated: {},
},
},
matches: ["about:httpsonlyerror?*"],
allFrames: true,
},
AudioPlayback: {
},
child: {
observers: ["audio-playback"],
},
allFrames: true,
},
AutoComplete: {
parent: {
// These two messages are also used, but are currently synchronous calls
// through the per-process message manager.
// "FormAutoComplete:GetSelectedIndex",
// "FormAutoComplete:SelectBy"
},
},
allFrames: true,
},
Autoplay: {
},
child: {
events: {
GloballyAutoplayBlocked: {},
},
},
allFrames: true,
},
AutoScroll: {
},
child: {
events: {
mousedown: { capture: true, mozSystemGroup: true },
},
},
allFrames: true,
},
BackgroundThumbnails: {
child: {
events: {
DOMDocElementInserted: { capture: true },
},
},
messageManagerGroups: ["thumbnails"],
},
BrowserElement: {
},
child: {
events: {
DOMWindowClose: {},
},
},
allFrames: true,
},
Conduits: {
},
},
allFrames: true,
},
Controllers: {
},
},
allFrames: true,
},
DateTimePicker: {
},
child: {
events: {
MozOpenDateTimePicker: {},
MozUpdateDateTimePicker: {},
MozCloseDateTimePicker: {},
},
},
allFrames: true,
},
ExtFind: {
},
allFrames: true,
},
FindBar: {
parent: {
},
child: {
events: {
keypress: { mozSystemGroup: true },
},
},
allFrames: true,
messageManagerGroups: ["browsers", "test"],
},
// This is the actor that responds to requests from the find toolbar and
// searches for matches and highlights them.
Finder: {
child: {
},
allFrames: true,
},
FormHistory: {
},
child: {
events: {
DOMFormBeforeSubmit: {},
},
},
allFrames: true,
},
InlineSpellChecker: {
},
},
allFrames: true,
},
KeyPressEventModelChecker: {
child: {
events: {
CheckKeyPressEventModel: { capture: true, mozSystemGroup: true },
},
},
allFrames: true,
},
LoginManager: {
},
child: {
events: {
DOMDocFetchSuccess: {},
DOMFormBeforeSubmit: {},
DOMFormHasPassword: {},
DOMFormHasPossibleUsername: {},
DOMInputPasswordAdded: {},
},
},
allFrames: true,
messageManagerGroups: ["browsers", "webext-browsers", ""],
},
ManifestMessages: {
},
},
PictureInPictureLauncher: {
},
child: {
events: {
MozTogglePictureInPicture: { capture: true },
},
},
allFrames: true,
},
PictureInPicture: {
},
},
allFrames: true,
},
PictureInPictureToggle: {
},
child: {
events: {
UAWidgetSetupOrChange: {},
contextmenu: { capture: true },
},
},
allFrames: true,
},
PopupBlocking: {
},
child: {
events: {
DOMPopupBlocked: { capture: true },
// Only listen for the `pageshow` event after the actor has already been
// created for some other reason.
pageshow: { createActor: false },
},
},
allFrames: true,
},
Printing: {
},
child: {
events: {
PrintingError: { capture: true },
printPreviewUpdate: { capture: true },
},
},
},
PrintingSelection: {
},
allFrames: true,
},
PurgeSessionHistory: {
},
allFrames: true,
},
Select: {
parent: {
},
child: {
events: {
mozshowdropdown: {},
"mozshowdropdown-sourcetouch": {},
mozhidedropdown: { mozSystemGroup: true },
},
},
allFrames: true,
},
// This actor is available for all pages that one can
// view the source of, however it won't be created until a
// request to view the source is made via the message
// 'ViewSource:LoadSource' or 'ViewSource:LoadSourceWithSelection'.
ViewSource: {
},
allFrames: true,
},
// This actor is for the view-source page itself.
ViewSourcePage: {
},
child: {
events: {
pageshow: { capture: true },
click: {},
},
},
matches: ["view-source:*"],
allFrames: true,
},
WebChannel: {
},
child: {
events: {
WebChannelMessageToChrome: { capture: true, wantUntrusted: true },
},
},
allFrames: true,
},
Thumbnails: {
},
},
UAWidgets: {
child: {
events: {
UAWidgetSetupOrChange: {},
UAWidgetTeardown: {},
},
},
allFrames: true,
},
UnselectedTabHover: {
},
child: {
events: {
"UnselectedTabHover:Enable": {},
"UnselectedTabHover:Disable": {},
},
},
allFrames: true,
},
};
var ActorManagerParent = {
_addActors(actors, kind) {
let register, unregister;
switch (kind) {
case "JSProcessActor":
register = ChromeUtils.registerProcessActor;
unregister = ChromeUtils.unregisterProcessActor;
break;
case "JSWindowActor":
register = ChromeUtils.registerWindowActor;
unregister = ChromeUtils.unregisterWindowActor;
break;
default:
throw new Error("Invalid JSActor kind " + kind);
}
for (let [actorName, actor] of Object.entries(actors)) {
// If enablePreference is set, only register the actor while the
// preference is set to true.
if (actor.enablePreference) {
let actorNameProp = actorName + "_Preference";
XPCOMUtils.defineLazyPreferenceGetter(
this,
actorNameProp,
actor.enablePreference,
false,
(prefName, prevValue, isEnabled) => {
if (isEnabled) {
register(actorName, actor);
} else {
unregister(actorName, actor);
}
if (actor.onPreferenceChanged) {
actor.onPreferenceChanged(prefName, prevValue, isEnabled);
}
}
);
if (!this[actorNameProp]) {
continue;
}
}
register(actorName, actor);
}
},
addJSProcessActors(actors) {
this._addActors(actors, "JSProcessActor");
},
addJSWindowActors(actors) {
this._addActors(actors, "JSWindowActor");
},
};
ActorManagerParent.addJSProcessActors(JSPROCESSACTORS);
ActorManagerParent.addJSWindowActors(JSWINDOWACTORS);