OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 8215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8226 | 8226 |
8227 // Getting the prototype of o0 should get the first visible one | 8227 // Getting the prototype of o0 should get the first visible one |
8228 // which is o3. Therefore, z should not be defined on the prototype | 8228 // which is o3. Therefore, z should not be defined on the prototype |
8229 // object. | 8229 // object. |
8230 Local<Value> proto = o0->Get(v8_str("__proto__")); | 8230 Local<Value> proto = o0->Get(v8_str("__proto__")); |
8231 CHECK(proto->IsObject()); | 8231 CHECK(proto->IsObject()); |
8232 CHECK(proto.As<v8::Object>()->Get(v8_str("z"))->IsUndefined()); | 8232 CHECK(proto.As<v8::Object>()->Get(v8_str("z"))->IsUndefined()); |
8233 } | 8233 } |
8234 | 8234 |
8235 | 8235 |
| 8236 THREADED_TEST(HiddenPrototypeSet) { |
| 8237 v8::HandleScope handle_scope; |
| 8238 LocalContext context; |
| 8239 |
| 8240 Local<v8::FunctionTemplate> ot = v8::FunctionTemplate::New(); |
| 8241 Local<v8::FunctionTemplate> ht = v8::FunctionTemplate::New(); |
| 8242 ht->SetHiddenPrototype(true); |
| 8243 Local<v8::FunctionTemplate> pt = v8::FunctionTemplate::New(); |
| 8244 ht->InstanceTemplate()->Set(v8_str("x"), v8_num(0)); |
| 8245 |
| 8246 Local<v8::Object> o = ot->GetFunction()->NewInstance(); |
| 8247 Local<v8::Object> h = ht->GetFunction()->NewInstance(); |
| 8248 Local<v8::Object> p = pt->GetFunction()->NewInstance(); |
| 8249 o->Set(v8_str("__proto__"), h); |
| 8250 h->Set(v8_str("__proto__"), p); |
| 8251 |
| 8252 // Setting a property that exists on the hidden prototype goes there. |
| 8253 o->Set(v8_str("x"), v8_num(7)); |
| 8254 CHECK_EQ(7, o->Get(v8_str("x"))->Int32Value()); |
| 8255 CHECK_EQ(7, h->Get(v8_str("x"))->Int32Value()); |
| 8256 CHECK(p->Get(v8_str("x"))->IsUndefined()); |
| 8257 |
| 8258 // Setting a new property should not be forwarded to the hidden prototype. |
| 8259 o->Set(v8_str("y"), v8_num(6)); |
| 8260 CHECK_EQ(6, o->Get(v8_str("y"))->Int32Value()); |
| 8261 CHECK(h->Get(v8_str("y"))->IsUndefined()); |
| 8262 CHECK(p->Get(v8_str("y"))->IsUndefined()); |
| 8263 |
| 8264 // Setting a property that only exists on a prototype of the hidden prototype |
| 8265 // is treated normally again. |
| 8266 p->Set(v8_str("z"), v8_num(8)); |
| 8267 CHECK_EQ(8, o->Get(v8_str("z"))->Int32Value()); |
| 8268 CHECK_EQ(8, h->Get(v8_str("z"))->Int32Value()); |
| 8269 CHECK_EQ(8, p->Get(v8_str("z"))->Int32Value()); |
| 8270 o->Set(v8_str("z"), v8_num(9)); |
| 8271 CHECK_EQ(9, o->Get(v8_str("z"))->Int32Value()); |
| 8272 CHECK_EQ(8, h->Get(v8_str("z"))->Int32Value()); |
| 8273 CHECK_EQ(8, p->Get(v8_str("z"))->Int32Value()); |
| 8274 } |
| 8275 |
| 8276 |
| 8277 // Regression test for issue 2457. |
| 8278 THREADED_TEST(HiddenPrototypeIdentityHash) { |
| 8279 v8::HandleScope handle_scope; |
| 8280 LocalContext context; |
| 8281 |
| 8282 Handle<FunctionTemplate> t = FunctionTemplate::New(); |
| 8283 t->SetHiddenPrototype(true); |
| 8284 t->InstanceTemplate()->Set(v8_str("foo"), v8_num(75)); |
| 8285 Handle<Object> p = t->GetFunction()->NewInstance(); |
| 8286 Handle<Object> o = Object::New(); |
| 8287 o->SetPrototype(p); |
| 8288 |
| 8289 int hash = o->GetIdentityHash(); |
| 8290 USE(hash); |
| 8291 o->Set(v8_str("foo"), v8_num(42)); |
| 8292 ASSERT_EQ(hash, o->GetIdentityHash()); |
| 8293 } |
| 8294 |
| 8295 |
8236 THREADED_TEST(SetPrototype) { | 8296 THREADED_TEST(SetPrototype) { |
8237 v8::HandleScope handle_scope; | 8297 v8::HandleScope handle_scope; |
8238 LocalContext context; | 8298 LocalContext context; |
8239 | 8299 |
8240 Local<v8::FunctionTemplate> t0 = v8::FunctionTemplate::New(); | 8300 Local<v8::FunctionTemplate> t0 = v8::FunctionTemplate::New(); |
8241 t0->InstanceTemplate()->Set(v8_str("x"), v8_num(0)); | 8301 t0->InstanceTemplate()->Set(v8_str("x"), v8_num(0)); |
8242 Local<v8::FunctionTemplate> t1 = v8::FunctionTemplate::New(); | 8302 Local<v8::FunctionTemplate> t1 = v8::FunctionTemplate::New(); |
8243 t1->SetHiddenPrototype(true); | 8303 t1->SetHiddenPrototype(true); |
8244 t1->InstanceTemplate()->Set(v8_str("y"), v8_num(1)); | 8304 t1->InstanceTemplate()->Set(v8_str("y"), v8_num(1)); |
8245 Local<v8::FunctionTemplate> t2 = v8::FunctionTemplate::New(); | 8305 Local<v8::FunctionTemplate> t2 = v8::FunctionTemplate::New(); |
(...skipping 9883 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
18129 | 18189 |
18130 i::Semaphore* sem_; | 18190 i::Semaphore* sem_; |
18131 volatile int sem_value_; | 18191 volatile int sem_value_; |
18132 }; | 18192 }; |
18133 | 18193 |
18134 | 18194 |
18135 THREADED_TEST(SemaphoreInterruption) { | 18195 THREADED_TEST(SemaphoreInterruption) { |
18136 ThreadInterruptTest().RunTest(); | 18196 ThreadInterruptTest().RunTest(); |
18137 } | 18197 } |
18138 #endif // WIN32 | 18198 #endif // WIN32 |
OLD | NEW |