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 5634 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5645 "return true;})()"); | 5645 "return true;})()"); |
5646 CHECK(value->IsTrue()); | 5646 CHECK(value->IsTrue()); |
5647 | 5647 |
5648 context1->Exit(); | 5648 context1->Exit(); |
5649 context0->Exit(); | 5649 context0->Exit(); |
5650 context1.Dispose(); | 5650 context1.Dispose(); |
5651 context0.Dispose(); | 5651 context0.Dispose(); |
5652 } | 5652 } |
5653 | 5653 |
5654 | 5654 |
5655 // This is a regression test for issue 1154. | 5655 TEST(AccessControlES5) { |
5656 TEST(AccessControlObjectKeys) { | |
5657 v8::HandleScope handle_scope; | 5656 v8::HandleScope handle_scope; |
5658 v8::Handle<v8::ObjectTemplate> global_template = v8::ObjectTemplate::New(); | 5657 v8::Handle<v8::ObjectTemplate> global_template = v8::ObjectTemplate::New(); |
5659 | 5658 |
5660 global_template->SetAccessCheckCallbacks(NamedAccessBlocker, | 5659 global_template->SetAccessCheckCallbacks(NamedAccessBlocker, |
5661 IndexedAccessBlocker); | 5660 IndexedAccessBlocker); |
5662 | 5661 |
5663 // Add an accessor that is not accessible by cross-domain JS code. | 5662 // Add an accessor that is not accessible by cross-domain JS code. |
5664 global_template->SetAccessor(v8_str("blocked_prop"), | 5663 global_template->SetAccessor(v8_str("blocked_prop"), |
5665 UnreachableGetter, UnreachableSetter, | 5664 UnreachableGetter, UnreachableSetter, |
5666 v8::Handle<Value>(), | 5665 v8::Handle<Value>(), |
5667 v8::DEFAULT); | 5666 v8::DEFAULT); |
5668 | 5667 |
5669 // Create an environment | 5668 // Create an environment |
5670 v8::Persistent<Context> context0 = Context::New(NULL, global_template); | 5669 v8::Persistent<Context> context0 = Context::New(NULL, global_template); |
5671 context0->Enter(); | 5670 context0->Enter(); |
5672 | 5671 |
5673 v8::Handle<v8::Object> global0 = context0->Global(); | 5672 v8::Handle<v8::Object> global0 = context0->Global(); |
5674 | 5673 |
5675 v8::Persistent<Context> context1 = Context::New(); | 5674 v8::Persistent<Context> context1 = Context::New(); |
5676 context1->Enter(); | 5675 context1->Enter(); |
5677 v8::Handle<v8::Object> global1 = context1->Global(); | 5676 v8::Handle<v8::Object> global1 = context1->Global(); |
5678 global1->Set(v8_str("other"), global0); | 5677 global1->Set(v8_str("other"), global0); |
5679 | 5678 |
5679 // Regression test for issue 1154. | |
5680 ExpectTrue("Object.keys(other).indexOf('blocked_prop') == -1"); | 5680 ExpectTrue("Object.keys(other).indexOf('blocked_prop') == -1"); |
5681 | |
5682 ExpectUndefined("other.blocked_prop"); | |
5683 | |
5684 // Regression test for issue 1027. | |
5685 ExpectUndefined( | |
5686 "Object.defineProperty(" | |
antonm
2011/02/17 15:44:12
feel free to ignore: I would group lines into some
Rico
2011/02/18 07:49:09
Done.
| |
5687 "other," | |
5688 "'blocked_prop'," | |
5689 "{configurable: false}" | |
5690 ").blocked_prop"); | |
antonm
2011/02/17 15:44:12
might be slightly easier for people not that exper
Rico
2011/02/18 07:49:09
Done.
| |
5691 ExpectUndefined( | |
5692 "Object.getOwnPropertyDescriptor(other, 'blocked_prop')"); | |
5693 | |
5694 // Regression test for issue 1171. | |
5695 ExpectTrue("Object.isExtensible(other)"); | |
5696 CompileRun("Object.preventExtensions(other)"); | |
5697 ExpectTrue("Object.isExtensible(other)"); | |
5698 | |
5699 // Seal and freeze uses other functions which already includes access | |
antonm
2011/02/17 15:44:12
function[s] hence include with not s, correct?
Rico
2011/02/18 07:49:09
Changed comment
| |
5700 // checks, but we check these anyway. | |
antonm
2011/02/17 15:44:12
and maybe you can just drop this comment
Rico
2011/02/18 07:49:09
Done.
| |
5701 CompileRun("Object.freeze(other)"); | |
5702 ExpectTrue("Object.isExtensible(other)"); | |
5703 | |
5704 CompileRun("Object.seal(other)"); | |
5705 ExpectTrue("Object.isExtensible(other)"); | |
5681 } | 5706 } |
5682 | 5707 |
5683 | 5708 |
5684 static bool GetOwnPropertyNamesNamedBlocker(Local<v8::Object> global, | 5709 static bool GetOwnPropertyNamesNamedBlocker(Local<v8::Object> global, |
5685 Local<Value> name, | 5710 Local<Value> name, |
5686 v8::AccessType type, | 5711 v8::AccessType type, |
5687 Local<Value> data) { | 5712 Local<Value> data) { |
5688 return false; | 5713 return false; |
5689 } | 5714 } |
5690 | 5715 |
(...skipping 7075 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
12766 v8::Handle<v8::Function> define_property = | 12791 v8::Handle<v8::Function> define_property = |
12767 CompileRun("(function() {" | 12792 CompileRun("(function() {" |
12768 " Object.defineProperty(" | 12793 " Object.defineProperty(" |
12769 " this," | 12794 " this," |
12770 " 1," | 12795 " 1," |
12771 " { configurable: true, enumerable: true, value: 3 });" | 12796 " { configurable: true, enumerable: true, value: 3 });" |
12772 "})").As<Function>(); | 12797 "})").As<Function>(); |
12773 context->DetachGlobal(); | 12798 context->DetachGlobal(); |
12774 define_property->Call(proxy, 0, NULL); | 12799 define_property->Call(proxy, 0, NULL); |
12775 } | 12800 } |
OLD | NEW |