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 4106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4117 "return true;})()"); | 4117 "return true;})()"); |
4118 CHECK(result->IsTrue()); | 4118 CHECK(result->IsTrue()); |
4119 | 4119 |
4120 context1->Exit(); | 4120 context1->Exit(); |
4121 context0->Exit(); | 4121 context0->Exit(); |
4122 context1.Dispose(); | 4122 context1.Dispose(); |
4123 context0.Dispose(); | 4123 context0.Dispose(); |
4124 } | 4124 } |
4125 | 4125 |
4126 | 4126 |
| 4127 static bool GetOwnPropertyNamesNamedBlocker(Local<v8::Object> global, |
| 4128 Local<Value> name, |
| 4129 v8::AccessType type, |
| 4130 Local<Value> data) { |
| 4131 return false; |
| 4132 } |
| 4133 |
| 4134 |
| 4135 static bool GetOwnPropertyNamesIndexedBlocker(Local<v8::Object> global, |
| 4136 uint32_t key, |
| 4137 v8::AccessType type, |
| 4138 Local<Value> data) { |
| 4139 return false; |
| 4140 } |
| 4141 |
| 4142 |
| 4143 THREADED_TEST(AccessControlGetOwnPropertyNames) { |
| 4144 v8::HandleScope handle_scope; |
| 4145 v8::Handle<v8::ObjectTemplate> obj_template = v8::ObjectTemplate::New(); |
| 4146 |
| 4147 obj_template->Set(v8_str("x"), v8::Integer::New(42)); |
| 4148 obj_template->SetAccessCheckCallbacks(GetOwnPropertyNamesNamedBlocker, |
| 4149 GetOwnPropertyNamesIndexedBlocker); |
| 4150 |
| 4151 // Create an environment |
| 4152 v8::Persistent<Context> context0 = Context::New(NULL, obj_template); |
| 4153 context0->Enter(); |
| 4154 |
| 4155 v8::Handle<v8::Object> global0 = context0->Global(); |
| 4156 |
| 4157 v8::HandleScope scope1; |
| 4158 |
| 4159 v8::Persistent<Context> context1 = Context::New(); |
| 4160 context1->Enter(); |
| 4161 |
| 4162 v8::Handle<v8::Object> global1 = context1->Global(); |
| 4163 global1->Set(v8_str("other"), global0); |
| 4164 global1->Set(v8_str("object"), obj_template->NewInstance()); |
| 4165 |
| 4166 v8::Handle<Value> value; |
| 4167 |
| 4168 // Attempt to get the property names of the other global object and |
| 4169 // of an object that requires access checks. Accessing the other |
| 4170 // global object should be blocked by access checks on the global |
| 4171 // proxy object. Accessing the object that requires access checks |
| 4172 // is blocked by the access checks on the object itself. |
| 4173 value = CompileRun("Object.getOwnPropertyNames(other).length == 0"); |
| 4174 CHECK(value->IsTrue()); |
| 4175 |
| 4176 value = CompileRun("Object.getOwnPropertyNames(object).length == 0"); |
| 4177 CHECK(value->IsTrue()); |
| 4178 |
| 4179 context1->Exit(); |
| 4180 context0->Exit(); |
| 4181 context1.Dispose(); |
| 4182 context0.Dispose(); |
| 4183 } |
| 4184 |
| 4185 |
4127 static v8::Handle<Value> ConstTenGetter(Local<String> name, | 4186 static v8::Handle<Value> ConstTenGetter(Local<String> name, |
4128 const AccessorInfo& info) { | 4187 const AccessorInfo& info) { |
4129 return v8_num(10); | 4188 return v8_num(10); |
4130 } | 4189 } |
4131 | 4190 |
4132 | 4191 |
4133 THREADED_TEST(CrossDomainAccessors) { | 4192 THREADED_TEST(CrossDomainAccessors) { |
4134 v8::HandleScope handle_scope; | 4193 v8::HandleScope handle_scope; |
4135 | 4194 |
4136 v8::Handle<v8::FunctionTemplate> func_template = v8::FunctionTemplate::New(); | 4195 v8::Handle<v8::FunctionTemplate> func_template = v8::FunctionTemplate::New(); |
(...skipping 4626 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8763 CompileRun(source_exception); | 8822 CompileRun(source_exception); |
8764 other_context->Exit(); | 8823 other_context->Exit(); |
8765 v8::internal::Heap::CollectAllGarbage(false); | 8824 v8::internal::Heap::CollectAllGarbage(false); |
8766 if (GetGlobalObjectsCount() == 1) break; | 8825 if (GetGlobalObjectsCount() == 1) break; |
8767 } | 8826 } |
8768 CHECK_GE(2, gc_count); | 8827 CHECK_GE(2, gc_count); |
8769 CHECK_EQ(1, GetGlobalObjectsCount()); | 8828 CHECK_EQ(1, GetGlobalObjectsCount()); |
8770 | 8829 |
8771 other_context.Dispose(); | 8830 other_context.Dispose(); |
8772 } | 8831 } |
OLD | NEW |