[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 14:27:47 PST 2012


https://bugs.webkit.org/show_bug.cgi?id=75543





--- Comment #6 from Martin Robinson <mrobinson at webkit.org>  2012-02-17 14:27:47 PST ---
(From update of attachment 126740)
View in context: https://bugs.webkit.org/attachment.cgi?id=126740&action=review

It seems that there are three things we want to return for every JavaScript invocation: a JSContextRef, a JSValueRef and a JSValueRef for exceptions. I'm not sure the cleanest way to pass all this to the user with the GIO style API.

I'm am fairly certain though that it doesn't make sense to pass the exception as a GError. I think we should reserve GErrors for when we actually have problems executing the JavaScript. It's important that the client can distinguish between script exceptions and problems internal to WebKit. The exception must be a JSValueRef in the end anyhow.

> Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp:1396
> +    JSValueRef scriptValue = WKSerializedScriptValueDeserialize(wkSerializedScriptValue, scriptContext, 0);

Instead of throwing away the exception it would be better to pass it to the client somehow. It's a pretty important piece of the story.

> Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitWebView.cpp:474
> +    callbackData.expectedResult = "WebKitGTK+ Title";
> +    test->runJavaScriptAndWaitUntilFinished("window.document.getElementById('WebKitLink').title;", testWebViewRunJavaScriptFinishedCallback, &callbackData);

Instead of writing this with the use of a callback function, why not just store the results of the operation in WebKitWebView and read them after you call runJavaScriptAndWaitUntilFinished. This more closely matches how LoadTrackingTest works. I think it's a little more straight-forward too.

> Source/WebKit2/UIProcess/API/gtk/tests/WebViewTest.h:52
> +    void runJavaScriptAndWaitUntilFinished(const char* js, JavascriptFinishedCallback, void* userData);

Would prefer something like scriptString instead of just "js"

-- 
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