Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2007-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2007-2008 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 3149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3160 | 3160 |
| 3161 // Check that env1.prop still exists. | 3161 // Check that env1.prop still exists. |
| 3162 Local<Value> v = env1->Global()->Get(v8_str("prop")); | 3162 Local<Value> v = env1->Global()->Get(v8_str("prop")); |
| 3163 CHECK(v->IsNumber()); | 3163 CHECK(v->IsNumber()); |
| 3164 CHECK_EQ(3, v->Int32Value()); | 3164 CHECK_EQ(3, v->Int32Value()); |
| 3165 | 3165 |
| 3166 env2.Dispose(); | 3166 env2.Dispose(); |
| 3167 } | 3167 } |
| 3168 | 3168 |
| 3169 | 3169 |
| 3170 THREADED_TEST(CrossDomainForIn) { | |
| 3171 v8::HandleScope handle_scope; | |
| 3172 LocalContext env1; | |
| 3173 v8::Persistent<Context> env2 = Context::New(); | |
| 3174 | |
| 3175 Local<Value> foo = v8_str("foo"); | |
| 3176 Local<Value> bar = v8_str("bar"); | |
| 3177 | |
| 3178 // Set to the same domain. | |
| 3179 env1->SetSecurityToken(foo); | |
| 3180 env2->SetSecurityToken(foo); | |
| 3181 | |
| 3182 env1->Global()->Set(v8_str("prop"), v8_num(3)); | |
| 3183 env2->Global()->Set(v8_str("env1"), env1->Global()); | |
| 3184 | |
| 3185 // Change env2 to a different domain and set env1's global object | |
| 3186 // as the __proto__ of an object in env2 and enumerate properties | |
| 3187 // in for-in. It shouldn't enumerate properties on env1's global | |
| 3188 // object. | |
| 3189 env2->SetSecurityToken(bar); | |
| 3190 { | |
| 3191 Context::Scope scope_env2(env2); | |
| 3192 Local<Value> result = | |
| 3193 Script::Compile(v8_str("(function(){var obj = {'__proto__':env1};\ | |
|
Mads Ager (chromium)
2008/09/24 06:09:21
I find it easier to read if you do not use \ and i
Feng Qian
2008/09/24 15:30:27
Done.
| |
| 3194 for (var p in obj) \ | |
| 3195 if (p == 'prop') return false; \ | |
| 3196 return true;})()"))->Run(); | |
| 3197 CHECK(result->IsTrue()); | |
| 3198 } | |
| 3199 env2.Dispose(); | |
| 3200 } | |
| 3201 | |
| 3170 | 3202 |
| 3171 static bool NamedAccessBlocker(Local<v8::Object> global, | 3203 static bool NamedAccessBlocker(Local<v8::Object> global, |
| 3172 Local<Value> name, | 3204 Local<Value> name, |
| 3173 v8::AccessType type, | 3205 v8::AccessType type, |
| 3174 Local<Value> data) { | 3206 Local<Value> data) { |
| 3175 return Context::GetCurrentSecurityContext()->Global()->Equals(global); | 3207 return Context::GetCurrentSecurityContext()->Global()->Equals(global); |
| 3176 } | 3208 } |
| 3177 | 3209 |
| 3178 | 3210 |
| 3179 static bool IndexedAccessBlocker(Local<v8::Object> global, | 3211 static bool IndexedAccessBlocker(Local<v8::Object> global, |
| (...skipping 1718 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4898 v8::Handle<v8::Script> script0 = | 4930 v8::Handle<v8::Script> script0 = |
| 4899 v8::Script::Compile(source0, v8::String::New("test.js")); | 4931 v8::Script::Compile(source0, v8::String::New("test.js")); |
| 4900 v8::Handle<v8::Script> script1 = | 4932 v8::Handle<v8::Script> script1 = |
| 4901 v8::Script::Compile(source1, v8::String::New("test.js")); | 4933 v8::Script::Compile(source1, v8::String::New("test.js")); |
| 4902 v8::Handle<v8::Script> script2 = | 4934 v8::Handle<v8::Script> script2 = |
| 4903 v8::Script::Compile(source0); // different origin | 4935 v8::Script::Compile(source0); // different origin |
| 4904 CHECK_EQ(1234, script0->Run()->Int32Value()); | 4936 CHECK_EQ(1234, script0->Run()->Int32Value()); |
| 4905 CHECK_EQ(1234, script1->Run()->Int32Value()); | 4937 CHECK_EQ(1234, script1->Run()->Int32Value()); |
| 4906 CHECK_EQ(1234, script2->Run()->Int32Value()); | 4938 CHECK_EQ(1234, script2->Run()->Int32Value()); |
| 4907 } | 4939 } |
| OLD | NEW |