Index: src/objects.cc |
diff --git a/src/objects.cc b/src/objects.cc |
index 21784c0f0bf71f51f67515cc7b8dec27878cf107..30dda853ecf8c3ca97d3c036c1fc1f1880ae9783 100644 |
--- a/src/objects.cc |
+++ b/src/objects.cc |
@@ -178,6 +178,16 @@ MaybeObject* JSObject::GetPropertyWithCallback(Object* receiver, |
// api style callbacks. |
if (structure->IsAccessorInfo()) { |
AccessorInfo* data = AccessorInfo::cast(structure); |
+ if (!data->IsCompatibleReceiver(receiver)) { |
+ Handle<Object> name_handle(name); |
+ Handle<Object> receiver_handle(receiver); |
+ Handle<Object> args[2] = { name_handle, receiver_handle }; |
+ Handle<Object> error = |
+ isolate->factory()->NewTypeError("incompatible_method_receiver", |
+ HandleVector(args, |
+ ARRAY_SIZE(args))); |
+ return isolate->Throw(*error); |
+ } |
Object* fun_obj = data->getter(); |
v8::AccessorGetter call_fun = v8::ToCData<v8::AccessorGetter>(fun_obj); |
HandleScope scope(isolate); |
@@ -1984,6 +1994,16 @@ MaybeObject* JSObject::SetPropertyWithCallback(Object* structure, |
if (structure->IsAccessorInfo()) { |
// api style callbacks |
AccessorInfo* data = AccessorInfo::cast(structure); |
+ if (!data->IsCompatibleReceiver(this)) { |
+ Handle<Object> name_handle(name); |
+ Handle<Object> receiver_handle(this); |
+ Handle<Object> args[2] = { name_handle, receiver_handle }; |
+ Handle<Object> error = |
+ isolate->factory()->NewTypeError("incompatible_method_receiver", |
+ HandleVector(args, |
+ ARRAY_SIZE(args))); |
+ return isolate->Throw(*error); |
+ } |
Object* call_obj = data->setter(); |
v8::AccessorSetter call_fun = v8::ToCData<v8::AccessorSetter>(call_obj); |
if (call_fun == NULL) return value; |