Allow omitting `moduleURI` for JSWindowActor declarations
Categories
(Core :: DOM: Content Processes, enhancement, P2)
Tracking
()
Tracking | Status | |
---|---|---|
firefox69 | --- | fixed |
People
(Reporter: nika, Assigned: jdai)
References
Details
Attachments
(1 file)
Sometimes, a custom JS implementation of the JSWindowActor object is unnecessary. For example, it is occasionally desirable to treat one end of the actor as a simple interface with sendAsyncMessage
and sendQuery
methods, without caring what the other side has to send back.
In these cases, it is currently necessary to create an entire JSM
file with an empty subclass of the JSWindowActor
object, such as: https://searchfox.org/mozilla-central/rev/94c6b5f06d2464f6780a52f32e917d25ddc30d6b/browser/actors/SubframeCrashParent.jsm#9-10
We should allow the implementor to omit the moduleURI
field from the parent
and child
sides of the actor declaration, and default to generating an empty JSWindowActor
object in these cases.
This would take the look of something like this:
- In
WindowGlobalActor::ConstructActor
, an additional check would need to be made here thatmModuleURI
was passed: https://searchfox.org/mozilla-central/rev/94c6b5f06d2464f6780a52f32e917d25ddc30d6b/dom/ipc/WindowGlobalActor.cpp#60 - If the module URI was not passed, based on the side provided, a basic empty actor must be created & returned. This probably will look something vaguely like this:
if (!side->mModuleURI.WasPassed()) {
RefPtr<JSWindowActor> actor;
if (actorType == JSWindowActor::Type::Parent) {
actor = new JSWindowActorParent();
} else {
actor = new JSWindowActorChild();
}
JS::Rooted<JS::Value> wrapper(cx);
if (!ToJSValue(cx, actor, &wrapper)) {
aRv.NoteJSContextException(cx);
return;
}
MOZ_ASSERT(wrapper.isObject());
aActor.set(wrapper.toObject());
return;
}
Assignee | ||
Updated•5 years ago
|
Assignee | ||
Comment 1•5 years ago
|
||
Comment 3•5 years ago
|
||
bugherder |
Description
•