From 4e82c3fb1aff7b0563df95af133bd1e2858a3a34 Mon Sep 17 00:00:00 2001 From: "yangguo@chromium.org" Date: Mon, 6 Aug 2012 07:55:05 +0000 Subject: [PATCH] Allow SetHiddenValue to accept empty value. 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 | 1 + test/cctest/test-api.cc | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/src/api.cc b/src/api.cc index 77bb982..954f821 100644 --- a/src/api.cc +++ b/src/api.cc @@ -3299,6 +3299,7 @@ bool v8::Object::SetHiddenValue(v8::Handle key, v8::Handle 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 self = Utils::OpenHandle(this); diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc index b646049..77c0952 100644 --- a/test/cctest/test-api.cc +++ b/test/cctest/test-api.cc @@ -2081,6 +2081,10 @@ THREADED_TEST(HiddenProperties) { HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); + CHECK(obj->SetHiddenValue(key, Handle())); + CHECK(obj->GetHiddenValue(key).IsEmpty()); + + CHECK(obj->SetHiddenValue(key, v8::Integer::New(2002))); CHECK(obj->DeleteHiddenValue(key)); CHECK(obj->GetHiddenValue(key).IsEmpty()); } -- 2.7.4