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