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 5429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5440 templ->SetAccessCheckCallbacks(NamedSetAccessBlocker, | 5440 templ->SetAccessCheckCallbacks(NamedSetAccessBlocker, |
5441 IndexedSetAccessBlocker); | 5441 IndexedSetAccessBlocker); |
5442 templ->Set(v8_str("x"), v8::True()); | 5442 templ->Set(v8_str("x"), v8::True()); |
5443 Local<v8::Object> instance = templ->NewInstance(); | 5443 Local<v8::Object> instance = templ->NewInstance(); |
5444 context->Global()->Set(v8_str("obj"), instance); | 5444 context->Global()->Set(v8_str("obj"), instance); |
5445 Local<Value> value = CompileRun("obj.x"); | 5445 Local<Value> value = CompileRun("obj.x"); |
5446 CHECK(value->BooleanValue()); | 5446 CHECK(value->BooleanValue()); |
5447 } | 5447 } |
5448 | 5448 |
5449 | 5449 |
| 5450 // This tests that access check information remains on the global |
| 5451 // object template when creating contexts. |
| 5452 THREADED_TEST(AccessControlRepeatedContextCreation) { |
| 5453 v8::HandleScope handle_scope; |
| 5454 v8::Handle<v8::ObjectTemplate> global_template = v8::ObjectTemplate::New(); |
| 5455 global_template->SetAccessCheckCallbacks(NamedSetAccessBlocker, |
| 5456 IndexedSetAccessBlocker); |
| 5457 i::Handle<i::ObjectTemplateInfo> internal_template = |
| 5458 v8::Utils::OpenHandle(*global_template); |
| 5459 CHECK(!internal_template->constructor()->IsUndefined()); |
| 5460 i::Handle<i::FunctionTemplateInfo> constructor( |
| 5461 i::FunctionTemplateInfo::cast(internal_template->constructor())); |
| 5462 CHECK(!constructor->access_check_info()->IsUndefined()); |
| 5463 v8::Persistent<Context> context0 = Context::New(NULL, global_template); |
| 5464 CHECK(!constructor->access_check_info()->IsUndefined()); |
| 5465 } |
| 5466 |
| 5467 |
5450 static String::ExternalStringResource* SymbolCallback(const char* chars, | 5468 static String::ExternalStringResource* SymbolCallback(const char* chars, |
5451 size_t length) { | 5469 size_t length) { |
5452 uint16_t* buffer = i::NewArray<uint16_t>(length + 1); | 5470 uint16_t* buffer = i::NewArray<uint16_t>(length + 1); |
5453 for (size_t i = 0; i < length; i++) { | 5471 for (size_t i = 0; i < length; i++) { |
5454 buffer[i] = chars[i]; | 5472 buffer[i] = chars[i]; |
5455 } | 5473 } |
5456 buffer[length] = '\0'; | 5474 buffer[length] = '\0'; |
5457 return new TestResource(buffer); | 5475 return new TestResource(buffer); |
5458 } | 5476 } |
5459 | 5477 |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5528 CompileRun("for (var j = 0; j < 10; j++) new RegExp('');"); | 5546 CompileRun("for (var j = 0; j < 10; j++) new RegExp('');"); |
5529 } | 5547 } |
5530 // Test CallIC. | 5548 // Test CallIC. |
5531 for (int i = 0; i < 2; i++) { | 5549 for (int i = 0; i < 2; i++) { |
5532 LocalContext context; | 5550 LocalContext context; |
5533 context->Global()->Set(v8_str("tmp"), v8::True()); | 5551 context->Global()->Set(v8_str("tmp"), v8::True()); |
5534 context->Global()->Delete(v8_str("tmp")); | 5552 context->Global()->Delete(v8_str("tmp")); |
5535 CompileRun("for (var j = 0; j < 10; j++) RegExp('')"); | 5553 CompileRun("for (var j = 0; j < 10; j++) RegExp('')"); |
5536 } | 5554 } |
5537 } | 5555 } |
OLD | NEW |