| 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 454 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 465 | 465 |
| 466 | 466 |
| 467 static AccessType g_access_block_type = ACCESS_GET; | 467 static AccessType g_access_block_type = ACCESS_GET; |
| 468 | 468 |
| 469 | 469 |
| 470 static bool NamedAccessAllowUnlessBlocked(Local<Object> host, | 470 static bool NamedAccessAllowUnlessBlocked(Local<Object> host, |
| 471 Local<Value> key, | 471 Local<Value> key, |
| 472 AccessType type, | 472 AccessType type, |
| 473 Local<Value>) { | 473 Local<Value>) { |
| 474 if (type != g_access_block_type) return true; | 474 if (type != g_access_block_type) return true; |
| 475 Handle<Object> global = Context::GetCurrent()->Global(); | 475 v8::Isolate* isolate = reinterpret_cast<v8::Isolate*>( |
| 476 Utils::OpenHandle(*host)->GetIsolate()); |
| 477 Handle<Object> global = isolate->GetCurrentContext()->Global(); |
| 476 Handle<Value> blacklist = global->Get(String::New("blacklist")); | 478 Handle<Value> blacklist = global->Get(String::New("blacklist")); |
| 477 if (!blacklist->IsObject()) return true; | 479 if (!blacklist->IsObject()) return true; |
| 478 if (key->IsString()) return !blacklist.As<Object>()->Has(key); | 480 if (key->IsString()) return !blacklist.As<Object>()->Has(key); |
| 479 return true; | 481 return true; |
| 480 } | 482 } |
| 481 | 483 |
| 482 | 484 |
| 483 static bool IndexedAccessAllowUnlessBlocked(Local<Object> host, | 485 static bool IndexedAccessAllowUnlessBlocked(Local<Object> host, |
| 484 uint32_t index, | 486 uint32_t index, |
| 485 AccessType type, | 487 AccessType type, |
| 486 Local<Value>) { | 488 Local<Value>) { |
| 487 if (type != ACCESS_GET) return true; | 489 if (type != ACCESS_GET) return true; |
| 488 Handle<Object> global = Context::GetCurrent()->Global(); | 490 v8::Isolate* isolate = reinterpret_cast<v8::Isolate*>( |
| 491 Utils::OpenHandle(*host)->GetIsolate()); |
| 492 Handle<Object> global = isolate->GetCurrentContext()->Global(); |
| 489 Handle<Value> blacklist = global->Get(String::New("blacklist")); | 493 Handle<Value> blacklist = global->Get(String::New("blacklist")); |
| 490 if (!blacklist->IsObject()) return true; | 494 if (!blacklist->IsObject()) return true; |
| 491 return !blacklist.As<Object>()->Has(index); | 495 return !blacklist.As<Object>()->Has(index); |
| 492 } | 496 } |
| 493 | 497 |
| 494 | 498 |
| 495 static bool BlockAccessKeys(Local<Object> host, Local<Value> key, | 499 static bool BlockAccessKeys(Local<Object> host, Local<Value> key, |
| 496 AccessType type, Local<Value>) { | 500 AccessType type, Local<Value>) { |
| 497 Handle<Object> global = Context::GetCurrent()->Global(); | 501 v8::Isolate* isolate = reinterpret_cast<v8::Isolate*>( |
| 502 Utils::OpenHandle(*host)->GetIsolate()); |
| 503 Handle<Object> global = isolate->GetCurrentContext()->Global(); |
| 498 Handle<Value> blacklist = global->Get(String::New("blacklist")); | 504 Handle<Value> blacklist = global->Get(String::New("blacklist")); |
| 499 if (!blacklist->IsObject()) return true; | 505 if (!blacklist->IsObject()) return true; |
| 500 return type != ACCESS_KEYS || | 506 return type != ACCESS_KEYS || |
| 501 !blacklist.As<Object>()->Has(String::New("__block_access_keys")); | 507 !blacklist.As<Object>()->Has(String::New("__block_access_keys")); |
| 502 } | 508 } |
| 503 | 509 |
| 504 | 510 |
| 505 static Handle<Object> CreateAccessCheckedObject( | 511 static Handle<Object> CreateAccessCheckedObject( |
| 506 NamedSecurityCallback namedCallback, | 512 NamedSecurityCallback namedCallback, |
| 507 IndexedSecurityCallback indexedCallback) { | 513 IndexedSecurityCallback indexedCallback) { |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 710 instance->Set(String::New("foo"), String::New("bar")); | 716 instance->Set(String::New("foo"), String::New("bar")); |
| 711 CompileRun(""); // trigger delivery | 717 CompileRun(""); // trigger delivery |
| 712 const RecordExpectation expected_records2[] = { | 718 const RecordExpectation expected_records2[] = { |
| 713 { instance, "new", "5", Handle<Value>() }, | 719 { instance, "new", "5", Handle<Value>() }, |
| 714 { instance, "new", "foo", Handle<Value>() } | 720 { instance, "new", "foo", Handle<Value>() } |
| 715 }; | 721 }; |
| 716 EXPECT_RECORDS(CompileRun("records2"), expected_records2); | 722 EXPECT_RECORDS(CompileRun("records2"), expected_records2); |
| 717 } | 723 } |
| 718 CHECK(CompileRun("records")->IsNull()); | 724 CHECK(CompileRun("records")->IsNull()); |
| 719 } | 725 } |
| OLD | NEW |