<html>
<head>
<base href="https://bugs.webkit.org/" />
</head>
<body><span class="vcard"><a class="email" href="mailto:jgdev@posteo.ch" title="Jack Goofy <jgdev@posteo.ch>"> <span class="fn">Jack Goofy</span></a>
</span> changed
<a class="bz_bug_link
bz_status_NEW "
title="NEW - WebKit2 Gtk+ JavaScriptCore bindings doesn't work properly"
href="https://bugs.webkit.org/show_bug.cgi?id=136989">bug 136989</a>
<br>
<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>What</th>
<th>Removed</th>
<th>Added</th>
</tr>
<tr>
<td style="text-align:right;">CC</td>
<td>
</td>
<td>jgdev@posteo.ch
</td>
</tr></table>
<p>
<div>
<b><a class="bz_bug_link
bz_status_NEW "
title="NEW - WebKit2 Gtk+ JavaScriptCore bindings doesn't work properly"
href="https://bugs.webkit.org/show_bug.cgi?id=136989#c10">Comment # 10</a>
on <a class="bz_bug_link
bz_status_NEW "
title="NEW - WebKit2 Gtk+ JavaScriptCore bindings doesn't work properly"
href="https://bugs.webkit.org/show_bug.cgi?id=136989">bug 136989</a>
from <span class="vcard"><a class="email" href="mailto:jgdev@posteo.ch" title="Jack Goofy <jgdev@posteo.ch>"> <span class="fn">Jack Goofy</span></a>
</span></b>
<pre>modified the patch from anewtobi with the comments from Michael.
--- a/Source/WebKit2/UIProcess/API/gtk/WebKitJavascriptResult.cpp 2016-03-17 16:58:24.866081047 +0100
+++ b/Source/WebKit2/UIProcess/API/gtk/WebKitJavascriptResult.cpp 2016-03-17 17:09:58.702068622 +0100
@@ -108,3 +108,34 @@
{
return javascriptResult->value;
}
+
+
+/**
+ * webkit_javascript_result_to_string:
+ * @js_result: a #WebKitJavascriptResult
+ *
+ * Get string representing the value of @js_result. The value referenced by <function>JSValueRef</function>
+ * gets converted to a string, if possible. In any case where this isn't possible %NULL is returned.
+ *
+ * Return value: (transfer full): a newly allocated result
+ * string; free with g_free()
+ */
+gchar* webkit_javascript_result_to_string(WebKitJavascriptResult* javascriptResult)
+{
+ JSGlobalContextRef context = webkit_javascript_result_get_global_context(javascriptResult);
+
+ JSStringRef js_str_value = JSValueToStringCopy(context, javascriptResult->value, nullptr);
+
+ // If JSValueToStringCopy returns Null, this means JSValueRef couldn't be converted to a JSStringRef,
+ // so we return NULL
+ if (!js_str_value) {
+ return nullptr;
+ }
+
+ gsize str_length = JSStringGetMaximumUTF8CStringSize(js_str_value);
+ gchar* str_value = static_cast<gchar*>(g_malloc(str_length));
+ JSStringGetUTF8CString(js_str_value, str_value, str_length);
+ JSStringRelease(js_str_value);
+
+ return str_value;
+}
--- a/Source/WebKit2/UIProcess/API/gtk/WebKitJavascriptResult.h 2013-08-03 18:10:40.000000000 +0200
+++ a/Source/WebKit2/UIProcess/API/gtk/WebKitJavascriptResult.h 2016-03-17 17:15:28.362062718 +0100
@@ -50,6 +50,9 @@
WEBKIT_API JSValueRef
webkit_javascript_result_get_value (WebKitJavascriptResult *js_result);
+WEBKIT_API gchar*
+webkit_javascript_result_to_string (WebKitJavascriptResult *js_result);
+
G_END_DECLS
#endif</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are the assignee for the bug.</li>
</ul>
</body>
</html>