[Webkit-unassigned] [Bug 75543] [GTK] Add webkit_web_view_run_javascript() to WebKit2 GTK+
bugzilla-daemon at webkit.org
bugzilla-daemon at webkit.org
Fri Feb 17 12:07:32 PST 2012
https://bugs.webkit.org/show_bug.cgi?id=75543
Martin Robinson <mrobinson at webkit.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Attachment #126740|review? |review-
Flag| |
--- Comment #5 from Martin Robinson <mrobinson at webkit.org> 2012-02-17 12:07:32 PST ---
(From update of attachment 126740)
View in context: https://bugs.webkit.org/attachment.cgi?id=126740&action=review
Looks pretty good, but it's an error to access JavaScript values with a different global context.
> Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp:1399
> + JSGlobalContextRef scriptContext = JSGlobalContextCreate(0);
> + JSValueRef scriptValue = WKSerializedScriptValueDeserialize(wkSerializedScriptValue, scriptContext, 0);
> + g_simple_async_result_set_op_res_gpointer(result.get(), const_cast<OpaqueJSValue*>(scriptValue), 0);
> + g_simple_async_result_complete(result.get());
> + JSGlobalContextRelease(scriptContext);
Instead of creating a temporary JSGlobalContext, it would probably be better to create one with the WebView, so that JavaScriptCore values can stay alive longer.
> Source/WebKit2/UIProcess/API/gtk/tests/ScriptContext.cpp:45
> + JSRetainPtr<JSStringRef> stringValue(Adopt, JSValueToStringCopy(m_context, value, 0));
> + g_assert(stringValue);
> +
> + size_t cStringLength = JSStringGetMaximumUTF8CStringSize(stringValue.get());
> + char* cString = static_cast<char*>(g_malloc(cStringLength));
> + JSStringGetUTF8CString(stringValue.get(), cString, cStringLength);
It's important to access the value with the same JSC context that created the value. Thus it should probably be passed as property of the AsyncResult or kept as a property of the WebKitWebView.
--
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
More information about the webkit-unassigned
mailing list