Chromium Code Reviews| Index: src/api.cc |
| diff --git a/src/api.cc b/src/api.cc |
| index b7dcd446c154e9d232ada47575fe5c227775e07a..493201a1fd4d0a54fcab432462e0378a0b40238e 100644 |
| --- a/src/api.cc |
| +++ b/src/api.cc |
| @@ -3600,8 +3600,27 @@ bool v8::Object::ForceSet(v8::Local<Value> key, v8::Local<Value> value, |
| Maybe<bool> v8::Object::SetPrivate(Local<Context> context, Local<Private> key, |
| Local<Value> value) { |
| - return DefineOwnProperty(context, Local<Name>(reinterpret_cast<Name*>(*key)), |
| - value, DontEnum); |
| + PREPARE_FOR_EXECUTION_PRIMITIVE(context, "v8::Object::SetPrivate()", bool); |
| + auto self = Utils::OpenHandle(this); |
| + auto key_obj = Utils::OpenHandle(reinterpret_cast<Name*>(*key)); |
| + auto value_obj = Utils::OpenHandle(*value); |
| + if (self->IsJSProxy()) { |
| + i::PropertyDescriptor desc; |
| + desc.set_writable(true); |
| + desc.set_enumerable(false); |
| + desc.set_configurable(true); |
| + desc.set_value(value_obj); |
| + return i::JSProxy::DefineOwnProperty(isolate, |
| + i::Handle<i::JSProxy>::cast(self), |
| + key_obj, &desc, i::Object::DONT_THROW); |
|
Toon Verwaest
2016/02/18 08:13:51
What about just calling JSProxy::AddPrivatePropert
|
| + } |
| + auto js_object = i::Handle<i::JSObject>::cast(self); |
| + i::LookupIterator it(js_object, key_obj); |
| + has_pending_exception = i::JSObject::DefineOwnPropertyIgnoreAttributes( |
| + &it, value_obj, i::DONT_ENUM) |
| + .is_null(); |
| + RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); |
| + return Just(true); |
| } |