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

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

Issue 368783006: Treat ExecutableAccessorInfo as regular data properties. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 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
Index: test/cctest/test-api.cc
diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc
index 0b50181bcf8c70379b14c815bd05a15d03ba04c6..efaafc8fd7643a4b356b1c23603df689a7137f03 100644
--- a/test/cctest/test-api.cc
+++ b/test/cctest/test-api.cc
@@ -1924,7 +1924,7 @@ void AddAccessor(Handle<FunctionTemplate> templ,
Handle<String> name,
v8::AccessorGetterCallback getter,
v8::AccessorSetterCallback setter) {
- templ->PrototypeTemplate()->SetAccessor(name, getter, setter);
+ templ->InstanceTemplate()->SetAccessor(name, getter, setter);
}
void AddInterceptor(Handle<FunctionTemplate> templ,
@@ -1937,6 +1937,7 @@ void AddInterceptor(Handle<FunctionTemplate> templ,
THREADED_TEST(EmptyInterceptorDoesNotShadowAccessors) {
v8::HandleScope scope(CcTest::isolate());
Handle<FunctionTemplate> parent = FunctionTemplate::New(CcTest::isolate());
+ parent->SetHiddenPrototype(true);
Handle<FunctionTemplate> child = FunctionTemplate::New(CcTest::isolate());
child->Inherit(parent);
AddAccessor(parent, v8_str("age"),
@@ -1946,7 +1947,7 @@ THREADED_TEST(EmptyInterceptorDoesNotShadowAccessors) {
env->Global()->Set(v8_str("Child"), child->GetFunction());
CompileRun("var child = new Child;"
"child.age = 10;");
- ExpectBoolean("child.hasOwnProperty('age')", false);
+ ExpectBoolean("child.hasOwnProperty('age')", true);
ExpectInt32("child.age", 10);
ExpectInt32("child.accessor_age", 10);
}
@@ -9985,10 +9986,13 @@ THREADED_TEST(ShadowObject) {
LocalContext context(NULL, global_template);
Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New(isolate);
- t->InstanceTemplate()->SetNamedPropertyHandler(ShadowNamedGet);
- t->InstanceTemplate()->SetIndexedPropertyHandler(ShadowIndexedGet);
- Local<ObjectTemplate> proto = t->PrototypeTemplate();
+ t->SetHiddenPrototype(true);
+ Local<v8::FunctionTemplate> pt = v8::FunctionTemplate::New(isolate);
+ t->Inherit(pt);
+ Local<ObjectTemplate> proto = pt->PrototypeTemplate();
Local<ObjectTemplate> instance = t->InstanceTemplate();
+ instance->SetNamedPropertyHandler(ShadowNamedGet);
+ instance->SetIndexedPropertyHandler(ShadowIndexedGet);
proto->Set(v8_str("f"),
v8::FunctionTemplate::New(isolate,
@@ -18534,12 +18538,12 @@ void FooSetInterceptor(Local<String> name,
TEST(SetterOnConstructorPrototype) {
v8::Isolate* isolate = CcTest::isolate();
v8::HandleScope scope(isolate);
- Local<ObjectTemplate> templ = ObjectTemplate::New(isolate);
- templ->SetAccessor(v8_str("x"),
- GetterWhichReturns42,
- SetterWhichSetsYOnThisTo23);
+ Local<FunctionTemplate> templ = FunctionTemplate::New(isolate);
+ templ->SetHiddenPrototype(true);
+ templ->InstanceTemplate()->SetAccessor(
+ v8_str("x"), GetterWhichReturns42, SetterWhichSetsYOnThisTo23);
LocalContext context;
- context->Global()->Set(v8_str("P"), templ->NewInstance());
+ context->Global()->Set(v8_str("P"), templ->InstanceTemplate()->NewInstance());
CompileRun("function C1() {"
" this.x = 23;"
"};"
@@ -18561,8 +18565,7 @@ TEST(SetterOnConstructorPrototype) {
script = v8_compile("new C2();");
for (int i = 0; i < 10; i++) {
v8::Handle<v8::Object> c2 = v8::Handle<v8::Object>::Cast(script->Run());
- CHECK_EQ(42, c2->Get(v8_str("x"))->Int32Value());
- CHECK_EQ(23, c2->Get(v8_str("y"))->Int32Value());
+ CHECK_EQ(23, c2->Get(v8_str("x"))->Int32Value());
}
}
@@ -18648,11 +18651,11 @@ TEST(Regress618) {
}
// Use an API object with accessors as prototype.
- Local<ObjectTemplate> templ = ObjectTemplate::New(isolate);
- templ->SetAccessor(v8_str("x"),
- GetterWhichReturns42,
- SetterWhichSetsYOnThisTo23);
- context->Global()->Set(v8_str("P"), templ->NewInstance());
+ Local<FunctionTemplate> templ = FunctionTemplate::New(isolate);
+ templ->SetHiddenPrototype(true);
+ templ->InstanceTemplate()->SetAccessor(
+ v8_str("x"), GetterWhichReturns42, SetterWhichSetsYOnThisTo23);
+ context->Global()->Set(v8_str("P"), templ->InstanceTemplate()->NewInstance());
// This compile will get the code from the compilation cache.
CompileRun(source);
@@ -21066,13 +21069,15 @@ static void InstanceCheckedSetter(Local<String> name,
static void CheckInstanceCheckedResult(int getters,
int setters,
bool expects_callbacks,
+ bool is_setter,
TryCatch* try_catch) {
if (expects_callbacks) {
CHECK(!try_catch->HasCaught());
CHECK_EQ(getters, instance_checked_getter_count);
CHECK_EQ(setters, instance_checked_setter_count);
} else {
- CHECK(try_catch->HasCaught());
+ CHECK((is_setter && !try_catch->HasCaught()) ||
+ (!is_setter && try_catch->HasCaught()));
CHECK_EQ(0, instance_checked_getter_count);
CHECK_EQ(0, instance_checked_setter_count);
}
@@ -21087,33 +21092,38 @@ static void CheckInstanceCheckedAccessors(bool expects_callbacks) {
// Test path through generic runtime code.
CompileRun("obj.foo");
- CheckInstanceCheckedResult(1, 0, expects_callbacks, &try_catch);
+ CheckInstanceCheckedResult(1, 0, expects_callbacks, false, &try_catch);
CompileRun("obj.foo = 23");
- CheckInstanceCheckedResult(1, 1, expects_callbacks, &try_catch);
+ CheckInstanceCheckedResult(1, 1, expects_callbacks, true, &try_catch);
+ if (!expects_callbacks) CompileRun("delete obj.foo");
// Test path through generated LoadIC and StoredIC.
CompileRun("function test_get(o) { o.foo; }"
"test_get(obj);");
- CheckInstanceCheckedResult(2, 1, expects_callbacks, &try_catch);
+ CheckInstanceCheckedResult(2, 1, expects_callbacks, false, &try_catch);
CompileRun("test_get(obj);");
- CheckInstanceCheckedResult(3, 1, expects_callbacks, &try_catch);
+ CheckInstanceCheckedResult(3, 1, expects_callbacks, false, &try_catch);
CompileRun("test_get(obj);");
- CheckInstanceCheckedResult(4, 1, expects_callbacks, &try_catch);
+ CheckInstanceCheckedResult(4, 1, expects_callbacks, false, &try_catch);
CompileRun("function test_set(o) { o.foo = 23; }"
"test_set(obj);");
- CheckInstanceCheckedResult(4, 2, expects_callbacks, &try_catch);
+ CheckInstanceCheckedResult(4, 2, expects_callbacks, true, &try_catch);
+ if (!expects_callbacks) CompileRun("delete obj.foo");
CompileRun("test_set(obj);");
- CheckInstanceCheckedResult(4, 3, expects_callbacks, &try_catch);
+ CheckInstanceCheckedResult(4, 3, expects_callbacks, true, &try_catch);
+ if (!expects_callbacks) CompileRun("delete obj.foo");
CompileRun("test_set(obj);");
- CheckInstanceCheckedResult(4, 4, expects_callbacks, &try_catch);
+ CheckInstanceCheckedResult(4, 4, expects_callbacks, true, &try_catch);
+ if (!expects_callbacks) CompileRun("delete obj.foo");
// Test path through optimized code.
CompileRun("%OptimizeFunctionOnNextCall(test_get);"
"test_get(obj);");
- CheckInstanceCheckedResult(5, 4, expects_callbacks, &try_catch);
+ CheckInstanceCheckedResult(5, 4, expects_callbacks, false, &try_catch);
CompileRun("%OptimizeFunctionOnNextCall(test_set);"
"test_set(obj);");
- CheckInstanceCheckedResult(5, 5, expects_callbacks, &try_catch);
+ if (!expects_callbacks) CompileRun("delete obj.foo");
+ CheckInstanceCheckedResult(5, 5, expects_callbacks, true, &try_catch);
// Cleanup so that closures start out fresh in next check.
CompileRun("%DeoptimizeFunction(test_get);"
@@ -21185,14 +21195,20 @@ THREADED_TEST(InstanceCheckOnPrototypeAccessor) {
LocalContext context;
v8::HandleScope scope(context->GetIsolate());
- Local<FunctionTemplate> templ = FunctionTemplate::New(context->GetIsolate());
- Local<ObjectTemplate> proto = templ->PrototypeTemplate();
+ Local<FunctionTemplate> proto_templ =
+ FunctionTemplate::New(context->GetIsolate());
+ proto_templ->SetHiddenPrototype(true);
+ Local<ObjectTemplate> proto = proto_templ->InstanceTemplate();
proto->SetAccessor(v8_str("foo"),
InstanceCheckedGetter, InstanceCheckedSetter,
Handle<Value>(),
v8::DEFAULT,
v8::None,
- v8::AccessorSignature::New(context->GetIsolate(), templ));
+ v8::AccessorSignature::New(context->GetIsolate(),
+ proto_templ));
+ Local<FunctionTemplate> templ =
+ FunctionTemplate::New(context->GetIsolate());
+ templ->Inherit(proto_templ);
context->Global()->Set(v8_str("f"), templ->GetFunction());
printf("Testing positive ...\n");
« src/objects.cc ('K') | « src/objects.cc ('k') | test/mjsunit/es7/object-observe.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698