Open Bug 1768471 Opened 3 years ago

Consider changing BrowserExtensionContent emit method to return as the superclass emit method does

Categories

(WebExtensions :: General, task, P3)

task

Tracking

(Not tracked)

People

(Reporter: rpl, Unassigned)

Details

As part of the work on the patch attached to Bug 1759300 we did notice that there are some small differences between

While both EventEmitter and Extension's emitmethods are returning a value (which is either a Promise that resolves to the array of all the results collected by the listeners subscribed for the emitted event, or undefined when all listeners did throw an error or returned undefined), BrowserExtensionContent class emit method does never return a value.

Not returning a value only from the BrowserExtensionContent emit method while returning it from the other two seems an arbitrary difference and a very likely surprising one, and so it may be reasonable to consider changing BrowserExtensionContent emit method to match the behavior of the other two, but we have to double-check if it may introduce some regressions as a side-effect first.

Another interesting different between BrowerExtensionContent and Extension emit methods definitions:

  • Extension's emit only send to the child process the events explicitly listed in the PROXIED_EVENTS Set
  • whereas BrowserExtensionContent emit method will forward to the part process any event emitted

forwarding all events to the parent process may be increasing the amount of IPC, but before restricting the events forwarded by BrowserExtensionContent class from the child process to the parent process we want to explicitly confirm which events we are actually need to be forwarded to the parent process and which are just happening to be forwarded but wouldn't need to be.

You need to log in before you can comment on or make changes to this bug.