We no longer distinguish between internal and protocol events within the framework.
All events now have the same behavior:
- emitted both under their own name and under the name message-handler-event
- bubble up to the root message handler
- the session which owns the RootMessageHandler does not listen for those events
The emitProtocolEvent has been moved to the RootMessageHandler only and can be used to emit events under a specific name "message-handler-protocol-event".
Only those events will be sent over to the actual client.
Internally the session module now keeps track of which events have already been subscribed to, to avoid forwarding duplicated events.
In a followup this will be centralized over in the EventsDispatcher, which can now play a bigger role.
Note that in the same way as for commands, there is still an implicit notion of "internal event", as in "an event which can not be subscribed to by consumers".
For commands this is done by having a "_" before the command name.
For events this is done by listing or not the event in the "supportedEvents" static array of the Module.
Differential Revision: https://phabricator.services.mozilla.com/D155025
Depends on D147713
This adds a "retryOnAbort" property on MessageHandler Commands.
When set to true, this will allow the FrameTransport to retry a command up to 10 times in case of an AbortError.
Difference with Marionette, this doesn't attempt to detect BrowsingContexts in bfcache, because retrying commands
does not make sense in bfcache (this is not a temporary state, retrying in a loop will most likely not help).
A browser mochitest is added to cover various retry scenarios.
Differential Revision: https://phabricator.services.mozilla.com/D147715
This replaces all `instanceof` uses for DOM interfaces, since the operator in priviliged context works same as .isInstance().
Differential Revision: https://phabricator.services.mozilla.com/D141785
This replaces all `instanceof` uses for DOM interfaces, since the operator in priviliged context works same as .isInstance().
Differential Revision: https://phabricator.services.mozilla.com/D141785
Depends on D138523
Given our current broadcast logic, we should not stumble on webextension contexts during broadcast.
This is because getAllBrowsingContextsInSubtree will not cross process boundaries.
Nevertheless, adding explicit support for WebExtensions in our filter method should be ok, with the added test.
Whenever we lift the JSWindowActor restrictions and rely on isBrowsingContextCompatible for filtering this will help avoid regressions.
Differential Revision: https://phabricator.services.mozilla.com/D138531
We are not supporting the TOP_BROWSING_CONTEXT yet in BiDi, but message handler already supports it, and assumes browser ids. But as discussed we will need to use custom UUIDs, and on the side have a mapping between browser ids and UUIDs, as browserids might be available late.
Differential Revision: https://phabricator.services.mozilla.com/D135414
There are two kind of events that can be used by module implementations
to pass information within the message handler framework.
First, with internal events the different modules and the message handlers
themselves can send around information eg. informing the parent process
about specific DOM events happening in the child process. These events
are not intended to be sent to external clients.
Second, with protocol events the different modules can send events with
a payload as specified in the appropriate protocol. These events shouldn't
be intercepted, modified, or ignored and will be sent to external clients.
Differential Revision: https://phabricator.services.mozilla.com/D134264
Depends on D131439
Add a new CONTEXT_DESCRIPTOR_TYPES for top level browsing contexts, called TOP_BROWSING_CONTEXT.
The corresponding context descriptor id should be a browserId.
The FrameTransport is updated to support both CONTEXT_DESCRIPTOR_TYPES: ALL and TOP_BROWSING_CONTEXT.
A browser mochitest is added to check that broadcasts are correctly filtered for a top level browsing context.
Differential Revision: https://phabricator.services.mozilla.com/D131440
Instead of using a broadcast boolean flag in the CommandDestination, use a contextDescriptor.
The only context descriptor type supported here is CONTEXT_DESCRIPTOR_TYPES.ALL, and the behavior is unchanged.
Differential Revision: https://phabricator.services.mozilla.com/D131439
Depends on D131439
Add a new CONTEXT_DESCRIPTOR_TYPES for top level browsing contexts, called TOP_BROWSING_CONTEXT.
The corresponding context descriptor id should be a browserId.
The FrameTransport is updated to support both CONTEXT_DESCRIPTOR_TYPES: ALL and TOP_BROWSING_CONTEXT.
A browser mochitest is added to check that broadcasts are correctly filtered for a top level browsing context.
Differential Revision: https://phabricator.services.mozilla.com/D131440
Instead of using a broadcast boolean flag in the CommandDestination, use a contextDescriptor.
The only context descriptor type supported here is CONTEXT_DESCRIPTOR_TYPES.ALL, and the behavior is unchanged.
Differential Revision: https://phabricator.services.mozilla.com/D131439
Depends on D123655
With this patch, the MessageHandler can immediately check if a command is implemented by the modules, and therefore reject as early as possible.
This is implemented via a checkCommand method on MessageHandler.
Other required changes:
- ModuleRegistry now owns the logic to import BiDi modules.
- ModuleCache exposes a `getAllModuleClasses` to get all the relevant modules for a moduleName+destination pair.
Error messages have been improved and are verified with a dedicated test
Differential Revision: https://phabricator.services.mozilla.com/D123655