Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(892)

Side by Side Diff: test/cctest/test-api.cc

Issue 6386027: Port r6539 to 2.4 branch (Closed) Base URL: http://v8.googlecode.com/svn/branches/2.4/
Patch Set: Created 9 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/version.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 5195 matching lines...) Expand 10 before | Expand all | Expand 10 after
5206 5206
5207 v8::Persistent<Context> context1 = Context::New(); 5207 v8::Persistent<Context> context1 = Context::New();
5208 context1->Enter(); 5208 context1->Enter();
5209 5209
5210 v8::Handle<v8::Object> global1 = context1->Global(); 5210 v8::Handle<v8::Object> global1 = context1->Global();
5211 global1->Set(v8_str("other"), global0); 5211 global1->Set(v8_str("other"), global0);
5212 5212
5213 v8::Handle<Value> value; 5213 v8::Handle<Value> value;
5214 5214
5215 // Access blocked property 5215 // Access blocked property
5216 value = v8_compile("other.blocked_prop = 1")->Run(); 5216 value = CompileRun("other.blocked_prop = 1");
5217 value = v8_compile("other.blocked_prop")->Run(); 5217 value = CompileRun("other.blocked_prop");
5218 CHECK(value->IsUndefined()); 5218 CHECK(value->IsUndefined());
5219 5219
5220 value = v8_compile("propertyIsEnumerable.call(other, 'blocked_prop')")->Run(); 5220 value = CompileRun(
5221 "Object.getOwnPropertyDescriptor(other, 'blocked_prop').value");
5222 CHECK(value->IsUndefined());
5223
5224 value = CompileRun("propertyIsEnumerable.call(other, 'blocked_prop')");
5221 CHECK(value->IsFalse()); 5225 CHECK(value->IsFalse());
5222 5226
5223 // Access accessible property 5227 // Access accessible property
5224 value = v8_compile("other.accessible_prop = 3")->Run(); 5228 value = CompileRun("other.accessible_prop = 3");
5225 CHECK(value->IsNumber()); 5229 CHECK(value->IsNumber());
5226 CHECK_EQ(3, value->Int32Value()); 5230 CHECK_EQ(3, value->Int32Value());
5227 CHECK_EQ(3, g_echo_value); 5231 CHECK_EQ(3, g_echo_value);
5228 5232
5229 value = v8_compile("other.accessible_prop")->Run(); 5233 value = CompileRun("other.accessible_prop");
5230 CHECK(value->IsNumber()); 5234 CHECK(value->IsNumber());
5231 CHECK_EQ(3, value->Int32Value()); 5235 CHECK_EQ(3, value->Int32Value());
5232 5236
5233 value = 5237 value = CompileRun(
5234 v8_compile("propertyIsEnumerable.call(other, 'accessible_prop')")->Run(); 5238 "Object.getOwnPropertyDescriptor(other, 'accessible_prop').value");
5239 CHECK(value->IsNumber());
5240 CHECK_EQ(3, value->Int32Value());
5241
5242 value = CompileRun("propertyIsEnumerable.call(other, 'accessible_prop')");
5235 CHECK(value->IsTrue()); 5243 CHECK(value->IsTrue());
5236 5244
5237 // Enumeration doesn't enumerate accessors from inaccessible objects in 5245 // Enumeration doesn't enumerate accessors from inaccessible objects in
5238 // the prototype chain even if the accessors are in themselves accessible. 5246 // the prototype chain even if the accessors are in themselves accessible.
5239 Local<Value> result = 5247 value =
5240 CompileRun("(function(){var obj = {'__proto__':other};" 5248 CompileRun("(function(){var obj = {'__proto__':other};"
5241 "for (var p in obj)" 5249 "for (var p in obj)"
5242 " if (p == 'accessible_prop' || p == 'blocked_prop') {" 5250 " if (p == 'accessible_prop' || p == 'blocked_prop') {"
5243 " return false;" 5251 " return false;"
5244 " }" 5252 " }"
5245 "return true;})()"); 5253 "return true;})()");
5246 CHECK(result->IsTrue()); 5254 CHECK(value->IsTrue());
5247 5255
5248 context1->Exit(); 5256 context1->Exit();
5249 context0->Exit(); 5257 context0->Exit();
5250 context1.Dispose(); 5258 context1.Dispose();
5251 context0.Dispose(); 5259 context0.Dispose();
5252 } 5260 }
5253 5261
5254 5262
5255 static bool GetOwnPropertyNamesNamedBlocker(Local<v8::Object> global, 5263 static bool GetOwnPropertyNamesNamedBlocker(Local<v8::Object> global,
5256 Local<Value> name, 5264 Local<Value> name,
(...skipping 6564 matching lines...) Expand 10 before | Expand all | Expand 10 after
11821 v8::Context::Scope context_scope(context.local()); 11829 v8::Context::Scope context_scope(context.local());
11822 11830
11823 v8::Handle<v8::ObjectTemplate> tmpl = v8::ObjectTemplate::New(); 11831 v8::Handle<v8::ObjectTemplate> tmpl = v8::ObjectTemplate::New();
11824 tmpl->SetNamedPropertyHandler(Getter, NULL, NULL, NULL, Enumerator); 11832 tmpl->SetNamedPropertyHandler(Getter, NULL, NULL, NULL, Enumerator);
11825 context->Global()->Set(v8_str("o"), tmpl->NewInstance()); 11833 context->Global()->Set(v8_str("o"), tmpl->NewInstance());
11826 v8::Handle<v8::Array> result = v8::Handle<v8::Array>::Cast(CompileRun( 11834 v8::Handle<v8::Array> result = v8::Handle<v8::Array>::Cast(CompileRun(
11827 "var result = []; for (var k in o) result.push(k); result")); 11835 "var result = []; for (var k in o) result.push(k); result"));
11828 CHECK_EQ(1, result->Length()); 11836 CHECK_EQ(1, result->Length());
11829 CHECK_EQ(v8_str("universalAnswer"), result->Get(0)); 11837 CHECK_EQ(v8_str("universalAnswer"), result->Get(0));
11830 } 11838 }
OLDNEW
« no previous file with comments | « src/version.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698