| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 v8::FunctionTemplate::New(XSetter)); | 198 v8::FunctionTemplate::New(XSetter)); |
| 199 x_holder = obj->NewInstance(); | 199 x_holder = obj->NewInstance(); |
| 200 context->Global()->Set(v8_str("holder"), x_holder); | 200 context->Global()->Set(v8_str("holder"), x_holder); |
| 201 x_receiver = v8::Object::New(); | 201 x_receiver = v8::Object::New(); |
| 202 context->Global()->Set(v8_str("obj"), x_receiver); | 202 context->Global()->Set(v8_str("obj"), x_receiver); |
| 203 v8::Handle<v8::Array> array = v8::Handle<v8::Array>::Cast(CompileRun( | 203 v8::Handle<v8::Array> array = v8::Handle<v8::Array>::Cast(CompileRun( |
| 204 "obj.__proto__ = holder;" | 204 "obj.__proto__ = holder;" |
| 205 "var result = [];" | 205 "var result = [];" |
| 206 "var key_0 = 'x0';" | 206 "var key_0 = 'x0';" |
| 207 "var key_1 = 'x1';" | 207 "var key_1 = 'x1';" |
| 208 "for (var i = 0; i < 10; i++) {" | 208 "for (var j = 0; j < 10; j++) {" |
| 209 " var i = 4*j;" |
| 209 " holder.x0 = i;" | 210 " holder.x0 = i;" |
| 210 " result.push(obj.x0);" | 211 " result.push(obj.x0);" |
| 211 " holder.x1 = i;" | 212 " holder.x1 = i + 1;" |
| 212 " result.push(obj.x1);" | 213 " result.push(obj.x1);" |
| 213 " holder[key_0] = i;" | 214 " holder[key_0] = i + 2;" |
| 214 " result.push(obj[key_0]);" | 215 " result.push(obj[key_0]);" |
| 215 " holder[key_1] = i;" | 216 " holder[key_1] = i + 3;" |
| 216 " result.push(obj[key_1]);" | 217 " result.push(obj[key_1]);" |
| 217 "}" | 218 "}" |
| 218 "result")); | 219 "result")); |
| 219 CHECK_EQ(40, array->Length()); | 220 CHECK_EQ(40, array->Length()); |
| 220 for (int i = 0; i < 40; i++) { | 221 for (int i = 0; i < 40; i++) { |
| 221 v8::Handle<Value> entry = array->Get(v8::Integer::New(i)); | 222 v8::Handle<Value> entry = array->Get(v8::Integer::New(i)); |
| 222 CHECK_EQ(v8::Integer::New(i/4), entry); | 223 CHECK_EQ(v8::Integer::New(i), entry); |
| 223 } | 224 } |
| 224 } | 225 } |
| 225 | 226 |
| 226 | 227 |
| 227 static void AccessorProhibitsOverwritingGetter( | 228 static void AccessorProhibitsOverwritingGetter( |
| 228 Local<String> name, | 229 Local<String> name, |
| 229 const v8::PropertyCallbackInfo<v8::Value>& info) { | 230 const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 230 ApiTestFuzzer::Fuzz(); | 231 ApiTestFuzzer::Fuzz(); |
| 231 info.GetReturnValue().Set(true); | 232 info.GetReturnValue().Set(true); |
| 232 } | 233 } |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 453 "for (var i = 0; i < 5; i++) {" | 454 "for (var i = 0; i < 5; i++) {" |
| 454 " try { obj.x = i; } catch (e) { result += e; }" | 455 " try { obj.x = i; } catch (e) { result += e; }" |
| 455 "}; result"))->Run(); | 456 "}; result"))->Run(); |
| 456 CHECK_EQ(v8_str("01234"), result); | 457 CHECK_EQ(v8_str("01234"), result); |
| 457 } | 458 } |
| 458 | 459 |
| 459 | 460 |
| 460 static void AllocGetter(Local<String> name, | 461 static void AllocGetter(Local<String> name, |
| 461 const v8::PropertyCallbackInfo<v8::Value>& info) { | 462 const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 462 ApiTestFuzzer::Fuzz(); | 463 ApiTestFuzzer::Fuzz(); |
| 463 info.GetReturnValue().Set(v8::Array::New(1000)); | 464 info.GetReturnValue().Set(v8::Array::New(info.GetIsolate(), 1000)); |
| 464 } | 465 } |
| 465 | 466 |
| 466 | 467 |
| 467 THREADED_TEST(Gc) { | 468 THREADED_TEST(Gc) { |
| 468 LocalContext env; | 469 LocalContext env; |
| 469 v8::HandleScope scope(env->GetIsolate()); | 470 v8::HandleScope scope(env->GetIsolate()); |
| 470 v8::Handle<v8::ObjectTemplate> obj = ObjectTemplate::New(); | 471 v8::Handle<v8::ObjectTemplate> obj = ObjectTemplate::New(); |
| 471 obj->SetAccessor(v8_str("xxx"), AllocGetter); | 472 obj->SetAccessor(v8_str("xxx"), AllocGetter); |
| 472 env->Global()->Set(v8_str("obj"), obj->NewInstance()); | 473 env->Global()->Set(v8_str("obj"), obj->NewInstance()); |
| 473 Script::Compile(String::NewFromUtf8( | 474 Script::Compile(String::NewFromUtf8( |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 536 env->GetIsolate(), | 537 env->GetIsolate(), |
| 537 "var result;" | 538 "var result;" |
| 538 "for (var i = 0; i < 4; i++)" | 539 "for (var i = 0; i < 4; i++)" |
| 539 " result = obj.xxx;" | 540 " result = obj.xxx;" |
| 540 "result;"))->Run(); | 541 "result;"))->Run(); |
| 541 CHECK_EQ(100, result->Int32Value()); | 542 CHECK_EQ(100, result->Int32Value()); |
| 542 } | 543 } |
| 543 | 544 |
| 544 | 545 |
| 545 void JSONStringifyEnumerator(const v8::PropertyCallbackInfo<v8::Array>& info) { | 546 void JSONStringifyEnumerator(const v8::PropertyCallbackInfo<v8::Array>& info) { |
| 546 v8::Handle<v8::Array> array = v8::Array::New(1); | 547 v8::Handle<v8::Array> array = v8::Array::New(info.GetIsolate(), 1); |
| 547 array->Set(0, v8_str("regress")); | 548 array->Set(0, v8_str("regress")); |
| 548 info.GetReturnValue().Set(array); | 549 info.GetReturnValue().Set(array); |
| 549 } | 550 } |
| 550 | 551 |
| 551 | 552 |
| 552 void JSONStringifyGetter(Local<String> name, | 553 void JSONStringifyGetter(Local<String> name, |
| 553 const v8::PropertyCallbackInfo<v8::Value>& info) { | 554 const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 554 info.GetReturnValue().Set(v8_str("crbug-161028")); | 555 info.GetReturnValue().Set(v8_str("crbug-161028")); |
| 555 } | 556 } |
| 556 | 557 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 574 v8::HandleScope scope(isolate); | 575 v8::HandleScope scope(isolate); |
| 575 v8::Handle<v8::Function> fun = v8::Function::New(isolate, handle_property); | 576 v8::Handle<v8::Function> fun = v8::Function::New(isolate, handle_property); |
| 576 LocalContext switch_context; | 577 LocalContext switch_context; |
| 577 switch_context->Global()->Set(v8_str("fun"), fun); | 578 switch_context->Global()->Set(v8_str("fun"), fun); |
| 578 v8::TryCatch try_catch; | 579 v8::TryCatch try_catch; |
| 579 CompileRun( | 580 CompileRun( |
| 580 "var o = Object.create(null, { n: { get:fun } });" | 581 "var o = Object.create(null, { n: { get:fun } });" |
| 581 "for (var i = 0; i < 10; i++) o.n;"); | 582 "for (var i = 0; i < 10; i++) o.n;"); |
| 582 CHECK(!try_catch.HasCaught()); | 583 CHECK(!try_catch.HasCaught()); |
| 583 } | 584 } |
| OLD | NEW |