| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 8122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8133 // Change env2 to a different domain and test again. | 8133 // Change env2 to a different domain and test again. |
| 8134 env2->SetSecurityToken(bar); | 8134 env2->SetSecurityToken(bar); |
| 8135 { | 8135 { |
| 8136 Context::Scope scope_env2(env2); | 8136 Context::Scope scope_env2(env2); |
| 8137 Local<Value> result = CompileRun(test); | 8137 Local<Value> result = CompileRun(test); |
| 8138 CHECK(result.IsEmpty()); | 8138 CHECK(result.IsEmpty()); |
| 8139 } | 8139 } |
| 8140 } | 8140 } |
| 8141 | 8141 |
| 8142 | 8142 |
| 8143 THREADED_TEST(CrossDomainForIn) { | 8143 THREADED_TEST(CrossDomainFor) { |
| 8144 LocalContext env1; | 8144 LocalContext env1; |
| 8145 v8::HandleScope handle_scope(env1->GetIsolate()); | 8145 v8::HandleScope handle_scope(env1->GetIsolate()); |
| 8146 v8::Handle<Context> env2 = Context::New(env1->GetIsolate()); | 8146 v8::Handle<Context> env2 = Context::New(env1->GetIsolate()); |
| 8147 | 8147 |
| 8148 Local<Value> foo = v8_str("foo"); | 8148 Local<Value> foo = v8_str("foo"); |
| 8149 Local<Value> bar = v8_str("bar"); | 8149 Local<Value> bar = v8_str("bar"); |
| 8150 | 8150 |
| 8151 // Set to the same domain. | 8151 // Set to the same domain. |
| 8152 env1->SetSecurityToken(foo); | 8152 env1->SetSecurityToken(foo); |
| 8153 env2->SetSecurityToken(foo); | 8153 env2->SetSecurityToken(foo); |
| 8154 | 8154 |
| 8155 env1->Global()->Set(v8_str("prop"), v8_num(3)); | 8155 env1->Global()->Set(v8_str("prop"), v8_num(3)); |
| 8156 env2->Global()->Set(v8_str("env1"), env1->Global()); | 8156 env2->Global()->Set(v8_str("env1"), env1->Global()); |
| 8157 | 8157 |
| 8158 // Change env2 to a different domain and set env1's global object | 8158 // Change env2 to a different domain and set env1's global object |
| 8159 // as the __proto__ of an object in env2 and enumerate properties | 8159 // as the __proto__ of an object in env2 and enumerate properties |
| 8160 // in for-in. It shouldn't enumerate properties on env1's global | 8160 // in for-in. It shouldn't enumerate properties on env1's global |
| 8161 // object. | 8161 // object. |
| 8162 env2->SetSecurityToken(bar); | 8162 env2->SetSecurityToken(bar); |
| 8163 { | 8163 { |
| 8164 Context::Scope scope_env2(env2); | 8164 Context::Scope scope_env2(env2); |
| 8165 Local<Value> result = CompileRun( | 8165 Local<Value> result = CompileRun( |
| 8166 "(function() {" | 8166 "(function() {" |
| 8167 " var obj = { '__proto__': env1 };" | |
| 8168 " try {" | 8167 " try {" |
| 8169 " for (var p in obj) {" | 8168 " for (var p in env1) {" |
| 8170 " if (p == 'prop') return false;" | 8169 " if (p == 'prop') return false;" |
| 8171 " }" | 8170 " }" |
| 8172 " return true;" | 8171 " return true;" |
| 8173 " } catch (e) {" | 8172 " } catch (e) {" |
| 8174 " return false;" | 8173 " return false;" |
| 8175 " }" | 8174 " }" |
| 8176 "})()"); | 8175 "})()"); |
| 8177 CHECK(result->IsTrue()); | 8176 CHECK(result->IsTrue()); |
| 8178 } | 8177 } |
| 8179 } | 8178 } |
| 8180 | 8179 |
| 8181 | 8180 |
| 8181 THREADED_TEST(CrossDomainForInOnPrototype) { |
| 8182 LocalContext env1; |
| 8183 v8::HandleScope handle_scope(env1->GetIsolate()); |
| 8184 v8::Handle<Context> env2 = Context::New(env1->GetIsolate()); |
| 8185 |
| 8186 Local<Value> foo = v8_str("foo"); |
| 8187 Local<Value> bar = v8_str("bar"); |
| 8188 |
| 8189 // Set to the same domain. |
| 8190 env1->SetSecurityToken(foo); |
| 8191 env2->SetSecurityToken(foo); |
| 8192 |
| 8193 env1->Global()->Set(v8_str("prop"), v8_num(3)); |
| 8194 env2->Global()->Set(v8_str("env1"), env1->Global()); |
| 8195 |
| 8196 // Change env2 to a different domain and set env1's global object |
| 8197 // as the __proto__ of an object in env2 and enumerate properties |
| 8198 // in for-in. It shouldn't enumerate properties on env1's global |
| 8199 // object. |
| 8200 env2->SetSecurityToken(bar); |
| 8201 { |
| 8202 Context::Scope scope_env2(env2); |
| 8203 Local<Value> result = CompileRun( |
| 8204 "(function() {" |
| 8205 " var obj = { '__proto__': env1 };" |
| 8206 " try {" |
| 8207 " for (var p in obj) {" |
| 8208 " if (p == 'prop') return false;" |
| 8209 " }" |
| 8210 " return false;" |
| 8211 " } catch (e) {" |
| 8212 " return true;" |
| 8213 " }" |
| 8214 "})()"); |
| 8215 CHECK(result->IsTrue()); |
| 8216 } |
| 8217 } |
| 8218 |
| 8219 |
| 8182 TEST(ContextDetachGlobal) { | 8220 TEST(ContextDetachGlobal) { |
| 8183 LocalContext env1; | 8221 LocalContext env1; |
| 8184 v8::HandleScope handle_scope(env1->GetIsolate()); | 8222 v8::HandleScope handle_scope(env1->GetIsolate()); |
| 8185 v8::Handle<Context> env2 = Context::New(env1->GetIsolate()); | 8223 v8::Handle<Context> env2 = Context::New(env1->GetIsolate()); |
| 8186 | 8224 |
| 8187 Local<v8::Object> global1 = env1->Global(); | 8225 Local<v8::Object> global1 = env1->Global(); |
| 8188 | 8226 |
| 8189 Local<Value> foo = v8_str("foo"); | 8227 Local<Value> foo = v8_str("foo"); |
| 8190 | 8228 |
| 8191 // Set to the same domain. | 8229 // Set to the same domain. |
| (...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8620 "(function() {" | 8658 "(function() {" |
| 8621 " var obj = { '__proto__': other };" | 8659 " var obj = { '__proto__': other };" |
| 8622 " try {" | 8660 " try {" |
| 8623 " for (var p in obj) {" | 8661 " for (var p in obj) {" |
| 8624 " if (p == 'accessible_prop' ||" | 8662 " if (p == 'accessible_prop' ||" |
| 8625 " p == 'blocked_js_prop' ||" | 8663 " p == 'blocked_js_prop' ||" |
| 8626 " p == 'blocked_js_prop') {" | 8664 " p == 'blocked_js_prop') {" |
| 8627 " return false;" | 8665 " return false;" |
| 8628 " }" | 8666 " }" |
| 8629 " }" | 8667 " }" |
| 8668 " return false;" |
| 8669 " } catch (e) {" |
| 8630 " return true;" | 8670 " return true;" |
| 8631 " } catch (e) {" | |
| 8632 " return false;" | |
| 8633 " }" | 8671 " }" |
| 8634 "})()"); | 8672 "})()"); |
| 8635 CHECK(value->IsTrue()); | 8673 CHECK(value->IsTrue()); |
| 8636 | 8674 |
| 8637 context1->Exit(); | 8675 context1->Exit(); |
| 8638 context0->Exit(); | 8676 context0->Exit(); |
| 8639 } | 8677 } |
| 8640 | 8678 |
| 8641 | 8679 |
| 8642 TEST(AccessControlES5) { | 8680 TEST(AccessControlES5) { |
| (...skipping 23 matching lines...) Expand all Loading... |
| 8666 context0->Enter(); | 8704 context0->Enter(); |
| 8667 | 8705 |
| 8668 v8::Handle<v8::Object> global0 = context0->Global(); | 8706 v8::Handle<v8::Object> global0 = context0->Global(); |
| 8669 | 8707 |
| 8670 v8::Local<Context> context1 = Context::New(isolate); | 8708 v8::Local<Context> context1 = Context::New(isolate); |
| 8671 context1->Enter(); | 8709 context1->Enter(); |
| 8672 v8::Handle<v8::Object> global1 = context1->Global(); | 8710 v8::Handle<v8::Object> global1 = context1->Global(); |
| 8673 global1->Set(v8_str("other"), global0); | 8711 global1->Set(v8_str("other"), global0); |
| 8674 | 8712 |
| 8675 // Regression test for issue 1154. | 8713 // Regression test for issue 1154. |
| 8676 CHECK(CompileRun("Object.keys(other)").IsEmpty()); | 8714 CHECK(CompileRun("Object.keys(other).length == 0")->BooleanValue()); |
| 8677 CHECK(CompileRun("other.blocked_prop").IsEmpty()); | 8715 CHECK(CompileRun("other.blocked_prop").IsEmpty()); |
| 8678 | 8716 |
| 8679 // Regression test for issue 1027. | 8717 // Regression test for issue 1027. |
| 8680 CompileRun("Object.defineProperty(\n" | 8718 CompileRun("Object.defineProperty(\n" |
| 8681 " other, 'blocked_prop', {configurable: false})"); | 8719 " other, 'blocked_prop', {configurable: false})"); |
| 8682 CHECK(CompileRun("other.blocked_prop").IsEmpty()); | 8720 CHECK(CompileRun("other.blocked_prop").IsEmpty()); |
| 8683 CHECK(CompileRun("Object.getOwnPropertyDescriptor(other, 'blocked_prop')") | 8721 CHECK(CompileRun("Object.getOwnPropertyDescriptor(other, 'blocked_prop')") |
| 8684 .IsEmpty()); | 8722 .IsEmpty()); |
| 8685 | 8723 |
| 8686 // Regression test for issue 1171. | 8724 // Regression test for issue 1171. |
| (...skipping 13149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 21836 " fake.age;\n" | 21874 " fake.age;\n" |
| 21837 " result = 1;\n" | 21875 " result = 1;\n" |
| 21838 " } catch (e) {\n" | 21876 " } catch (e) {\n" |
| 21839 " }\n" | 21877 " }\n" |
| 21840 " test(d+1);\n" | 21878 " test(d+1);\n" |
| 21841 "}\n" | 21879 "}\n" |
| 21842 "test(0);\n" | 21880 "test(0);\n" |
| 21843 "result;\n", | 21881 "result;\n", |
| 21844 0); | 21882 0); |
| 21845 } | 21883 } |
| OLD | NEW |