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

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: Fix bot failure 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
« no previous file with comments | « 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 f8edb2b5a444304a99c35224a6e859442d9c039f..e4fcf4ad1464c48e9857b47a5273e2ba3e0f9531 100644
--- a/test/cctest/test-api.cc
+++ b/test/cctest/test-api.cc
@@ -21921,3 +21921,36 @@ TEST(AccessCheckedIsConcatSpreadable) {
ExpectTrue("result.length === 1");
ExpectTrue("object[Symbol.isConcatSpreadable] === undefined");
}
+
+
+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);
+ }
+}
« no previous file with comments | « src/objects.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698