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

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

Issue 1409593002: [api] expose API for adding per-context Intrinsics to Templates (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 2 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
« src/api-natives.cc ('K') | « src/objects.h ('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.cc
diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc
index 06582526af8d8ea70bb246f3cc1fe16e82f052a1..a39d28888794159bf004eac1588b1872dc1b05df 100644
--- a/test/cctest/test-api.cc
+++ b/test/cctest/test-api.cc
@@ -21946,3 +21946,36 @@ TEST(ArrayIteratorMethods) {
ExpectString("typeof values", "function");
ExpectString("typeof entries", "function");
}
+
+
+TEST(ObjectTemplateIntrinsics) {
+ v8::Isolate* isolate = CcTest::isolate();
+ v8::HandleScope scope(isolate);
+ LocalContext env;
+
+ Local<ObjectTemplate> object_template = v8::ObjectTemplate::New(isolate);
+ object_template->SetIntrinsicDataProperty(v8_str("values"),
+ v8::kArrayProto_values);
+ Local<Object> object = object_template->NewInstance();
+
+ env->Global()->Set(v8_str("obj1"), object);
+ ExpectString("typeof obj1.values", "function");
+
+ auto values = Local<Function>::Cast(object->Get(v8_str("values")));
+ auto fn = v8::Utils::OpenHandle(*values);
+ auto ctx = v8::Utils::OpenHandle(*env.local());
+ CHECK_EQ(fn->GetCreationContext(), *ctx);
+
+ {
+ LocalContext env2;
+ Local<Object> object2 = object_template->NewInstance();
+ env2->Global()->Set(v8_str("obj2"), object2);
+ ExpectString("typeof obj2.values", "function");
+ CHECK_NE(*object->Get(v8_str("values")), *object2->Get(v8_str("values")));
+
+ auto values2 = Local<Function>::Cast(object2->Get(v8_str("values")));
+ auto fn2 = v8::Utils::OpenHandle(*values2);
+ auto ctx2 = v8::Utils::OpenHandle(*env2.local());
+ CHECK_EQ(fn2->GetCreationContext(), *ctx2);
+ }
+}
« src/api-natives.cc ('K') | « src/objects.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698