Closed Bug 1552268 Opened 5 years ago Closed 5 years ago

Allow omitting `moduleURI` for JSWindowActor declarations

Categories

(Core :: DOM: Content Processes, enhancement, P2)

enhancement

Tracking

()

RESOLVED FIXED
mozilla69
Fission Milestone M3
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:

  1. In WindowGlobalActor::ConstructActor, an additional check would need to be made here that mModuleURI was passed: https://searchfox.org/mozilla-central/rev/94c6b5f06d2464f6780a52f32e917d25ddc30d6b/dom/ipc/WindowGlobalActor.cpp#60
  2. 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;
}
Blocks: 1467212
Status: NEW → ASSIGNED
Pushed by jdai@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/9b58a3bb222a
Allow omitting moduleURI for JSWindowActor declarations; r=nika
Status: ASSIGNED → RESOLVED
Closed: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla69
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: