Index: test/cctest/test-api.cc |
=================================================================== |
--- test/cctest/test-api.cc (revision 2137) |
+++ test/cctest/test-api.cc (working copy) |
@@ -551,6 +551,7 @@ |
CHECK(isymbol->IsSymbol()); |
} |
i::Heap::CollectAllGarbage(); |
+ i::Heap::CollectAllGarbage(); |
} |
@@ -568,6 +569,7 @@ |
CHECK(isymbol->IsSymbol()); |
} |
i::Heap::CollectAllGarbage(); |
+ i::Heap::CollectAllGarbage(); |
} |
@@ -2281,7 +2283,7 @@ |
} |
-THREADED_TEST(NamedInterceporPropertyRead) { |
+THREADED_TEST(NamedInterceptorPropertyRead) { |
v8::HandleScope scope; |
Local<ObjectTemplate> templ = ObjectTemplate::New(); |
templ->SetNamedPropertyHandler(XPropertyGetter); |
@@ -2294,6 +2296,58 @@ |
} |
} |
+ |
+static v8::Handle<Value> IndexedPropertyGetter(uint32_t index, |
+ const AccessorInfo& info) { |
+ ApiTestFuzzer::Fuzz(); |
+ if (index == 37) { |
+ return v8::Handle<Value>(v8_num(625)); |
+ } |
+ return v8::Handle<Value>(); |
+} |
+ |
+ |
+static v8::Handle<Value> IndexedPropertySetter(uint32_t index, |
+ Local<Value> value, |
+ const AccessorInfo& info) { |
+ ApiTestFuzzer::Fuzz(); |
+ if (index == 39) { |
+ return value; |
+ } |
+ return v8::Handle<Value>(); |
+} |
+ |
+ |
+THREADED_TEST(IndexedInterceptorWithIndexedAccessor) { |
+ v8::HandleScope scope; |
+ Local<ObjectTemplate> templ = ObjectTemplate::New(); |
+ templ->SetIndexedPropertyHandler(IndexedPropertyGetter, |
+ IndexedPropertySetter); |
+ LocalContext context; |
+ context->Global()->Set(v8_str("obj"), templ->NewInstance()); |
+ Local<Script> getter_script = Script::Compile(v8_str( |
+ "obj.__defineGetter__(\"3\", function(){return 5;});obj[3];")); |
+ Local<Script> setter_script = Script::Compile(v8_str( |
+ "obj.__defineSetter__(\"17\", function(val){this.foo = val;});" |
+ "obj[17] = 23;" |
+ "obj.foo;")); |
+ Local<Script> interceptor_setter_script = Script::Compile(v8_str( |
+ "obj.__defineSetter__(\"39\", function(val){this.foo = \"hit\";});" |
+ "obj[39] = 47;" |
+ "obj.foo;")); // This setter should not run, due to the interceptor. |
+ Local<Script> interceptor_getter_script = Script::Compile(v8_str( |
+ "obj[37];")); |
+ Local<Value> result = getter_script->Run(); |
+ CHECK_EQ(v8_num(5), result); |
+ result = setter_script->Run(); |
+ CHECK_EQ(v8_num(23), result); |
+ result = interceptor_setter_script->Run(); |
+ CHECK_EQ(v8_num(23), result); |
+ result = interceptor_getter_script->Run(); |
+ CHECK_EQ(v8_num(625), result); |
+} |
+ |
+ |
THREADED_TEST(MultiContexts) { |
v8::HandleScope scope; |
v8::Handle<ObjectTemplate> templ = ObjectTemplate::New(); |