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

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

Issue 7229007: Add possibility to configure 'prototype' property via FunctionTemplate (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: . Created 9 years, 6 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.cc ('K') | « src/objects-inl.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 e0bcbc92cfabfcdace40f8c63937d20167879516..6b6befb88b57f77603344048061514edb3f02605 100644
--- a/test/cctest/test-api.cc
+++ b/test/cctest/test-api.cc
@@ -6842,6 +6842,47 @@ THREADED_TEST(SetPrototype) {
}
+THREADED_TEST(SetPrototypeProperties) {
+ ASSERT(i::FunctionTemplateInfo::kPrototypePropertiesOffset ==
Mads Ager (chromium) 2011/06/22 12:13:46 This assert seems like an internal detail that we
Jakob Kummerow 2011/06/22 12:36:59 Done. Removed.
+ 15*i::kPointerSize + i::HeapObject::kHeaderSize);
+ v8::HandleScope handle_scope;
+ LocalContext context;
+
+ Local<v8::FunctionTemplate> t1 = v8::FunctionTemplate::New();
+ t1->SetPrototypeProperties(v8::DontDelete);
+ context->Global()->Set(v8_str("func1"), t1->GetFunction());
+ CHECK(CompileRun(
+ "(function() {"
+ " descriptor = Object.getOwnPropertyDescriptor(func1, 'prototype');"
+ " return (descriptor['writable'] == true) &&"
+ " (descriptor['enumerable'] == true) &&"
+ " (descriptor['configurable'] == false);"
+ "})()")->BooleanValue());
+
+ Local<v8::FunctionTemplate> t2 = v8::FunctionTemplate::New();
+ t2->SetPrototypeProperties(v8::DontEnum);
+ context->Global()->Set(v8_str("func2"), t2->GetFunction());
+ CHECK(CompileRun(
+ "(function() {"
+ " descriptor = Object.getOwnPropertyDescriptor(func2, 'prototype');"
+ " return (descriptor['writable'] == true) &&"
+ " (descriptor['enumerable'] == false) &&"
+ " (descriptor['configurable'] == true);"
+ "})()")->BooleanValue());
+
+ Local<v8::FunctionTemplate> t3 = v8::FunctionTemplate::New();
+ t3->SetPrototypeProperties(v8::ReadOnly);
+ context->Global()->Set(v8_str("func3"), t3->GetFunction());
+ CHECK(CompileRun(
+ "(function() {"
+ " descriptor = Object.getOwnPropertyDescriptor(func3, 'prototype');"
+ " return (descriptor['writable'] == false) &&"
+ " (descriptor['enumerable'] == true) &&"
+ " (descriptor['configurable'] == true);"
+ "})()")->BooleanValue());
+}
Mads Ager (chromium) 2011/06/22 12:13:46 Let's add a test for the combination of all three
Jakob Kummerow 2011/06/22 12:36:59 Done.
+
+
THREADED_TEST(SetPrototypeThrows) {
v8::HandleScope handle_scope;
LocalContext context;
« src/api.cc ('K') | « src/objects-inl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698