[wpe-webkit] Web Extension Support In WPE

Munez Bn munezbn.dev at gmail.com
Thu Jun 20 10:59:53 PDT 2019


Thanks Michael & Carlos for all your suggestions. It was very helpful. I am
able to return native objects and have better understanding of JSC APi now
:)
I will update my stack-overflow post.

Please note that when I tried initially, my sample extension was stored in
*Tools/MiniBrowser/gtk/TestExtension/CMakeLists.tx*t and in Extension's
*CMakeLists.tx*t I had exported all the internal include paths. Also Some
function I declaration locally in extension file. I will do all the cleanup
and do it in a clean way now.

Cheers..
Munez

On Thu, Jun 20, 2019 at 12:55 PM Carlos Garcia Campos <cgarcia at igalia.com>
wrote:

> El mié, 19-06-2019 a las 15:33 -0500, Michael Catanzaro escribió:
> > Hi Munez,
> >
> > On Wed, Jun 19, 2019 at 2:10 PM, Munez Bn <munezbn.dev at gmail.com>
> > wrote:
> > > I didn't do any changes in webkit or makefiles to install internal
> > > headers.
> >
> > I'm really confused then. You are using multiple internal APIs that
> > are
> > not defined in any public headers, so you must have somehow made
> > some
> > major changes to WebKit to gain access to these APIs.
> >
> > On Wed, Jun 19, 2019 at 2:10 PM, Munez Bn <munezbn.dev at gmail.com>
> > wrote:
> > > 1. The API description of jsc_value_new_function() says that, If
> > > we
> > > really want to return a new copy of the boxed type in the callback
> > > function passed as argument to jsc_value_new_function(), then use
> > > #JSC_TYPE_VALUE and return a #JSCValue created with
> > > jsc_value_new_object() that receives the copy as instance
> > > parameter.
> > > But jsc_value_new_object() also needs a context so when I tried to
> > > passed jsc_context as user data to callback function, the callback
> > > function threw following error.
> > >
> > > JSCValue* jsc_value_new_undefined(JSCContext*): assertion
> > > 'JSC_IS_CONTEXT(context)' failed
> > >
> > > Please let me know if i am missing anything. I was planing to
> > > register class in callback function getTestExtObjec().
> >
> > OK, this at least looks straightforward. You correctly noticed that
> > the
> > JSCContext returned by
> > webkit_frame_get_js_context_for_script_world()
> > is returned transfer full, so your code is responsible for taking
> > ownership. You used g_autoptr to hold that ownership, which is good.
> > But you're failing to transfer the ownership from your
> > windowObjectCleared function to the getTestExtObject callback. The
> > fix
> > would be to use g_steal_pointer():
> >
> > g_autoptr(JSCValue) function = jsc_value_new_function(jsContext,
> > "getTestExtObject", G_CALLBACK(getTestExtObject),
> > g_steal_pointer(&jsContext), NULL, JSC_TYPE_VALUE, 1, G_TYPE_STRING);
> >
> > Otherwise, it's deleted before your getTestExtObject() is called.
> > Using
> > g_steal_pointer() makes the ownership clear. You could also just not
> > use g_autoptr at all, but then the ownership will not be obvious in
> > the
> > code. Either way, once that is fixed you will need to unref it in
> > getTestExtObject() to avoid leaking it.
>
> Right, you are passing the context as callback data, but it's freed at
> the time the callback is called. I don't think it's a good idea to pass
> the context, though. You can simply use jsc_context_get_current(). That
> always work inside function callbacks. The JSCContext won't be the same
> as the one you got in window_object_cleared, but the wrapped
> JSGlobalObjectRef is.
>
> You have an example of that in the unit tests too, in the function to
> get the parent of a GFile (we need to create a new wrapped GFile in the
> callback, see:
>
>
> https://trac.webkit.org/browser/webkit/trunk/Tools/TestWebKitAPI/Tests/JavaScriptCore/glib/TestJSC.cpp#L1640
>
> > Hope that helps,
> >
> > Michael
> >
> >
> >
> --
> Carlos Garcia Campos
> http://pgp.rediris.es:11371/pks/lookup?op=get&search=0xF3D322D0EC4582C3
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-wpe/attachments/20190620/b8c1bb0f/attachment-0001.html>


More information about the webkit-wpe mailing list