[wpe-webkit] Web Extension Support In WPE
Michael Catanzaro
mcatanzaro at igalia.com
Wed Jun 19 13:33:47 PDT 2019
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.
Hope that helps,
Michael
More information about the webkit-wpe
mailing list