| Index: test/cctest/test-api-interceptors.cc
|
| diff --git a/test/cctest/test-api-interceptors.cc b/test/cctest/test-api-interceptors.cc
|
| index 2667d24f4602a0e0b09a605e1aa5431b0fd00f67..e0a5b9610bbfa659600c29bcb3a7bad85b221725 100644
|
| --- a/test/cctest/test-api-interceptors.cc
|
| +++ b/test/cctest/test-api-interceptors.cc
|
| @@ -3100,3 +3100,94 @@ THREADED_TEST(IndexedAllCanReadInterceptor) {
|
| ExpectInt32("checked[15]", intercept_data_1.value);
|
| CHECK_EQ(3, access_check_data.count);
|
| }
|
| +
|
| +
|
| +THREADED_TEST(NonMaskingInterceptorOwnProperty) {
|
| + auto isolate = CcTest::isolate();
|
| + v8::HandleScope handle_scope(isolate);
|
| + LocalContext context;
|
| +
|
| + ShouldInterceptData intercept_data;
|
| + intercept_data.value = 239;
|
| + intercept_data.should_intercept = true;
|
| +
|
| + auto interceptor_templ = v8::ObjectTemplate::New(isolate);
|
| + v8::NamedPropertyHandlerConfiguration conf(ShouldNamedInterceptor);
|
| + conf.flags = v8::PropertyHandlerFlags::kNonMasking;
|
| + conf.data = BuildWrappedObject<ShouldInterceptData>(isolate, &intercept_data);
|
| + interceptor_templ->SetHandler(conf);
|
| +
|
| + auto interceptor = interceptor_templ->NewInstance();
|
| + context->Global()->Set(v8_str("obj"), interceptor);
|
| +
|
| + ExpectInt32("obj.whatever", 239);
|
| +
|
| + CompileRun("obj.whatever = 4;");
|
| + ExpectInt32("obj.whatever", 4);
|
| +
|
| + CompileRun("delete obj.whatever;");
|
| + ExpectInt32("obj.whatever", 239);
|
| +}
|
| +
|
| +
|
| +THREADED_TEST(NonMaskingInterceptorPrototypeProperty) {
|
| + auto isolate = CcTest::isolate();
|
| + v8::HandleScope handle_scope(isolate);
|
| + LocalContext context;
|
| +
|
| + ShouldInterceptData intercept_data;
|
| + intercept_data.value = 239;
|
| + intercept_data.should_intercept = true;
|
| +
|
| + auto interceptor_templ = v8::ObjectTemplate::New(isolate);
|
| + v8::NamedPropertyHandlerConfiguration conf(ShouldNamedInterceptor);
|
| + conf.flags = v8::PropertyHandlerFlags::kNonMasking;
|
| + conf.data = BuildWrappedObject<ShouldInterceptData>(isolate, &intercept_data);
|
| + interceptor_templ->SetHandler(conf);
|
| +
|
| + auto interceptor = interceptor_templ->NewInstance();
|
| + context->Global()->Set(v8_str("obj"), interceptor);
|
| +
|
| + ExpectInt32("obj.whatever", 239);
|
| +
|
| + CompileRun("obj.__proto__ = {'whatever': 4};");
|
| + ExpectInt32("obj.whatever", 4);
|
| +
|
| + CompileRun("delete obj.__proto__.whatever;");
|
| + ExpectInt32("obj.whatever", 239);
|
| +}
|
| +
|
| +
|
| +THREADED_TEST(NonMaskingInterceptorPrototypePropertyIC) {
|
| + auto isolate = CcTest::isolate();
|
| + v8::HandleScope handle_scope(isolate);
|
| + LocalContext context;
|
| +
|
| + ShouldInterceptData intercept_data;
|
| + intercept_data.value = 239;
|
| + intercept_data.should_intercept = true;
|
| +
|
| + auto interceptor_templ = v8::ObjectTemplate::New(isolate);
|
| + v8::NamedPropertyHandlerConfiguration conf(ShouldNamedInterceptor);
|
| + conf.flags = v8::PropertyHandlerFlags::kNonMasking;
|
| + conf.data = BuildWrappedObject<ShouldInterceptData>(isolate, &intercept_data);
|
| + interceptor_templ->SetHandler(conf);
|
| +
|
| + auto interceptor = interceptor_templ->NewInstance();
|
| + context->Global()->Set(v8_str("obj"), interceptor);
|
| +
|
| + CompileRun("obj.__proto__ = {};");
|
| + CompileRun(
|
| + "function f() {"
|
| + " var x;"
|
| + " for (var i = 0; i < 4; i++) {"
|
| + " x = obj.whatever;"
|
| + " }"
|
| + " return x;"
|
| + "}");
|
| + ExpectInt32("f()", 239);
|
| + CompileRun("obj.__proto__.whatever = 4;");
|
| + ExpectInt32("f()", 4);
|
| + CompileRun("delete obj.__proto__.whatever;");
|
| + ExpectInt32("f()", 239);
|
| +}
|
|
|