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

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

Issue 6386026: Port r6539 to 2.5 branch (Closed) Base URL: http://v8.googlecode.com/svn/branches/2.5/
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 5196 matching lines...) Expand 10 before | Expand all | Expand 10 after
5207 5207
5208 v8::Persistent<Context> context1 = Context::New(); 5208 v8::Persistent<Context> context1 = Context::New();
5209 context1->Enter(); 5209 context1->Enter();
5210 5210
5211 v8::Handle<v8::Object> global1 = context1->Global(); 5211 v8::Handle<v8::Object> global1 = context1->Global();
5212 global1->Set(v8_str("other"), global0); 5212 global1->Set(v8_str("other"), global0);
5213 5213
5214 v8::Handle<Value> value; 5214 v8::Handle<Value> value;
5215 5215
5216 // Access blocked property 5216 // Access blocked property
5217 value = v8_compile("other.blocked_prop = 1")->Run(); 5217 value = CompileRun("other.blocked_prop = 1");
5218 value = v8_compile("other.blocked_prop")->Run(); 5218 value = CompileRun("other.blocked_prop");
5219 CHECK(value->IsUndefined()); 5219 CHECK(value->IsUndefined());
5220 5220
5221 value = v8_compile("propertyIsEnumerable.call(other, 'blocked_prop')")->Run(); 5221 value = CompileRun(
5222 "Object.getOwnPropertyDescriptor(other, 'blocked_prop').value");
5223 CHECK(value->IsUndefined());
5224
5225 value = CompileRun("propertyIsEnumerable.call(other, 'blocked_prop')");
5222 CHECK(value->IsFalse()); 5226 CHECK(value->IsFalse());
5223 5227
5224 // Access accessible property 5228 // Access accessible property
5225 value = v8_compile("other.accessible_prop = 3")->Run(); 5229 value = CompileRun("other.accessible_prop = 3");
5226 CHECK(value->IsNumber()); 5230 CHECK(value->IsNumber());
5227 CHECK_EQ(3, value->Int32Value()); 5231 CHECK_EQ(3, value->Int32Value());
5228 CHECK_EQ(3, g_echo_value); 5232 CHECK_EQ(3, g_echo_value);
5229 5233
5230 value = v8_compile("other.accessible_prop")->Run(); 5234 value = CompileRun("other.accessible_prop");
5231 CHECK(value->IsNumber()); 5235 CHECK(value->IsNumber());
5232 CHECK_EQ(3, value->Int32Value()); 5236 CHECK_EQ(3, value->Int32Value());
5233 5237
5234 value = 5238 value = CompileRun(
5235 v8_compile("propertyIsEnumerable.call(other, 'accessible_prop')")->Run(); 5239 "Object.getOwnPropertyDescriptor(other, 'accessible_prop').value");
5240 CHECK(value->IsNumber());
5241 CHECK_EQ(3, value->Int32Value());
5242
5243 value = CompileRun("propertyIsEnumerable.call(other, 'accessible_prop')");
5236 CHECK(value->IsTrue()); 5244 CHECK(value->IsTrue());
5237 5245
5238 // Enumeration doesn't enumerate accessors from inaccessible objects in 5246 // Enumeration doesn't enumerate accessors from inaccessible objects in
5239 // the prototype chain even if the accessors are in themselves accessible. 5247 // the prototype chain even if the accessors are in themselves accessible.
5240 Local<Value> result = 5248 value =
5241 CompileRun("(function(){var obj = {'__proto__':other};" 5249 CompileRun("(function(){var obj = {'__proto__':other};"
5242 "for (var p in obj)" 5250 "for (var p in obj)"
5243 " if (p == 'accessible_prop' || p == 'blocked_prop') {" 5251 " if (p == 'accessible_prop' || p == 'blocked_prop') {"
5244 " return false;" 5252 " return false;"
5245 " }" 5253 " }"
5246 "return true;})()"); 5254 "return true;})()");
5247 CHECK(result->IsTrue()); 5255 CHECK(value->IsTrue());
5248 5256
5249 context1->Exit(); 5257 context1->Exit();
5250 context0->Exit(); 5258 context0->Exit();
5251 context1.Dispose(); 5259 context1.Dispose();
5252 context0.Dispose(); 5260 context0.Dispose();
5253 } 5261 }
5254 5262
5255 5263
5256 static bool GetOwnPropertyNamesNamedBlocker(Local<v8::Object> global, 5264 static bool GetOwnPropertyNamesNamedBlocker(Local<v8::Object> global,
5257 Local<Value> name, 5265 Local<Value> name,
(...skipping 6607 matching lines...) Expand 10 before | Expand all | Expand 10 after
11865 v8::Context::Scope context_scope(context.local()); 11873 v8::Context::Scope context_scope(context.local());
11866 11874
11867 v8::Handle<v8::ObjectTemplate> tmpl = v8::ObjectTemplate::New(); 11875 v8::Handle<v8::ObjectTemplate> tmpl = v8::ObjectTemplate::New();
11868 tmpl->SetNamedPropertyHandler(Getter, NULL, NULL, NULL, Enumerator); 11876 tmpl->SetNamedPropertyHandler(Getter, NULL, NULL, NULL, Enumerator);
11869 context->Global()->Set(v8_str("o"), tmpl->NewInstance()); 11877 context->Global()->Set(v8_str("o"), tmpl->NewInstance());
11870 v8::Handle<v8::Array> result = v8::Handle<v8::Array>::Cast(CompileRun( 11878 v8::Handle<v8::Array> result = v8::Handle<v8::Array>::Cast(CompileRun(
11871 "var result = []; for (var k in o) result.push(k); result")); 11879 "var result = []; for (var k in o) result.push(k); result"));
11872 CHECK_EQ(1, result->Length()); 11880 CHECK_EQ(1, result->Length());
11873 CHECK_EQ(v8_str("universalAnswer"), result->Get(0)); 11881 CHECK_EQ(v8_str("universalAnswer"), result->Get(0));
11874 } 11882 }
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