<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Jul 31, 2017 at 2:30 AM, Jeremy Rand <span dir="ltr"><<a href="mailto:jeremyrand@airmail.cc" target="_blank">jeremyrand@airmail.cc</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">I'm trying to build a WebExtensions Experiment that overrides an XPCOM<br>
contract with a custom implementation.  The custom implementation of the<br>
XPCOM contract is intended to call a function in a WebExtension, and use<br>
the return value to decide what the XPCOM contract function<br>
implementation should return.<br>
<br>
Unfortunately, based on my testing, it looks like whenever an Experiment<br>
calls a function in a WebExtension, the thing that gets returned is<br>
actually a Promise rather than the raw value.  Furthermore, it looks<br>
like the XPCOM contract that I'm overriding isn't designed to process a<br>
Promise properly as a return value, so the WebExtension can't actually<br>
influence what the XPCOM contract function returns.<br>
<br>
Is this the expected behavior?  Is there a way to synchronously call a<br>
WebExtension function from an Experiment?  </blockquote><div><br></div><div>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?</div><div>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.</div><div> </div><div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Is there a way to override an<br>
XPCOM contract in a way that is compatible with asynchronous functions?<br></blockquote><div><br></div><div>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.<br></div></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
Apologies if this is a stupid question, I've been unsuccessful at<br>
finding any documentation on this.<br></blockquote><div><br></div>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.</div><div class="gmail_quote"><br></div><div class="gmail_quote">-Andrew</div><div class="gmail_quote"><br></div></div></div>