Title: [243283] trunk
Revision
243283
Author
[email protected]
Date
2019-03-21 02:43:15 -0700 (Thu, 21 Mar 2019)

Log Message

[GLib] Returning G_TYPE_OBJECT from a method does not work
https://bugs.webkit.org/show_bug.cgi?id=195574

Reviewed by Michael Catanzaro.

Source/_javascript_Core:

Add more documentation to clarify the ownership of wrapped objects when created and when returned by functions.

* API/glib/JSCCallbackFunction.cpp:
(JSC::JSCCallbackFunction::construct): Also allow to return boxed types from a constructor.
* API/glib/JSCClass.cpp:
* API/glib/JSCValue.cpp:

Tools:

Add new test cases to check the behavior of constructors and functions returning GObject and boxed types.

* TestWebKitAPI/Tests/_javascript_Core/glib/TestJSC.cpp:
(getGFile):
(getParent):
(createGString):
(getGString):
(getGStringCopyWillRaise):
(getGStringCopy):
(getGStringStr):
(getGStringLen):
(freeGString):
(testJSCClass):

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/API/glib/JSCCallbackFunction.cpp (243282 => 243283)


--- trunk/Source/_javascript_Core/API/glib/JSCCallbackFunction.cpp	2019-03-21 09:24:31 UTC (rev 243282)
+++ trunk/Source/_javascript_Core/API/glib/JSCCallbackFunction.cpp	2019-03-21 09:43:15 UTC (rev 243283)
@@ -204,6 +204,7 @@
 
     switch (g_type_fundamental(G_VALUE_TYPE(&returnValue))) {
     case G_TYPE_POINTER:
+    case G_TYPE_BOXED:
     case G_TYPE_OBJECT:
         if (auto* ptr = returnValue.data[0].v_pointer)
             return toRef(jscClassGetOrCreateJSWrapper(m_class.get(), ptr));

Modified: trunk/Source/_javascript_Core/API/glib/JSCClass.cpp (243282 => 243283)


--- trunk/Source/_javascript_Core/API/glib/JSCClass.cpp	2019-03-21 09:24:31 UTC (rev 243282)
+++ trunk/Source/_javascript_Core/API/glib/JSCClass.cpp	2019-03-21 09:43:15 UTC (rev 243283)
@@ -589,6 +589,9 @@
  * This function creates the constructor, which needs to be added to an object as a property to be able to use it. Use
  * jsc_context_set_value() to make the constructor available in the global object.
  *
+ * Note that the value returned by @callback is adopted by @jsc_class, and the #GDestroyNotify passed to
+ * jsc_context_register_class() is responsible for disposing of it.
+ *
  * Returns: (transfer full): a #JSCValue representing the class constructor.
  */
 JSCValue* jsc_class_add_constructor(JSCClass* jscClass, const char* name, GCallback callback, gpointer userData, GDestroyNotify destroyNotify, GType returnType, unsigned paramCount, ...)
@@ -635,6 +638,9 @@
  * This function creates the constructor, which needs to be added to an object as a property to be able to use it. Use
  * jsc_context_set_value() to make the constructor available in the global object.
  *
+ * Note that the value returned by @callback is adopted by @jsc_class, and the #GDestroyNotify passed to
+ * jsc_context_register_class() is responsible for disposing of it.
+ *
  * Returns: (transfer full): a #JSCValue representing the class constructor.
  */
 JSCValue* jsc_class_add_constructorv(JSCClass* jscClass, const char* name, GCallback callback, gpointer userData, GDestroyNotify destroyNotify, GType returnType, unsigned parametersCount, GType* parameterTypes)
@@ -676,6 +682,9 @@
  * This function creates the constructor, which needs to be added to an object as a property to be able to use it. Use
  * jsc_context_set_value() to make the constructor available in the global object.
  *
+ * Note that the value returned by @callback is adopted by @jsc_class, and the #GDestroyNotify passed to
+ * jsc_context_register_class() is responsible for disposing of it.
+ *
  * Returns: (transfer full): a #JSCValue representing the class constructor.
  */
 JSCValue* jsc_class_add_constructor_variadic(JSCClass* jscClass, const char* name, GCallback callback, gpointer userData, GDestroyNotify destroyNotify, GType returnType)
@@ -722,6 +731,11 @@
  * @callback is called receiving the class instance as first parameter, followed by the method parameters and then
  * @user_data as last parameter. When the method is cleared in the #JSCClass context, @destroy_notify is called with
  * @user_data as parameter.
+ *
+ * Note that the value returned by @callback must be transfer full. In case of non-refcounted boxed types, you should use
+ * %G_TYPE_POINTER instead of the actual boxed #GType to ensure that the instance owned by #JSCClass is used.
+ * If you really want to return a new copy of the boxed type, use #JSC_TYPE_VALUE and return a #JSCValue created
+ * with jsc_value_new_object() that receives the copy as the instance parameter.
  */
 void jsc_class_add_method(JSCClass* jscClass, const char* name, GCallback callback, gpointer userData, GDestroyNotify destroyNotify, GType returnType, unsigned paramCount, ...)
 {
@@ -758,6 +772,11 @@
  * @callback is called receiving the class instance as first parameter, followed by the method parameters and then
  * @user_data as last parameter. When the method is cleared in the #JSCClass context, @destroy_notify is called with
  * @user_data as parameter.
+ *
+ * Note that the value returned by @callback must be transfer full. In case of non-refcounted boxed types, you should use
+ * %G_TYPE_POINTER instead of the actual boxed #GType to ensure that the instance owned by #JSCClass is used.
+ * If you really want to return a new copy of the boxed type, use #JSC_TYPE_VALUE and return a #JSCValue created
+ * with jsc_value_new_object() that receives the copy as the instance parameter.
  */
 void jsc_class_add_methodv(JSCClass* jscClass, const char* name, GCallback callback, gpointer userData, GDestroyNotify destroyNotify, GType returnType, unsigned parametersCount, GType *parameterTypes)
 {
@@ -790,6 +809,11 @@
  * @callback is called receiving the class instance as first parameter, followed by a #GPtrArray of #JSCValue<!-- -->s
  * with the method arguments and then @user_data as last parameter. When the method is cleared in the #JSCClass context,
  * @destroy_notify is called with @user_data as parameter.
+ *
+ * Note that the value returned by @callback must be transfer full. In case of non-refcounted boxed types, you should use
+ * %G_TYPE_POINTER instead of the actual boxed #GType to ensure that the instance owned by #JSCClass is used.
+ * If you really want to return a new copy of the boxed type, use #JSC_TYPE_VALUE and return a #JSCValue created
+ * with jsc_value_new_object() that receives the copy as the instance parameter.
  */
 void jsc_class_add_method_variadic(JSCClass* jscClass, const char* name, GCallback callback, gpointer userData, GDestroyNotify destroyNotify, GType returnType)
 {
@@ -816,6 +840,11 @@
  * value needs to be set, @setter is called receiving the the class instance as first parameter, followed
  * by the value to be set and then @user_data as the last parameter. When the property is cleared in the
  * #JSCClass context, @destroy_notify is called with @user_data as parameter.
+ *
+ * Note that the value returned by @getter must be transfer full. In case of non-refcounted boxed types, you should use
+ * %G_TYPE_POINTER instead of the actual boxed #GType to ensure that the instance owned by #JSCClass is used.
+ * If you really want to return a new copy of the boxed type, use #JSC_TYPE_VALUE and return a #JSCValue created
+ * with jsc_value_new_object() that receives the copy as the instance parameter.
  */
 void jsc_class_add_property(JSCClass* jscClass, const char* name, GType propertyType, GCallback getter, GCallback setter, gpointer userData, GDestroyNotify destroyNotify)
 {

Modified: trunk/Source/_javascript_Core/API/glib/JSCValue.cpp (243282 => 243283)


--- trunk/Source/_javascript_Core/API/glib/JSCValue.cpp	2019-03-21 09:24:31 UTC (rev 243282)
+++ trunk/Source/_javascript_Core/API/glib/JSCValue.cpp	2019-03-21 09:43:15 UTC (rev 243283)
@@ -588,11 +588,12 @@
 /**
  * jsc_value_new_object:
  * @context: a #JSCContext
- * @instance: (nullable): an object instance or %NULL
+ * @instance: (nullable) (transfer full): an object instance or %NULL
  * @jsc_class: (nullable): the #JSCClass of @instance
  *
  * Create a new #JSCValue from @instance. If @instance is %NULL a new empty object is created.
- * When @instance is provided, @jsc_class must be provided too.
+ * When @instance is provided, @jsc_class must be provided too. @jsc_class takes ownership of
+ * @instance that will be freed by the #GDestroyNotify passed to jsc_context_register_class().
  *
  * Returns: (transfer full): a #JSCValue.
  */
@@ -1083,6 +1084,11 @@
  * When the property is cleared in the #JSCClass context, @destroy_notify is called with
  * @user_data as parameter. This is equivalent to _javascript_ <function>Object.defineProperty()</function>
  * when used with an accessor descriptor.
+ *
+ * Note that the value returned by @getter must be fully transferred. In case of boxed types, you could use
+ * %G_TYPE_POINTER instead of the actual boxed #GType to ensure that the instance owned by #JSCClass is used.
+ * If you really want to return a new copy of the boxed type, use #JSC_TYPE_VALUE and return a #JSCValue created
+ * with jsc_value_new_object() that receives the copy as instance parameter.
  */
 void jsc_value_object_define_property_accessor(JSCValue* value, const char* propertyName, JSCValuePropertyFlags flags, GType propertyType, GCallback getter, GCallback setter, gpointer userData, GDestroyNotify destroyNotify)
 {
@@ -1159,6 +1165,11 @@
  * receiving the function parameters and then @user_data as last parameter. When the function is
  * cleared in @context, @destroy_notify is called with @user_data as parameter.
  *
+ * Note that the value returned by @callback must be fully transferred. In case of boxed types, you could use
+ * %G_TYPE_POINTER instead of the actual boxed #GType to ensure that the instance owned by #JSCClass is used.
+ * If you really want to return a new copy of the boxed type, use #JSC_TYPE_VALUE and return a #JSCValue created
+ * with jsc_value_new_object() that receives the copy as instance parameter.
+ *
  * Returns: (transfer full): a #JSCValue.
  */
 JSCValue* jsc_value_new_function(JSCContext* context, const char* name, GCallback callback, gpointer userData, GDestroyNotify destroyNotify, GType returnType, unsigned paramCount, ...)
@@ -1195,6 +1206,11 @@
  * receiving the function parameters and then @user_data as last parameter. When the function is
  * cleared in @context, @destroy_notify is called with @user_data as parameter.
  *
+ * Note that the value returned by @callback must be fully transferred. In case of boxed types, you could use
+ * %G_TYPE_POINTER instead of the actual boxed #GType to ensure that the instance owned by #JSCClass is used.
+ * If you really want to return a new copy of the boxed type, use #JSC_TYPE_VALUE and return a #JSCValue created
+ * with jsc_value_new_object() that receives the copy as instance parameter.
+ *
  * Returns: (transfer full): a #JSCValue.
  */
 JSCValue* jsc_value_new_functionv(JSCContext* context, const char* name, GCallback callback, gpointer userData, GDestroyNotify destroyNotify, GType returnType, unsigned parametersCount, GType *parameterTypes)
@@ -1227,6 +1243,11 @@
  * receiving an #GPtrArray of #JSCValue<!-- -->s with the arguments and then @user_data as last parameter.
  * When the function is cleared in @context, @destroy_notify is called with @user_data as parameter.
  *
+ * Note that the value returned by @callback must be fully transferred. In case of boxed types, you could use
+ * %G_TYPE_POINTER instead of the actual boxed #GType to ensure that the instance owned by #JSCClass is used.
+ * If you really want to return a new copy of the boxed type, use #JSC_TYPE_VALUE and return a #JSCValue created
+ * with jsc_value_new_object() that receives the copy as instance parameter.
+ *
  * Returns: (transfer full): a #JSCValue.
  */
 JSCValue* jsc_value_new_function_variadic(JSCContext* context, const char* name, GCallback callback, gpointer userData, GDestroyNotify destroyNotify, GType returnType)

Modified: trunk/Source/_javascript_Core/ChangeLog (243282 => 243283)


--- trunk/Source/_javascript_Core/ChangeLog	2019-03-21 09:24:31 UTC (rev 243282)
+++ trunk/Source/_javascript_Core/ChangeLog	2019-03-21 09:43:15 UTC (rev 243283)
@@ -1,3 +1,17 @@
+2019-03-21  Carlos Garcia Campos  <[email protected]>
+
+        [GLib] Returning G_TYPE_OBJECT from a method does not work
+        https://bugs.webkit.org/show_bug.cgi?id=195574
+
+        Reviewed by Michael Catanzaro.
+
+        Add more documentation to clarify the ownership of wrapped objects when created and when returned by functions.
+
+        * API/glib/JSCCallbackFunction.cpp:
+        (JSC::JSCCallbackFunction::construct): Also allow to return boxed types from a constructor.
+        * API/glib/JSCClass.cpp:
+        * API/glib/JSCValue.cpp:
+
 2019-03-21  Mark Lam  <[email protected]>
 
         Cap length of an array with spread to MIN_ARRAY_STORAGE_CONSTRUCTION_LENGTH.

Modified: trunk/Tools/ChangeLog (243282 => 243283)


--- trunk/Tools/ChangeLog	2019-03-21 09:24:31 UTC (rev 243282)
+++ trunk/Tools/ChangeLog	2019-03-21 09:43:15 UTC (rev 243283)
@@ -1,3 +1,24 @@
+2019-03-21  Carlos Garcia Campos  <[email protected]>
+
+        [GLib] Returning G_TYPE_OBJECT from a method does not work
+        https://bugs.webkit.org/show_bug.cgi?id=195574
+
+        Reviewed by Michael Catanzaro.
+
+        Add new test cases to check the behavior of constructors and functions returning GObject and boxed types.
+
+        * TestWebKitAPI/Tests/_javascript_Core/glib/TestJSC.cpp:
+        (getGFile):
+        (getParent):
+        (createGString):
+        (getGString):
+        (getGStringCopyWillRaise):
+        (getGStringCopy):
+        (getGStringStr):
+        (getGStringLen):
+        (freeGString):
+        (testJSCClass):
+
 2019-03-20  Saam Barati  <[email protected]>
 
         DFG::AbstractValue::validateOSREntry is wrong when isHeapTop and the incoming value is Empty

Modified: trunk/Tools/TestWebKitAPI/Tests/_javascript_Core/glib/TestJSC.cpp (243282 => 243283)


--- trunk/Tools/TestWebKitAPI/Tests/_javascript_Core/glib/TestJSC.cpp	2019-03-21 09:24:31 UTC (rev 243282)
+++ trunk/Tools/TestWebKitAPI/Tests/_javascript_Core/glib/TestJSC.cpp	2019-03-21 09:43:15 UTC (rev 243283)
@@ -1597,6 +1597,60 @@
     return file;
 }
 
+static GFile* getGFile(GFile* file)
+{
+    return G_FILE(g_object_ref(file));
+}
+
+static JSCValue* getParent(GFile* file, JSCClass* jscClass)
+{
+    auto* checker = static_cast<LeakChecker*>(g_object_get_data(G_OBJECT(jsc_context_get_current()), "leak-checker"));
+    GFile* parent = g_file_get_parent(file);
+    checker->watch(parent);
+    auto* value = jsc_value_new_object(jsc_context_get_current(), parent, jscClass);
+    checker->watch(value);
+    return value;
+}
+
+static GString* createGString(const char* str)
+{
+    return g_string_new(str);
+}
+
+static GString* getGString(GString* str)
+{
+    return str;
+}
+
+static GString* getGStringCopyWillRaise(GString* str)
+{
+    return static_cast<GString*>(g_boxed_copy(G_TYPE_GSTRING, str));
+}
+
+static JSCValue* getGStringCopy(GString *str, JSCClass* jscClass)
+{
+    auto* checker = static_cast<LeakChecker*>(g_object_get_data(G_OBJECT(jsc_context_get_current()), "leak-checker"));
+    auto* copy = getGStringCopyWillRaise(str);
+    auto* value = jsc_value_new_object(jsc_context_get_current(), copy, jscClass);
+    checker->watch(value);
+    return value;
+}
+
+static char* getGStringStr(GString* str)
+{
+    return g_strdup(str->str);
+}
+
+static guint64 getGStringLen(GString* str)
+{
+    return str->len;
+}
+
+static void freeGString(GString* str)
+{
+    g_string_free(str, TRUE);
+}
+
 static void testJSCClass()
 {
     {
@@ -2296,7 +2350,136 @@
         g_assert_true(jsc_value_is_string(value2.get()));
         resultString.reset(jsc_value_to_string(value2.get()));
         g_assert_cmpstr(resultString.get(), ==, currentDirectory.get());
+
+        jsc_class_add_method(jscClass, "getGFile", G_CALLBACK(getGFile), nullptr, nullptr, G_TYPE_OBJECT, 0, G_TYPE_NONE);
+        result = adoptGRef(jsc_context_evaluate(context.get(), "f = new GFile('.'); f2 = f.getGFile(); f2.getPath()", -1));
+        checker.watch(result.get());
+        g_assert_true(jsc_value_is_string(result.get()));
+        resultString.reset(jsc_value_to_string(result.get()));
+        g_assert_cmpstr(resultString.get(), ==, currentDirectory.get());
+
+        value = adoptGRef(jsc_value_object_invoke_method(file.get(), "getGFile", G_TYPE_NONE));
+        checker.watch(value.get());
+        g_assert_true(value.get() == file.get());
+
+        jsc_class_add_method(jscClass, "getParent", G_CALLBACK(getParent), jscClass, nullptr, JSC_TYPE_VALUE, 0, G_TYPE_NONE);
+        result = adoptGRef(jsc_context_evaluate(context.get(), "f = new GFile('.'); p = f.getParent(); p.getPath()", -1));
+        checker.watch(result.get());
+        g_assert_true(jsc_value_is_string(result.get()));
+        resultString.reset(jsc_value_to_string(result.get()));
+        GUniquePtr<char> parentDirectory(g_path_get_dirname(currentDirectory.get()));
+        g_assert_cmpstr(resultString.get(), ==, parentDirectory.get());
+
+        jsc_class_add_method(jscClass, "equal", G_CALLBACK(g_file_equal), nullptr, nullptr, G_TYPE_BOOLEAN, 1, G_TYPE_OBJECT);
+        result = adoptGRef(jsc_context_evaluate(context.get(), "f1 = new GFile('.'); f2 = new GFile('.'); f1.equal(f2);", -1));
+        checker.watch(result.get());
+        g_assert_true(jsc_value_is_boolean(result.get()));
+        g_assert_true(jsc_value_to_boolean(result.get()));
+
+        GFile* fileObject = g_file_new_for_path(".");
+        checker.watch(fileObject);
+        GRefPtr<JSCValue> fileValue = adoptGRef(jsc_value_new_object(context.get(), fileObject, jscClass));
+        checker.watch(fileValue.get());
+
+        result = adoptGRef(jsc_value_object_invoke_method(file.get(), "equal", G_TYPE_OBJECT, fileObject, G_TYPE_NONE));
+        checker.watch(result.get());
+        g_assert_true(jsc_value_is_boolean(result.get()));
+        g_assert_true(jsc_value_to_boolean(result.get()));
+
+        result = adoptGRef(jsc_value_object_invoke_method(file.get(), "equal", JSC_TYPE_VALUE, fileValue.get(), G_TYPE_NONE));
+        checker.watch(result.get());
+        g_assert_true(jsc_value_is_boolean(result.get()));
+        g_assert_true(jsc_value_to_boolean(result.get()));
     }
+
+    {
+        LeakChecker checker;
+        GRefPtr<JSCContext> context = adoptGRef(jsc_context_new());
+        checker.watch(context.get());
+        g_object_set_data(G_OBJECT(context.get()), "leak-checker", &checker);
+        ExceptionHandler exceptionHandler(context.get());
+
+        JSCClass* jscClass = jsc_context_register_class(context.get(), "GString", nullptr, nullptr, reinterpret_cast<GDestroyNotify>(freeGString));
+        checker.watch(jscClass);
+
+        GRefPtr<JSCValue> constructor = adoptGRef(jsc_class_add_constructor(jscClass, nullptr, G_CALLBACK(createGString), nullptr, nullptr, G_TYPE_GSTRING, 1, G_TYPE_STRING));
+        checker.watch(constructor.get());
+        g_assert_true(jsc_value_is_constructor(constructor.get()));
+
+        jsc_class_add_property(jscClass, "str", G_TYPE_STRING, G_CALLBACK(getGStringStr), nullptr, nullptr, nullptr);
+        jsc_class_add_property(jscClass, "len", G_TYPE_UINT64, G_CALLBACK(getGStringLen), nullptr, nullptr, nullptr);
+
+        jsc_context_set_value(context.get(), jsc_class_get_name(jscClass), constructor.get());
+
+        GRefPtr<JSCValue> str = adoptGRef(jsc_context_evaluate(context.get(), "s = new GString('Foo');", -1));
+        checker.watch(str.get());
+        g_assert_true(jsc_value_is_object(str.get()));
+        g_assert_true(jsc_value_object_is_instance_of(str.get(), jsc_class_get_name(jscClass)));
+        GRefPtr<JSCValue> result = adoptGRef(jsc_context_evaluate(context.get(), "s instanceof GString;", -1));
+        checker.watch(result.get());
+        g_assert_true(jsc_value_is_boolean(result.get()));
+        g_assert_true(jsc_value_to_boolean(result.get()));
+
+        g_assert_true(jsc_value_object_has_property(str.get(), "str"));
+        GRefPtr<JSCValue> value = adoptGRef(jsc_value_object_get_property(str.get(), "str"));
+        checker.watch(value.get());
+        g_assert_true(jsc_value_is_string(value.get()));
+        GUniquePtr<char> resultString(jsc_value_to_string(value.get()));
+        g_assert_cmpstr(resultString.get(), ==, "Foo");
+
+        GRefPtr<JSCValue> value2 = adoptGRef(jsc_context_evaluate(context.get(), "s.str", -1));
+        checker.watch(value2.get());
+        g_assert_true(jsc_value_is_string(value2.get()));
+        resultString.reset(jsc_value_to_string(value2.get()));
+        g_assert_cmpstr(resultString.get(), ==, "Foo");
+
+        GRefPtr<JSCValue> value3 = adoptGRef(jsc_context_evaluate(context.get(), "s.len", -1));
+        checker.watch(value3.get());
+        g_assert_true(jsc_value_is_number(value3.get()));
+        g_assert_cmpint(jsc_value_to_int32(value3.get()), ==, 3);
+
+        jsc_class_add_method(jscClass, "getGString", G_CALLBACK(getGString), nullptr, nullptr, G_TYPE_POINTER, 0, G_TYPE_NONE);
+        result = adoptGRef(jsc_context_evaluate(context.get(), "s = new GString('Self'); s2 = s.getGString(); s2.str;", -1));
+        checker.watch(result.get());
+        g_assert_true(jsc_value_is_string(result.get()));
+        resultString.reset(jsc_value_to_string(result.get()));
+        g_assert_cmpstr(resultString.get(), ==, "Self");
+
+        jsc_class_add_method(jscClass, "getGStringCopy", G_CALLBACK(getGStringCopy), jscClass, nullptr, JSC_TYPE_VALUE, 0, G_TYPE_NONE);
+        result = adoptGRef(jsc_context_evaluate(context.get(), "s = new GString('Copy'); s2 = s.getGStringCopy(); s2.str;", -1));
+        checker.watch(result.get());
+        g_assert_true(jsc_value_is_string(result.get()));
+        resultString.reset(jsc_value_to_string(result.get()));
+        g_assert_cmpstr(resultString.get(), ==, "Copy");
+
+        jsc_class_add_method(jscClass, "getGStringCopyWillRaise", G_CALLBACK(getGStringCopyWillRaise), nullptr, nullptr, G_TYPE_GSTRING, 0, G_TYPE_NONE);
+        bool didThrow = false;
+        g_assert_throw_begin(exceptionHandler, didThrow);
+        result = adoptGRef(jsc_context_evaluate(context.get(), "s = new GString('Copy'); s2 = s.getGStringCopyWillRaise(); s2.str;", -1));
+        checker.watch(result.get());
+        g_assert_true(jsc_value_is_undefined(result.get()));
+        g_assert_did_throw(exceptionHandler, didThrow);
+
+        jsc_class_add_method(jscClass, "equal", G_CALLBACK(g_string_equal), nullptr, nullptr, G_TYPE_BOOLEAN, 1, G_TYPE_GSTRING);
+        result = adoptGRef(jsc_context_evaluate(context.get(), "s1 = new GString('Bar'); s2 = new GString('Bar'); s1.equal(s2);", -1));
+        checker.watch(result.get());
+        g_assert_true(jsc_value_is_boolean(result.get()));
+        g_assert_true(jsc_value_to_boolean(result.get()));
+
+        GString* strBoxed = g_string_new("Foo");
+        GRefPtr<JSCValue> strValue = adoptGRef(jsc_value_new_object(context.get(), strBoxed, jscClass));
+        checker.watch(strValue.get());
+
+        result = adoptGRef(jsc_value_object_invoke_method(str.get(), "equal", G_TYPE_GSTRING, strBoxed, G_TYPE_NONE));
+        checker.watch(result.get());
+        g_assert_true(jsc_value_is_boolean(result.get()));
+        g_assert_true(jsc_value_to_boolean(result.get()));
+
+        result = adoptGRef(jsc_value_object_invoke_method(str.get(), "equal", JSC_TYPE_VALUE, strValue.get(), G_TYPE_NONE));
+        checker.watch(result.get());
+        g_assert_true(jsc_value_is_boolean(result.get()));
+        g_assert_true(jsc_value_to_boolean(result.get()));
+    }
 }
 
 typedef struct {
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to