[webkit-gtk] Extending JavascriptCore

Christian Frost cf at cfrost.dk
Fri Feb 22 04:28:10 PST 2013


I have a question on how to extent the JavascriptCore. My example is
similar to the one found at the bottom at the following site:


However, I use WebKit2 which may cause that my WebKitWebView does not
have the "window-object-cleared" signal. Therefore it cannot be
connected. I have tried to "hook" it to the "resource-load-started"
with the following callback function:

static void resource_load_started_cb(WebKitWebView  *web_view,
WebKitWebResource *resource, WebKitURIRequest  *request, gpointer
    JSGlobalContextRef * context

    JSClassRef classDef = JSClassCreate(&class_def);
    JSObjectRef classObj = JSObjectMake(context, classDef, context);
    JSObjectRef globalObj = JSContextGetGlobalObject(context);
    JSStringRef str = JSStringCreateWithUTF8CString("CustomClass");
    JSObjectSetProperty(context, globalObj, str, classObj,
kJSPropertyAttributeNone, NULL);

However, when I use my CustomClass in Javascript, WebKit cannot find the class.

Can someone guide me how to do this? Currently I use the Minibrowser
as a sample program to implement it.


More information about the webkit-gtk mailing list