Title: [113660] trunk/Source/_javascript_Core
- Revision
- 113660
- Author
- [email protected]
- Date
- 2012-04-09 19:12:24 -0700 (Mon, 09 Apr 2012)
Log Message
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.
Modified Paths
Diff
Modified: trunk/Source/_javascript_Core/API/JSCallbackConstructor.cpp (113659 => 113660)
--- trunk/Source/_javascript_Core/API/JSCallbackConstructor.cpp 2012-04-10 02:06:15 UTC (rev 113659)
+++ trunk/Source/_javascript_Core/API/JSCallbackConstructor.cpp 2012-04-10 02:12:24 UTC (rev 113660)
@@ -85,6 +85,9 @@
}
if (exception)
throwError(exec, toJS(exec, exception));
+ // result must be a valid JSValue.
+ if (!result)
+ return throwVMTypeError(exec);
return JSValue::encode(toJS(result));
}
Modified: trunk/Source/_javascript_Core/API/tests/testapi.c (113659 => 113660)
--- trunk/Source/_javascript_Core/API/tests/testapi.c 2012-04-10 02:06:15 UTC (rev 113659)
+++ trunk/Source/_javascript_Core/API/tests/testapi.c 2012-04-10 02:12:24 UTC (rev 113660)
@@ -865,7 +865,18 @@
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)
{
UNUSED_PARAM(object);
@@ -1461,6 +1472,11 @@
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));
Modified: trunk/Source/_javascript_Core/API/tests/testapi.js (113659 => 113660)
--- trunk/Source/_javascript_Core/API/tests/testapi.js 2012-04-10 02:06:15 UTC (rev 113659)
+++ trunk/Source/_javascript_Core/API/tests/testapi.js 2012-04-10 02:12:24 UTC (rev 113660)
@@ -167,6 +167,8 @@
shouldBe("myObject instanceof MyObject", true);
shouldBe("(new Object()) instanceof MyObject", false);
+shouldThrow("new MyBadConstructor()");
+
MyObject.nullGetSet = 1;
shouldBe("MyObject.nullGetSet", 1);
shouldThrow("MyObject.nullCall()");
Modified: trunk/Source/_javascript_Core/ChangeLog (113659 => 113660)
--- trunk/Source/_javascript_Core/ChangeLog 2012-04-10 02:06:15 UTC (rev 113659)
+++ trunk/Source/_javascript_Core/ChangeLog 2012-04-10 02:12:24 UTC (rev 113660)
@@ -1,5 +1,20 @@
2012-04-09 Gavin Barraclough <[email protected]>
+ 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 <[email protected]>
+
If a callback function returns a C++ null, convert to undefined.
https://bugs.webkit.org/show_bug.cgi?id=83534
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes