Bug 193530 - [webkit2gtk][JavaScriptCore glib] typeof "API created function" == "string"
Summary: [webkit2gtk][JavaScriptCore glib] typeof "API created function" == "string"
Status: RESOLVED INVALID
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: WebKit Local Build
Hardware: PC Linux
: P2 Normal
Assignee: Nobody
URL:
Keywords: Gtk
Depends on:
Blocks:
 
Reported: 2019-01-17 00:05 PST by li
Modified: 2019-01-17 12:33 PST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description li 2019-01-17 00:05:17 PST
I'm trying to use the JavaScriptCore glib API to define some native functions for use in user scripts, they work great so far, but somehow the js user script typeof doesn't recognize them as "function".
For example:

/* web-extension.c */
static void
zzz(void)
{	
	printf("zzz\n");
}

static void
windowobjectcleared(WebKitScriptWorld *w, WebKitWebPage *wp, WebKitFrame *frame,
                    gpointer unused)
{
	JSCContext *ctx;

	ctx = webkit_frame_get_js_context_for_script_world(frame, w);
	jsc_context_set_value(ctx, "zzz", jsc_value_new_function(
	  ctx, "zzz", (GCallback)zzz, NULL, NULL, G_TYPE_NONE, 0));
}

/* user-script.js */
console.log(typeof 'zzz');      /* logs string instead of function */
console.log(zzz);               /* function zzz() { [native code] } */
Comment 1 li 2019-01-17 04:36:50 PST
my bad, it's not a bug. I shouldn't have put quotes around the function name.