[wpe-webkit] Synchronous JS interactions with native code

Ryan Walklin ryan at testtoast.com
Mon Jun 24 23:45:25 PDT 2019

Hi Munez,

Thanks but I mean the WebExtension API for cross-platform HTML/CSS/JS browser extensions as supported by Firefox and Chrome, not WebKit Web Extensions in C.



On Tue, 25 Jun 2019, at 3:54 PM, Munez Bn wrote:
> Hi Ryan,
> I am not sure if it is really helpful , but i was looking something similar [1] and then after getting all help from folks here, I wrote a sample web-extension using JSC Glib API which you can find at [2] .
> If you want to learn more about web extension then refer [3] and for understanding JSC Glib API refer [4]
> [1] https://lists.webkit.org/pipermail/webkit-wpe/2019-June/000175.html
> [2] https://github.com/munezbn/sample_webkit_extension
> [3] https://trac.webkit.org/browser/webkit/trunk/Tools/TestWebKitAPI/Tests/JavaScriptCore/glib/TestJSC.cpp#L2369
> [4] https://webkitgtk.org/reference/jsc-glib/stable/index.html
> Thanks & Regards
> Munez
> On Tue, Jun 25, 2019 at 5:51 AM Ryan Walklin <ryan at testtoast.com> wrote:
>> Hi All,
>>  I'm currently experimenting with implementing a basic subset of the WebExtension API (https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions) with WPE, and struggling with some basics. This may be due to my poor knowledge of JS, or sheer impossibility, but I'd love some help.
>>  I know that Midori has a stub implementation using WebKitGTK (https://github.com/midori-browser/core/pull/250) and they use a combination of webkit_user_content_manager_register_script_message_handler to register a script handler, then in JS call window.webkit.messageHandlers.midori.postMessage to get back to UI code, then in their UI code use webkit_web_view_run_javascript to call "Promise.resolve()" to execute the callback. 
>>  So far they have implemented functions that themselves return promises, however I need to implement APIs to directly return function results and variables, e.g. browser.runtime.getManifest() that returns the WebExtension's manifest.json file. I've tried to modify Midori's JS function to use async/await to return the value once the promise resolves, but have had no success so far. 
>>  Has anyone else tried anything like this? Or is there any way to have synchronous communication between the JS context and my app?
>>  Regards,
>>  Ryan
>>  _______________________________________________
>>  Do not post admin requests to the list. They will be ignored.
>>  webkit-wpe mailing list (webkit-wpe at lists.webkit.org)
>>  Help/Unsubscribe/Update your Subscription:
>> https://lists.webkit.org/mailman//listinfo/webkit-wpe
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-wpe/attachments/20190625/de349e22/attachment.html>

More information about the webkit-wpe mailing list