Skip to content

Commit 1f5959e

Browse files
committed
Bug 1650837 - Part 2: Add an includeParent JSProcessActor config option, r=kmag
This is similar to JSWindowActor's includeChrome option, and defaults to 'false'. If users want to also instantiate the actor in-process, they can set this option to 'true'. Differential Revision: https://phabricator.services.mozilla.com/D82449
1 parent 5a67517 commit 1f5959e

File tree

4 files changed

+23
-1
lines changed

4 files changed

+23
-1
lines changed

dom/chrome-webidl/JSProcessActor.webidl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,12 @@ dictionary ProcessActorOptions {
4848
*/
4949
sequence<UTF8String> remoteTypes;
5050

51+
/**
52+
* If this is set to `true`, allow this actor to be created for the parent
53+
* process.
54+
*/
55+
boolean includeParent = false;
56+
5157
/** This fields are used for configuring individual sides of the actor. */
5258
ProcessActorSidedOptions parent;
5359
ProcessActorChildOptions child;

dom/ipc/jsactor/JSProcessActorProtocol.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ JSProcessActorProtocol::FromIPC(const JSProcessActorInfo& aInfo) {
2626
RefPtr<JSProcessActorProtocol> proto =
2727
new JSProcessActorProtocol(aInfo.name());
2828

29+
// Content processes aren't the parent process, so this flag is irrelevant and
30+
// not propagated.
31+
proto->mIncludeParent = false;
2932
proto->mRemoteTypes = aInfo.remoteTypes().Clone();
3033
proto->mChild.mModuleURI = aInfo.url();
3134
proto->mChild.mObservers = aInfo.observers().Clone();
@@ -51,6 +54,7 @@ JSProcessActorProtocol::FromWebIDLOptions(const nsACString& aName,
5154
MOZ_DIAGNOSTIC_ASSERT(XRE_IsParentProcess());
5255

5356
RefPtr<JSProcessActorProtocol> proto = new JSProcessActorProtocol(aName);
57+
proto->mIncludeParent = aOptions.mIncludeParent;
5458

5559
if (aOptions.mRemoteTypes.WasPassed()) {
5660
MOZ_ASSERT(aOptions.mRemoteTypes.Value().Length());
@@ -136,6 +140,10 @@ bool JSProcessActorProtocol::RemoteTypePrefixMatches(
136140
}
137141

138142
bool JSProcessActorProtocol::Matches(const nsACString& aRemoteType) {
143+
if (!mIncludeParent && aRemoteType.IsEmpty()) {
144+
return false;
145+
}
146+
139147
if (!mRemoteTypes.IsEmpty() &&
140148
!RemoteTypePrefixMatches(RemoteTypePrefix(aRemoteType))) {
141149
return false;

dom/ipc/jsactor/JSProcessActorProtocol.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ class JSProcessActorProtocol final : public JSActorProtocol,
6363

6464
nsCString mName;
6565
nsTArray<nsCString> mRemoteTypes;
66+
bool mIncludeParent = false;
6667

6768
ParentSide mParent;
6869
ChildSide mChild;

dom/ipc/tests/JSProcessActor/head.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,20 @@ function promiseNotification(aNotification) {
3333
}
3434

3535
function declTest(name, cfg) {
36-
let { url = "about:blank", remoteTypes, fission, test } = cfg;
36+
let {
37+
url = "about:blank",
38+
includeParent = false,
39+
remoteTypes,
40+
fission,
41+
test,
42+
} = cfg;
3743

3844
// Build the actor options object which will be used to register & unregister our window actor.
3945
let actorOptions = {
4046
parent: Object.assign({}, processActorOptions.parent),
4147
child: Object.assign({}, processActorOptions.child),
4248
};
49+
actorOptions.includeParent = includeParent;
4350
if (remoteTypes !== undefined) {
4451
actorOptions.remoteTypes = remoteTypes;
4552
}

0 commit comments

Comments
 (0)