return result;
}
+static JSObjectRef myBadConstructor_callAsConstructor(JSContextRef context, JSObjectRef constructorObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
+{
+ UNUSED_PARAM(context);
+ UNUSED_PARAM(constructorObject);
+ UNUSED_PARAM(argumentCount);
+ UNUSED_PARAM(arguments);
+ UNUSED_PARAM(exception);
+
+ return 0;
+}
+
static void globalObject_initialize(JSContextRef context, JSObjectRef object)
{
JSObjectSetProperty(context, globalObject, myConstructorIString, myConstructor, kJSPropertyAttributeNone, NULL);
JSStringRelease(myConstructorIString);
+ JSStringRef myBadConstructorIString = JSStringCreateWithUTF8CString("MyBadConstructor");
+ JSObjectRef myBadConstructor = JSObjectMakeConstructor(context, NULL, myBadConstructor_callAsConstructor);
+ JSObjectSetProperty(context, globalObject, myBadConstructorIString, myBadConstructor, kJSPropertyAttributeNone, NULL);
+ JSStringRelease(myBadConstructorIString);
+
ASSERT(!JSObjectSetPrivate(myConstructor, (void*)1));
ASSERT(!JSObjectGetPrivate(myConstructor));
shouldBe("myObject instanceof MyObject", true);
shouldBe("(new Object()) instanceof MyObject", false);
+shouldThrow("new MyBadConstructor()");
+
MyObject.nullGetSet = 1;
shouldBe("MyObject.nullGetSet", 1);
shouldThrow("MyObject.nullCall()");
2012-04-09 Gavin Barraclough <barraclough@apple.com>
+ If a callback constructor returns a C++ null, throw a type error.
+ https://bugs.webkit.org/show_bug.cgi?id=83537
+
+ Rubber Stamped by Geoff Garen.
+
+ * API/JSCallbackConstructor.cpp:
+ (JSC::constructJSCallback):
+ - If a callback constructor returns a C++ null, throw a type error.
+ * API/tests/testapi.c:
+ (Base_returnHardNull):
+ * API/tests/testapi.js:
+ - Add a test case for callback constructors that return a C++ null.
+
+2012-04-09 Gavin Barraclough <barraclough@apple.com>
+
If a callback function returns a C++ null, convert to undefined.
https://bugs.webkit.org/show_bug.cgi?id=83534