Index: test/cctest/test-api.cc |
=================================================================== |
--- test/cctest/test-api.cc (revision 366) |
+++ test/cctest/test-api.cc (working copy) |
@@ -3167,7 +3167,39 @@ |
} |
+THREADED_TEST(CrossDomainForIn) { |
+ v8::HandleScope handle_scope; |
+ LocalContext env1; |
+ v8::Persistent<Context> env2 = Context::New(); |
+ Local<Value> foo = v8_str("foo"); |
+ Local<Value> bar = v8_str("bar"); |
+ |
+ // Set to the same domain. |
+ env1->SetSecurityToken(foo); |
+ env2->SetSecurityToken(foo); |
+ |
+ env1->Global()->Set(v8_str("prop"), v8_num(3)); |
+ env2->Global()->Set(v8_str("env1"), env1->Global()); |
+ |
+ // Change env2 to a different domain and set env1's global object |
+ // as the __proto__ of an object in env2 and enumerate properties |
+ // in for-in. It shouldn't enumerate properties on env1's global |
+ // object. |
+ env2->SetSecurityToken(bar); |
+ { |
+ Context::Scope scope_env2(env2); |
+ Local<Value> result = |
+ 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.
|
+ for (var p in obj) \ |
+ if (p == 'prop') return false; \ |
+ return true;})()"))->Run(); |
+ CHECK(result->IsTrue()); |
+ } |
+ env2.Dispose(); |
+} |
+ |
+ |
static bool NamedAccessBlocker(Local<v8::Object> global, |
Local<Value> name, |
v8::AccessType type, |