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

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

Issue 7366: Split window support from V8. ... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 12 years, 2 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/v8natives.js ('k') | test/cctest/test-debug.cc » ('j') | 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-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 969 matching lines...) Expand 10 before | Expand all | Expand 10 after
980 980
981 // Indexed and named deleter. 981 // Indexed and named deleter.
982 Script::Compile(v8_str("delete obj[0]"))->Run(); 982 Script::Compile(v8_str("delete obj[0]"))->Run();
983 Script::Compile(v8_str("delete obj.x"))->Run(); 983 Script::Compile(v8_str("delete obj.x"))->Run();
984 984
985 // Enumerators. 985 // Enumerators.
986 Script::Compile(v8_str("for (var p in obj) ;"))->Run(); 986 Script::Compile(v8_str("for (var p in obj) ;"))->Run();
987 } 987 }
988 988
989 989
990 v8::Handle<Value> pre_post_global;
991
992 static v8::Handle<Value> PrePropertyHandlerGet(Local<String> key, 990 static v8::Handle<Value> PrePropertyHandlerGet(Local<String> key,
993 const AccessorInfo& info) { 991 const AccessorInfo& info) {
994 ApiTestFuzzer::Fuzz(); 992 ApiTestFuzzer::Fuzz();
995 CHECK(info.This()->Equals(pre_post_global));
996 CHECK(info.Holder()->Equals(pre_post_global));
997 if (v8_str("pre")->Equals(key)) { 993 if (v8_str("pre")->Equals(key)) {
998 return v8_str("PrePropertyHandler: pre"); 994 return v8_str("PrePropertyHandler: pre");
999 } 995 }
1000 return v8::Handle<String>(); 996 return v8::Handle<String>();
1001 } 997 }
1002 998
1003 999
1004 static v8::Handle<v8::Boolean> PrePropertyHandlerHas(Local<String> key, 1000 static v8::Handle<v8::Boolean> PrePropertyHandlerHas(Local<String> key,
1005 const AccessorInfo&) { 1001 const AccessorInfo&) {
1006 if (v8_str("pre")->Equals(key)) { 1002 if (v8_str("pre")->Equals(key)) {
1007 return v8::True(); 1003 return v8::True();
1008 } 1004 }
1009 1005
1010 return v8::Handle<v8::Boolean>(); // do not intercept the call 1006 return v8::Handle<v8::Boolean>(); // do not intercept the call
1011 } 1007 }
1012 1008
1013 1009
1014 THREADED_TEST(PrePropertyHandler) { 1010 THREADED_TEST(PrePropertyHandler) {
1015 v8::HandleScope scope; 1011 v8::HandleScope scope;
1016 v8::Handle<v8::FunctionTemplate> desc = v8::FunctionTemplate::New(); 1012 v8::Handle<v8::FunctionTemplate> desc = v8::FunctionTemplate::New();
1017 desc->InstanceTemplate()->SetNamedPropertyHandler(PrePropertyHandlerGet, 1013 desc->InstanceTemplate()->SetNamedPropertyHandler(PrePropertyHandlerGet,
1018 0, 1014 0,
1019 PrePropertyHandlerHas); 1015 PrePropertyHandlerHas);
1020 LocalContext env(NULL, desc->InstanceTemplate()); 1016 LocalContext env(NULL, desc->InstanceTemplate());
1021 pre_post_global = env->Global();
1022 Script::Compile(v8_str( 1017 Script::Compile(v8_str(
1023 "var pre = 'Object: pre'; var on = 'Object: on';"))->Run(); 1018 "var pre = 'Object: pre'; var on = 'Object: on';"))->Run();
1024 v8::Handle<Value> result_pre = Script::Compile(v8_str("pre"))->Run(); 1019 v8::Handle<Value> result_pre = Script::Compile(v8_str("pre"))->Run();
1025 CHECK_EQ(v8_str("PrePropertyHandler: pre"), result_pre); 1020 CHECK_EQ(v8_str("PrePropertyHandler: pre"), result_pre);
1026 v8::Handle<Value> result_on = Script::Compile(v8_str("on"))->Run(); 1021 v8::Handle<Value> result_on = Script::Compile(v8_str("on"))->Run();
1027 CHECK_EQ(v8_str("Object: on"), result_on); 1022 CHECK_EQ(v8_str("Object: on"), result_on);
1028 v8::Handle<Value> result_post = Script::Compile(v8_str("post"))->Run(); 1023 v8::Handle<Value> result_post = Script::Compile(v8_str("post"))->Run();
1029 CHECK(result_post.IsEmpty()); 1024 CHECK(result_post.IsEmpty());
1030 } 1025 }
1031 1026
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
1158 Foo->PrototypeTemplate()->Set(v8_str("plak"), v8_num(321)); 1153 Foo->PrototypeTemplate()->Set(v8_str("plak"), v8_num(321));
1159 LocalContext env; 1154 LocalContext env;
1160 env->Global()->Set(v8_str("Foo"), Foo->GetFunction()); 1155 env->Global()->Set(v8_str("Foo"), Foo->GetFunction());
1161 Local<Script> script = Script::Compile(v8_str("Foo.prototype.plak")); 1156 Local<Script> script = Script::Compile(v8_str("Foo.prototype.plak"));
1162 CHECK_EQ(script->Run()->Int32Value(), 321); 1157 CHECK_EQ(script->Run()->Int32Value(), 321);
1163 } 1158 }
1164 1159
1165 1160
1166 THREADED_TEST(InternalFields) { 1161 THREADED_TEST(InternalFields) {
1167 v8::HandleScope scope; 1162 v8::HandleScope scope;
1163 LocalContext env;
1164
1168 Local<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(); 1165 Local<v8::FunctionTemplate> templ = v8::FunctionTemplate::New();
1169 Local<v8::ObjectTemplate> instance_templ = templ->InstanceTemplate(); 1166 Local<v8::ObjectTemplate> instance_templ = templ->InstanceTemplate();
1170 instance_templ->SetInternalFieldCount(1); 1167 instance_templ->SetInternalFieldCount(1);
1171 LocalContext env(0, instance_templ);
1172 CHECK_EQ(1, env->Global()->InternalFieldCount());
1173
1174 Local<v8::Object> obj = templ->GetFunction()->NewInstance(); 1168 Local<v8::Object> obj = templ->GetFunction()->NewInstance();
1175 CHECK_EQ(1, obj->InternalFieldCount()); 1169 CHECK_EQ(1, obj->InternalFieldCount());
1176 CHECK(obj->GetInternalField(0)->IsUndefined()); 1170 CHECK(obj->GetInternalField(0)->IsUndefined());
1177 obj->SetInternalField(0, v8_num(17)); 1171 obj->SetInternalField(0, v8_num(17));
1178 CHECK_EQ(17, obj->GetInternalField(0)->Int32Value()); 1172 CHECK_EQ(17, obj->GetInternalField(0)->Int32Value());
1179 } 1173 }
1180 1174
1181 1175
1182 THREADED_TEST(External) { 1176 THREADED_TEST(External) {
1183 v8::HandleScope scope; 1177 v8::HandleScope scope;
(...skipping 1870 matching lines...) Expand 10 before | Expand all | Expand 10 after
3054 3048
3055 // Set to the same domain. 3049 // Set to the same domain.
3056 env1->SetSecurityToken(foo); 3050 env1->SetSecurityToken(foo);
3057 3051
3058 // Create a function in env1. 3052 // Create a function in env1.
3059 Script::Compile(v8_str("spy=function(){return spy;}"))->Run(); 3053 Script::Compile(v8_str("spy=function(){return spy;}"))->Run();
3060 Local<Value> spy = env1->Global()->Get(v8_str("spy")); 3054 Local<Value> spy = env1->Global()->Get(v8_str("spy"));
3061 CHECK(spy->IsFunction()); 3055 CHECK(spy->IsFunction());
3062 3056
3063 // Create another function accessing global objects. 3057 // Create another function accessing global objects.
3064 Script::Compile(v8_str("spy2=function(){return new Array();}"))->Run(); 3058 Script::Compile(v8_str("spy2=function(){return new this.Array();}"))->Run();
3065 Local<Value> spy2 = env1->Global()->Get(v8_str("spy2")); 3059 Local<Value> spy2 = env1->Global()->Get(v8_str("spy2"));
3066 CHECK(spy2->IsFunction()); 3060 CHECK(spy2->IsFunction());
3067 3061
3068 // Switch to env2 in the same domain and invoke spy on env2. 3062 // Switch to env2 in the same domain and invoke spy on env2.
3069 { 3063 {
3070 env2->SetSecurityToken(foo); 3064 env2->SetSecurityToken(foo);
3071 // Enter env2 3065 // Enter env2
3072 Context::Scope scope_env2(env2); 3066 Context::Scope scope_env2(env2);
3073 Local<Value> result = Function::Cast(*spy)->Call(env2->Global(), 0, NULL); 3067 Local<Value> result = Function::Cast(*spy)->Call(env2->Global(), 0, NULL);
3074 CHECK(result->IsFunction()); 3068 CHECK(result->IsFunction());
3075 } 3069 }
3076 3070
3077 // Change env2 to a new domain and invoke spy on env2. It should be blocked
3078 // by security check.
3079 { 3071 {
3080 env2->SetSecurityToken(bar); 3072 env2->SetSecurityToken(bar);
3081 Context::Scope scope_env2(env2); 3073 Context::Scope scope_env2(env2);
3082 Local<Value> result = Function::Cast(*spy)->Call(env2->Global(), 0, NULL);
3083 CHECK(result->IsUndefined());
3084 3074
3085 // Call cross_domain_call, it should throw an exception 3075 // Call cross_domain_call, it should throw an exception
3086 v8::TryCatch try_catch; 3076 v8::TryCatch try_catch;
3087 Function::Cast(*spy2)->Call(env2->Global(), 0, NULL); 3077 Function::Cast(*spy2)->Call(env2->Global(), 0, NULL);
3088 CHECK(try_catch.HasCaught()); 3078 CHECK(try_catch.HasCaught());
3089 } 3079 }
3090 3080
3091 env2.Dispose(); 3081 env2.Dispose();
3092 } 3082 }
3093 3083
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
3220 CompileRun("(function(){var obj = {'__proto__':env1};" 3210 CompileRun("(function(){var obj = {'__proto__':env1};"
3221 "for (var p in obj)" 3211 "for (var p in obj)"
3222 " if (p == 'prop') return false;" 3212 " if (p == 'prop') return false;"
3223 "return true;})()"); 3213 "return true;})()");
3224 CHECK(result->IsTrue()); 3214 CHECK(result->IsTrue());
3225 } 3215 }
3226 env2.Dispose(); 3216 env2.Dispose();
3227 } 3217 }
3228 3218
3229 3219
3220 TEST(ContextDetachGlobal) {
3221 v8::HandleScope handle_scope;
3222 LocalContext env1;
3223 v8::Persistent<Context> env2 = Context::New();
3224
3225 Local<v8::Object> global1 = env1->Global();
3226
3227 Local<Value> foo = v8_str("foo");
3228
3229 // Set to the same domain.
3230 env1->SetSecurityToken(foo);
3231 env2->SetSecurityToken(foo);
3232
3233 // Enter env2
3234 env2->Enter();
3235
3236 // Create a function in env1
3237 Local<v8::Object> global2 = env2->Global();
3238 global2->Set(v8_str("prop"), v8::Integer::New(1));
3239 CompileRun("function getProp() {return prop;}");
3240
3241 env1->Global()->Set(v8_str("getProp"),
3242 global2->Get(v8_str("getProp")));
3243
3244 // Detach env1's global, and reuse the global object of env1
3245 env2->Exit();
3246 env2->DetachGlobal();
3247 // env2 has a new global object.
3248 CHECK(!env2->Global()->Equals(global2));
3249
3250 v8::Persistent<Context> env3 =
3251 Context::New(0, v8::Handle<v8::ObjectTemplate>(), global2);
3252 env3->SetSecurityToken(v8_str("bar"));
3253 env3->Enter();
3254
3255 Local<v8::Object> global3 = env3->Global();
3256 CHECK_EQ(global2, global3);
3257 CHECK(global3->Get(v8_str("prop"))->IsUndefined());
3258 CHECK(global3->Get(v8_str("getProp"))->IsUndefined());
3259 global3->Set(v8_str("prop"), v8::Integer::New(-1));
3260 global3->Set(v8_str("prop2"), v8::Integer::New(2));
3261 env3->Exit();
3262
3263 // Call getProp in env1, and it should return the value 1
3264 {
3265 Local<Value> get_prop = global1->Get(v8_str("getProp"));
3266 CHECK(get_prop->IsFunction());
3267 v8::TryCatch try_catch;
3268 Local<Value> r = Function::Cast(*get_prop)->Call(global1, 0, NULL);
3269 CHECK(!try_catch.HasCaught());
3270 CHECK_EQ(1, r->Int32Value());
3271 }
3272
3273 // Check that env3 is not accessible from env1
3274 {
3275 Local<Value> r = global3->Get(v8_str("prop2"));
3276 CHECK(r->IsUndefined());
3277 }
3278
3279 env2.Dispose();
3280 env3.Dispose();
3281 }
3282
3283
3230 static bool NamedAccessBlocker(Local<v8::Object> global, 3284 static bool NamedAccessBlocker(Local<v8::Object> global,
3231 Local<Value> name, 3285 Local<Value> name,
3232 v8::AccessType type, 3286 v8::AccessType type,
3233 Local<Value> data) { 3287 Local<Value> data) {
3234 return Context::GetCurrentSecurityContext()->Global()->Equals(global); 3288 return Context::GetCurrent()->Global()->Equals(global);
3235 } 3289 }
3236 3290
3237 3291
3238 static bool IndexedAccessBlocker(Local<v8::Object> global, 3292 static bool IndexedAccessBlocker(Local<v8::Object> global,
3239 uint32_t key, 3293 uint32_t key,
3240 v8::AccessType type, 3294 v8::AccessType type,
3241 Local<Value> data) { 3295 Local<Value> data) {
3242 return Context::GetCurrentSecurityContext()->Global()->Equals(global); 3296 return Context::GetCurrent()->Global()->Equals(global);
3243 } 3297 }
3244 3298
3245 3299
3246 static int g_echo_value = -1; 3300 static int g_echo_value = -1;
3247 static v8::Handle<Value> EchoGetter(Local<String> name, 3301 static v8::Handle<Value> EchoGetter(Local<String> name,
3248 const AccessorInfo& info) { 3302 const AccessorInfo& info) {
3249 return v8_num(g_echo_value); 3303 return v8_num(g_echo_value);
3250 } 3304 }
3251 3305
3252 3306
3253 static void EchoSetter(Local<String> name, 3307 static void EchoSetter(Local<String> name,
3254 Local<Value> value, 3308 Local<Value> value,
3255 const AccessorInfo& info) { 3309 const AccessorInfo&) {
3256 if (value->IsNumber()) 3310 if (value->IsNumber())
3257 g_echo_value = value->Int32Value(); 3311 g_echo_value = value->Int32Value();
3258 } 3312 }
3259 3313
3260 3314
3261 static v8::Handle<Value> UnreachableGetter(Local<String> name, 3315 static v8::Handle<Value> UnreachableGetter(Local<String> name,
3262 const AccessorInfo& info) { 3316 const AccessorInfo& info) {
3263 CHECK(false); // This function should not be called.. 3317 CHECK(false); // This function should not be called..
3264 return v8::Undefined(); 3318 return v8::Undefined();
3265 } 3319 }
3266 3320
3267 3321
3268 static void UnreachableSetter(Local<String> name, 3322 static void UnreachableSetter(Local<String>, Local<Value>,
3269 Local<Value> value, 3323 const AccessorInfo&) {
3270 const AccessorInfo& info) {
3271 CHECK(false); // This function should nto be called. 3324 CHECK(false); // This function should nto be called.
3272 } 3325 }
3273 3326
3274 3327
3275 THREADED_TEST(AccessControl) { 3328 THREADED_TEST(AccessControl) {
3276 v8::HandleScope handle_scope; 3329 v8::HandleScope handle_scope;
3277 v8::Handle<v8::ObjectTemplate> global_template = v8::ObjectTemplate::New(); 3330 v8::Handle<v8::ObjectTemplate> global_template = v8::ObjectTemplate::New();
3278 3331
3279 global_template->SetAccessCheckCallbacks(NamedAccessBlocker, 3332 global_template->SetAccessCheckCallbacks(NamedAccessBlocker,
3280 IndexedAccessBlocker); 3333 IndexedAccessBlocker);
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
3539 value = v8_compile("var p = 'as' + 'df';")->Run(); 3592 value = v8_compile("var p = 'as' + 'df';")->Run();
3540 value = v8_compile("obj[p];")->Run(); 3593 value = v8_compile("obj[p];")->Run();
3541 3594
3542 context1->Exit(); 3595 context1->Exit();
3543 context0->Exit(); 3596 context0->Exit();
3544 context1.Dispose(); 3597 context1.Dispose();
3545 context0.Dispose(); 3598 context0.Dispose();
3546 } 3599 }
3547 3600
3548 3601
3549 static v8::Handle<Value> AccessControlNamedGetter(Local<String> name, 3602 static v8::Handle<Value> AccessControlNamedGetter(
3550 const AccessorInfo& info) { 3603 Local<String>, const AccessorInfo&) {
3551 return v8::Integer::New(42); 3604 return v8::Integer::New(42);
3552 } 3605 }
3553 3606
3554 3607
3555 static v8::Handle<Value> AccessControlNamedSetter(Local<String> key, 3608 static v8::Handle<Value> AccessControlNamedSetter(
3556 Local<Value> value, 3609 Local<String>, Local<Value> value, const AccessorInfo&) {
3557 const AccessorInfo&) {
3558 return value; 3610 return value;
3559 } 3611 }
3560 3612
3561 3613
3562 static v8::Handle<Value> AccessControlIndexedGetter( 3614 static v8::Handle<Value> AccessControlIndexedGetter(
3563 uint32_t index, 3615 uint32_t index,
3564 const AccessorInfo& info) { 3616 const AccessorInfo& info) {
3565 return v8_num(42); 3617 return v8_num(42);
3566 } 3618 }
3567 3619
3568 3620
3569 static v8::Handle<Value> AccessControlIndexedSetter(uint32_t index, 3621 static v8::Handle<Value> AccessControlIndexedSetter(
3570 Local<Value> value, 3622 uint32_t, Local<Value> value, const AccessorInfo&) {
3571 const AccessorInfo&) {
3572 return value; 3623 return value;
3573 } 3624 }
3574 3625
3575 3626
3576 THREADED_TEST(AccessControlInterceptorIC) { 3627 THREADED_TEST(AccessControlInterceptorIC) {
3577 named_access_count = 0; 3628 named_access_count = 0;
3578 indexed_access_count = 0; 3629 indexed_access_count = 0;
3579 3630
3580 v8::HandleScope handle_scope; 3631 v8::HandleScope handle_scope;
3581 3632
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
3720 ApiTestFuzzer::Fuzz(); 3771 ApiTestFuzzer::Fuzz();
3721 return v8_num(42); 3772 return v8_num(42);
3722 } 3773 }
3723 3774
3724 3775
3725 static int shadow_y; 3776 static int shadow_y;
3726 static int shadow_y_setter_call_count; 3777 static int shadow_y_setter_call_count;
3727 static int shadow_y_getter_call_count; 3778 static int shadow_y_getter_call_count;
3728 3779
3729 3780
3730 static void ShadowYSetter(Local<String> name, 3781 static void ShadowYSetter(Local<String>, Local<Value>, const AccessorInfo&) {
3731 Local<Value> value,
3732 const AccessorInfo& info) {
3733 shadow_y_setter_call_count++; 3782 shadow_y_setter_call_count++;
3734 shadow_y = 42; 3783 shadow_y = 42;
3735 } 3784 }
3736 3785
3737 3786
3738 static v8::Handle<Value> ShadowYGetter(Local<String> name, 3787 static v8::Handle<Value> ShadowYGetter(Local<String> name,
3739 const AccessorInfo& info) { 3788 const AccessorInfo& info) {
3740 ApiTestFuzzer::Fuzz(); 3789 ApiTestFuzzer::Fuzz();
3741 shadow_y_getter_call_count++; 3790 shadow_y_getter_call_count++;
3742 return v8_num(shadow_y); 3791 return v8_num(shadow_y);
(...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after
4138 v8::Handle<Value> value = CompileRun( 4187 v8::Handle<Value> value = CompileRun(
4139 "var result = 0;" 4188 "var result = 0;"
4140 "for (var i = 0; i < 1000; i++) {" 4189 "for (var i = 0; i < 1000; i++) {"
4141 " result = o.x;" 4190 " result = o.x;"
4142 "}"); 4191 "}");
4143 CHECK_EQ(42, value->Int32Value()); 4192 CHECK_EQ(42, value->Int32Value());
4144 } 4193 }
4145 4194
4146 4195
4147 static v8::Handle<Value> InterceptorStoreICSetter( 4196 static v8::Handle<Value> InterceptorStoreICSetter(
4148 Local<String> key, 4197 Local<String> key, Local<Value> value, const AccessorInfo&) {
4149 Local<Value> value,
4150 const AccessorInfo&) {
4151 CHECK(v8_str("x")->Equals(key)); 4198 CHECK(v8_str("x")->Equals(key));
4152 CHECK_EQ(42, value->Int32Value()); 4199 CHECK_EQ(42, value->Int32Value());
4153 return value; 4200 return value;
4154 } 4201 }
4155 4202
4156 4203
4157 // This test should hit the store IC for the interceptor case. 4204 // This test should hit the store IC for the interceptor case.
4158 THREADED_TEST(InterceptorStoreIC) { 4205 THREADED_TEST(InterceptorStoreIC) {
4159 v8::HandleScope scope; 4206 v8::HandleScope scope;
4160 v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New(); 4207 v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New();
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
4285 " return false;" 4332 " return false;"
4286 "};" 4333 "};"
4287 "f();"); 4334 "f();");
4288 CHECK_EQ(true, value->BooleanValue()); 4335 CHECK_EQ(true, value->BooleanValue());
4289 } 4336 }
4290 4337
4291 4338
4292 static int interceptor_ic_exception_set_count = 0; 4339 static int interceptor_ic_exception_set_count = 0;
4293 4340
4294 static v8::Handle<Value> InterceptorICExceptionSetter( 4341 static v8::Handle<Value> InterceptorICExceptionSetter(
4295 Local<String> key, 4342 Local<String> key, Local<Value> value, const AccessorInfo&) {
4296 Local<Value> value,
4297 const AccessorInfo&) {
4298 ApiTestFuzzer::Fuzz(); 4343 ApiTestFuzzer::Fuzz();
4299 if (++interceptor_ic_exception_set_count > 20) { 4344 if (++interceptor_ic_exception_set_count > 20) {
4300 return v8::ThrowException(v8_num(42)); 4345 return v8::ThrowException(v8_num(42));
4301 } 4346 }
4302 // Do not actually handle setting. 4347 // Do not actually handle setting.
4303 return v8::Handle<Value>(); 4348 return v8::Handle<Value>();
4304 } 4349 }
4305 4350
4306 // Test interceptor store IC where the interceptor throws an exception 4351 // Test interceptor store IC where the interceptor throws an exception
4307 // once in a while. 4352 // once in a while.
(...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after
4767 #endif 4812 #endif
4768 return count; 4813 return count;
4769 } 4814 }
4770 4815
4771 4816
4772 TEST(DontLeakGlobalObjects) { 4817 TEST(DontLeakGlobalObjects) {
4773 // Regression test for issues 1139850 and 1174891. 4818 // Regression test for issues 1139850 and 1174891.
4774 4819
4775 v8::V8::Initialize(); 4820 v8::V8::Initialize();
4776 4821
4822 // TODO(121): when running "cctest test-api", the initial count is 2,
4823 // after second GC, the counter drops to 1. Needs to figure out why
4824 // one GC is not enough to collect all garbage.
4825 GetSurvivingGlobalObjectsCount();
4777 int count = GetSurvivingGlobalObjectsCount(); 4826 int count = GetSurvivingGlobalObjectsCount();
4778 4827
4779 for (int i = 0; i < 5; i++) { 4828 for (int i = 0; i < 5; i++) {
4780 { v8::HandleScope scope; 4829 { v8::HandleScope scope;
4781 LocalContext context; 4830 LocalContext context;
4782 } 4831 }
4783 CHECK_EQ(count, GetSurvivingGlobalObjectsCount()); 4832 CHECK_EQ(count, GetSurvivingGlobalObjectsCount());
4784 4833
4785 { v8::HandleScope scope; 4834 { v8::HandleScope scope;
4786 LocalContext context; 4835 LocalContext context;
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
4968 v8::HandleScope scope; 5017 v8::HandleScope scope;
4969 LocalContext context; 5018 LocalContext context;
4970 Local<ObjectTemplate> t = ObjectTemplate::New(); 5019 Local<ObjectTemplate> t = ObjectTemplate::New();
4971 t->Set(v8_str("asdf"), v8::FunctionTemplate::New(FunctionNameCallback)); 5020 t->Set(v8_str("asdf"), v8::FunctionTemplate::New(FunctionNameCallback));
4972 context->Global()->Set(v8_str("obj"), t->NewInstance()); 5021 context->Global()->Set(v8_str("obj"), t->NewInstance());
4973 v8::Handle<v8::Value> value = CompileRun("obj.asdf.name"); 5022 v8::Handle<v8::Value> value = CompileRun("obj.asdf.name");
4974 CHECK(value->IsString()); 5023 CHECK(value->IsString());
4975 v8::String::AsciiValue name(value); 5024 v8::String::AsciiValue name(value);
4976 CHECK_EQ("asdf", *name); 5025 CHECK_EQ("asdf", *name);
4977 } 5026 }
OLDNEW
« no previous file with comments | « src/v8natives.js ('k') | test/cctest/test-debug.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698