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 5641 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5652 } | 5652 } |
5653 | 5653 |
5654 | 5654 |
5655 TEST(AccessControlES5) { | 5655 TEST(AccessControlES5) { |
5656 v8::HandleScope handle_scope; | 5656 v8::HandleScope handle_scope; |
5657 v8::Handle<v8::ObjectTemplate> global_template = v8::ObjectTemplate::New(); | 5657 v8::Handle<v8::ObjectTemplate> global_template = v8::ObjectTemplate::New(); |
5658 | 5658 |
5659 global_template->SetAccessCheckCallbacks(NamedAccessBlocker, | 5659 global_template->SetAccessCheckCallbacks(NamedAccessBlocker, |
5660 IndexedAccessBlocker); | 5660 IndexedAccessBlocker); |
5661 | 5661 |
5662 // Add accessible accessor. | |
5663 global_template->SetAccessor( | |
5664 v8_str("accessible_prop"), | |
5665 EchoGetter, EchoSetter, | |
5666 v8::Handle<Value>(), | |
5667 v8::AccessControl(v8::ALL_CAN_READ | v8::ALL_CAN_WRITE)); | |
5668 | |
5669 | |
5662 // Add an accessor that is not accessible by cross-domain JS code. | 5670 // Add an accessor that is not accessible by cross-domain JS code. |
5663 global_template->SetAccessor(v8_str("blocked_prop"), | 5671 global_template->SetAccessor(v8_str("blocked_prop"), |
5664 UnreachableGetter, UnreachableSetter, | 5672 UnreachableGetter, UnreachableSetter, |
5665 v8::Handle<Value>(), | 5673 v8::Handle<Value>(), |
5666 v8::DEFAULT); | 5674 v8::DEFAULT); |
5667 | 5675 |
5668 // Create an environment | 5676 // Create an environment |
5669 v8::Persistent<Context> context0 = Context::New(NULL, global_template); | 5677 v8::Persistent<Context> context0 = Context::New(NULL, global_template); |
5670 context0->Enter(); | 5678 context0->Enter(); |
5671 | 5679 |
(...skipping 20 matching lines...) Expand all Loading... | |
5692 ExpectTrue("Object.isExtensible(other)"); | 5700 ExpectTrue("Object.isExtensible(other)"); |
5693 CompileRun("Object.preventExtensions(other)"); | 5701 CompileRun("Object.preventExtensions(other)"); |
5694 ExpectTrue("Object.isExtensible(other)"); | 5702 ExpectTrue("Object.isExtensible(other)"); |
5695 | 5703 |
5696 // Object.seal and Object.freeze. | 5704 // Object.seal and Object.freeze. |
5697 CompileRun("Object.freeze(other)"); | 5705 CompileRun("Object.freeze(other)"); |
5698 ExpectTrue("Object.isExtensible(other)"); | 5706 ExpectTrue("Object.isExtensible(other)"); |
5699 | 5707 |
5700 CompileRun("Object.seal(other)"); | 5708 CompileRun("Object.seal(other)"); |
5701 ExpectTrue("Object.isExtensible(other)"); | 5709 ExpectTrue("Object.isExtensible(other)"); |
5710 | |
5711 // Regression test for issue 1250. | |
5712 // Make sure that we can set the accessible accessors value using normal | |
5713 // assignment. | |
5714 CompileRun("other.accessible_prop = 42"); | |
5715 CHECK_EQ(42, g_echo_value); | |
5716 | |
5717 v8::Handle<Value> value; | |
Mads Ager (chromium)
2011/03/15 09:12:50
Add comment here saying something like: We follow
| |
5718 CompileRun("Object.defineProperty(other, 'accessible_prop', {value: -1})"); | |
5719 value = CompileRun("other.accessible_prop == 42"); | |
5720 CHECK(value->IsTrue()); | |
5702 } | 5721 } |
5703 | 5722 |
5704 | 5723 |
5705 static bool GetOwnPropertyNamesNamedBlocker(Local<v8::Object> global, | 5724 static bool GetOwnPropertyNamesNamedBlocker(Local<v8::Object> global, |
5706 Local<Value> name, | 5725 Local<Value> name, |
5707 v8::AccessType type, | 5726 v8::AccessType type, |
5708 Local<Value> data) { | 5727 Local<Value> data) { |
5709 return false; | 5728 return false; |
5710 } | 5729 } |
5711 | 5730 |
(...skipping 7196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
12908 v8::Handle<v8::Function> define_property = | 12927 v8::Handle<v8::Function> define_property = |
12909 CompileRun("(function() {" | 12928 CompileRun("(function() {" |
12910 " Object.defineProperty(" | 12929 " Object.defineProperty(" |
12911 " this," | 12930 " this," |
12912 " 1," | 12931 " 1," |
12913 " { configurable: true, enumerable: true, value: 3 });" | 12932 " { configurable: true, enumerable: true, value: 3 });" |
12914 "})").As<Function>(); | 12933 "})").As<Function>(); |
12915 context->DetachGlobal(); | 12934 context->DetachGlobal(); |
12916 define_property->Call(proxy, 0, NULL); | 12935 define_property->Call(proxy, 0, NULL); |
12917 } | 12936 } |
OLD | NEW |