Index: test/cctest/test-api.cc |
diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc |
index da40058a352b003f0ed3c3c2e39f30ec506cf042..6c9266b53b891fa994dfb0b3eec451840dd65fa2 100644 |
--- a/test/cctest/test-api.cc |
+++ b/test/cctest/test-api.cc |
@@ -20927,3 +20927,42 @@ TEST(SealHandleScopeNested) { |
USE(obj); |
} |
} |
+ |
+ |
+TEST(CompatibleReceiverCheckOnCachedICHandler) { |
+ v8::Isolate* isolate = CcTest::isolate(); |
+ v8::HandleScope scope(isolate); |
+ v8::Local<v8::FunctionTemplate> parent = FunctionTemplate::New(isolate); |
+ v8::Local<v8::Signature> signature = v8::Signature::New(isolate, parent); |
+ auto returns_42 = |
+ v8::FunctionTemplate::New(isolate, Returns42, Local<Value>(), signature); |
+ parent->PrototypeTemplate()->SetAccessorProperty(v8_str("age"), returns_42); |
+ v8::Local<v8::FunctionTemplate> child = v8::FunctionTemplate::New(isolate); |
+ child->Inherit(parent); |
+ LocalContext env; |
+ env->Global()->Set(v8_str("Child"), child->GetFunction()); |
+ |
+ // Make sure there's a compiled stub for "Child.prototype.age" in the cache. |
+ CompileRun( |
+ "var real = new Child();\n" |
+ "for (var i = 0; i < 3; ++i) {\n" |
+ " real.age;\n" |
+ "}\n"); |
+ |
+ // Check that the cached stub is never used. |
+ ExpectInt32( |
+ "var fake = Object.create(Child.prototype);\n" |
+ "var result = 0;\n" |
+ "function test(d) {\n" |
+ " if (d == 3) return;\n" |
+ " try {\n" |
+ " fake.age;\n" |
+ " result = 1;\n" |
+ " } catch (e) {\n" |
+ " }\n" |
+ " test(d+1);\n" |
+ "}\n" |
+ "test(0);\n" |
+ "result;\n", |
+ 0); |
+} |