summaryrefslogtreecommitdiffstats
path: root/JavaScriptCore/API
diff options
context:
space:
mode:
authorIain Merrick <husky@google.com>2010-09-13 16:35:48 +0100
committerIain Merrick <husky@google.com>2010-09-16 12:10:42 +0100
commit5abb8606fa57c3ebfc8b3c3dbc3fa4a25d2ae306 (patch)
treeddce1aa5e3b6967a69691892e500897558ff8ab6 /JavaScriptCore/API
parent12bec63ec71e46baba27f0bd9bd9d8067683690a (diff)
downloadexternal_webkit-5abb8606fa57c3ebfc8b3c3dbc3fa4a25d2ae306.zip
external_webkit-5abb8606fa57c3ebfc8b3c3dbc3fa4a25d2ae306.tar.gz
external_webkit-5abb8606fa57c3ebfc8b3c3dbc3fa4a25d2ae306.tar.bz2
Merge WebKit at r67178 : Initial merge by git.
Change-Id: I57e01163b6866cb029cdadf405a0394a3918bc18
Diffstat (limited to 'JavaScriptCore/API')
-rw-r--r--JavaScriptCore/API/JSObjectRef.cpp2
-rw-r--r--JavaScriptCore/API/tests/testapi.c29
2 files changed, 20 insertions, 11 deletions
diff --git a/JavaScriptCore/API/JSObjectRef.cpp b/JavaScriptCore/API/JSObjectRef.cpp
index 5e0536f..8bd33d6 100644
--- a/JavaScriptCore/API/JSObjectRef.cpp
+++ b/JavaScriptCore/API/JSObjectRef.cpp
@@ -382,7 +382,7 @@ bool JSObjectSetPrivateProperty(JSContextRef ctx, JSObjectRef object, JSStringRe
ExecState* exec = toJS(ctx);
APIEntryShim entryShim(exec);
JSObject* jsObject = toJS(object);
- JSValue jsValue = toJS(exec, value);
+ JSValue jsValue = value ? toJS(exec, value) : JSValue();
Identifier name(propertyName->identifier(&exec->globalData()));
if (jsObject->inherits(&JSCallbackObject<JSGlobalObject>::info)) {
static_cast<JSCallbackObject<JSGlobalObject>*>(jsObject)->setPrivateProperty(name, jsValue);
diff --git a/JavaScriptCore/API/tests/testapi.c b/JavaScriptCore/API/tests/testapi.c
index 183abf5..1ecfc7e 100644
--- a/JavaScriptCore/API/tests/testapi.c
+++ b/JavaScriptCore/API/tests/testapi.c
@@ -933,17 +933,15 @@ int main(int argc, char* argv[])
JSStringRef privatePropertyName = JSStringCreateWithUTF8CString("privateProperty");
if (!JSObjectSetPrivateProperty(context, myObject, privatePropertyName, aHeapRef)) {
printf("FAIL: Could not set private property.\n");
- failed = 1;
- } else {
+ failed = 1;
+ } else
printf("PASS: Set private property.\n");
- }
aStackRef = 0;
if (JSObjectSetPrivateProperty(context, aHeapRef, privatePropertyName, aHeapRef)) {
printf("FAIL: JSObjectSetPrivateProperty should fail on non-API objects.\n");
- failed = 1;
- } else {
+ failed = 1;
+ } else
printf("PASS: Did not allow JSObjectSetPrivateProperty on a non-API object.\n");
- }
if (JSObjectGetPrivateProperty(context, myObject, privatePropertyName) != aHeapRef) {
printf("FAIL: Could not retrieve private property.\n");
failed = 1;
@@ -954,15 +952,15 @@ int main(int argc, char* argv[])
failed = 1;
} else
printf("PASS: JSObjectGetPrivateProperty return NULL.\n");
-
+
if (JSObjectGetProperty(context, myObject, privatePropertyName, 0) == aHeapRef) {
printf("FAIL: Accessed private property through ordinary property lookup.\n");
failed = 1;
} else
printf("PASS: Cannot access private property through ordinary property lookup.\n");
-
+
JSGarbageCollect(context);
-
+
for (int i = 0; i < 10000; i++)
JSObjectMake(context, 0, 0);
@@ -973,7 +971,18 @@ int main(int argc, char* argv[])
} else
printf("PASS: Private property does not appear to have been collected.\n");
JSStringRelease(lengthStr);
-
+
+ if (!JSObjectSetPrivateProperty(context, myObject, privatePropertyName, 0)) {
+ printf("FAIL: Could not set private property to NULL.\n");
+ failed = 1;
+ } else
+ printf("PASS: Set private property to NULL.\n");
+ if (JSObjectGetPrivateProperty(context, myObject, privatePropertyName)) {
+ printf("FAIL: Could not retrieve private property.\n");
+ failed = 1;
+ } else
+ printf("PASS: Retrieved private property.\n");
+
JSStringRef validJSON = JSStringCreateWithUTF8CString("{\"aProperty\":true}");
JSValueRef jsonObject = JSValueMakeFromJSONString(context, validJSON);
JSStringRelease(validJSON);