Index: test/cctest/test-api.cc |
diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc |
index 49ee96988d4f55d7477e55878d0e8cbc046baac8..4c05aaf336d9718a176531048e3d2fcdedc9752f 100644 |
--- a/test/cctest/test-api.cc |
+++ b/test/cctest/test-api.cc |
@@ -21745,3 +21745,42 @@ TEST(Set) { |
set->Clear(); |
CHECK_EQ(0U, set->Size()); |
} |
+ |
+ |
+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); |
+} |