Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(94)

Unified Diff: test/cctest/test-api-interceptors.cc

Issue 1036843002: fix nonmasking interceptor ic with interceptor on receiver (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/ic/handler-compiler.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/test-api-interceptors.cc
diff --git a/test/cctest/test-api-interceptors.cc b/test/cctest/test-api-interceptors.cc
index 0b060d1e62c250e9cab5015b39b35a65fc8a2d25..8c2b222bbf054d309782948ebf3d9b177589afab 100644
--- a/test/cctest/test-api-interceptors.cc
+++ b/test/cctest/test-api-interceptors.cc
@@ -3247,3 +3247,66 @@ THREADED_TEST(NonMaskingInterceptorPrototypePropertyIC) {
ExpectInt32("f(obj)", 239);
ExpectInt32("f(outer)", 4);
}
+
+
+namespace {
+
+void DatabaseGetter(Local<Name> name,
+ const v8::PropertyCallbackInfo<Value>& info) {
+ ApiTestFuzzer::Fuzz();
+ auto context = info.GetIsolate()->GetCurrentContext();
+ Local<v8::Object> db = info.Holder()
+ ->GetRealNamedProperty(context, v8_str("db"))
+ .ToLocalChecked()
+ .As<v8::Object>();
+ if (!db->Has(context, name).FromJust()) return;
+ info.GetReturnValue().Set(db->Get(context, name).ToLocalChecked());
+}
+
+
+void DatabaseSetter(Local<Name> name, Local<Value> value,
+ const v8::PropertyCallbackInfo<Value>& info) {
+ ApiTestFuzzer::Fuzz();
+ auto context = info.GetIsolate()->GetCurrentContext();
+ if (name->Equals(v8_str("db"))) return;
+ Local<v8::Object> db = info.Holder()
+ ->GetRealNamedProperty(context, v8_str("db"))
+ .ToLocalChecked()
+ .As<v8::Object>();
+ db->Set(context, name, value).FromJust();
+ info.GetReturnValue().Set(value);
+}
+}
+
+
+THREADED_TEST(NonMaskingInterceptorGlobalEvalRegression) {
+ auto isolate = CcTest::isolate();
+ v8::HandleScope handle_scope(isolate);
+ LocalContext context;
+
+ auto interceptor_templ = v8::ObjectTemplate::New(isolate);
+ v8::NamedPropertyHandlerConfiguration conf(DatabaseGetter, DatabaseSetter);
+ conf.flags = v8::PropertyHandlerFlags::kNonMasking;
+ interceptor_templ->SetHandler(conf);
+
+ context->Global()->Set(v8_str("intercepted_1"),
+ interceptor_templ->NewInstance());
+ context->Global()->Set(v8_str("intercepted_2"),
+ interceptor_templ->NewInstance());
+
+ // Init dbs.
+ CompileRun(
+ "intercepted_1.db = {};"
+ "intercepted_2.db = {};");
+
+ ExpectInt32(
+ "var obj = intercepted_1;"
+ "obj.x = 4;"
+ "eval('obj.x');"
+ "eval('obj.x');"
+ "eval('obj.x');"
+ "obj = intercepted_2;"
+ "obj.x = 9;"
+ "eval('obj.x');",
+ 9);
+}
« no previous file with comments | « src/ic/handler-compiler.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698