| OLD | NEW |
| 1 // Copyright 2007-2009 the V8 project authors. All rights reserved. | 1 // Copyright 2007-2009 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 5353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5364 | 5364 |
| 5365 v8::Persistent<Context> context1 = Context::New(); | 5365 v8::Persistent<Context> context1 = Context::New(); |
| 5366 context1->Enter(); | 5366 context1->Enter(); |
| 5367 | 5367 |
| 5368 v8::Handle<v8::Object> global1 = context1->Global(); | 5368 v8::Handle<v8::Object> global1 = context1->Global(); |
| 5369 global1->Set(v8_str("other"), global0); | 5369 global1->Set(v8_str("other"), global0); |
| 5370 | 5370 |
| 5371 v8::Handle<Value> value; | 5371 v8::Handle<Value> value; |
| 5372 | 5372 |
| 5373 // Access blocked property | 5373 // Access blocked property |
| 5374 value = v8_compile("other.blocked_prop = 1")->Run(); | 5374 value = CompileRun("other.blocked_prop = 1"); |
| 5375 value = v8_compile("other.blocked_prop")->Run(); | 5375 value = CompileRun("other.blocked_prop"); |
| 5376 CHECK(value->IsUndefined()); | 5376 CHECK(value->IsUndefined()); |
| 5377 | 5377 |
| 5378 value = v8_compile("propertyIsEnumerable.call(other, 'blocked_prop')")->Run(); | 5378 value = CompileRun( |
| 5379 "Object.getOwnPropertyDescriptor(other, 'blocked_prop').value"); |
| 5380 CHECK(value->IsUndefined()); |
| 5381 |
| 5382 value = CompileRun("propertyIsEnumerable.call(other, 'blocked_prop')"); |
| 5379 CHECK(value->IsFalse()); | 5383 CHECK(value->IsFalse()); |
| 5380 | 5384 |
| 5381 // Access accessible property | 5385 // Access accessible property |
| 5382 value = v8_compile("other.accessible_prop = 3")->Run(); | 5386 value = CompileRun("other.accessible_prop = 3"); |
| 5383 CHECK(value->IsNumber()); | 5387 CHECK(value->IsNumber()); |
| 5384 CHECK_EQ(3, value->Int32Value()); | 5388 CHECK_EQ(3, value->Int32Value()); |
| 5385 CHECK_EQ(3, g_echo_value); | 5389 CHECK_EQ(3, g_echo_value); |
| 5386 | 5390 |
| 5387 value = v8_compile("other.accessible_prop")->Run(); | 5391 value = CompileRun("other.accessible_prop"); |
| 5388 CHECK(value->IsNumber()); | 5392 CHECK(value->IsNumber()); |
| 5389 CHECK_EQ(3, value->Int32Value()); | 5393 CHECK_EQ(3, value->Int32Value()); |
| 5390 | 5394 |
| 5391 value = | 5395 value = CompileRun( |
| 5392 v8_compile("propertyIsEnumerable.call(other, 'accessible_prop')")->Run(); | 5396 "Object.getOwnPropertyDescriptor(other, 'accessible_prop').value"); |
| 5397 CHECK(value->IsNumber()); |
| 5398 CHECK_EQ(3, value->Int32Value()); |
| 5399 |
| 5400 value = CompileRun("propertyIsEnumerable.call(other, 'accessible_prop')"); |
| 5393 CHECK(value->IsTrue()); | 5401 CHECK(value->IsTrue()); |
| 5394 | 5402 |
| 5395 // Enumeration doesn't enumerate accessors from inaccessible objects in | 5403 // Enumeration doesn't enumerate accessors from inaccessible objects in |
| 5396 // the prototype chain even if the accessors are in themselves accessible. | 5404 // the prototype chain even if the accessors are in themselves accessible. |
| 5397 Local<Value> result = | 5405 value = |
| 5398 CompileRun("(function(){var obj = {'__proto__':other};" | 5406 CompileRun("(function(){var obj = {'__proto__':other};" |
| 5399 "for (var p in obj)" | 5407 "for (var p in obj)" |
| 5400 " if (p == 'accessible_prop' || p == 'blocked_prop') {" | 5408 " if (p == 'accessible_prop' || p == 'blocked_prop') {" |
| 5401 " return false;" | 5409 " return false;" |
| 5402 " }" | 5410 " }" |
| 5403 "return true;})()"); | 5411 "return true;})()"); |
| 5404 CHECK(result->IsTrue()); | 5412 CHECK(value->IsTrue()); |
| 5405 | 5413 |
| 5406 context1->Exit(); | 5414 context1->Exit(); |
| 5407 context0->Exit(); | 5415 context0->Exit(); |
| 5408 context1.Dispose(); | 5416 context1.Dispose(); |
| 5409 context0.Dispose(); | 5417 context0.Dispose(); |
| 5410 } | 5418 } |
| 5411 | 5419 |
| 5412 | 5420 |
| 5413 static bool GetOwnPropertyNamesNamedBlocker(Local<v8::Object> global, | 5421 static bool GetOwnPropertyNamesNamedBlocker(Local<v8::Object> global, |
| 5414 Local<Value> name, | 5422 Local<Value> name, |
| (...skipping 6795 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12210 v8::Context::Scope context_scope(context.local()); | 12218 v8::Context::Scope context_scope(context.local()); |
| 12211 | 12219 |
| 12212 v8::Handle<v8::ObjectTemplate> tmpl = v8::ObjectTemplate::New(); | 12220 v8::Handle<v8::ObjectTemplate> tmpl = v8::ObjectTemplate::New(); |
| 12213 tmpl->SetNamedPropertyHandler(Getter, NULL, NULL, NULL, Enumerator); | 12221 tmpl->SetNamedPropertyHandler(Getter, NULL, NULL, NULL, Enumerator); |
| 12214 context->Global()->Set(v8_str("o"), tmpl->NewInstance()); | 12222 context->Global()->Set(v8_str("o"), tmpl->NewInstance()); |
| 12215 v8::Handle<v8::Array> result = v8::Handle<v8::Array>::Cast(CompileRun( | 12223 v8::Handle<v8::Array> result = v8::Handle<v8::Array>::Cast(CompileRun( |
| 12216 "var result = []; for (var k in o) result.push(k); result")); | 12224 "var result = []; for (var k in o) result.push(k); result")); |
| 12217 CHECK_EQ(1, result->Length()); | 12225 CHECK_EQ(1, result->Length()); |
| 12218 CHECK_EQ(v8_str("universalAnswer"), result->Get(0)); | 12226 CHECK_EQ(v8_str("universalAnswer"), result->Get(0)); |
| 12219 } | 12227 } |
| OLD | NEW |