| Index: test/cctest/test-api.cc
|
| ===================================================================
|
| --- test/cctest/test-api.cc (revision 5515)
|
| +++ test/cctest/test-api.cc (working copy)
|
| @@ -2937,6 +2937,49 @@
|
| }
|
|
|
|
|
| +THREADED_TEST(NamedInterceptorDictionaryICMultipleContext) {
|
| + v8::HandleScope scope;
|
| +
|
| + v8::Persistent<Context> context1 = Context::New();
|
| +
|
| + context1->Enter();
|
| + Local<ObjectTemplate> templ = ObjectTemplate::New();
|
| + templ->SetNamedPropertyHandler(XPropertyGetter);
|
| + // Create an object with a named interceptor.
|
| + v8::Local<v8::Object> object = templ->NewInstance();
|
| + context1->Global()->Set(v8_str("interceptor_obj"), object);
|
| +
|
| + // Force the object into the slow case.
|
| + CompileRun("interceptor_obj.y = 0;"
|
| + "delete interceptor_obj.y;");
|
| + context1->Exit();
|
| +
|
| + {
|
| + // Introduce the object into a different context.
|
| + // Repeat named loads to exercise ICs.
|
| + LocalContext context2;
|
| + context2->Global()->Set(v8_str("interceptor_obj"), object);
|
| + Local<Value> result =
|
| + CompileRun("function get_x(o) { return o.x; }"
|
| + "interceptor_obj.x = 42;"
|
| + "for (var i=0; i != 10; i++) {"
|
| + " get_x(interceptor_obj);"
|
| + "}"
|
| + "get_x(interceptor_obj)");
|
| + // Check that the interceptor was actually invoked.
|
| + CHECK_EQ(result, v8_str("x"));
|
| + }
|
| +
|
| + // Return to the original context and force some object to the slow case
|
| + // to cause the NormalizedMapCache to verify.
|
| + context1->Enter();
|
| + CompileRun("var obj = { x : 0 }; delete obj.x;");
|
| + context1->Exit();
|
| +
|
| + context1.Dispose();
|
| +}
|
| +
|
| +
|
| static v8::Handle<Value> SetXOnPrototypeGetter(Local<String> property,
|
| const AccessorInfo& info) {
|
| // Set x on the prototype object and do not handle the get request.
|
|
|