Allow SetHiddenValue to accept empty value.
authoryangguo@chromium.org <yangguo@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Mon, 6 Aug 2012 07:55:05 +0000 (07:55 +0000)
committeryangguo@chromium.org <yangguo@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Mon, 6 Aug 2012 07:55:05 +0000 (07:55 +0000)
R=mstarzinger@chromium.org
BUG=v8:2274

Review URL: https://chromiumcodereview.appspot.com/10825196

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@12257 ce2b1a6d-e550-0410-aec6-3dcde31c8c00

src/api.cc
test/cctest/test-api.cc

index 77bb9828253f327808d88b8200c236ed4e467de7..954f82144135a95cf2832a5cf90c135c7ab96135 100644 (file)
@@ -3299,6 +3299,7 @@ bool v8::Object::SetHiddenValue(v8::Handle<v8::String> key,
                                 v8::Handle<v8::Value> value) {
   i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
   ON_BAILOUT(isolate, "v8::Object::SetHiddenValue()", return false);
+  if (value.IsEmpty()) return DeleteHiddenValue(key);
   ENTER_V8(isolate);
   i::HandleScope scope(isolate);
   i::Handle<i::JSObject> self = Utils::OpenHandle(this);
index b646049f335e0edd32bb56fd6a025edfd0139895..77c0952520b6bb5dcad3bc9f764d42a7a0f2a35a 100644 (file)
@@ -2081,6 +2081,10 @@ THREADED_TEST(HiddenProperties) {
 
   HEAP->CollectAllGarbage(i::Heap::kNoGCFlags);
 
+  CHECK(obj->SetHiddenValue(key, Handle<Value>()));
+  CHECK(obj->GetHiddenValue(key).IsEmpty());
+
+  CHECK(obj->SetHiddenValue(key, v8::Integer::New(2002)));
   CHECK(obj->DeleteHiddenValue(key));
   CHECK(obj->GetHiddenValue(key).IsEmpty());
 }