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 341 matching lines...) Expand 10 before | Expand all | Expand 10 after 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 |