| 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 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 251 CHECK(info.GetIsolate() == v8::Isolate::GetCurrent()); | 251 CHECK(info.GetIsolate() == v8::Isolate::GetCurrent()); |
| 252 CHECK(info.This() == info.Holder()); | 252 CHECK(info.This() == info.Holder()); |
| 253 CHECK(info.Data()->Equals(v8::String::New("data"))); | 253 CHECK(info.Data()->Equals(v8::String::New("data"))); |
| 254 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); | 254 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); |
| 255 CHECK(info.GetIsolate() == v8::Isolate::GetCurrent()); | 255 CHECK(info.GetIsolate() == v8::Isolate::GetCurrent()); |
| 256 CHECK(info.This() == info.Holder()); | 256 CHECK(info.This() == info.Holder()); |
| 257 CHECK(info.Data()->Equals(v8::String::New("data"))); | 257 CHECK(info.Data()->Equals(v8::String::New("data"))); |
| 258 info.GetReturnValue().Set(17); | 258 info.GetReturnValue().Set(17); |
| 259 } | 259 } |
| 260 | 260 |
| 261 |
| 261 THREADED_TEST(DirectCall) { | 262 THREADED_TEST(DirectCall) { |
| 262 LocalContext context; | 263 LocalContext context; |
| 263 v8::HandleScope scope(context->GetIsolate()); | 264 v8::HandleScope scope(context->GetIsolate()); |
| 264 v8::Handle<v8::ObjectTemplate> obj = ObjectTemplate::New(); | 265 v8::Handle<v8::ObjectTemplate> obj = ObjectTemplate::New(); |
| 265 obj->SetAccessor(v8_str("xxx"), | 266 obj->SetAccessor(v8_str("xxx"), |
| 266 CheckAccessorArgsCorrect, | 267 CheckAccessorArgsCorrect, |
| 267 NULL, | 268 NULL, |
| 268 v8::String::New("data")); | 269 v8::String::New("data")); |
| 269 v8::Handle<v8::Object> inst = obj->NewInstance(); | 270 v8::Handle<v8::Object> inst = obj->NewInstance(); |
| 270 context->Global()->Set(v8::String::New("obj"), inst); | 271 context->Global()->Set(v8::String::New("obj"), inst); |
| 271 Local<Script> scr = v8::Script::Compile(v8::String::New("obj.xxx")); | 272 Local<Script> scr = v8::Script::Compile(v8::String::New("obj.xxx")); |
| 272 for (int i = 0; i < 10; i++) { | 273 for (int i = 0; i < 10; i++) { |
| 273 Local<Value> result = scr->Run(); | 274 Local<Value> result = scr->Run(); |
| 274 CHECK(!result.IsEmpty()); | 275 CHECK(!result.IsEmpty()); |
| 275 CHECK_EQ(17, result->Int32Value()); | 276 CHECK_EQ(17, result->Int32Value()); |
| 276 } | 277 } |
| 277 } | 278 } |
| 278 | 279 |
| 279 static void EmptyGetter(Local<String> name, | 280 static void EmptyGetter(Local<String> name, |
| 280 const v8::PropertyCallbackInfo<v8::Value>& info) { | 281 const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 281 CheckAccessorArgsCorrect(name, info); | 282 CheckAccessorArgsCorrect(name, info); |
| 282 ApiTestFuzzer::Fuzz(); | 283 ApiTestFuzzer::Fuzz(); |
| 283 CheckAccessorArgsCorrect(name, info); | 284 CheckAccessorArgsCorrect(name, info); |
| 284 info.GetReturnValue().Set(v8::Handle<v8::Value>()); | 285 info.GetReturnValue().Set(v8::Handle<v8::Value>()); |
| 285 } | 286 } |
| 286 | 287 |
| 288 |
| 287 THREADED_TEST(EmptyResult) { | 289 THREADED_TEST(EmptyResult) { |
| 288 LocalContext context; | 290 LocalContext context; |
| 289 v8::HandleScope scope(context->GetIsolate()); | 291 v8::HandleScope scope(context->GetIsolate()); |
| 290 v8::Handle<v8::ObjectTemplate> obj = ObjectTemplate::New(); | 292 v8::Handle<v8::ObjectTemplate> obj = ObjectTemplate::New(); |
| 291 obj->SetAccessor(v8_str("xxx"), EmptyGetter, NULL, v8::String::New("data")); | 293 obj->SetAccessor(v8_str("xxx"), EmptyGetter, NULL, v8::String::New("data")); |
| 292 v8::Handle<v8::Object> inst = obj->NewInstance(); | 294 v8::Handle<v8::Object> inst = obj->NewInstance(); |
| 293 context->Global()->Set(v8::String::New("obj"), inst); | 295 context->Global()->Set(v8::String::New("obj"), inst); |
| 294 Local<Script> scr = v8::Script::Compile(v8::String::New("obj.xxx")); | 296 Local<Script> scr = v8::Script::Compile(v8::String::New("obj.xxx")); |
| 295 for (int i = 0; i < 10; i++) { | 297 for (int i = 0; i < 10; i++) { |
| 296 Local<Value> result = scr->Run(); | 298 Local<Value> result = scr->Run(); |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 476 LocalContext env; | 478 LocalContext env; |
| 477 v8::HandleScope scope(env->GetIsolate()); | 479 v8::HandleScope scope(env->GetIsolate()); |
| 478 | 480 |
| 479 v8::Handle<v8::ObjectTemplate> obj = ObjectTemplate::New(); | 481 v8::Handle<v8::ObjectTemplate> obj = ObjectTemplate::New(); |
| 480 obj->SetNamedPropertyHandler( | 482 obj->SetNamedPropertyHandler( |
| 481 JSONStringifyGetter, NULL, NULL, NULL, JSONStringifyEnumerator); | 483 JSONStringifyGetter, NULL, NULL, NULL, JSONStringifyEnumerator); |
| 482 env->Global()->Set(v8_str("obj"), obj->NewInstance()); | 484 env->Global()->Set(v8_str("obj"), obj->NewInstance()); |
| 483 v8::Handle<v8::String> expected = v8_str("{\"regress\":\"crbug-161028\"}"); | 485 v8::Handle<v8::String> expected = v8_str("{\"regress\":\"crbug-161028\"}"); |
| 484 CHECK(CompileRun("JSON.stringify(obj)")->Equals(expected)); | 486 CHECK(CompileRun("JSON.stringify(obj)")->Equals(expected)); |
| 485 } | 487 } |
| OLD | NEW |