Asynchronous Experiment/WebExtension communication incompatible with XPCOM overrides?

Jeremy Rand jeremyrand at airmail.cc
Thu Aug 3 19:28:55 UTC 2017


Andrew Swan:
> On Mon, Jul 31, 2017 at 2:30 AM, Jeremy Rand <jeremyrand at airmail.cc> 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?

I attempted both, and got the same issue in both cases.

> 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.

This certainly explains the behavior I was seeing.

>> 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.

Makes sense.

>> 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.

You understood and answered my question perfectly (despite my clumsy
wording), no worries.  It sounds like the approach I was going for is
not feasible, so I guess I'll be looking into alternative approaches
that modify the C/C++ source code instead of solely using a
WebExtensions Experiment.  Thanks for the answer.  :)

Cheers,
-- 
-Jeremy Rand
Lead Application Engineer at Namecoin
Mobile email: jeremyrandmobile at airmail.cc
Mobile OpenPGP: 2158 0643 C13B B40F B0FD 5854 B007 A32D AB44 3D9C
Send non-security-critical things to my Mobile with OpenPGP.
Please don't send me unencrypted messages.
My business email jeremy at veclabs.net is having technical issues at the
moment.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: OpenPGP digital signature
URL: <http://mail.mozilla.org/pipermail/dev-addons/attachments/20170803/90b09400/attachment.sig>


More information about the Dev-addons mailing list