Asynchronous Experiment/WebExtension communication incompatible with XPCOM overrides?

Andrew Swan aswan at
Tue Aug 1 03:39:00 UTC 2017

On Mon, Jul 31, 2017 at 2:30 AM, Jeremy Rand <jeremyrand at> wrote:

> I'm trying to build a WebExtensions Experiment that overrides an XPCOM
> contract with a custom implementation.  The custom implementation of the
> XPCOM contract is intended to call a function in a WebExtension, and use
> the return value to decide what the XPCOM contract function
> implementation should return.
> Unfortunately, based on my testing, it looks like whenever an Experiment
> calls a function in a WebExtension, the thing that gets returned is
> actually a Promise rather than the raw value.  Furthermore, it looks
> like the XPCOM contract that I'm overriding isn't designed to process a
> Promise properly as a return value, so the WebExtension can't actually
> influence what the XPCOM contract function returns.
> Is this the expected behavior?  Is there a way to synchronously call a
> WebExtension function from an Experiment?

I'm not sure what you mean by "call a WebExtension function from an
Experiment".  Are you implementing an event or something else where the
extension passes a callback into the api implementation?
Regardless, in the current implementation of experiments, all experiment
code runs in the parent process, while extensions run in content processes,
so communication between the two must be asynchronous.

> Is there a way to override an
> XPCOM contract in a way that is compatible with asynchronous functions?

Again I'm not sure what you're asking.  If an existing XPCOM contract has a
synchronous interface, there's no way to make it asynchronous without
revising the interface.

> Apologies if this is a stupid question, I've been unsuccessful at
> finding any documentation on this.

Its not a stupid question, our documentation is still pretty sparse.  I
think I may not have fully understood your questions so please feel free to
send follow-ups to this list.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the Dev-addons mailing list