OLD | NEW |
1 // Copyright 2007-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2007-2008 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 5430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5441 Local<ObjectTemplate> templ = ObjectTemplate::New(); | 5441 Local<ObjectTemplate> templ = ObjectTemplate::New(); |
5442 templ->SetAccessCheckCallbacks(NamedSetAccessBlocker, | 5442 templ->SetAccessCheckCallbacks(NamedSetAccessBlocker, |
5443 IndexedSetAccessBlocker); | 5443 IndexedSetAccessBlocker); |
5444 templ->Set(v8_str("x"), v8::True()); | 5444 templ->Set(v8_str("x"), v8::True()); |
5445 Local<v8::Object> instance = templ->NewInstance(); | 5445 Local<v8::Object> instance = templ->NewInstance(); |
5446 context->Global()->Set(v8_str("obj"), instance); | 5446 context->Global()->Set(v8_str("obj"), instance); |
5447 Local<Value> value = CompileRun("obj.x"); | 5447 Local<Value> value = CompileRun("obj.x"); |
5448 CHECK(value->BooleanValue()); | 5448 CHECK(value->BooleanValue()); |
5449 } | 5449 } |
5450 | 5450 |
| 5451 static bool NamedGetAccessBlocker(Local<v8::Object> obj, |
| 5452 Local<Value> name, |
| 5453 v8::AccessType type, |
| 5454 Local<Value> data) { |
| 5455 return false; |
| 5456 } |
| 5457 |
| 5458 |
| 5459 static bool IndexedGetAccessBlocker(Local<v8::Object> obj, |
| 5460 uint32_t key, |
| 5461 v8::AccessType type, |
| 5462 Local<Value> data) { |
| 5463 return false; |
| 5464 } |
| 5465 |
| 5466 |
| 5467 |
| 5468 THREADED_TEST(AccessChecksReenabledCorrectly) { |
| 5469 v8::HandleScope scope; |
| 5470 LocalContext context; |
| 5471 Local<ObjectTemplate> templ = ObjectTemplate::New(); |
| 5472 templ->SetAccessCheckCallbacks(NamedGetAccessBlocker, |
| 5473 IndexedGetAccessBlocker); |
| 5474 templ->Set(v8_str("a"), v8_str("a")); |
| 5475 // Add more than 8 (see kMaxFastProperties) properties |
| 5476 // so that the constructor will force copying map. |
| 5477 char buf[5]; |
| 5478 for (int i = 0; i < 999; i++) { |
| 5479 sprintf(buf, "x%3d", i); |
| 5480 buf[4] = 0; |
| 5481 templ->Set(v8_str(buf), v8::Number::New(i)); |
| 5482 } |
| 5483 |
| 5484 Local<v8::Object> instance_1 = templ->NewInstance(); |
| 5485 context->Global()->Set(v8_str("obj_1"), instance_1); |
| 5486 |
| 5487 Local<Value> value_1 = CompileRun("obj_1.a"); |
| 5488 CHECK(value_1->IsUndefined()); |
| 5489 |
| 5490 Local<v8::Object> instance_2 = templ->NewInstance(); |
| 5491 context->Global()->Set(v8_str("obj_2"), instance_2); |
| 5492 |
| 5493 Local<Value> value_2 = CompileRun("obj_2.a"); |
| 5494 CHECK(value_2->IsUndefined()); |
| 5495 } |
5451 | 5496 |
5452 // This tests that access check information remains on the global | 5497 // This tests that access check information remains on the global |
5453 // object template when creating contexts. | 5498 // object template when creating contexts. |
5454 THREADED_TEST(AccessControlRepeatedContextCreation) { | 5499 THREADED_TEST(AccessControlRepeatedContextCreation) { |
5455 v8::HandleScope handle_scope; | 5500 v8::HandleScope handle_scope; |
5456 v8::Handle<v8::ObjectTemplate> global_template = v8::ObjectTemplate::New(); | 5501 v8::Handle<v8::ObjectTemplate> global_template = v8::ObjectTemplate::New(); |
5457 global_template->SetAccessCheckCallbacks(NamedSetAccessBlocker, | 5502 global_template->SetAccessCheckCallbacks(NamedSetAccessBlocker, |
5458 IndexedSetAccessBlocker); | 5503 IndexedSetAccessBlocker); |
5459 i::Handle<i::ObjectTemplateInfo> internal_template = | 5504 i::Handle<i::ObjectTemplateInfo> internal_template = |
5460 v8::Utils::OpenHandle(*global_template); | 5505 v8::Utils::OpenHandle(*global_template); |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5548 CompileRun("for (var j = 0; j < 10; j++) new RegExp('');"); | 5593 CompileRun("for (var j = 0; j < 10; j++) new RegExp('');"); |
5549 } | 5594 } |
5550 // Test CallIC. | 5595 // Test CallIC. |
5551 for (int i = 0; i < 2; i++) { | 5596 for (int i = 0; i < 2; i++) { |
5552 LocalContext context; | 5597 LocalContext context; |
5553 context->Global()->Set(v8_str("tmp"), v8::True()); | 5598 context->Global()->Set(v8_str("tmp"), v8::True()); |
5554 context->Global()->Delete(v8_str("tmp")); | 5599 context->Global()->Delete(v8_str("tmp")); |
5555 CompileRun("for (var j = 0; j < 10; j++) RegExp('')"); | 5600 CompileRun("for (var j = 0; j < 10; j++) RegExp('')"); |
5556 } | 5601 } |
5557 } | 5602 } |
OLD | NEW |