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 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 reinterpret_cast<i::CpuProfiler*>(cpu_profiler)->DeleteAllProfiles(); | 100 reinterpret_cast<i::CpuProfiler*>(cpu_profiler)->DeleteAllProfiles(); |
101 } | 101 } |
102 | 102 |
103 | 103 |
104 static int signature_callback_count; | 104 static int signature_callback_count; |
105 static Local<Value> signature_expected_receiver; | 105 static Local<Value> signature_expected_receiver; |
106 static void IncrementingSignatureCallback( | 106 static void IncrementingSignatureCallback( |
107 const v8::FunctionCallbackInfo<v8::Value>& args) { | 107 const v8::FunctionCallbackInfo<v8::Value>& args) { |
108 ApiTestFuzzer::Fuzz(); | 108 ApiTestFuzzer::Fuzz(); |
109 signature_callback_count++; | 109 signature_callback_count++; |
110 CHECK(signature_expected_receiver->Equals(args.Holder())); | 110 CHECK_EQ(signature_expected_receiver, args.Holder()); |
111 CHECK(signature_expected_receiver->Equals(args.This())); | 111 CHECK_EQ(signature_expected_receiver, args.This()); |
112 v8::Handle<v8::Array> result = | 112 v8::Handle<v8::Array> result = |
113 v8::Array::New(args.GetIsolate(), args.Length()); | 113 v8::Array::New(args.GetIsolate(), args.Length()); |
114 for (int i = 0; i < args.Length(); i++) | 114 for (int i = 0; i < args.Length(); i++) |
115 result->Set(v8::Integer::New(args.GetIsolate(), i), args[i]); | 115 result->Set(v8::Integer::New(args.GetIsolate(), i), args[i]); |
116 args.GetReturnValue().Set(result); | 116 args.GetReturnValue().Set(result); |
117 } | 117 } |
118 | 118 |
119 | 119 |
120 // Tests that call v8::V8::Dispose() cannot be threaded. | 120 // Tests that call v8::V8::Dispose() cannot be threaded. |
121 UNINITIALIZED_TEST(InitializeAndDisposeOnce) { | 121 UNINITIALIZED_TEST(InitializeAndDisposeOnce) { |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 loop_js); | 183 loop_js); |
184 signature_callback_count = 0; | 184 signature_callback_count = 0; |
185 signature_expected_receiver = receiver; | 185 signature_expected_receiver = receiver; |
186 bool expected_to_throw = receiver.IsEmpty(); | 186 bool expected_to_throw = receiver.IsEmpty(); |
187 v8::TryCatch try_catch; | 187 v8::TryCatch try_catch; |
188 CompileRun(source.start()); | 188 CompileRun(source.start()); |
189 CHECK_EQ(expected_to_throw, try_catch.HasCaught()); | 189 CHECK_EQ(expected_to_throw, try_catch.HasCaught()); |
190 if (!expected_to_throw) { | 190 if (!expected_to_throw) { |
191 CHECK_EQ(10, signature_callback_count); | 191 CHECK_EQ(10, signature_callback_count); |
192 } else { | 192 } else { |
193 CHECK(v8_str("TypeError: Illegal invocation") | 193 CHECK_EQ(v8_str("TypeError: Illegal invocation"), |
194 ->Equals(try_catch.Exception()->ToString(isolate))); | 194 try_catch.Exception()->ToString(isolate)); |
195 } | 195 } |
196 } | 196 } |
197 | 197 |
198 | 198 |
199 THREADED_TEST(ReceiverSignature) { | 199 THREADED_TEST(ReceiverSignature) { |
200 LocalContext env; | 200 LocalContext env; |
201 v8::Isolate* isolate = env->GetIsolate(); | 201 v8::Isolate* isolate = env->GetIsolate(); |
202 v8::HandleScope scope(isolate); | 202 v8::HandleScope scope(isolate); |
203 // Setup templates. | 203 // Setup templates. |
204 v8::Handle<v8::FunctionTemplate> fun = v8::FunctionTemplate::New(isolate); | 204 v8::Handle<v8::FunctionTemplate> fun = v8::FunctionTemplate::New(isolate); |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
289 v8::Isolate* isolate = env->GetIsolate(); | 289 v8::Isolate* isolate = env->GetIsolate(); |
290 v8::HandleScope scope(isolate); | 290 v8::HandleScope scope(isolate); |
291 Local<v8::Object> obj = v8::Object::New(isolate); | 291 Local<v8::Object> obj = v8::Object::New(isolate); |
292 Local<Value> foo_before = obj->Get(v8_str("foo")); | 292 Local<Value> foo_before = obj->Get(v8_str("foo")); |
293 CHECK(foo_before->IsUndefined()); | 293 CHECK(foo_before->IsUndefined()); |
294 Local<String> bar_str = v8_str("bar"); | 294 Local<String> bar_str = v8_str("bar"); |
295 obj->Set(v8_str("foo"), bar_str); | 295 obj->Set(v8_str("foo"), bar_str); |
296 Local<Value> foo_after = obj->Get(v8_str("foo")); | 296 Local<Value> foo_after = obj->Get(v8_str("foo")); |
297 CHECK(!foo_after->IsUndefined()); | 297 CHECK(!foo_after->IsUndefined()); |
298 CHECK(foo_after->IsString()); | 298 CHECK(foo_after->IsString()); |
299 CHECK(bar_str->Equals(foo_after)); | 299 CHECK_EQ(bar_str, foo_after); |
300 } | 300 } |
301 | 301 |
302 | 302 |
303 THREADED_TEST(AccessElement) { | 303 THREADED_TEST(AccessElement) { |
304 LocalContext env; | 304 LocalContext env; |
305 v8::HandleScope scope(env->GetIsolate()); | 305 v8::HandleScope scope(env->GetIsolate()); |
306 Local<v8::Object> obj = v8::Object::New(env->GetIsolate()); | 306 Local<v8::Object> obj = v8::Object::New(env->GetIsolate()); |
307 Local<Value> before = obj->Get(1); | 307 Local<Value> before = obj->Get(1); |
308 CHECK(before->IsUndefined()); | 308 CHECK(before->IsUndefined()); |
309 Local<String> bar_str = v8_str("bar"); | 309 Local<String> bar_str = v8_str("bar"); |
310 obj->Set(1, bar_str); | 310 obj->Set(1, bar_str); |
311 Local<Value> after = obj->Get(1); | 311 Local<Value> after = obj->Get(1); |
312 CHECK(!after->IsUndefined()); | 312 CHECK(!after->IsUndefined()); |
313 CHECK(after->IsString()); | 313 CHECK(after->IsString()); |
314 CHECK(bar_str->Equals(after)); | 314 CHECK_EQ(bar_str, after); |
315 | 315 |
316 Local<v8::Array> value = CompileRun("[\"a\", \"b\"]").As<v8::Array>(); | 316 Local<v8::Array> value = CompileRun("[\"a\", \"b\"]").As<v8::Array>(); |
317 CHECK(v8_str("a")->Equals(value->Get(0))); | 317 CHECK_EQ(v8_str("a"), value->Get(0)); |
318 CHECK(v8_str("b")->Equals(value->Get(1))); | 318 CHECK_EQ(v8_str("b"), value->Get(1)); |
319 } | 319 } |
320 | 320 |
321 | 321 |
322 THREADED_TEST(Script) { | 322 THREADED_TEST(Script) { |
323 LocalContext env; | 323 LocalContext env; |
324 v8::HandleScope scope(env->GetIsolate()); | 324 v8::HandleScope scope(env->GetIsolate()); |
325 const char* source = "1 + 2 + 3"; | 325 const char* source = "1 + 2 + 3"; |
326 Local<Script> script = v8_compile(source); | 326 Local<Script> script = v8_compile(source); |
327 CHECK_EQ(6, script->Run()->Int32Value()); | 327 CHECK_EQ(6, script->Run()->Int32Value()); |
328 } | 328 } |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
452 LocalContext env; | 452 LocalContext env; |
453 v8::HandleScope scope(env->GetIsolate()); | 453 v8::HandleScope scope(env->GetIsolate()); |
454 Local<String> source = | 454 Local<String> source = |
455 String::NewFromTwoByte(env->GetIsolate(), two_byte_source); | 455 String::NewFromTwoByte(env->GetIsolate(), two_byte_source); |
456 // Trigger GCs so that the newly allocated string moves to old gen. | 456 // Trigger GCs so that the newly allocated string moves to old gen. |
457 CcTest::heap()->CollectGarbage(i::NEW_SPACE); // in survivor space now | 457 CcTest::heap()->CollectGarbage(i::NEW_SPACE); // in survivor space now |
458 CcTest::heap()->CollectGarbage(i::NEW_SPACE); // in old gen now | 458 CcTest::heap()->CollectGarbage(i::NEW_SPACE); // in old gen now |
459 CHECK_EQ(source->IsExternal(), false); | 459 CHECK_EQ(source->IsExternal(), false); |
460 CHECK_EQ(source->IsExternalOneByte(), false); | 460 CHECK_EQ(source->IsExternalOneByte(), false); |
461 String::Encoding encoding = String::UNKNOWN_ENCODING; | 461 String::Encoding encoding = String::UNKNOWN_ENCODING; |
462 CHECK(!source->GetExternalStringResourceBase(&encoding)); | 462 CHECK_EQ(NULL, source->GetExternalStringResourceBase(&encoding)); |
463 CHECK_EQ(String::ONE_BYTE_ENCODING, encoding); | 463 CHECK_EQ(String::ONE_BYTE_ENCODING, encoding); |
464 bool success = source->MakeExternal(new TestResource(two_byte_source, | 464 bool success = source->MakeExternal(new TestResource(two_byte_source, |
465 &dispose_count)); | 465 &dispose_count)); |
466 CHECK(success); | 466 CHECK(success); |
467 Local<Script> script = v8_compile(source); | 467 Local<Script> script = v8_compile(source); |
468 Local<Value> value = script->Run(); | 468 Local<Value> value = script->Run(); |
469 CHECK(value->IsNumber()); | 469 CHECK(value->IsNumber()); |
470 CHECK_EQ(7, value->Int32Value()); | 470 CHECK_EQ(7, value->Int32Value()); |
471 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); | 471 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); |
472 CHECK_EQ(0, dispose_count); | 472 CHECK_EQ(0, dispose_count); |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
690 THREADED_TEST(NewExternalForVeryLongString) { | 690 THREADED_TEST(NewExternalForVeryLongString) { |
691 { | 691 { |
692 LocalContext env; | 692 LocalContext env; |
693 v8::HandleScope scope(env->GetIsolate()); | 693 v8::HandleScope scope(env->GetIsolate()); |
694 v8::TryCatch try_catch; | 694 v8::TryCatch try_catch; |
695 RandomLengthOneByteResource r(1 << 30); | 695 RandomLengthOneByteResource r(1 << 30); |
696 v8::Local<v8::String> str = v8::String::NewExternal(CcTest::isolate(), &r); | 696 v8::Local<v8::String> str = v8::String::NewExternal(CcTest::isolate(), &r); |
697 CHECK(str.IsEmpty()); | 697 CHECK(str.IsEmpty()); |
698 CHECK(try_catch.HasCaught()); | 698 CHECK(try_catch.HasCaught()); |
699 String::Utf8Value exception_value(try_catch.Exception()); | 699 String::Utf8Value exception_value(try_catch.Exception()); |
700 CHECK_EQ(0, strcmp("RangeError: Invalid string length", *exception_value)); | 700 CHECK_EQ("RangeError: Invalid string length", *exception_value); |
701 } | 701 } |
702 | 702 |
703 { | 703 { |
704 LocalContext env; | 704 LocalContext env; |
705 v8::HandleScope scope(env->GetIsolate()); | 705 v8::HandleScope scope(env->GetIsolate()); |
706 v8::TryCatch try_catch; | 706 v8::TryCatch try_catch; |
707 RandomLengthResource r(1 << 30); | 707 RandomLengthResource r(1 << 30); |
708 v8::Local<v8::String> str = v8::String::NewExternal(CcTest::isolate(), &r); | 708 v8::Local<v8::String> str = v8::String::NewExternal(CcTest::isolate(), &r); |
709 CHECK(str.IsEmpty()); | 709 CHECK(str.IsEmpty()); |
710 CHECK(try_catch.HasCaught()); | 710 CHECK(try_catch.HasCaught()); |
711 String::Utf8Value exception_value(try_catch.Exception()); | 711 String::Utf8Value exception_value(try_catch.Exception()); |
712 CHECK_EQ(0, strcmp("RangeError: Invalid string length", *exception_value)); | 712 CHECK_EQ("RangeError: Invalid string length", *exception_value); |
713 } | 713 } |
714 } | 714 } |
715 | 715 |
716 | 716 |
717 THREADED_TEST(ScavengeExternalString) { | 717 THREADED_TEST(ScavengeExternalString) { |
718 i::FLAG_stress_compaction = false; | 718 i::FLAG_stress_compaction = false; |
719 i::FLAG_gc_global = false; | 719 i::FLAG_gc_global = false; |
720 int dispose_count = 0; | 720 int dispose_count = 0; |
721 bool in_new_space = false; | 721 bool in_new_space = false; |
722 { | 722 { |
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
994 LocalContext env; | 994 LocalContext env; |
995 v8::HandleScope scope(env->GetIsolate()); | 995 v8::HandleScope scope(env->GetIsolate()); |
996 | 996 |
997 Local<v8::FunctionTemplate> fun_templ = | 997 Local<v8::FunctionTemplate> fun_templ = |
998 v8::FunctionTemplate::New(env->GetIsolate(), constructor); | 998 v8::FunctionTemplate::New(env->GetIsolate(), constructor); |
999 fun_templ->SetClassName(v8_str("funky")); | 999 fun_templ->SetClassName(v8_str("funky")); |
1000 fun_templ->InstanceTemplate()->SetAccessor(v8_str("m"), accessor); | 1000 fun_templ->InstanceTemplate()->SetAccessor(v8_str("m"), accessor); |
1001 Local<Function> fun = fun_templ->GetFunction(); | 1001 Local<Function> fun = fun_templ->GetFunction(); |
1002 env->Global()->Set(v8_str("obj"), fun); | 1002 env->Global()->Set(v8_str("obj"), fun); |
1003 Local<Value> result = v8_compile("(new obj()).toString()")->Run(); | 1003 Local<Value> result = v8_compile("(new obj()).toString()")->Run(); |
1004 CHECK(v8_str("[object funky]")->Equals(result)); | 1004 CHECK_EQ(v8_str("[object funky]"), result); |
1005 CompileRun("var obj_instance = new obj();"); | 1005 CompileRun("var obj_instance = new obj();"); |
1006 Local<Script> script; | 1006 Local<Script> script; |
1007 script = v8_compile("obj_instance.x"); | 1007 script = v8_compile("obj_instance.x"); |
1008 for (int i = 0; i < 30; i++) { | 1008 for (int i = 0; i < 30; i++) { |
1009 CHECK_EQ(1, script->Run()->Int32Value()); | 1009 CHECK_EQ(1, script->Run()->Int32Value()); |
1010 } | 1010 } |
1011 script = v8_compile("obj_instance.m"); | 1011 script = v8_compile("obj_instance.m"); |
1012 for (int i = 0; i < 30; i++) { | 1012 for (int i = 0; i < 30; i++) { |
1013 CHECK_EQ(239, script->Run()->Int32Value()); | 1013 CHECK_EQ(239, script->Run()->Int32Value()); |
1014 } | 1014 } |
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1346 Local<v8::Function> other_function = other->GetFunction(); | 1346 Local<v8::Function> other_function = other->GetFunction(); |
1347 | 1347 |
1348 Local<v8::Object> base_instance = base_function->NewInstance(); | 1348 Local<v8::Object> base_instance = base_function->NewInstance(); |
1349 Local<v8::Object> derived_instance = derived_function->NewInstance(); | 1349 Local<v8::Object> derived_instance = derived_function->NewInstance(); |
1350 Local<v8::Object> derived_instance2 = derived_function->NewInstance(); | 1350 Local<v8::Object> derived_instance2 = derived_function->NewInstance(); |
1351 Local<v8::Object> other_instance = other_function->NewInstance(); | 1351 Local<v8::Object> other_instance = other_function->NewInstance(); |
1352 derived_instance2->Set(v8_str("__proto__"), derived_instance); | 1352 derived_instance2->Set(v8_str("__proto__"), derived_instance); |
1353 other_instance->Set(v8_str("__proto__"), derived_instance2); | 1353 other_instance->Set(v8_str("__proto__"), derived_instance2); |
1354 | 1354 |
1355 // base_instance is only an instance of base. | 1355 // base_instance is only an instance of base. |
1356 CHECK( | 1356 CHECK_EQ(base_instance, |
1357 base_instance->Equals(base_instance->FindInstanceInPrototypeChain(base))); | 1357 base_instance->FindInstanceInPrototypeChain(base)); |
1358 CHECK(base_instance->FindInstanceInPrototypeChain(derived).IsEmpty()); | 1358 CHECK(base_instance->FindInstanceInPrototypeChain(derived).IsEmpty()); |
1359 CHECK(base_instance->FindInstanceInPrototypeChain(other).IsEmpty()); | 1359 CHECK(base_instance->FindInstanceInPrototypeChain(other).IsEmpty()); |
1360 | 1360 |
1361 // derived_instance is an instance of base and derived. | 1361 // derived_instance is an instance of base and derived. |
1362 CHECK(derived_instance->Equals( | 1362 CHECK_EQ(derived_instance, |
1363 derived_instance->FindInstanceInPrototypeChain(base))); | 1363 derived_instance->FindInstanceInPrototypeChain(base)); |
1364 CHECK(derived_instance->Equals( | 1364 CHECK_EQ(derived_instance, |
1365 derived_instance->FindInstanceInPrototypeChain(derived))); | 1365 derived_instance->FindInstanceInPrototypeChain(derived)); |
1366 CHECK(derived_instance->FindInstanceInPrototypeChain(other).IsEmpty()); | 1366 CHECK(derived_instance->FindInstanceInPrototypeChain(other).IsEmpty()); |
1367 | 1367 |
1368 // other_instance is an instance of other and its immediate | 1368 // other_instance is an instance of other and its immediate |
1369 // prototype derived_instance2 is an instance of base and derived. | 1369 // prototype derived_instance2 is an instance of base and derived. |
1370 // Note, derived_instance is an instance of base and derived too, | 1370 // Note, derived_instance is an instance of base and derived too, |
1371 // but it comes after derived_instance2 in the prototype chain of | 1371 // but it comes after derived_instance2 in the prototype chain of |
1372 // other_instance. | 1372 // other_instance. |
1373 CHECK(derived_instance2->Equals( | 1373 CHECK_EQ(derived_instance2, |
1374 other_instance->FindInstanceInPrototypeChain(base))); | 1374 other_instance->FindInstanceInPrototypeChain(base)); |
1375 CHECK(derived_instance2->Equals( | 1375 CHECK_EQ(derived_instance2, |
1376 other_instance->FindInstanceInPrototypeChain(derived))); | 1376 other_instance->FindInstanceInPrototypeChain(derived)); |
1377 CHECK(other_instance->Equals( | 1377 CHECK_EQ(other_instance, |
1378 other_instance->FindInstanceInPrototypeChain(other))); | 1378 other_instance->FindInstanceInPrototypeChain(other)); |
1379 } | 1379 } |
1380 | 1380 |
1381 | 1381 |
1382 THREADED_TEST(TinyInteger) { | 1382 THREADED_TEST(TinyInteger) { |
1383 LocalContext env; | 1383 LocalContext env; |
1384 v8::Isolate* isolate = env->GetIsolate(); | 1384 v8::Isolate* isolate = env->GetIsolate(); |
1385 v8::HandleScope scope(isolate); | 1385 v8::HandleScope scope(isolate); |
1386 | 1386 |
1387 int32_t value = 239; | 1387 int32_t value = 239; |
1388 Local<v8::Integer> value_obj = v8::Integer::New(isolate, value); | 1388 Local<v8::Integer> value_obj = v8::Integer::New(isolate, value); |
(...skipping 512 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1901 CHECK(v8_compile("obj2.v1")->Run()->IsUndefined()); | 1901 CHECK(v8_compile("obj2.v1")->Run()->IsUndefined()); |
1902 } | 1902 } |
1903 | 1903 |
1904 | 1904 |
1905 int echo_named_call_count; | 1905 int echo_named_call_count; |
1906 | 1906 |
1907 | 1907 |
1908 static void EchoNamedProperty(Local<Name> name, | 1908 static void EchoNamedProperty(Local<Name> name, |
1909 const v8::PropertyCallbackInfo<v8::Value>& info) { | 1909 const v8::PropertyCallbackInfo<v8::Value>& info) { |
1910 ApiTestFuzzer::Fuzz(); | 1910 ApiTestFuzzer::Fuzz(); |
1911 CHECK(v8_str("data")->Equals(info.Data())); | 1911 CHECK_EQ(v8_str("data"), info.Data()); |
1912 echo_named_call_count++; | 1912 echo_named_call_count++; |
1913 info.GetReturnValue().Set(name); | 1913 info.GetReturnValue().Set(name); |
1914 } | 1914 } |
1915 | 1915 |
1916 | 1916 |
1917 // Helper functions for Interceptor/Accessor interaction tests | 1917 // Helper functions for Interceptor/Accessor interaction tests |
1918 | 1918 |
1919 void SimpleAccessorGetter(Local<String> name, | 1919 void SimpleAccessorGetter(Local<String> name, |
1920 const v8::PropertyCallbackInfo<v8::Value>& info) { | 1920 const v8::PropertyCallbackInfo<v8::Value>& info) { |
1921 Handle<Object> self = Handle<Object>::Cast(info.This()); | 1921 Handle<Object> self = Handle<Object>::Cast(info.This()); |
(...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2417 EchoNamedProperty, 0, 0, 0, 0, v8_str("data"))); | 2417 EchoNamedProperty, 0, 0, 0, 0, v8_str("data"))); |
2418 LocalContext env; | 2418 LocalContext env; |
2419 env->Global()->Set(v8_str("obj"), | 2419 env->Global()->Set(v8_str("obj"), |
2420 templ->GetFunction()->NewInstance()); | 2420 templ->GetFunction()->NewInstance()); |
2421 CHECK_EQ(echo_named_call_count, 0); | 2421 CHECK_EQ(echo_named_call_count, 0); |
2422 v8_compile("obj.x")->Run(); | 2422 v8_compile("obj.x")->Run(); |
2423 CHECK_EQ(echo_named_call_count, 1); | 2423 CHECK_EQ(echo_named_call_count, 1); |
2424 const char* code = "var str = 'oddle'; obj[str] + obj.poddle;"; | 2424 const char* code = "var str = 'oddle'; obj[str] + obj.poddle;"; |
2425 v8::Handle<Value> str = CompileRun(code); | 2425 v8::Handle<Value> str = CompileRun(code); |
2426 String::Utf8Value value(str); | 2426 String::Utf8Value value(str); |
2427 CHECK_EQ(0, strcmp(*value, "oddlepoddle")); | 2427 CHECK_EQ(*value, "oddlepoddle"); |
2428 // Check default behavior | 2428 // Check default behavior |
2429 CHECK_EQ(10, v8_compile("obj.flob = 10;")->Run()->Int32Value()); | 2429 CHECK_EQ(v8_compile("obj.flob = 10;")->Run()->Int32Value(), 10); |
2430 CHECK(v8_compile("'myProperty' in obj")->Run()->BooleanValue()); | 2430 CHECK(v8_compile("'myProperty' in obj")->Run()->BooleanValue()); |
2431 CHECK(v8_compile("delete obj.myProperty")->Run()->BooleanValue()); | 2431 CHECK(v8_compile("delete obj.myProperty")->Run()->BooleanValue()); |
2432 } | 2432 } |
2433 | 2433 |
2434 | 2434 |
2435 int echo_indexed_call_count = 0; | 2435 int echo_indexed_call_count = 0; |
2436 | 2436 |
2437 | 2437 |
2438 static void EchoIndexedProperty( | 2438 static void EchoIndexedProperty( |
2439 uint32_t index, | 2439 uint32_t index, |
2440 const v8::PropertyCallbackInfo<v8::Value>& info) { | 2440 const v8::PropertyCallbackInfo<v8::Value>& info) { |
2441 ApiTestFuzzer::Fuzz(); | 2441 ApiTestFuzzer::Fuzz(); |
2442 CHECK(v8_num(637)->Equals(info.Data())); | 2442 CHECK_EQ(v8_num(637), info.Data()); |
2443 echo_indexed_call_count++; | 2443 echo_indexed_call_count++; |
2444 info.GetReturnValue().Set(v8_num(index)); | 2444 info.GetReturnValue().Set(v8_num(index)); |
2445 } | 2445 } |
2446 | 2446 |
2447 | 2447 |
2448 THREADED_TEST(IndexedPropertyHandlerGetter) { | 2448 THREADED_TEST(IndexedPropertyHandlerGetter) { |
2449 v8::Isolate* isolate = CcTest::isolate(); | 2449 v8::Isolate* isolate = CcTest::isolate(); |
2450 v8::HandleScope scope(isolate); | 2450 v8::HandleScope scope(isolate); |
2451 v8::Handle<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(isolate); | 2451 v8::Handle<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(isolate); |
2452 templ->InstanceTemplate()->SetHandler(v8::IndexedPropertyHandlerConfiguration( | 2452 templ->InstanceTemplate()->SetHandler(v8::IndexedPropertyHandlerConfiguration( |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2609 | 2609 |
2610 THREADED_TEST(PrePropertyHandler) { | 2610 THREADED_TEST(PrePropertyHandler) { |
2611 v8::Isolate* isolate = CcTest::isolate(); | 2611 v8::Isolate* isolate = CcTest::isolate(); |
2612 v8::HandleScope scope(isolate); | 2612 v8::HandleScope scope(isolate); |
2613 v8::Handle<v8::FunctionTemplate> desc = v8::FunctionTemplate::New(isolate); | 2613 v8::Handle<v8::FunctionTemplate> desc = v8::FunctionTemplate::New(isolate); |
2614 desc->InstanceTemplate()->SetHandler(v8::NamedPropertyHandlerConfiguration( | 2614 desc->InstanceTemplate()->SetHandler(v8::NamedPropertyHandlerConfiguration( |
2615 PrePropertyHandlerGet, 0, PrePropertyHandlerQuery)); | 2615 PrePropertyHandlerGet, 0, PrePropertyHandlerQuery)); |
2616 LocalContext env(NULL, desc->InstanceTemplate()); | 2616 LocalContext env(NULL, desc->InstanceTemplate()); |
2617 CompileRun("var pre = 'Object: pre'; var on = 'Object: on';"); | 2617 CompileRun("var pre = 'Object: pre'; var on = 'Object: on';"); |
2618 v8::Handle<Value> result_pre = CompileRun("pre"); | 2618 v8::Handle<Value> result_pre = CompileRun("pre"); |
2619 CHECK(v8_str("PrePropertyHandler: pre")->Equals(result_pre)); | 2619 CHECK_EQ(v8_str("PrePropertyHandler: pre"), result_pre); |
2620 v8::Handle<Value> result_on = CompileRun("on"); | 2620 v8::Handle<Value> result_on = CompileRun("on"); |
2621 CHECK(v8_str("Object: on")->Equals(result_on)); | 2621 CHECK_EQ(v8_str("Object: on"), result_on); |
2622 v8::Handle<Value> result_post = CompileRun("post"); | 2622 v8::Handle<Value> result_post = CompileRun("post"); |
2623 CHECK(result_post.IsEmpty()); | 2623 CHECK(result_post.IsEmpty()); |
2624 } | 2624 } |
2625 | 2625 |
2626 | 2626 |
2627 THREADED_TEST(UndefinedIsNotEnumerable) { | 2627 THREADED_TEST(UndefinedIsNotEnumerable) { |
2628 LocalContext env; | 2628 LocalContext env; |
2629 v8::HandleScope scope(env->GetIsolate()); | 2629 v8::HandleScope scope(env->GetIsolate()); |
2630 v8::Handle<Value> result = CompileRun("this.propertyIsEnumerable(undefined)"); | 2630 v8::Handle<Value> result = CompileRun("this.propertyIsEnumerable(undefined)"); |
2631 CHECK(result->IsFalse()); | 2631 CHECK(result->IsFalse()); |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2705 THREADED_TEST(CallbackExceptionRegression) { | 2705 THREADED_TEST(CallbackExceptionRegression) { |
2706 v8::Isolate* isolate = CcTest::isolate(); | 2706 v8::Isolate* isolate = CcTest::isolate(); |
2707 v8::HandleScope scope(isolate); | 2707 v8::HandleScope scope(isolate); |
2708 v8::Handle<v8::ObjectTemplate> obj = ObjectTemplate::New(isolate); | 2708 v8::Handle<v8::ObjectTemplate> obj = ObjectTemplate::New(isolate); |
2709 obj->SetHandler(v8::NamedPropertyHandlerConfiguration( | 2709 obj->SetHandler(v8::NamedPropertyHandlerConfiguration( |
2710 ThrowingPropertyHandlerGet, ThrowingPropertyHandlerSet)); | 2710 ThrowingPropertyHandlerGet, ThrowingPropertyHandlerSet)); |
2711 LocalContext env; | 2711 LocalContext env; |
2712 env->Global()->Set(v8_str("obj"), obj->NewInstance()); | 2712 env->Global()->Set(v8_str("obj"), obj->NewInstance()); |
2713 v8::Handle<Value> otto = CompileRun( | 2713 v8::Handle<Value> otto = CompileRun( |
2714 "try { with (obj) { otto; } } catch (e) { e; }"); | 2714 "try { with (obj) { otto; } } catch (e) { e; }"); |
2715 CHECK(v8_str("otto")->Equals(otto)); | 2715 CHECK_EQ(v8_str("otto"), otto); |
2716 v8::Handle<Value> netto = CompileRun( | 2716 v8::Handle<Value> netto = CompileRun( |
2717 "try { with (obj) { netto = 4; } } catch (e) { e; }"); | 2717 "try { with (obj) { netto = 4; } } catch (e) { e; }"); |
2718 CHECK(v8_str("netto")->Equals(netto)); | 2718 CHECK_EQ(v8_str("netto"), netto); |
2719 } | 2719 } |
2720 | 2720 |
2721 | 2721 |
2722 THREADED_TEST(FunctionPrototype) { | 2722 THREADED_TEST(FunctionPrototype) { |
2723 v8::Isolate* isolate = CcTest::isolate(); | 2723 v8::Isolate* isolate = CcTest::isolate(); |
2724 v8::HandleScope scope(isolate); | 2724 v8::HandleScope scope(isolate); |
2725 Local<v8::FunctionTemplate> Foo = v8::FunctionTemplate::New(isolate); | 2725 Local<v8::FunctionTemplate> Foo = v8::FunctionTemplate::New(isolate); |
2726 Foo->PrototypeTemplate()->Set(v8_str("plak"), v8_num(321)); | 2726 Foo->PrototypeTemplate()->Set(v8_str("plak"), v8_num(321)); |
2727 LocalContext env; | 2727 LocalContext env; |
2728 env->Global()->Set(v8_str("Foo"), Foo->GetFunction()); | 2728 env->Global()->Set(v8_str("Foo"), Foo->GetFunction()); |
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3046 CHECK(!obj->Has(sym1)); | 3046 CHECK(!obj->Has(sym1)); |
3047 | 3047 |
3048 CHECK(obj->Set(sym1, v8::Integer::New(isolate, 1503))); | 3048 CHECK(obj->Set(sym1, v8::Integer::New(isolate, 1503))); |
3049 CHECK(obj->Has(sym1)); | 3049 CHECK(obj->Has(sym1)); |
3050 CHECK_EQ(1503, obj->Get(sym1)->Int32Value()); | 3050 CHECK_EQ(1503, obj->Get(sym1)->Int32Value()); |
3051 CHECK(obj->Set(sym1, v8::Integer::New(isolate, 2002))); | 3051 CHECK(obj->Set(sym1, v8::Integer::New(isolate, 2002))); |
3052 CHECK(obj->Has(sym1)); | 3052 CHECK(obj->Has(sym1)); |
3053 CHECK_EQ(2002, obj->Get(sym1)->Int32Value()); | 3053 CHECK_EQ(2002, obj->Get(sym1)->Int32Value()); |
3054 CHECK_EQ(v8::None, obj->GetPropertyAttributes(sym1)); | 3054 CHECK_EQ(v8::None, obj->GetPropertyAttributes(sym1)); |
3055 | 3055 |
3056 CHECK_EQ(0u, obj->GetOwnPropertyNames()->Length()); | 3056 CHECK_EQ(0, obj->GetOwnPropertyNames()->Length()); |
3057 unsigned num_props = obj->GetPropertyNames()->Length(); | 3057 int num_props = obj->GetPropertyNames()->Length(); |
3058 CHECK(obj->Set(v8::String::NewFromUtf8(isolate, "bla"), | 3058 CHECK(obj->Set(v8::String::NewFromUtf8(isolate, "bla"), |
3059 v8::Integer::New(isolate, 20))); | 3059 v8::Integer::New(isolate, 20))); |
3060 CHECK_EQ(1u, obj->GetOwnPropertyNames()->Length()); | 3060 CHECK_EQ(1, obj->GetOwnPropertyNames()->Length()); |
3061 CHECK_EQ(num_props + 1, obj->GetPropertyNames()->Length()); | 3061 CHECK_EQ(num_props + 1, obj->GetPropertyNames()->Length()); |
3062 | 3062 |
3063 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); | 3063 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); |
3064 | 3064 |
3065 CHECK(obj->SetAccessor(sym3, SymbolAccessorGetter, SymbolAccessorSetter)); | 3065 CHECK(obj->SetAccessor(sym3, SymbolAccessorGetter, SymbolAccessorSetter)); |
3066 CHECK(obj->Get(sym3)->IsUndefined()); | 3066 CHECK(obj->Get(sym3)->IsUndefined()); |
3067 CHECK(obj->Set(sym3, v8::Integer::New(isolate, 42))); | 3067 CHECK(obj->Set(sym3, v8::Integer::New(isolate, 42))); |
3068 CHECK(obj->Get(sym3)->Equals(v8::Integer::New(isolate, 42))); | 3068 CHECK(obj->Get(sym3)->Equals(v8::Integer::New(isolate, 42))); |
3069 CHECK(obj->Get(v8::String::NewFromUtf8(isolate, "accessor_sym3"))->Equals( | 3069 CHECK(obj->Get(v8::String::NewFromUtf8(isolate, "accessor_sym3"))->Equals( |
3070 v8::Integer::New(isolate, 42))); | 3070 v8::Integer::New(isolate, 42))); |
3071 | 3071 |
3072 // Add another property and delete it afterwards to force the object in | 3072 // Add another property and delete it afterwards to force the object in |
3073 // slow case. | 3073 // slow case. |
3074 CHECK(obj->Set(sym2, v8::Integer::New(isolate, 2008))); | 3074 CHECK(obj->Set(sym2, v8::Integer::New(isolate, 2008))); |
3075 CHECK_EQ(2002, obj->Get(sym1)->Int32Value()); | 3075 CHECK_EQ(2002, obj->Get(sym1)->Int32Value()); |
3076 CHECK_EQ(2008, obj->Get(sym2)->Int32Value()); | 3076 CHECK_EQ(2008, obj->Get(sym2)->Int32Value()); |
3077 CHECK_EQ(2002, obj->Get(sym1)->Int32Value()); | 3077 CHECK_EQ(2002, obj->Get(sym1)->Int32Value()); |
3078 CHECK_EQ(2u, obj->GetOwnPropertyNames()->Length()); | 3078 CHECK_EQ(2, obj->GetOwnPropertyNames()->Length()); |
3079 | 3079 |
3080 CHECK(obj->Has(sym1)); | 3080 CHECK(obj->Has(sym1)); |
3081 CHECK(obj->Has(sym2)); | 3081 CHECK(obj->Has(sym2)); |
3082 CHECK(obj->Has(sym3)); | 3082 CHECK(obj->Has(sym3)); |
3083 CHECK(obj->Has(v8::String::NewFromUtf8(isolate, "accessor_sym3"))); | 3083 CHECK(obj->Has(v8::String::NewFromUtf8(isolate, "accessor_sym3"))); |
3084 CHECK(obj->Delete(sym2)); | 3084 CHECK(obj->Delete(sym2)); |
3085 CHECK(obj->Has(sym1)); | 3085 CHECK(obj->Has(sym1)); |
3086 CHECK(!obj->Has(sym2)); | 3086 CHECK(!obj->Has(sym2)); |
3087 CHECK(obj->Has(sym3)); | 3087 CHECK(obj->Has(sym3)); |
3088 CHECK(obj->Has(v8::String::NewFromUtf8(isolate, "accessor_sym3"))); | 3088 CHECK(obj->Has(v8::String::NewFromUtf8(isolate, "accessor_sym3"))); |
3089 CHECK_EQ(2002, obj->Get(sym1)->Int32Value()); | 3089 CHECK_EQ(2002, obj->Get(sym1)->Int32Value()); |
3090 CHECK(obj->Get(sym3)->Equals(v8::Integer::New(isolate, 42))); | 3090 CHECK(obj->Get(sym3)->Equals(v8::Integer::New(isolate, 42))); |
3091 CHECK(obj->Get(v8::String::NewFromUtf8(isolate, "accessor_sym3"))->Equals( | 3091 CHECK(obj->Get(v8::String::NewFromUtf8(isolate, "accessor_sym3"))->Equals( |
3092 v8::Integer::New(isolate, 42))); | 3092 v8::Integer::New(isolate, 42))); |
3093 CHECK_EQ(2u, obj->GetOwnPropertyNames()->Length()); | 3093 CHECK_EQ(2, obj->GetOwnPropertyNames()->Length()); |
3094 | 3094 |
3095 // Symbol properties are inherited. | 3095 // Symbol properties are inherited. |
3096 v8::Local<v8::Object> child = v8::Object::New(isolate); | 3096 v8::Local<v8::Object> child = v8::Object::New(isolate); |
3097 child->SetPrototype(obj); | 3097 child->SetPrototype(obj); |
3098 CHECK(child->Has(sym1)); | 3098 CHECK(child->Has(sym1)); |
3099 CHECK_EQ(2002, child->Get(sym1)->Int32Value()); | 3099 CHECK_EQ(2002, child->Get(sym1)->Int32Value()); |
3100 CHECK(obj->Get(sym3)->Equals(v8::Integer::New(isolate, 42))); | 3100 CHECK(obj->Get(sym3)->Equals(v8::Integer::New(isolate, 42))); |
3101 CHECK(obj->Get(v8::String::NewFromUtf8(isolate, "accessor_sym3"))->Equals( | 3101 CHECK(obj->Get(v8::String::NewFromUtf8(isolate, "accessor_sym3"))->Equals( |
3102 v8::Integer::New(isolate, 42))); | 3102 v8::Integer::New(isolate, 42))); |
3103 CHECK_EQ(0u, child->GetOwnPropertyNames()->Length()); | 3103 CHECK_EQ(0, child->GetOwnPropertyNames()->Length()); |
3104 } | 3104 } |
3105 | 3105 |
3106 | 3106 |
3107 THREADED_TEST(SymbolTemplateProperties) { | 3107 THREADED_TEST(SymbolTemplateProperties) { |
3108 LocalContext env; | 3108 LocalContext env; |
3109 v8::Isolate* isolate = env->GetIsolate(); | 3109 v8::Isolate* isolate = env->GetIsolate(); |
3110 v8::HandleScope scope(isolate); | 3110 v8::HandleScope scope(isolate); |
3111 v8::Local<v8::FunctionTemplate> foo = v8::FunctionTemplate::New(isolate); | 3111 v8::Local<v8::FunctionTemplate> foo = v8::FunctionTemplate::New(isolate); |
3112 v8::Local<v8::Name> name = v8::Symbol::New(isolate); | 3112 v8::Local<v8::Name> name = v8::Symbol::New(isolate); |
3113 CHECK(!name.IsEmpty()); | 3113 CHECK(!name.IsEmpty()); |
(...skipping 22 matching lines...) Expand all Loading... |
3136 CHECK(obj->DeletePrivate(priv1)); | 3136 CHECK(obj->DeletePrivate(priv1)); |
3137 CHECK(!obj->HasPrivate(priv1)); | 3137 CHECK(!obj->HasPrivate(priv1)); |
3138 | 3138 |
3139 CHECK(obj->SetPrivate(priv1, v8::Integer::New(isolate, 1503))); | 3139 CHECK(obj->SetPrivate(priv1, v8::Integer::New(isolate, 1503))); |
3140 CHECK(obj->HasPrivate(priv1)); | 3140 CHECK(obj->HasPrivate(priv1)); |
3141 CHECK_EQ(1503, obj->GetPrivate(priv1)->Int32Value()); | 3141 CHECK_EQ(1503, obj->GetPrivate(priv1)->Int32Value()); |
3142 CHECK(obj->SetPrivate(priv1, v8::Integer::New(isolate, 2002))); | 3142 CHECK(obj->SetPrivate(priv1, v8::Integer::New(isolate, 2002))); |
3143 CHECK(obj->HasPrivate(priv1)); | 3143 CHECK(obj->HasPrivate(priv1)); |
3144 CHECK_EQ(2002, obj->GetPrivate(priv1)->Int32Value()); | 3144 CHECK_EQ(2002, obj->GetPrivate(priv1)->Int32Value()); |
3145 | 3145 |
3146 CHECK_EQ(0u, obj->GetOwnPropertyNames()->Length()); | 3146 CHECK_EQ(0, obj->GetOwnPropertyNames()->Length()); |
3147 unsigned num_props = obj->GetPropertyNames()->Length(); | 3147 int num_props = obj->GetPropertyNames()->Length(); |
3148 CHECK(obj->Set(v8::String::NewFromUtf8(isolate, "bla"), | 3148 CHECK(obj->Set(v8::String::NewFromUtf8(isolate, "bla"), |
3149 v8::Integer::New(isolate, 20))); | 3149 v8::Integer::New(isolate, 20))); |
3150 CHECK_EQ(1u, obj->GetOwnPropertyNames()->Length()); | 3150 CHECK_EQ(1, obj->GetOwnPropertyNames()->Length()); |
3151 CHECK_EQ(num_props + 1, obj->GetPropertyNames()->Length()); | 3151 CHECK_EQ(num_props + 1, obj->GetPropertyNames()->Length()); |
3152 | 3152 |
3153 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); | 3153 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); |
3154 | 3154 |
3155 // Add another property and delete it afterwards to force the object in | 3155 // Add another property and delete it afterwards to force the object in |
3156 // slow case. | 3156 // slow case. |
3157 CHECK(obj->SetPrivate(priv2, v8::Integer::New(isolate, 2008))); | 3157 CHECK(obj->SetPrivate(priv2, v8::Integer::New(isolate, 2008))); |
3158 CHECK_EQ(2002, obj->GetPrivate(priv1)->Int32Value()); | 3158 CHECK_EQ(2002, obj->GetPrivate(priv1)->Int32Value()); |
3159 CHECK_EQ(2008, obj->GetPrivate(priv2)->Int32Value()); | 3159 CHECK_EQ(2008, obj->GetPrivate(priv2)->Int32Value()); |
3160 CHECK_EQ(2002, obj->GetPrivate(priv1)->Int32Value()); | 3160 CHECK_EQ(2002, obj->GetPrivate(priv1)->Int32Value()); |
3161 CHECK_EQ(1u, obj->GetOwnPropertyNames()->Length()); | 3161 CHECK_EQ(1, obj->GetOwnPropertyNames()->Length()); |
3162 | 3162 |
3163 CHECK(obj->HasPrivate(priv1)); | 3163 CHECK(obj->HasPrivate(priv1)); |
3164 CHECK(obj->HasPrivate(priv2)); | 3164 CHECK(obj->HasPrivate(priv2)); |
3165 CHECK(obj->DeletePrivate(priv2)); | 3165 CHECK(obj->DeletePrivate(priv2)); |
3166 CHECK(obj->HasPrivate(priv1)); | 3166 CHECK(obj->HasPrivate(priv1)); |
3167 CHECK(!obj->HasPrivate(priv2)); | 3167 CHECK(!obj->HasPrivate(priv2)); |
3168 CHECK_EQ(2002, obj->GetPrivate(priv1)->Int32Value()); | 3168 CHECK_EQ(2002, obj->GetPrivate(priv1)->Int32Value()); |
3169 CHECK_EQ(1u, obj->GetOwnPropertyNames()->Length()); | 3169 CHECK_EQ(1, obj->GetOwnPropertyNames()->Length()); |
3170 | 3170 |
3171 // Private properties are inherited (for the time being). | 3171 // Private properties are inherited (for the time being). |
3172 v8::Local<v8::Object> child = v8::Object::New(isolate); | 3172 v8::Local<v8::Object> child = v8::Object::New(isolate); |
3173 child->SetPrototype(obj); | 3173 child->SetPrototype(obj); |
3174 CHECK(child->HasPrivate(priv1)); | 3174 CHECK(child->HasPrivate(priv1)); |
3175 CHECK_EQ(2002, child->GetPrivate(priv1)->Int32Value()); | 3175 CHECK_EQ(2002, child->GetPrivate(priv1)->Int32Value()); |
3176 CHECK_EQ(0u, child->GetOwnPropertyNames()->Length()); | 3176 CHECK_EQ(0, child->GetOwnPropertyNames()->Length()); |
3177 } | 3177 } |
3178 | 3178 |
3179 | 3179 |
3180 THREADED_TEST(GlobalSymbols) { | 3180 THREADED_TEST(GlobalSymbols) { |
3181 LocalContext env; | 3181 LocalContext env; |
3182 v8::Isolate* isolate = env->GetIsolate(); | 3182 v8::Isolate* isolate = env->GetIsolate(); |
3183 v8::HandleScope scope(isolate); | 3183 v8::HandleScope scope(isolate); |
3184 | 3184 |
3185 v8::Local<String> name = v8_str("my-symbol"); | 3185 v8::Local<String> name = v8_str("my-symbol"); |
3186 v8::Local<v8::Symbol> glob = v8::Symbol::For(isolate, name); | 3186 v8::Local<v8::Symbol> glob = v8::Symbol::For(isolate, name); |
(...skipping 670 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3857 int initial_handle_count = global_handles->global_handles_count(); | 3857 int initial_handle_count = global_handles->global_handles_count(); |
3858 CHECK_EQ(0, static_cast<int>(map.Size())); | 3858 CHECK_EQ(0, static_cast<int>(map.Size())); |
3859 { | 3859 { |
3860 HandleScope scope(isolate); | 3860 HandleScope scope(isolate); |
3861 Local<v8::Object> obj = map.Get(7); | 3861 Local<v8::Object> obj = map.Get(7); |
3862 CHECK(obj.IsEmpty()); | 3862 CHECK(obj.IsEmpty()); |
3863 Local<v8::Object> expected = v8::Object::New(isolate); | 3863 Local<v8::Object> expected = v8::Object::New(isolate); |
3864 map.Set(7, expected); | 3864 map.Set(7, expected); |
3865 CHECK_EQ(1, static_cast<int>(map.Size())); | 3865 CHECK_EQ(1, static_cast<int>(map.Size())); |
3866 obj = map.Get(7); | 3866 obj = map.Get(7); |
3867 CHECK(expected->Equals(obj)); | 3867 CHECK_EQ(expected, obj); |
3868 { | 3868 { |
3869 typename Map::PersistentValueReference ref = map.GetReference(7); | 3869 typename Map::PersistentValueReference ref = map.GetReference(7); |
3870 CHECK(expected->Equals(ref.NewLocal(isolate))); | 3870 CHECK_EQ(expected, ref.NewLocal(isolate)); |
3871 } | 3871 } |
3872 v8::UniquePersistent<v8::Object> removed = map.Remove(7); | 3872 v8::UniquePersistent<v8::Object> removed = map.Remove(7); |
3873 CHECK_EQ(0, static_cast<int>(map.Size())); | 3873 CHECK_EQ(0, static_cast<int>(map.Size())); |
3874 CHECK(expected == removed); | 3874 CHECK(expected == removed); |
3875 removed = map.Remove(7); | 3875 removed = map.Remove(7); |
3876 CHECK(removed.IsEmpty()); | 3876 CHECK(removed.IsEmpty()); |
3877 map.Set(8, expected); | 3877 map.Set(8, expected); |
3878 CHECK_EQ(1, static_cast<int>(map.Size())); | 3878 CHECK_EQ(1, static_cast<int>(map.Size())); |
3879 map.Set(8, expected); | 3879 map.Set(8, expected); |
3880 CHECK_EQ(1, static_cast<int>(map.Size())); | 3880 CHECK_EQ(1, static_cast<int>(map.Size())); |
3881 { | 3881 { |
3882 typename Map::PersistentValueReference ref; | 3882 typename Map::PersistentValueReference ref; |
3883 Local<v8::Object> expected2 = v8::Object::New(isolate); | 3883 Local<v8::Object> expected2 = v8::Object::New(isolate); |
3884 removed = map.Set(8, | 3884 removed = map.Set(8, |
3885 v8::UniquePersistent<v8::Object>(isolate, expected2), &ref); | 3885 v8::UniquePersistent<v8::Object>(isolate, expected2), &ref); |
3886 CHECK_EQ(1, static_cast<int>(map.Size())); | 3886 CHECK_EQ(1, static_cast<int>(map.Size())); |
3887 CHECK(expected == removed); | 3887 CHECK(expected == removed); |
3888 CHECK(expected2->Equals(ref.NewLocal(isolate))); | 3888 CHECK_EQ(expected2, ref.NewLocal(isolate)); |
3889 } | 3889 } |
3890 } | 3890 } |
3891 CHECK_EQ(initial_handle_count + 1, global_handles->global_handles_count()); | 3891 CHECK_EQ(initial_handle_count + 1, global_handles->global_handles_count()); |
3892 if (map.IsWeak()) { | 3892 if (map.IsWeak()) { |
3893 reinterpret_cast<v8::internal::Isolate*>(isolate)->heap()-> | 3893 reinterpret_cast<v8::internal::Isolate*>(isolate)->heap()-> |
3894 CollectAllGarbage(i::Heap::kAbortIncrementalMarkingMask); | 3894 CollectAllGarbage(i::Heap::kAbortIncrementalMarkingMask); |
3895 } else { | 3895 } else { |
3896 map.Clear(); | 3896 map.Clear(); |
3897 } | 3897 } |
3898 CHECK_EQ(0, static_cast<int>(map.Size())); | 3898 CHECK_EQ(0, static_cast<int>(map.Size())); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3933 | 3933 |
3934 vector.Append(obj1); | 3934 vector.Append(obj1); |
3935 vector.Append(obj2); | 3935 vector.Append(obj2); |
3936 vector.Append(obj1); | 3936 vector.Append(obj1); |
3937 vector.Append(obj3.Pass()); | 3937 vector.Append(obj3.Pass()); |
3938 vector.Append(obj1); | 3938 vector.Append(obj1); |
3939 | 3939 |
3940 CHECK(!vector.IsEmpty()); | 3940 CHECK(!vector.IsEmpty()); |
3941 CHECK_EQ(5, static_cast<int>(vector.Size())); | 3941 CHECK_EQ(5, static_cast<int>(vector.Size())); |
3942 CHECK(obj3.IsEmpty()); | 3942 CHECK(obj3.IsEmpty()); |
3943 CHECK(obj1->Equals(vector.Get(0))); | 3943 CHECK_EQ(obj1, vector.Get(0)); |
3944 CHECK(obj1->Equals(vector.Get(2))); | 3944 CHECK_EQ(obj1, vector.Get(2)); |
3945 CHECK(obj1->Equals(vector.Get(4))); | 3945 CHECK_EQ(obj1, vector.Get(4)); |
3946 CHECK(obj2->Equals(vector.Get(1))); | 3946 CHECK_EQ(obj2, vector.Get(1)); |
3947 | 3947 |
3948 CHECK_EQ(5 + handle_count, global_handles->global_handles_count()); | 3948 CHECK_EQ(5 + handle_count, global_handles->global_handles_count()); |
3949 | 3949 |
3950 vector.Clear(); | 3950 vector.Clear(); |
3951 CHECK(vector.IsEmpty()); | 3951 CHECK(vector.IsEmpty()); |
3952 CHECK_EQ(0, static_cast<int>(vector.Size())); | 3952 CHECK_EQ(0, static_cast<int>(vector.Size())); |
3953 CHECK_EQ(handle_count, global_handles->global_handles_count()); | 3953 CHECK_EQ(handle_count, global_handles->global_handles_count()); |
3954 } | 3954 } |
3955 | 3955 |
3956 | 3956 |
(...skipping 537 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4494 | 4494 |
4495 THREADED_TEST(ScriptException) { | 4495 THREADED_TEST(ScriptException) { |
4496 LocalContext env; | 4496 LocalContext env; |
4497 v8::HandleScope scope(env->GetIsolate()); | 4497 v8::HandleScope scope(env->GetIsolate()); |
4498 Local<Script> script = v8_compile("throw 'panama!';"); | 4498 Local<Script> script = v8_compile("throw 'panama!';"); |
4499 v8::TryCatch try_catch; | 4499 v8::TryCatch try_catch; |
4500 Local<Value> result = script->Run(); | 4500 Local<Value> result = script->Run(); |
4501 CHECK(result.IsEmpty()); | 4501 CHECK(result.IsEmpty()); |
4502 CHECK(try_catch.HasCaught()); | 4502 CHECK(try_catch.HasCaught()); |
4503 String::Utf8Value exception_value(try_catch.Exception()); | 4503 String::Utf8Value exception_value(try_catch.Exception()); |
4504 CHECK_EQ(0, strcmp(*exception_value, "panama!")); | 4504 CHECK_EQ(*exception_value, "panama!"); |
4505 } | 4505 } |
4506 | 4506 |
4507 | 4507 |
4508 TEST(TryCatchCustomException) { | 4508 TEST(TryCatchCustomException) { |
4509 LocalContext env; | 4509 LocalContext env; |
4510 v8::Isolate* isolate = env->GetIsolate(); | 4510 v8::Isolate* isolate = env->GetIsolate(); |
4511 v8::HandleScope scope(isolate); | 4511 v8::HandleScope scope(isolate); |
4512 v8::TryCatch try_catch; | 4512 v8::TryCatch try_catch; |
4513 CompileRun("function CustomError() { this.a = 'b'; }" | 4513 CompileRun("function CustomError() { this.a = 'b'; }" |
4514 "(function f() { throw new CustomError(); })();"); | 4514 "(function f() { throw new CustomError(); })();"); |
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4768 CHECK_EQ(v8::None, context->Global()->GetPropertyAttributes(prop)); | 4768 CHECK_EQ(v8::None, context->Global()->GetPropertyAttributes(prop)); |
4769 Local<Value> fake_prop = v8_num(1); | 4769 Local<Value> fake_prop = v8_num(1); |
4770 CHECK_EQ(v8::None, context->Global()->GetPropertyAttributes(fake_prop)); | 4770 CHECK_EQ(v8::None, context->Global()->GetPropertyAttributes(fake_prop)); |
4771 // exception | 4771 // exception |
4772 TryCatch try_catch; | 4772 TryCatch try_catch; |
4773 Local<Value> exception = | 4773 Local<Value> exception = |
4774 CompileRun("({ toString: function() { throw 'exception';} })"); | 4774 CompileRun("({ toString: function() { throw 'exception';} })"); |
4775 CHECK_EQ(v8::None, context->Global()->GetPropertyAttributes(exception)); | 4775 CHECK_EQ(v8::None, context->Global()->GetPropertyAttributes(exception)); |
4776 CHECK(try_catch.HasCaught()); | 4776 CHECK(try_catch.HasCaught()); |
4777 String::Utf8Value exception_value(try_catch.Exception()); | 4777 String::Utf8Value exception_value(try_catch.Exception()); |
4778 CHECK_EQ(0, strcmp("exception", *exception_value)); | 4778 CHECK_EQ("exception", *exception_value); |
4779 try_catch.Reset(); | 4779 try_catch.Reset(); |
4780 } | 4780 } |
4781 | 4781 |
4782 | 4782 |
4783 THREADED_TEST(Array) { | 4783 THREADED_TEST(Array) { |
4784 LocalContext context; | 4784 LocalContext context; |
4785 v8::HandleScope scope(context->GetIsolate()); | 4785 v8::HandleScope scope(context->GetIsolate()); |
4786 Local<v8::Array> array = v8::Array::New(context->GetIsolate()); | 4786 Local<v8::Array> array = v8::Array::New(context->GetIsolate()); |
4787 CHECK_EQ(0u, array->Length()); | 4787 CHECK_EQ(0, array->Length()); |
4788 CHECK(array->Get(0)->IsUndefined()); | 4788 CHECK(array->Get(0)->IsUndefined()); |
4789 CHECK(!array->Has(0)); | 4789 CHECK(!array->Has(0)); |
4790 CHECK(array->Get(100)->IsUndefined()); | 4790 CHECK(array->Get(100)->IsUndefined()); |
4791 CHECK(!array->Has(100)); | 4791 CHECK(!array->Has(100)); |
4792 array->Set(2, v8_num(7)); | 4792 array->Set(2, v8_num(7)); |
4793 CHECK_EQ(3u, array->Length()); | 4793 CHECK_EQ(3, array->Length()); |
4794 CHECK(!array->Has(0)); | 4794 CHECK(!array->Has(0)); |
4795 CHECK(!array->Has(1)); | 4795 CHECK(!array->Has(1)); |
4796 CHECK(array->Has(2)); | 4796 CHECK(array->Has(2)); |
4797 CHECK_EQ(7, array->Get(2)->Int32Value()); | 4797 CHECK_EQ(7, array->Get(2)->Int32Value()); |
4798 Local<Value> obj = CompileRun("[1, 2, 3]"); | 4798 Local<Value> obj = CompileRun("[1, 2, 3]"); |
4799 Local<v8::Array> arr = obj.As<v8::Array>(); | 4799 Local<v8::Array> arr = obj.As<v8::Array>(); |
4800 CHECK_EQ(3u, arr->Length()); | 4800 CHECK_EQ(3, arr->Length()); |
4801 CHECK_EQ(1, arr->Get(0)->Int32Value()); | 4801 CHECK_EQ(1, arr->Get(0)->Int32Value()); |
4802 CHECK_EQ(2, arr->Get(1)->Int32Value()); | 4802 CHECK_EQ(2, arr->Get(1)->Int32Value()); |
4803 CHECK_EQ(3, arr->Get(2)->Int32Value()); | 4803 CHECK_EQ(3, arr->Get(2)->Int32Value()); |
4804 array = v8::Array::New(context->GetIsolate(), 27); | 4804 array = v8::Array::New(context->GetIsolate(), 27); |
4805 CHECK_EQ(27u, array->Length()); | 4805 CHECK_EQ(27, array->Length()); |
4806 array = v8::Array::New(context->GetIsolate(), -27); | 4806 array = v8::Array::New(context->GetIsolate(), -27); |
4807 CHECK_EQ(0u, array->Length()); | 4807 CHECK_EQ(0, array->Length()); |
4808 } | 4808 } |
4809 | 4809 |
4810 | 4810 |
4811 void HandleF(const v8::FunctionCallbackInfo<v8::Value>& args) { | 4811 void HandleF(const v8::FunctionCallbackInfo<v8::Value>& args) { |
4812 v8::EscapableHandleScope scope(args.GetIsolate()); | 4812 v8::EscapableHandleScope scope(args.GetIsolate()); |
4813 ApiTestFuzzer::Fuzz(); | 4813 ApiTestFuzzer::Fuzz(); |
4814 Local<v8::Array> result = v8::Array::New(args.GetIsolate(), args.Length()); | 4814 Local<v8::Array> result = v8::Array::New(args.GetIsolate(), args.Length()); |
4815 for (int i = 0; i < args.Length(); i++) | 4815 for (int i = 0; i < args.Length(); i++) |
4816 result->Set(i, args[i]); | 4816 result->Set(i, args[i]); |
4817 args.GetReturnValue().Set(scope.Escape(result)); | 4817 args.GetReturnValue().Set(scope.Escape(result)); |
4818 } | 4818 } |
4819 | 4819 |
4820 | 4820 |
4821 THREADED_TEST(Vector) { | 4821 THREADED_TEST(Vector) { |
4822 v8::Isolate* isolate = CcTest::isolate(); | 4822 v8::Isolate* isolate = CcTest::isolate(); |
4823 v8::HandleScope scope(isolate); | 4823 v8::HandleScope scope(isolate); |
4824 Local<ObjectTemplate> global = ObjectTemplate::New(isolate); | 4824 Local<ObjectTemplate> global = ObjectTemplate::New(isolate); |
4825 global->Set(v8_str("f"), v8::FunctionTemplate::New(isolate, HandleF)); | 4825 global->Set(v8_str("f"), v8::FunctionTemplate::New(isolate, HandleF)); |
4826 LocalContext context(0, global); | 4826 LocalContext context(0, global); |
4827 | 4827 |
4828 const char* fun = "f()"; | 4828 const char* fun = "f()"; |
4829 Local<v8::Array> a0 = CompileRun(fun).As<v8::Array>(); | 4829 Local<v8::Array> a0 = CompileRun(fun).As<v8::Array>(); |
4830 CHECK_EQ(0u, a0->Length()); | 4830 CHECK_EQ(0, a0->Length()); |
4831 | 4831 |
4832 const char* fun2 = "f(11)"; | 4832 const char* fun2 = "f(11)"; |
4833 Local<v8::Array> a1 = CompileRun(fun2).As<v8::Array>(); | 4833 Local<v8::Array> a1 = CompileRun(fun2).As<v8::Array>(); |
4834 CHECK_EQ(1u, a1->Length()); | 4834 CHECK_EQ(1, a1->Length()); |
4835 CHECK_EQ(11, a1->Get(0)->Int32Value()); | 4835 CHECK_EQ(11, a1->Get(0)->Int32Value()); |
4836 | 4836 |
4837 const char* fun3 = "f(12, 13)"; | 4837 const char* fun3 = "f(12, 13)"; |
4838 Local<v8::Array> a2 = CompileRun(fun3).As<v8::Array>(); | 4838 Local<v8::Array> a2 = CompileRun(fun3).As<v8::Array>(); |
4839 CHECK_EQ(2u, a2->Length()); | 4839 CHECK_EQ(2, a2->Length()); |
4840 CHECK_EQ(12, a2->Get(0)->Int32Value()); | 4840 CHECK_EQ(12, a2->Get(0)->Int32Value()); |
4841 CHECK_EQ(13, a2->Get(1)->Int32Value()); | 4841 CHECK_EQ(13, a2->Get(1)->Int32Value()); |
4842 | 4842 |
4843 const char* fun4 = "f(14, 15, 16)"; | 4843 const char* fun4 = "f(14, 15, 16)"; |
4844 Local<v8::Array> a3 = CompileRun(fun4).As<v8::Array>(); | 4844 Local<v8::Array> a3 = CompileRun(fun4).As<v8::Array>(); |
4845 CHECK_EQ(3u, a3->Length()); | 4845 CHECK_EQ(3, a3->Length()); |
4846 CHECK_EQ(14, a3->Get(0)->Int32Value()); | 4846 CHECK_EQ(14, a3->Get(0)->Int32Value()); |
4847 CHECK_EQ(15, a3->Get(1)->Int32Value()); | 4847 CHECK_EQ(15, a3->Get(1)->Int32Value()); |
4848 CHECK_EQ(16, a3->Get(2)->Int32Value()); | 4848 CHECK_EQ(16, a3->Get(2)->Int32Value()); |
4849 | 4849 |
4850 const char* fun5 = "f(17, 18, 19, 20)"; | 4850 const char* fun5 = "f(17, 18, 19, 20)"; |
4851 Local<v8::Array> a4 = CompileRun(fun5).As<v8::Array>(); | 4851 Local<v8::Array> a4 = CompileRun(fun5).As<v8::Array>(); |
4852 CHECK_EQ(4u, a4->Length()); | 4852 CHECK_EQ(4, a4->Length()); |
4853 CHECK_EQ(17, a4->Get(0)->Int32Value()); | 4853 CHECK_EQ(17, a4->Get(0)->Int32Value()); |
4854 CHECK_EQ(18, a4->Get(1)->Int32Value()); | 4854 CHECK_EQ(18, a4->Get(1)->Int32Value()); |
4855 CHECK_EQ(19, a4->Get(2)->Int32Value()); | 4855 CHECK_EQ(19, a4->Get(2)->Int32Value()); |
4856 CHECK_EQ(20, a4->Get(3)->Int32Value()); | 4856 CHECK_EQ(20, a4->Get(3)->Int32Value()); |
4857 } | 4857 } |
4858 | 4858 |
4859 | 4859 |
4860 THREADED_TEST(FunctionCall) { | 4860 THREADED_TEST(FunctionCall) { |
4861 LocalContext context; | 4861 LocalContext context; |
4862 v8::Isolate* isolate = context->GetIsolate(); | 4862 v8::Isolate* isolate = context->GetIsolate(); |
(...skipping 15 matching lines...) Expand all Loading... |
4878 "}"); | 4878 "}"); |
4879 Local<Function> Foo = | 4879 Local<Function> Foo = |
4880 Local<Function>::Cast(context->Global()->Get(v8_str("Foo"))); | 4880 Local<Function>::Cast(context->Global()->Get(v8_str("Foo"))); |
4881 Local<Function> ReturnThisSloppy = | 4881 Local<Function> ReturnThisSloppy = |
4882 Local<Function>::Cast(context->Global()->Get(v8_str("ReturnThisSloppy"))); | 4882 Local<Function>::Cast(context->Global()->Get(v8_str("ReturnThisSloppy"))); |
4883 Local<Function> ReturnThisStrict = | 4883 Local<Function> ReturnThisStrict = |
4884 Local<Function>::Cast(context->Global()->Get(v8_str("ReturnThisStrict"))); | 4884 Local<Function>::Cast(context->Global()->Get(v8_str("ReturnThisStrict"))); |
4885 | 4885 |
4886 v8::Handle<Value>* args0 = NULL; | 4886 v8::Handle<Value>* args0 = NULL; |
4887 Local<v8::Array> a0 = Local<v8::Array>::Cast(Foo->Call(Foo, 0, args0)); | 4887 Local<v8::Array> a0 = Local<v8::Array>::Cast(Foo->Call(Foo, 0, args0)); |
4888 CHECK_EQ(0u, a0->Length()); | 4888 CHECK_EQ(0, a0->Length()); |
4889 | 4889 |
4890 v8::Handle<Value> args1[] = { v8_num(1.1) }; | 4890 v8::Handle<Value> args1[] = { v8_num(1.1) }; |
4891 Local<v8::Array> a1 = Local<v8::Array>::Cast(Foo->Call(Foo, 1, args1)); | 4891 Local<v8::Array> a1 = Local<v8::Array>::Cast(Foo->Call(Foo, 1, args1)); |
4892 CHECK_EQ(1u, a1->Length()); | 4892 CHECK_EQ(1, a1->Length()); |
4893 CHECK_EQ(1.1, a1->Get(v8::Integer::New(isolate, 0))->NumberValue()); | 4893 CHECK_EQ(1.1, a1->Get(v8::Integer::New(isolate, 0))->NumberValue()); |
4894 | 4894 |
4895 v8::Handle<Value> args2[] = { v8_num(2.2), | 4895 v8::Handle<Value> args2[] = { v8_num(2.2), |
4896 v8_num(3.3) }; | 4896 v8_num(3.3) }; |
4897 Local<v8::Array> a2 = Local<v8::Array>::Cast(Foo->Call(Foo, 2, args2)); | 4897 Local<v8::Array> a2 = Local<v8::Array>::Cast(Foo->Call(Foo, 2, args2)); |
4898 CHECK_EQ(2u, a2->Length()); | 4898 CHECK_EQ(2, a2->Length()); |
4899 CHECK_EQ(2.2, a2->Get(v8::Integer::New(isolate, 0))->NumberValue()); | 4899 CHECK_EQ(2.2, a2->Get(v8::Integer::New(isolate, 0))->NumberValue()); |
4900 CHECK_EQ(3.3, a2->Get(v8::Integer::New(isolate, 1))->NumberValue()); | 4900 CHECK_EQ(3.3, a2->Get(v8::Integer::New(isolate, 1))->NumberValue()); |
4901 | 4901 |
4902 v8::Handle<Value> args3[] = { v8_num(4.4), | 4902 v8::Handle<Value> args3[] = { v8_num(4.4), |
4903 v8_num(5.5), | 4903 v8_num(5.5), |
4904 v8_num(6.6) }; | 4904 v8_num(6.6) }; |
4905 Local<v8::Array> a3 = Local<v8::Array>::Cast(Foo->Call(Foo, 3, args3)); | 4905 Local<v8::Array> a3 = Local<v8::Array>::Cast(Foo->Call(Foo, 3, args3)); |
4906 CHECK_EQ(3u, a3->Length()); | 4906 CHECK_EQ(3, a3->Length()); |
4907 CHECK_EQ(4.4, a3->Get(v8::Integer::New(isolate, 0))->NumberValue()); | 4907 CHECK_EQ(4.4, a3->Get(v8::Integer::New(isolate, 0))->NumberValue()); |
4908 CHECK_EQ(5.5, a3->Get(v8::Integer::New(isolate, 1))->NumberValue()); | 4908 CHECK_EQ(5.5, a3->Get(v8::Integer::New(isolate, 1))->NumberValue()); |
4909 CHECK_EQ(6.6, a3->Get(v8::Integer::New(isolate, 2))->NumberValue()); | 4909 CHECK_EQ(6.6, a3->Get(v8::Integer::New(isolate, 2))->NumberValue()); |
4910 | 4910 |
4911 v8::Handle<Value> args4[] = { v8_num(7.7), | 4911 v8::Handle<Value> args4[] = { v8_num(7.7), |
4912 v8_num(8.8), | 4912 v8_num(8.8), |
4913 v8_num(9.9), | 4913 v8_num(9.9), |
4914 v8_num(10.11) }; | 4914 v8_num(10.11) }; |
4915 Local<v8::Array> a4 = Local<v8::Array>::Cast(Foo->Call(Foo, 4, args4)); | 4915 Local<v8::Array> a4 = Local<v8::Array>::Cast(Foo->Call(Foo, 4, args4)); |
4916 CHECK_EQ(4u, a4->Length()); | 4916 CHECK_EQ(4, a4->Length()); |
4917 CHECK_EQ(7.7, a4->Get(v8::Integer::New(isolate, 0))->NumberValue()); | 4917 CHECK_EQ(7.7, a4->Get(v8::Integer::New(isolate, 0))->NumberValue()); |
4918 CHECK_EQ(8.8, a4->Get(v8::Integer::New(isolate, 1))->NumberValue()); | 4918 CHECK_EQ(8.8, a4->Get(v8::Integer::New(isolate, 1))->NumberValue()); |
4919 CHECK_EQ(9.9, a4->Get(v8::Integer::New(isolate, 2))->NumberValue()); | 4919 CHECK_EQ(9.9, a4->Get(v8::Integer::New(isolate, 2))->NumberValue()); |
4920 CHECK_EQ(10.11, a4->Get(v8::Integer::New(isolate, 3))->NumberValue()); | 4920 CHECK_EQ(10.11, a4->Get(v8::Integer::New(isolate, 3))->NumberValue()); |
4921 | 4921 |
4922 Local<v8::Value> r1 = ReturnThisSloppy->Call(v8::Undefined(isolate), 0, NULL); | 4922 Local<v8::Value> r1 = ReturnThisSloppy->Call(v8::Undefined(isolate), 0, NULL); |
4923 CHECK(r1->StrictEquals(context->Global())); | 4923 CHECK(r1->StrictEquals(context->Global())); |
4924 Local<v8::Value> r2 = ReturnThisSloppy->Call(v8::Null(isolate), 0, NULL); | 4924 Local<v8::Value> r2 = ReturnThisSloppy->Call(v8::Null(isolate), 0, NULL); |
4925 CHECK(r2->StrictEquals(context->Global())); | 4925 CHECK(r2->StrictEquals(context->Global())); |
4926 Local<v8::Value> r3 = ReturnThisSloppy->Call(v8_num(42), 0, NULL); | 4926 Local<v8::Value> r3 = ReturnThisSloppy->Call(v8_num(42), 0, NULL); |
(...skipping 29 matching lines...) Expand all Loading... |
4956 " for (var i = 0; i < arguments.length; i++) {" | 4956 " for (var i = 0; i < arguments.length; i++) {" |
4957 " result.push(arguments[i]);" | 4957 " result.push(arguments[i]);" |
4958 " }" | 4958 " }" |
4959 " return result;" | 4959 " return result;" |
4960 "}"); | 4960 "}"); |
4961 Local<Function> Foo = | 4961 Local<Function> Foo = |
4962 Local<Function>::Cast(context->Global()->Get(v8_str("Foo"))); | 4962 Local<Function>::Cast(context->Global()->Get(v8_str("Foo"))); |
4963 | 4963 |
4964 v8::Handle<Value>* args0 = NULL; | 4964 v8::Handle<Value>* args0 = NULL; |
4965 Local<v8::Array> a0 = Local<v8::Array>::Cast(Foo->NewInstance(0, args0)); | 4965 Local<v8::Array> a0 = Local<v8::Array>::Cast(Foo->NewInstance(0, args0)); |
4966 CHECK_EQ(0u, a0->Length()); | 4966 CHECK_EQ(0, a0->Length()); |
4967 | 4967 |
4968 v8::Handle<Value> args1[] = { v8_num(1.1) }; | 4968 v8::Handle<Value> args1[] = { v8_num(1.1) }; |
4969 Local<v8::Array> a1 = Local<v8::Array>::Cast(Foo->NewInstance(1, args1)); | 4969 Local<v8::Array> a1 = Local<v8::Array>::Cast(Foo->NewInstance(1, args1)); |
4970 CHECK_EQ(1u, a1->Length()); | 4970 CHECK_EQ(1, a1->Length()); |
4971 CHECK_EQ(1.1, a1->Get(v8::Integer::New(isolate, 0))->NumberValue()); | 4971 CHECK_EQ(1.1, a1->Get(v8::Integer::New(isolate, 0))->NumberValue()); |
4972 | 4972 |
4973 v8::Handle<Value> args2[] = { v8_num(2.2), | 4973 v8::Handle<Value> args2[] = { v8_num(2.2), |
4974 v8_num(3.3) }; | 4974 v8_num(3.3) }; |
4975 Local<v8::Array> a2 = Local<v8::Array>::Cast(Foo->NewInstance(2, args2)); | 4975 Local<v8::Array> a2 = Local<v8::Array>::Cast(Foo->NewInstance(2, args2)); |
4976 CHECK_EQ(2u, a2->Length()); | 4976 CHECK_EQ(2, a2->Length()); |
4977 CHECK_EQ(2.2, a2->Get(v8::Integer::New(isolate, 0))->NumberValue()); | 4977 CHECK_EQ(2.2, a2->Get(v8::Integer::New(isolate, 0))->NumberValue()); |
4978 CHECK_EQ(3.3, a2->Get(v8::Integer::New(isolate, 1))->NumberValue()); | 4978 CHECK_EQ(3.3, a2->Get(v8::Integer::New(isolate, 1))->NumberValue()); |
4979 | 4979 |
4980 v8::Handle<Value> args3[] = { v8_num(4.4), | 4980 v8::Handle<Value> args3[] = { v8_num(4.4), |
4981 v8_num(5.5), | 4981 v8_num(5.5), |
4982 v8_num(6.6) }; | 4982 v8_num(6.6) }; |
4983 Local<v8::Array> a3 = Local<v8::Array>::Cast(Foo->NewInstance(3, args3)); | 4983 Local<v8::Array> a3 = Local<v8::Array>::Cast(Foo->NewInstance(3, args3)); |
4984 CHECK_EQ(3u, a3->Length()); | 4984 CHECK_EQ(3, a3->Length()); |
4985 CHECK_EQ(4.4, a3->Get(v8::Integer::New(isolate, 0))->NumberValue()); | 4985 CHECK_EQ(4.4, a3->Get(v8::Integer::New(isolate, 0))->NumberValue()); |
4986 CHECK_EQ(5.5, a3->Get(v8::Integer::New(isolate, 1))->NumberValue()); | 4986 CHECK_EQ(5.5, a3->Get(v8::Integer::New(isolate, 1))->NumberValue()); |
4987 CHECK_EQ(6.6, a3->Get(v8::Integer::New(isolate, 2))->NumberValue()); | 4987 CHECK_EQ(6.6, a3->Get(v8::Integer::New(isolate, 2))->NumberValue()); |
4988 | 4988 |
4989 v8::Handle<Value> args4[] = { v8_num(7.7), | 4989 v8::Handle<Value> args4[] = { v8_num(7.7), |
4990 v8_num(8.8), | 4990 v8_num(8.8), |
4991 v8_num(9.9), | 4991 v8_num(9.9), |
4992 v8_num(10.11) }; | 4992 v8_num(10.11) }; |
4993 Local<v8::Array> a4 = Local<v8::Array>::Cast(Foo->NewInstance(4, args4)); | 4993 Local<v8::Array> a4 = Local<v8::Array>::Cast(Foo->NewInstance(4, args4)); |
4994 CHECK_EQ(4u, a4->Length()); | 4994 CHECK_EQ(4, a4->Length()); |
4995 CHECK_EQ(7.7, a4->Get(v8::Integer::New(isolate, 0))->NumberValue()); | 4995 CHECK_EQ(7.7, a4->Get(v8::Integer::New(isolate, 0))->NumberValue()); |
4996 CHECK_EQ(8.8, a4->Get(v8::Integer::New(isolate, 1))->NumberValue()); | 4996 CHECK_EQ(8.8, a4->Get(v8::Integer::New(isolate, 1))->NumberValue()); |
4997 CHECK_EQ(9.9, a4->Get(v8::Integer::New(isolate, 2))->NumberValue()); | 4997 CHECK_EQ(9.9, a4->Get(v8::Integer::New(isolate, 2))->NumberValue()); |
4998 CHECK_EQ(10.11, a4->Get(v8::Integer::New(isolate, 3))->NumberValue()); | 4998 CHECK_EQ(10.11, a4->Get(v8::Integer::New(isolate, 3))->NumberValue()); |
4999 } | 4999 } |
5000 | 5000 |
5001 | 5001 |
5002 static void CheckUncle(v8::TryCatch* try_catch) { | 5002 static void CheckUncle(v8::TryCatch* try_catch) { |
5003 CHECK(try_catch->HasCaught()); | 5003 CHECK(try_catch->HasCaught()); |
5004 String::Utf8Value str_value(try_catch->Exception()); | 5004 String::Utf8Value str_value(try_catch->Exception()); |
5005 CHECK_EQ(0, strcmp(*str_value, "uncle?")); | 5005 CHECK_EQ(*str_value, "uncle?"); |
5006 try_catch->Reset(); | 5006 try_catch->Reset(); |
5007 } | 5007 } |
5008 | 5008 |
5009 | 5009 |
5010 THREADED_TEST(ConversionNumber) { | 5010 THREADED_TEST(ConversionNumber) { |
5011 LocalContext env; | 5011 LocalContext env; |
5012 v8::Isolate* isolate = env->GetIsolate(); | 5012 v8::Isolate* isolate = env->GetIsolate(); |
5013 v8::HandleScope scope(isolate); | 5013 v8::HandleScope scope(isolate); |
5014 // Very large number. | 5014 // Very large number. |
5015 CompileRun("var obj = Math.pow(2,32) * 1237;"); | 5015 CompileRun("var obj = Math.pow(2,32) * 1237;"); |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5143 Local<Value> to_object_result = v8::Undefined(isolate)->ToObject(isolate); | 5143 Local<Value> to_object_result = v8::Undefined(isolate)->ToObject(isolate); |
5144 CHECK(to_object_result.IsEmpty()); | 5144 CHECK(to_object_result.IsEmpty()); |
5145 CHECK(try_catch.HasCaught()); | 5145 CHECK(try_catch.HasCaught()); |
5146 try_catch.Reset(); | 5146 try_catch.Reset(); |
5147 | 5147 |
5148 int32_t int32_value = obj->Int32Value(); | 5148 int32_t int32_value = obj->Int32Value(); |
5149 CHECK_EQ(0, int32_value); | 5149 CHECK_EQ(0, int32_value); |
5150 CheckUncle(&try_catch); | 5150 CheckUncle(&try_catch); |
5151 | 5151 |
5152 uint32_t uint32_value = obj->Uint32Value(); | 5152 uint32_t uint32_value = obj->Uint32Value(); |
5153 CHECK_EQ(0u, uint32_value); | 5153 CHECK_EQ(0, uint32_value); |
5154 CheckUncle(&try_catch); | 5154 CheckUncle(&try_catch); |
5155 | 5155 |
5156 double number_value = obj->NumberValue(); | 5156 double number_value = obj->NumberValue(); |
5157 CHECK(std::isnan(number_value)); | 5157 CHECK_NE(0, std::isnan(number_value)); |
5158 CheckUncle(&try_catch); | 5158 CheckUncle(&try_catch); |
5159 | 5159 |
5160 int64_t integer_value = obj->IntegerValue(); | 5160 int64_t integer_value = obj->IntegerValue(); |
5161 CHECK_EQ(0, integer_value); | 5161 CHECK_EQ(0.0, static_cast<double>(integer_value)); |
5162 CheckUncle(&try_catch); | 5162 CheckUncle(&try_catch); |
5163 } | 5163 } |
5164 | 5164 |
5165 | 5165 |
5166 void ThrowFromC(const v8::FunctionCallbackInfo<v8::Value>& args) { | 5166 void ThrowFromC(const v8::FunctionCallbackInfo<v8::Value>& args) { |
5167 ApiTestFuzzer::Fuzz(); | 5167 ApiTestFuzzer::Fuzz(); |
5168 args.GetIsolate()->ThrowException(v8_str("konto")); | 5168 args.GetIsolate()->ThrowException(v8_str("konto")); |
5169 } | 5169 } |
5170 | 5170 |
5171 | 5171 |
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5435 Local<ObjectTemplate> templ = ObjectTemplate::New(isolate); | 5435 Local<ObjectTemplate> templ = ObjectTemplate::New(isolate); |
5436 templ->Set(v8_str("ThrowFromC"), | 5436 templ->Set(v8_str("ThrowFromC"), |
5437 v8::FunctionTemplate::New(isolate, ThrowFromC)); | 5437 v8::FunctionTemplate::New(isolate, ThrowFromC)); |
5438 LocalContext context(0, templ); | 5438 LocalContext context(0, templ); |
5439 | 5439 |
5440 v8::TryCatch try_catch; | 5440 v8::TryCatch try_catch; |
5441 Local<Value> result = CompileRun("ThrowFromC(); throw 'panama';"); | 5441 Local<Value> result = CompileRun("ThrowFromC(); throw 'panama';"); |
5442 CHECK(result.IsEmpty()); | 5442 CHECK(result.IsEmpty()); |
5443 CHECK(try_catch.HasCaught()); | 5443 CHECK(try_catch.HasCaught()); |
5444 String::Utf8Value exception_value(try_catch.Exception()); | 5444 String::Utf8Value exception_value(try_catch.Exception()); |
5445 CHECK_EQ(0, strcmp("konto", *exception_value)); | 5445 CHECK_EQ("konto", *exception_value); |
5446 } | 5446 } |
5447 | 5447 |
5448 | 5448 |
5449 | 5449 |
5450 void CThrowCountDown(const v8::FunctionCallbackInfo<v8::Value>& args) { | 5450 void CThrowCountDown(const v8::FunctionCallbackInfo<v8::Value>& args) { |
5451 ApiTestFuzzer::Fuzz(); | 5451 ApiTestFuzzer::Fuzz(); |
5452 CHECK_EQ(4, args.Length()); | 5452 CHECK_EQ(4, args.Length()); |
5453 int count = args[0]->Int32Value(); | 5453 int count = args[0]->Int32Value(); |
5454 int cInterval = args[2]->Int32Value(); | 5454 int cInterval = args[2]->Int32Value(); |
5455 if (count == 0) { | 5455 if (count == 0) { |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5607 v8::Handle<v8::Array> result = v8::Handle<v8::Array>::Cast(CompileRun( | 5607 v8::Handle<v8::Array> result = v8::Handle<v8::Array>::Cast(CompileRun( |
5608 "function Run(obj) {" | 5608 "function Run(obj) {" |
5609 " try {" | 5609 " try {" |
5610 " Throw(obj);" | 5610 " Throw(obj);" |
5611 " } catch (e) {" | 5611 " } catch (e) {" |
5612 " return e;" | 5612 " return e;" |
5613 " }" | 5613 " }" |
5614 " return 'no exception';" | 5614 " return 'no exception';" |
5615 "}" | 5615 "}" |
5616 "[Run('str'), Run(1), Run(0), Run(null), Run(void 0)];")); | 5616 "[Run('str'), Run(1), Run(0), Run(null), Run(void 0)];")); |
5617 CHECK_EQ(5u, result->Length()); | 5617 CHECK_EQ(5, result->Length()); |
5618 CHECK(result->Get(v8::Integer::New(isolate, 0))->IsString()); | 5618 CHECK(result->Get(v8::Integer::New(isolate, 0))->IsString()); |
5619 CHECK(result->Get(v8::Integer::New(isolate, 1))->IsNumber()); | 5619 CHECK(result->Get(v8::Integer::New(isolate, 1))->IsNumber()); |
5620 CHECK_EQ(1, result->Get(v8::Integer::New(isolate, 1))->Int32Value()); | 5620 CHECK_EQ(1, result->Get(v8::Integer::New(isolate, 1))->Int32Value()); |
5621 CHECK(result->Get(v8::Integer::New(isolate, 2))->IsNumber()); | 5621 CHECK(result->Get(v8::Integer::New(isolate, 2))->IsNumber()); |
5622 CHECK_EQ(0, result->Get(v8::Integer::New(isolate, 2))->Int32Value()); | 5622 CHECK_EQ(0, result->Get(v8::Integer::New(isolate, 2))->Int32Value()); |
5623 CHECK(result->Get(v8::Integer::New(isolate, 3))->IsNull()); | 5623 CHECK(result->Get(v8::Integer::New(isolate, 3))->IsNull()); |
5624 CHECK(result->Get(v8::Integer::New(isolate, 4))->IsUndefined()); | 5624 CHECK(result->Get(v8::Integer::New(isolate, 4))->IsUndefined()); |
5625 } | 5625 } |
5626 | 5626 |
5627 | 5627 |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5825 | 5825 |
5826 | 5826 |
5827 THREADED_TEST(Equality) { | 5827 THREADED_TEST(Equality) { |
5828 LocalContext context; | 5828 LocalContext context; |
5829 v8::Isolate* isolate = context->GetIsolate(); | 5829 v8::Isolate* isolate = context->GetIsolate(); |
5830 v8::HandleScope scope(context->GetIsolate()); | 5830 v8::HandleScope scope(context->GetIsolate()); |
5831 // Check that equality works at all before relying on CHECK_EQ | 5831 // Check that equality works at all before relying on CHECK_EQ |
5832 CHECK(v8_str("a")->Equals(v8_str("a"))); | 5832 CHECK(v8_str("a")->Equals(v8_str("a"))); |
5833 CHECK(!v8_str("a")->Equals(v8_str("b"))); | 5833 CHECK(!v8_str("a")->Equals(v8_str("b"))); |
5834 | 5834 |
5835 CHECK(v8_str("a")->Equals(v8_str("a"))); | 5835 CHECK_EQ(v8_str("a"), v8_str("a")); |
5836 CHECK(!v8_str("a")->Equals(v8_str("b"))); | 5836 CHECK_NE(v8_str("a"), v8_str("b")); |
5837 CHECK(v8_num(1)->Equals(v8_num(1))); | 5837 CHECK_EQ(v8_num(1), v8_num(1)); |
5838 CHECK(v8_num(1.00)->Equals(v8_num(1))); | 5838 CHECK_EQ(v8_num(1.00), v8_num(1)); |
5839 CHECK(!v8_num(1)->Equals(v8_num(2))); | 5839 CHECK_NE(v8_num(1), v8_num(2)); |
5840 | 5840 |
5841 // Assume String is not internalized. | 5841 // Assume String is not internalized. |
5842 CHECK(v8_str("a")->StrictEquals(v8_str("a"))); | 5842 CHECK(v8_str("a")->StrictEquals(v8_str("a"))); |
5843 CHECK(!v8_str("a")->StrictEquals(v8_str("b"))); | 5843 CHECK(!v8_str("a")->StrictEquals(v8_str("b"))); |
5844 CHECK(!v8_str("5")->StrictEquals(v8_num(5))); | 5844 CHECK(!v8_str("5")->StrictEquals(v8_num(5))); |
5845 CHECK(v8_num(1)->StrictEquals(v8_num(1))); | 5845 CHECK(v8_num(1)->StrictEquals(v8_num(1))); |
5846 CHECK(!v8_num(1)->StrictEquals(v8_num(2))); | 5846 CHECK(!v8_num(1)->StrictEquals(v8_num(2))); |
5847 CHECK(v8_num(0.0)->StrictEquals(v8_num(-0.0))); | 5847 CHECK(v8_num(0.0)->StrictEquals(v8_num(-0.0))); |
5848 Local<Value> not_a_number = v8_num(std::numeric_limits<double>::quiet_NaN()); | 5848 Local<Value> not_a_number = v8_num(std::numeric_limits<double>::quiet_NaN()); |
5849 CHECK(!not_a_number->StrictEquals(not_a_number)); | 5849 CHECK(!not_a_number->StrictEquals(not_a_number)); |
(...skipping 22 matching lines...) Expand all Loading... |
5872 v8::HandleScope scope(context->GetIsolate()); | 5872 v8::HandleScope scope(context->GetIsolate()); |
5873 Local<Script> script = v8_compile("x"); | 5873 Local<Script> script = v8_compile("x"); |
5874 for (int i = 0; i < 10; i++) | 5874 for (int i = 0; i < 10; i++) |
5875 script->Run(); | 5875 script->Run(); |
5876 } | 5876 } |
5877 | 5877 |
5878 | 5878 |
5879 static void GetXValue(Local<String> name, | 5879 static void GetXValue(Local<String> name, |
5880 const v8::PropertyCallbackInfo<v8::Value>& info) { | 5880 const v8::PropertyCallbackInfo<v8::Value>& info) { |
5881 ApiTestFuzzer::Fuzz(); | 5881 ApiTestFuzzer::Fuzz(); |
5882 CHECK(info.Data()->Equals(v8_str("donut"))); | 5882 CHECK_EQ(info.Data(), v8_str("donut")); |
5883 CHECK(name->Equals(v8_str("x"))); | 5883 CHECK_EQ(name, v8_str("x")); |
5884 info.GetReturnValue().Set(name); | 5884 info.GetReturnValue().Set(name); |
5885 } | 5885 } |
5886 | 5886 |
5887 | 5887 |
5888 THREADED_TEST(SimplePropertyRead) { | 5888 THREADED_TEST(SimplePropertyRead) { |
5889 LocalContext context; | 5889 LocalContext context; |
5890 v8::Isolate* isolate = context->GetIsolate(); | 5890 v8::Isolate* isolate = context->GetIsolate(); |
5891 v8::HandleScope scope(isolate); | 5891 v8::HandleScope scope(isolate); |
5892 Local<ObjectTemplate> templ = ObjectTemplate::New(isolate); | 5892 Local<ObjectTemplate> templ = ObjectTemplate::New(isolate); |
5893 templ->SetAccessor(v8_str("x"), GetXValue, NULL, v8_str("donut")); | 5893 templ->SetAccessor(v8_str("x"), GetXValue, NULL, v8_str("donut")); |
5894 context->Global()->Set(v8_str("obj"), templ->NewInstance()); | 5894 context->Global()->Set(v8_str("obj"), templ->NewInstance()); |
5895 Local<Script> script = v8_compile("obj.x"); | 5895 Local<Script> script = v8_compile("obj.x"); |
5896 for (int i = 0; i < 10; i++) { | 5896 for (int i = 0; i < 10; i++) { |
5897 Local<Value> result = script->Run(); | 5897 Local<Value> result = script->Run(); |
5898 CHECK(result->Equals(v8_str("x"))); | 5898 CHECK_EQ(result, v8_str("x")); |
5899 } | 5899 } |
5900 } | 5900 } |
5901 | 5901 |
5902 | 5902 |
5903 THREADED_TEST(DefinePropertyOnAPIAccessor) { | 5903 THREADED_TEST(DefinePropertyOnAPIAccessor) { |
5904 LocalContext context; | 5904 LocalContext context; |
5905 v8::Isolate* isolate = context->GetIsolate(); | 5905 v8::Isolate* isolate = context->GetIsolate(); |
5906 v8::HandleScope scope(isolate); | 5906 v8::HandleScope scope(isolate); |
5907 Local<ObjectTemplate> templ = ObjectTemplate::New(isolate); | 5907 Local<ObjectTemplate> templ = ObjectTemplate::New(isolate); |
5908 templ->SetAccessor(v8_str("x"), GetXValue, NULL, v8_str("donut")); | 5908 templ->SetAccessor(v8_str("x"), GetXValue, NULL, v8_str("donut")); |
5909 context->Global()->Set(v8_str("obj"), templ->NewInstance()); | 5909 context->Global()->Set(v8_str("obj"), templ->NewInstance()); |
5910 | 5910 |
5911 // Uses getOwnPropertyDescriptor to check the configurable status | 5911 // Uses getOwnPropertyDescriptor to check the configurable status |
5912 Local<Script> script_desc = v8_compile( | 5912 Local<Script> script_desc = v8_compile( |
5913 "var prop = Object.getOwnPropertyDescriptor( " | 5913 "var prop = Object.getOwnPropertyDescriptor( " |
5914 "obj, 'x');" | 5914 "obj, 'x');" |
5915 "prop.configurable;"); | 5915 "prop.configurable;"); |
5916 Local<Value> result = script_desc->Run(); | 5916 Local<Value> result = script_desc->Run(); |
5917 CHECK_EQ(result->BooleanValue(), true); | 5917 CHECK_EQ(result->BooleanValue(), true); |
5918 | 5918 |
5919 // Redefine get - but still configurable | 5919 // Redefine get - but still configurable |
5920 Local<Script> script_define = v8_compile( | 5920 Local<Script> script_define = v8_compile( |
5921 "var desc = { get: function(){return 42; }," | 5921 "var desc = { get: function(){return 42; }," |
5922 " configurable: true };" | 5922 " configurable: true };" |
5923 "Object.defineProperty(obj, 'x', desc);" | 5923 "Object.defineProperty(obj, 'x', desc);" |
5924 "obj.x"); | 5924 "obj.x"); |
5925 result = script_define->Run(); | 5925 result = script_define->Run(); |
5926 CHECK(result->Equals(v8_num(42))); | 5926 CHECK_EQ(result, v8_num(42)); |
5927 | 5927 |
5928 // Check that the accessor is still configurable | 5928 // Check that the accessor is still configurable |
5929 result = script_desc->Run(); | 5929 result = script_desc->Run(); |
5930 CHECK_EQ(result->BooleanValue(), true); | 5930 CHECK_EQ(result->BooleanValue(), true); |
5931 | 5931 |
5932 // Redefine to a non-configurable | 5932 // Redefine to a non-configurable |
5933 script_define = v8_compile( | 5933 script_define = v8_compile( |
5934 "var desc = { get: function(){return 43; }," | 5934 "var desc = { get: function(){return 43; }," |
5935 " configurable: false };" | 5935 " configurable: false };" |
5936 "Object.defineProperty(obj, 'x', desc);" | 5936 "Object.defineProperty(obj, 'x', desc);" |
5937 "obj.x"); | 5937 "obj.x"); |
5938 result = script_define->Run(); | 5938 result = script_define->Run(); |
5939 CHECK(result->Equals(v8_num(43))); | 5939 CHECK_EQ(result, v8_num(43)); |
5940 result = script_desc->Run(); | 5940 result = script_desc->Run(); |
5941 CHECK_EQ(result->BooleanValue(), false); | 5941 CHECK_EQ(result->BooleanValue(), false); |
5942 | 5942 |
5943 // Make sure that it is not possible to redefine again | 5943 // Make sure that it is not possible to redefine again |
5944 v8::TryCatch try_catch; | 5944 v8::TryCatch try_catch; |
5945 result = script_define->Run(); | 5945 result = script_define->Run(); |
5946 CHECK(try_catch.HasCaught()); | 5946 CHECK(try_catch.HasCaught()); |
5947 String::Utf8Value exception_value(try_catch.Exception()); | 5947 String::Utf8Value exception_value(try_catch.Exception()); |
5948 CHECK_EQ(0, | 5948 CHECK_EQ(*exception_value, "TypeError: Cannot redefine property: x"); |
5949 strcmp(*exception_value, "TypeError: Cannot redefine property: x")); | |
5950 } | 5949 } |
5951 | 5950 |
5952 | 5951 |
5953 THREADED_TEST(DefinePropertyOnDefineGetterSetter) { | 5952 THREADED_TEST(DefinePropertyOnDefineGetterSetter) { |
5954 v8::Isolate* isolate = CcTest::isolate(); | 5953 v8::Isolate* isolate = CcTest::isolate(); |
5955 v8::HandleScope scope(isolate); | 5954 v8::HandleScope scope(isolate); |
5956 Local<ObjectTemplate> templ = ObjectTemplate::New(isolate); | 5955 Local<ObjectTemplate> templ = ObjectTemplate::New(isolate); |
5957 templ->SetAccessor(v8_str("x"), GetXValue, NULL, v8_str("donut")); | 5956 templ->SetAccessor(v8_str("x"), GetXValue, NULL, v8_str("donut")); |
5958 LocalContext context; | 5957 LocalContext context; |
5959 context->Global()->Set(v8_str("obj"), templ->NewInstance()); | 5958 context->Global()->Set(v8_str("obj"), templ->NewInstance()); |
5960 | 5959 |
5961 Local<Script> script_desc = v8_compile( | 5960 Local<Script> script_desc = v8_compile( |
5962 "var prop =" | 5961 "var prop =" |
5963 "Object.getOwnPropertyDescriptor( " | 5962 "Object.getOwnPropertyDescriptor( " |
5964 "obj, 'x');" | 5963 "obj, 'x');" |
5965 "prop.configurable;"); | 5964 "prop.configurable;"); |
5966 Local<Value> result = script_desc->Run(); | 5965 Local<Value> result = script_desc->Run(); |
5967 CHECK_EQ(result->BooleanValue(), true); | 5966 CHECK_EQ(result->BooleanValue(), true); |
5968 | 5967 |
5969 Local<Script> script_define = v8_compile( | 5968 Local<Script> script_define = v8_compile( |
5970 "var desc = {get: function(){return 42; }," | 5969 "var desc = {get: function(){return 42; }," |
5971 " configurable: true };" | 5970 " configurable: true };" |
5972 "Object.defineProperty(obj, 'x', desc);" | 5971 "Object.defineProperty(obj, 'x', desc);" |
5973 "obj.x"); | 5972 "obj.x"); |
5974 result = script_define->Run(); | 5973 result = script_define->Run(); |
5975 CHECK(result->Equals(v8_num(42))); | 5974 CHECK_EQ(result, v8_num(42)); |
5976 | 5975 |
5977 | 5976 |
5978 result = script_desc->Run(); | 5977 result = script_desc->Run(); |
5979 CHECK_EQ(result->BooleanValue(), true); | 5978 CHECK_EQ(result->BooleanValue(), true); |
5980 | 5979 |
5981 | 5980 |
5982 script_define = v8_compile( | 5981 script_define = v8_compile( |
5983 "var desc = {get: function(){return 43; }," | 5982 "var desc = {get: function(){return 43; }," |
5984 " configurable: false };" | 5983 " configurable: false };" |
5985 "Object.defineProperty(obj, 'x', desc);" | 5984 "Object.defineProperty(obj, 'x', desc);" |
5986 "obj.x"); | 5985 "obj.x"); |
5987 result = script_define->Run(); | 5986 result = script_define->Run(); |
5988 CHECK(result->Equals(v8_num(43))); | 5987 CHECK_EQ(result, v8_num(43)); |
5989 result = script_desc->Run(); | 5988 result = script_desc->Run(); |
5990 | 5989 |
5991 CHECK_EQ(result->BooleanValue(), false); | 5990 CHECK_EQ(result->BooleanValue(), false); |
5992 | 5991 |
5993 v8::TryCatch try_catch; | 5992 v8::TryCatch try_catch; |
5994 result = script_define->Run(); | 5993 result = script_define->Run(); |
5995 CHECK(try_catch.HasCaught()); | 5994 CHECK(try_catch.HasCaught()); |
5996 String::Utf8Value exception_value(try_catch.Exception()); | 5995 String::Utf8Value exception_value(try_catch.Exception()); |
5997 CHECK_EQ(0, | 5996 CHECK_EQ(*exception_value, "TypeError: Cannot redefine property: x"); |
5998 strcmp(*exception_value, "TypeError: Cannot redefine property: x")); | |
5999 } | 5997 } |
6000 | 5998 |
6001 | 5999 |
6002 static v8::Handle<v8::Object> GetGlobalProperty(LocalContext* context, | 6000 static v8::Handle<v8::Object> GetGlobalProperty(LocalContext* context, |
6003 char const* name) { | 6001 char const* name) { |
6004 return v8::Handle<v8::Object>::Cast((*context)->Global()->Get(v8_str(name))); | 6002 return v8::Handle<v8::Object>::Cast((*context)->Global()->Get(v8_str(name))); |
6005 } | 6003 } |
6006 | 6004 |
6007 | 6005 |
6008 THREADED_TEST(DefineAPIAccessorOnObject) { | 6006 THREADED_TEST(DefineAPIAccessorOnObject) { |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6108 SetAccessor(v8_str("x"), GetXValue, NULL, v8_str("donut"))); | 6106 SetAccessor(v8_str("x"), GetXValue, NULL, v8_str("donut"))); |
6109 CHECK(!GetGlobalProperty(&context, "obj2")-> | 6107 CHECK(!GetGlobalProperty(&context, "obj2")-> |
6110 SetAccessor(v8_str("x"), GetXValue, NULL, v8_str("donut"))); | 6108 SetAccessor(v8_str("x"), GetXValue, NULL, v8_str("donut"))); |
6111 | 6109 |
6112 { | 6110 { |
6113 v8::TryCatch try_catch; | 6111 v8::TryCatch try_catch; |
6114 CompileRun("Object.defineProperty(obj1, 'x'," | 6112 CompileRun("Object.defineProperty(obj1, 'x'," |
6115 "{get: function() { return 'func'; }})"); | 6113 "{get: function() { return 'func'; }})"); |
6116 CHECK(try_catch.HasCaught()); | 6114 CHECK(try_catch.HasCaught()); |
6117 String::Utf8Value exception_value(try_catch.Exception()); | 6115 String::Utf8Value exception_value(try_catch.Exception()); |
6118 CHECK_EQ( | 6116 CHECK_EQ(*exception_value, "TypeError: Cannot redefine property: x"); |
6119 0, strcmp(*exception_value, "TypeError: Cannot redefine property: x")); | |
6120 } | 6117 } |
6121 { | 6118 { |
6122 v8::TryCatch try_catch; | 6119 v8::TryCatch try_catch; |
6123 CompileRun("Object.defineProperty(obj2, 'x'," | 6120 CompileRun("Object.defineProperty(obj2, 'x'," |
6124 "{get: function() { return 'func'; }})"); | 6121 "{get: function() { return 'func'; }})"); |
6125 CHECK(try_catch.HasCaught()); | 6122 CHECK(try_catch.HasCaught()); |
6126 String::Utf8Value exception_value(try_catch.Exception()); | 6123 String::Utf8Value exception_value(try_catch.Exception()); |
6127 CHECK_EQ( | 6124 CHECK_EQ(*exception_value, "TypeError: Cannot redefine property: x"); |
6128 0, strcmp(*exception_value, "TypeError: Cannot redefine property: x")); | |
6129 } | 6125 } |
6130 } | 6126 } |
6131 | 6127 |
6132 | 6128 |
6133 static void Get239Value(Local<String> name, | 6129 static void Get239Value(Local<String> name, |
6134 const v8::PropertyCallbackInfo<v8::Value>& info) { | 6130 const v8::PropertyCallbackInfo<v8::Value>& info) { |
6135 ApiTestFuzzer::Fuzz(); | 6131 ApiTestFuzzer::Fuzz(); |
6136 CHECK(info.Data()->Equals(v8_str("donut"))); | 6132 CHECK_EQ(info.Data(), v8_str("donut")); |
6137 CHECK(name->Equals(v8_str("239"))); | 6133 CHECK_EQ(name, v8_str("239")); |
6138 info.GetReturnValue().Set(name); | 6134 info.GetReturnValue().Set(name); |
6139 } | 6135 } |
6140 | 6136 |
6141 | 6137 |
6142 THREADED_TEST(ElementAPIAccessor) { | 6138 THREADED_TEST(ElementAPIAccessor) { |
6143 v8::Isolate* isolate = CcTest::isolate(); | 6139 v8::Isolate* isolate = CcTest::isolate(); |
6144 v8::HandleScope scope(isolate); | 6140 v8::HandleScope scope(isolate); |
6145 Local<ObjectTemplate> templ = ObjectTemplate::New(isolate); | 6141 Local<ObjectTemplate> templ = ObjectTemplate::New(isolate); |
6146 LocalContext context; | 6142 LocalContext context; |
6147 | 6143 |
(...skipping 15 matching lines...) Expand all Loading... |
6163 ExpectString("obj2['239']", "239"); | 6159 ExpectString("obj2['239']", "239"); |
6164 } | 6160 } |
6165 | 6161 |
6166 | 6162 |
6167 v8::Persistent<Value> xValue; | 6163 v8::Persistent<Value> xValue; |
6168 | 6164 |
6169 | 6165 |
6170 static void SetXValue(Local<String> name, | 6166 static void SetXValue(Local<String> name, |
6171 Local<Value> value, | 6167 Local<Value> value, |
6172 const v8::PropertyCallbackInfo<void>& info) { | 6168 const v8::PropertyCallbackInfo<void>& info) { |
6173 CHECK(value->Equals(v8_num(4))); | 6169 CHECK_EQ(value, v8_num(4)); |
6174 CHECK(info.Data()->Equals(v8_str("donut"))); | 6170 CHECK_EQ(info.Data(), v8_str("donut")); |
6175 CHECK(name->Equals(v8_str("x"))); | 6171 CHECK_EQ(name, v8_str("x")); |
6176 CHECK(xValue.IsEmpty()); | 6172 CHECK(xValue.IsEmpty()); |
6177 xValue.Reset(info.GetIsolate(), value); | 6173 xValue.Reset(info.GetIsolate(), value); |
6178 } | 6174 } |
6179 | 6175 |
6180 | 6176 |
6181 THREADED_TEST(SimplePropertyWrite) { | 6177 THREADED_TEST(SimplePropertyWrite) { |
6182 v8::Isolate* isolate = CcTest::isolate(); | 6178 v8::Isolate* isolate = CcTest::isolate(); |
6183 v8::HandleScope scope(isolate); | 6179 v8::HandleScope scope(isolate); |
6184 Local<ObjectTemplate> templ = ObjectTemplate::New(isolate); | 6180 Local<ObjectTemplate> templ = ObjectTemplate::New(isolate); |
6185 templ->SetAccessor(v8_str("x"), GetXValue, SetXValue, v8_str("donut")); | 6181 templ->SetAccessor(v8_str("x"), GetXValue, SetXValue, v8_str("donut")); |
6186 LocalContext context; | 6182 LocalContext context; |
6187 context->Global()->Set(v8_str("obj"), templ->NewInstance()); | 6183 context->Global()->Set(v8_str("obj"), templ->NewInstance()); |
6188 Local<Script> script = v8_compile("obj.x = 4"); | 6184 Local<Script> script = v8_compile("obj.x = 4"); |
6189 for (int i = 0; i < 10; i++) { | 6185 for (int i = 0; i < 10; i++) { |
6190 CHECK(xValue.IsEmpty()); | 6186 CHECK(xValue.IsEmpty()); |
6191 script->Run(); | 6187 script->Run(); |
6192 CHECK(v8_num(4)->Equals(Local<Value>::New(CcTest::isolate(), xValue))); | 6188 CHECK_EQ(v8_num(4), Local<Value>::New(CcTest::isolate(), xValue)); |
6193 xValue.Reset(); | 6189 xValue.Reset(); |
6194 } | 6190 } |
6195 } | 6191 } |
6196 | 6192 |
6197 | 6193 |
6198 THREADED_TEST(SetterOnly) { | 6194 THREADED_TEST(SetterOnly) { |
6199 v8::Isolate* isolate = CcTest::isolate(); | 6195 v8::Isolate* isolate = CcTest::isolate(); |
6200 v8::HandleScope scope(isolate); | 6196 v8::HandleScope scope(isolate); |
6201 Local<ObjectTemplate> templ = ObjectTemplate::New(isolate); | 6197 Local<ObjectTemplate> templ = ObjectTemplate::New(isolate); |
6202 templ->SetAccessor(v8_str("x"), NULL, SetXValue, v8_str("donut")); | 6198 templ->SetAccessor(v8_str("x"), NULL, SetXValue, v8_str("donut")); |
6203 LocalContext context; | 6199 LocalContext context; |
6204 context->Global()->Set(v8_str("obj"), templ->NewInstance()); | 6200 context->Global()->Set(v8_str("obj"), templ->NewInstance()); |
6205 Local<Script> script = v8_compile("obj.x = 4; obj.x"); | 6201 Local<Script> script = v8_compile("obj.x = 4; obj.x"); |
6206 for (int i = 0; i < 10; i++) { | 6202 for (int i = 0; i < 10; i++) { |
6207 CHECK(xValue.IsEmpty()); | 6203 CHECK(xValue.IsEmpty()); |
6208 script->Run(); | 6204 script->Run(); |
6209 CHECK(v8_num(4)->Equals(Local<Value>::New(CcTest::isolate(), xValue))); | 6205 CHECK_EQ(v8_num(4), Local<Value>::New(CcTest::isolate(), xValue)); |
6210 xValue.Reset(); | 6206 xValue.Reset(); |
6211 } | 6207 } |
6212 } | 6208 } |
6213 | 6209 |
6214 | 6210 |
6215 THREADED_TEST(NoAccessors) { | 6211 THREADED_TEST(NoAccessors) { |
6216 v8::Isolate* isolate = CcTest::isolate(); | 6212 v8::Isolate* isolate = CcTest::isolate(); |
6217 v8::HandleScope scope(isolate); | 6213 v8::HandleScope scope(isolate); |
6218 Local<ObjectTemplate> templ = ObjectTemplate::New(isolate); | 6214 Local<ObjectTemplate> templ = ObjectTemplate::New(isolate); |
6219 templ->SetAccessor(v8_str("x"), | 6215 templ->SetAccessor(v8_str("x"), |
(...skipping 20 matching lines...) Expand all Loading... |
6240 THREADED_TEST(NamedInterceptorPropertyRead) { | 6236 THREADED_TEST(NamedInterceptorPropertyRead) { |
6241 v8::Isolate* isolate = CcTest::isolate(); | 6237 v8::Isolate* isolate = CcTest::isolate(); |
6242 v8::HandleScope scope(isolate); | 6238 v8::HandleScope scope(isolate); |
6243 Local<ObjectTemplate> templ = ObjectTemplate::New(isolate); | 6239 Local<ObjectTemplate> templ = ObjectTemplate::New(isolate); |
6244 templ->SetHandler(v8::NamedPropertyHandlerConfiguration(XPropertyGetter)); | 6240 templ->SetHandler(v8::NamedPropertyHandlerConfiguration(XPropertyGetter)); |
6245 LocalContext context; | 6241 LocalContext context; |
6246 context->Global()->Set(v8_str("obj"), templ->NewInstance()); | 6242 context->Global()->Set(v8_str("obj"), templ->NewInstance()); |
6247 Local<Script> script = v8_compile("obj.x"); | 6243 Local<Script> script = v8_compile("obj.x"); |
6248 for (int i = 0; i < 10; i++) { | 6244 for (int i = 0; i < 10; i++) { |
6249 Local<Value> result = script->Run(); | 6245 Local<Value> result = script->Run(); |
6250 CHECK(result->Equals(v8_str("x"))); | 6246 CHECK_EQ(result, v8_str("x")); |
6251 } | 6247 } |
6252 } | 6248 } |
6253 | 6249 |
6254 | 6250 |
6255 THREADED_TEST(NamedInterceptorDictionaryIC) { | 6251 THREADED_TEST(NamedInterceptorDictionaryIC) { |
6256 v8::Isolate* isolate = CcTest::isolate(); | 6252 v8::Isolate* isolate = CcTest::isolate(); |
6257 v8::HandleScope scope(isolate); | 6253 v8::HandleScope scope(isolate); |
6258 Local<ObjectTemplate> templ = ObjectTemplate::New(isolate); | 6254 Local<ObjectTemplate> templ = ObjectTemplate::New(isolate); |
6259 templ->SetHandler(v8::NamedPropertyHandlerConfiguration(XPropertyGetter)); | 6255 templ->SetHandler(v8::NamedPropertyHandlerConfiguration(XPropertyGetter)); |
6260 LocalContext context; | 6256 LocalContext context; |
6261 // Create an object with a named interceptor. | 6257 // Create an object with a named interceptor. |
6262 context->Global()->Set(v8_str("interceptor_obj"), templ->NewInstance()); | 6258 context->Global()->Set(v8_str("interceptor_obj"), templ->NewInstance()); |
6263 Local<Script> script = v8_compile("interceptor_obj.x"); | 6259 Local<Script> script = v8_compile("interceptor_obj.x"); |
6264 for (int i = 0; i < 10; i++) { | 6260 for (int i = 0; i < 10; i++) { |
6265 Local<Value> result = script->Run(); | 6261 Local<Value> result = script->Run(); |
6266 CHECK(result->Equals(v8_str("x"))); | 6262 CHECK_EQ(result, v8_str("x")); |
6267 } | 6263 } |
6268 // Create a slow case object and a function accessing a property in | 6264 // Create a slow case object and a function accessing a property in |
6269 // that slow case object (with dictionary probing in generated | 6265 // that slow case object (with dictionary probing in generated |
6270 // code). Then force object with a named interceptor into slow-case, | 6266 // code). Then force object with a named interceptor into slow-case, |
6271 // pass it to the function, and check that the interceptor is called | 6267 // pass it to the function, and check that the interceptor is called |
6272 // instead of accessing the local property. | 6268 // instead of accessing the local property. |
6273 Local<Value> result = | 6269 Local<Value> result = |
6274 CompileRun("function get_x(o) { return o.x; };" | 6270 CompileRun("function get_x(o) { return o.x; };" |
6275 "var obj = { x : 42, y : 0 };" | 6271 "var obj = { x : 42, y : 0 };" |
6276 "delete obj.y;" | 6272 "delete obj.y;" |
6277 "for (var i = 0; i < 10; i++) get_x(obj);" | 6273 "for (var i = 0; i < 10; i++) get_x(obj);" |
6278 "interceptor_obj.x = 42;" | 6274 "interceptor_obj.x = 42;" |
6279 "interceptor_obj.y = 10;" | 6275 "interceptor_obj.y = 10;" |
6280 "delete interceptor_obj.y;" | 6276 "delete interceptor_obj.y;" |
6281 "get_x(interceptor_obj)"); | 6277 "get_x(interceptor_obj)"); |
6282 CHECK(result->Equals(v8_str("x"))); | 6278 CHECK_EQ(result, v8_str("x")); |
6283 } | 6279 } |
6284 | 6280 |
6285 | 6281 |
6286 THREADED_TEST(NamedInterceptorDictionaryICMultipleContext) { | 6282 THREADED_TEST(NamedInterceptorDictionaryICMultipleContext) { |
6287 v8::Isolate* isolate = CcTest::isolate(); | 6283 v8::Isolate* isolate = CcTest::isolate(); |
6288 v8::HandleScope scope(isolate); | 6284 v8::HandleScope scope(isolate); |
6289 v8::Local<Context> context1 = Context::New(isolate); | 6285 v8::Local<Context> context1 = Context::New(isolate); |
6290 | 6286 |
6291 context1->Enter(); | 6287 context1->Enter(); |
6292 Local<ObjectTemplate> templ = ObjectTemplate::New(isolate); | 6288 Local<ObjectTemplate> templ = ObjectTemplate::New(isolate); |
(...skipping 13 matching lines...) Expand all Loading... |
6306 LocalContext context2; | 6302 LocalContext context2; |
6307 context2->Global()->Set(v8_str("interceptor_obj"), object); | 6303 context2->Global()->Set(v8_str("interceptor_obj"), object); |
6308 Local<Value> result = | 6304 Local<Value> result = |
6309 CompileRun("function get_x(o) { return o.x; }" | 6305 CompileRun("function get_x(o) { return o.x; }" |
6310 "interceptor_obj.x = 42;" | 6306 "interceptor_obj.x = 42;" |
6311 "for (var i=0; i != 10; i++) {" | 6307 "for (var i=0; i != 10; i++) {" |
6312 " get_x(interceptor_obj);" | 6308 " get_x(interceptor_obj);" |
6313 "}" | 6309 "}" |
6314 "get_x(interceptor_obj)"); | 6310 "get_x(interceptor_obj)"); |
6315 // Check that the interceptor was actually invoked. | 6311 // Check that the interceptor was actually invoked. |
6316 CHECK(result->Equals(v8_str("x"))); | 6312 CHECK_EQ(result, v8_str("x")); |
6317 } | 6313 } |
6318 | 6314 |
6319 // Return to the original context and force some object to the slow case | 6315 // Return to the original context and force some object to the slow case |
6320 // to cause the NormalizedMapCache to verify. | 6316 // to cause the NormalizedMapCache to verify. |
6321 context1->Enter(); | 6317 context1->Enter(); |
6322 CompileRun("var obj = { x : 0 }; delete obj.x;"); | 6318 CompileRun("var obj = { x : 0 }; delete obj.x;"); |
6323 context1->Exit(); | 6319 context1->Exit(); |
6324 } | 6320 } |
6325 | 6321 |
6326 | 6322 |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6389 "obj.__defineSetter__(\"17\", function(val){this.foo = val;});" | 6385 "obj.__defineSetter__(\"17\", function(val){this.foo = val;});" |
6390 "obj[17] = 23;" | 6386 "obj[17] = 23;" |
6391 "obj.foo;"); | 6387 "obj.foo;"); |
6392 Local<Script> interceptor_setter_script = v8_compile( | 6388 Local<Script> interceptor_setter_script = v8_compile( |
6393 "obj.__defineSetter__(\"39\", function(val){this.foo = \"hit\";});" | 6389 "obj.__defineSetter__(\"39\", function(val){this.foo = \"hit\";});" |
6394 "obj[39] = 47;" | 6390 "obj[39] = 47;" |
6395 "obj.foo;"); // This setter should not run, due to the interceptor. | 6391 "obj.foo;"); // This setter should not run, due to the interceptor. |
6396 Local<Script> interceptor_getter_script = v8_compile( | 6392 Local<Script> interceptor_getter_script = v8_compile( |
6397 "obj[37];"); | 6393 "obj[37];"); |
6398 Local<Value> result = getter_script->Run(); | 6394 Local<Value> result = getter_script->Run(); |
6399 CHECK(v8_num(5)->Equals(result)); | 6395 CHECK_EQ(v8_num(5), result); |
6400 result = setter_script->Run(); | 6396 result = setter_script->Run(); |
6401 CHECK(v8_num(23)->Equals(result)); | 6397 CHECK_EQ(v8_num(23), result); |
6402 result = interceptor_setter_script->Run(); | 6398 result = interceptor_setter_script->Run(); |
6403 CHECK(v8_num(23)->Equals(result)); | 6399 CHECK_EQ(v8_num(23), result); |
6404 result = interceptor_getter_script->Run(); | 6400 result = interceptor_getter_script->Run(); |
6405 CHECK(v8_num(625)->Equals(result)); | 6401 CHECK_EQ(v8_num(625), result); |
6406 } | 6402 } |
6407 | 6403 |
6408 | 6404 |
6409 static void UnboxedDoubleIndexedPropertyGetter( | 6405 static void UnboxedDoubleIndexedPropertyGetter( |
6410 uint32_t index, | 6406 uint32_t index, |
6411 const v8::PropertyCallbackInfo<v8::Value>& info) { | 6407 const v8::PropertyCallbackInfo<v8::Value>& info) { |
6412 ApiTestFuzzer::Fuzz(); | 6408 ApiTestFuzzer::Fuzz(); |
6413 if (index < 25) { | 6409 if (index < 25) { |
6414 info.GetReturnValue().Set(v8_num(index)); | 6410 info.GetReturnValue().Set(v8_num(index)); |
6415 } | 6411 } |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6453 // When obj is created, force it to be Stored in a FastDoubleArray. | 6449 // When obj is created, force it to be Stored in a FastDoubleArray. |
6454 Local<Script> create_unboxed_double_script = v8_compile( | 6450 Local<Script> create_unboxed_double_script = v8_compile( |
6455 "obj[125000] = 1; for(i = 0; i < 80000; i+=2) { obj[i] = i; } " | 6451 "obj[125000] = 1; for(i = 0; i < 80000; i+=2) { obj[i] = i; } " |
6456 "key_count = 0; " | 6452 "key_count = 0; " |
6457 "for (x in obj) {key_count++;};" | 6453 "for (x in obj) {key_count++;};" |
6458 "obj;"); | 6454 "obj;"); |
6459 Local<Value> result = create_unboxed_double_script->Run(); | 6455 Local<Value> result = create_unboxed_double_script->Run(); |
6460 CHECK(result->ToObject(isolate)->HasRealIndexedProperty(2000)); | 6456 CHECK(result->ToObject(isolate)->HasRealIndexedProperty(2000)); |
6461 Local<Script> key_count_check = v8_compile("key_count;"); | 6457 Local<Script> key_count_check = v8_compile("key_count;"); |
6462 result = key_count_check->Run(); | 6458 result = key_count_check->Run(); |
6463 CHECK(v8_num(40013)->Equals(result)); | 6459 CHECK_EQ(v8_num(40013), result); |
6464 } | 6460 } |
6465 | 6461 |
6466 | 6462 |
6467 void SloppyArgsIndexedPropertyEnumerator( | 6463 void SloppyArgsIndexedPropertyEnumerator( |
6468 const v8::PropertyCallbackInfo<v8::Array>& info) { | 6464 const v8::PropertyCallbackInfo<v8::Array>& info) { |
6469 // Force the list of returned keys to be stored in a Arguments object. | 6465 // Force the list of returned keys to be stored in a Arguments object. |
6470 Local<Script> indexed_property_names_script = v8_compile( | 6466 Local<Script> indexed_property_names_script = v8_compile( |
6471 "function f(w,x) {" | 6467 "function f(w,x) {" |
6472 " return arguments;" | 6468 " return arguments;" |
6473 "}" | 6469 "}" |
(...skipping 27 matching lines...) Expand all Loading... |
6501 Local<ObjectTemplate> templ = ObjectTemplate::New(isolate); | 6497 Local<ObjectTemplate> templ = ObjectTemplate::New(isolate); |
6502 templ->SetHandler(v8::IndexedPropertyHandlerConfiguration( | 6498 templ->SetHandler(v8::IndexedPropertyHandlerConfiguration( |
6503 SloppyIndexedPropertyGetter, 0, 0, 0, | 6499 SloppyIndexedPropertyGetter, 0, 0, 0, |
6504 SloppyArgsIndexedPropertyEnumerator)); | 6500 SloppyArgsIndexedPropertyEnumerator)); |
6505 LocalContext context; | 6501 LocalContext context; |
6506 context->Global()->Set(v8_str("obj"), templ->NewInstance()); | 6502 context->Global()->Set(v8_str("obj"), templ->NewInstance()); |
6507 Local<Script> create_args_script = v8_compile( | 6503 Local<Script> create_args_script = v8_compile( |
6508 "var key_count = 0;" | 6504 "var key_count = 0;" |
6509 "for (x in obj) {key_count++;} key_count;"); | 6505 "for (x in obj) {key_count++;} key_count;"); |
6510 Local<Value> result = create_args_script->Run(); | 6506 Local<Value> result = create_args_script->Run(); |
6511 CHECK(v8_num(4)->Equals(result)); | 6507 CHECK_EQ(v8_num(4), result); |
6512 } | 6508 } |
6513 | 6509 |
6514 | 6510 |
6515 static void IdentityIndexedPropertyGetter( | 6511 static void IdentityIndexedPropertyGetter( |
6516 uint32_t index, | 6512 uint32_t index, |
6517 const v8::PropertyCallbackInfo<v8::Value>& info) { | 6513 const v8::PropertyCallbackInfo<v8::Value>& info) { |
6518 info.GetReturnValue().Set(index); | 6514 info.GetReturnValue().Set(index); |
6519 } | 6515 } |
6520 | 6516 |
6521 | 6517 |
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6836 context0->SetSecurityToken(password); | 6832 context0->SetSecurityToken(password); |
6837 v8::Handle<v8::Object> global0 = context0->Global(); | 6833 v8::Handle<v8::Object> global0 = context0->Global(); |
6838 global0->Set(v8_str("custom"), v8_num(1234)); | 6834 global0->Set(v8_str("custom"), v8_num(1234)); |
6839 CHECK_EQ(1234, global0->Get(v8_str("custom"))->Int32Value()); | 6835 CHECK_EQ(1234, global0->Get(v8_str("custom"))->Int32Value()); |
6840 | 6836 |
6841 // Create an independent environment | 6837 // Create an independent environment |
6842 LocalContext context1(0, templ); | 6838 LocalContext context1(0, templ); |
6843 context1->SetSecurityToken(password); | 6839 context1->SetSecurityToken(password); |
6844 v8::Handle<v8::Object> global1 = context1->Global(); | 6840 v8::Handle<v8::Object> global1 = context1->Global(); |
6845 global1->Set(v8_str("custom"), v8_num(1234)); | 6841 global1->Set(v8_str("custom"), v8_num(1234)); |
6846 CHECK(!global0->Equals(global1)); | 6842 CHECK_NE(global0, global1); |
6847 CHECK_EQ(1234, global0->Get(v8_str("custom"))->Int32Value()); | 6843 CHECK_EQ(1234, global0->Get(v8_str("custom"))->Int32Value()); |
6848 CHECK_EQ(1234, global1->Get(v8_str("custom"))->Int32Value()); | 6844 CHECK_EQ(1234, global1->Get(v8_str("custom"))->Int32Value()); |
6849 | 6845 |
6850 // Now create a new context with the old global | 6846 // Now create a new context with the old global |
6851 LocalContext context2(0, templ, global1); | 6847 LocalContext context2(0, templ, global1); |
6852 context2->SetSecurityToken(password); | 6848 context2->SetSecurityToken(password); |
6853 v8::Handle<v8::Object> global2 = context2->Global(); | 6849 v8::Handle<v8::Object> global2 = context2->Global(); |
6854 CHECK(global1->Equals(global2)); | 6850 CHECK_EQ(global1, global2); |
6855 CHECK_EQ(0, global1->Get(v8_str("custom"))->Int32Value()); | 6851 CHECK_EQ(0, global1->Get(v8_str("custom"))->Int32Value()); |
6856 CHECK_EQ(0, global2->Get(v8_str("custom"))->Int32Value()); | 6852 CHECK_EQ(0, global2->Get(v8_str("custom"))->Int32Value()); |
6857 } | 6853 } |
6858 | 6854 |
6859 | 6855 |
6860 THREADED_TEST(FunctionPrototypeAcrossContexts) { | 6856 THREADED_TEST(FunctionPrototypeAcrossContexts) { |
6861 // Make sure that functions created by cloning boilerplates cannot | 6857 // Make sure that functions created by cloning boilerplates cannot |
6862 // communicate through their __proto__ field. | 6858 // communicate through their __proto__ field. |
6863 | 6859 |
6864 v8::HandleScope scope(CcTest::isolate()); | 6860 v8::HandleScope scope(CcTest::isolate()); |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7007 desc->InstanceTemplate()->MarkAsUndetectable(); // undetectable | 7003 desc->InstanceTemplate()->MarkAsUndetectable(); // undetectable |
7008 | 7004 |
7009 Local<v8::Object> obj = desc->GetFunction()->NewInstance(); | 7005 Local<v8::Object> obj = desc->GetFunction()->NewInstance(); |
7010 env->Global()->Set(v8_str("undetectable"), obj); | 7006 env->Global()->Set(v8_str("undetectable"), obj); |
7011 | 7007 |
7012 Local<String> source = v8_str("undetectable.x = 42;" | 7008 Local<String> source = v8_str("undetectable.x = 42;" |
7013 "undetectable.x"); | 7009 "undetectable.x"); |
7014 | 7010 |
7015 Local<Script> script = v8_compile(source); | 7011 Local<Script> script = v8_compile(source); |
7016 | 7012 |
7017 CHECK(v8::Integer::New(isolate, 42)->Equals(script->Run())); | 7013 CHECK_EQ(v8::Integer::New(isolate, 42), script->Run()); |
7018 | 7014 |
7019 ExpectBoolean("Object.isExtensible(undetectable)", true); | 7015 ExpectBoolean("Object.isExtensible(undetectable)", true); |
7020 | 7016 |
7021 source = v8_str("Object.preventExtensions(undetectable);"); | 7017 source = v8_str("Object.preventExtensions(undetectable);"); |
7022 script = v8_compile(source); | 7018 script = v8_compile(source); |
7023 script->Run(); | 7019 script->Run(); |
7024 ExpectBoolean("Object.isExtensible(undetectable)", false); | 7020 ExpectBoolean("Object.isExtensible(undetectable)", false); |
7025 | 7021 |
7026 source = v8_str("undetectable.y = 2000;"); | 7022 source = v8_str("undetectable.y = 2000;"); |
7027 script = v8_compile(source); | 7023 script = v8_compile(source); |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7149 | 7145 |
7150 TEST(SimpleExtensions) { | 7146 TEST(SimpleExtensions) { |
7151 v8::HandleScope handle_scope(CcTest::isolate()); | 7147 v8::HandleScope handle_scope(CcTest::isolate()); |
7152 v8::RegisterExtension(new Extension("simpletest", kSimpleExtensionSource)); | 7148 v8::RegisterExtension(new Extension("simpletest", kSimpleExtensionSource)); |
7153 const char* extension_names[] = { "simpletest" }; | 7149 const char* extension_names[] = { "simpletest" }; |
7154 v8::ExtensionConfiguration extensions(1, extension_names); | 7150 v8::ExtensionConfiguration extensions(1, extension_names); |
7155 v8::Handle<Context> context = | 7151 v8::Handle<Context> context = |
7156 Context::New(CcTest::isolate(), &extensions); | 7152 Context::New(CcTest::isolate(), &extensions); |
7157 Context::Scope lock(context); | 7153 Context::Scope lock(context); |
7158 v8::Handle<Value> result = CompileRun("Foo()"); | 7154 v8::Handle<Value> result = CompileRun("Foo()"); |
7159 CHECK(result->Equals(v8::Integer::New(CcTest::isolate(), 4))); | 7155 CHECK_EQ(result, v8::Integer::New(CcTest::isolate(), 4)); |
7160 } | 7156 } |
7161 | 7157 |
7162 | 7158 |
7163 static const char* kStackTraceFromExtensionSource = | 7159 static const char* kStackTraceFromExtensionSource = |
7164 "function foo() {" | 7160 "function foo() {" |
7165 " throw new Error();" | 7161 " throw new Error();" |
7166 "}" | 7162 "}" |
7167 "function bar() {" | 7163 "function bar() {" |
7168 " foo();" | 7164 " foo();" |
7169 "}"; | 7165 "}"; |
(...skipping 19 matching lines...) Expand all Loading... |
7189 | 7185 |
7190 TEST(NullExtensions) { | 7186 TEST(NullExtensions) { |
7191 v8::HandleScope handle_scope(CcTest::isolate()); | 7187 v8::HandleScope handle_scope(CcTest::isolate()); |
7192 v8::RegisterExtension(new Extension("nulltest", NULL)); | 7188 v8::RegisterExtension(new Extension("nulltest", NULL)); |
7193 const char* extension_names[] = { "nulltest" }; | 7189 const char* extension_names[] = { "nulltest" }; |
7194 v8::ExtensionConfiguration extensions(1, extension_names); | 7190 v8::ExtensionConfiguration extensions(1, extension_names); |
7195 v8::Handle<Context> context = | 7191 v8::Handle<Context> context = |
7196 Context::New(CcTest::isolate(), &extensions); | 7192 Context::New(CcTest::isolate(), &extensions); |
7197 Context::Scope lock(context); | 7193 Context::Scope lock(context); |
7198 v8::Handle<Value> result = CompileRun("1+3"); | 7194 v8::Handle<Value> result = CompileRun("1+3"); |
7199 CHECK(result->Equals(v8::Integer::New(CcTest::isolate(), 4))); | 7195 CHECK_EQ(result, v8::Integer::New(CcTest::isolate(), 4)); |
7200 } | 7196 } |
7201 | 7197 |
7202 | 7198 |
7203 static const char* kEmbeddedExtensionSource = | 7199 static const char* kEmbeddedExtensionSource = |
7204 "function Ret54321(){return 54321;}~~@@$" | 7200 "function Ret54321(){return 54321;}~~@@$" |
7205 "$%% THIS IS A SERIES OF NON-NULL-TERMINATED STRINGS."; | 7201 "$%% THIS IS A SERIES OF NON-NULL-TERMINATED STRINGS."; |
7206 static const int kEmbeddedExtensionSourceValidLen = 34; | 7202 static const int kEmbeddedExtensionSourceValidLen = 34; |
7207 | 7203 |
7208 | 7204 |
7209 TEST(ExtensionMissingSourceLength) { | 7205 TEST(ExtensionMissingSourceLength) { |
7210 v8::HandleScope handle_scope(CcTest::isolate()); | 7206 v8::HandleScope handle_scope(CcTest::isolate()); |
7211 v8::RegisterExtension(new Extension("srclentest_fail", | 7207 v8::RegisterExtension(new Extension("srclentest_fail", |
7212 kEmbeddedExtensionSource)); | 7208 kEmbeddedExtensionSource)); |
7213 const char* extension_names[] = { "srclentest_fail" }; | 7209 const char* extension_names[] = { "srclentest_fail" }; |
7214 v8::ExtensionConfiguration extensions(1, extension_names); | 7210 v8::ExtensionConfiguration extensions(1, extension_names); |
7215 v8::Handle<Context> context = | 7211 v8::Handle<Context> context = |
7216 Context::New(CcTest::isolate(), &extensions); | 7212 Context::New(CcTest::isolate(), &extensions); |
7217 CHECK(0 == *context); | 7213 CHECK_EQ(0, *context); |
7218 } | 7214 } |
7219 | 7215 |
7220 | 7216 |
7221 TEST(ExtensionWithSourceLength) { | 7217 TEST(ExtensionWithSourceLength) { |
7222 for (int source_len = kEmbeddedExtensionSourceValidLen - 1; | 7218 for (int source_len = kEmbeddedExtensionSourceValidLen - 1; |
7223 source_len <= kEmbeddedExtensionSourceValidLen + 1; ++source_len) { | 7219 source_len <= kEmbeddedExtensionSourceValidLen + 1; ++source_len) { |
7224 v8::HandleScope handle_scope(CcTest::isolate()); | 7220 v8::HandleScope handle_scope(CcTest::isolate()); |
7225 i::ScopedVector<char> extension_name(32); | 7221 i::ScopedVector<char> extension_name(32); |
7226 i::SNPrintF(extension_name, "ext #%d", source_len); | 7222 i::SNPrintF(extension_name, "ext #%d", source_len); |
7227 v8::RegisterExtension(new Extension(extension_name.start(), | 7223 v8::RegisterExtension(new Extension(extension_name.start(), |
7228 kEmbeddedExtensionSource, 0, 0, | 7224 kEmbeddedExtensionSource, 0, 0, |
7229 source_len)); | 7225 source_len)); |
7230 const char* extension_names[1] = { extension_name.start() }; | 7226 const char* extension_names[1] = { extension_name.start() }; |
7231 v8::ExtensionConfiguration extensions(1, extension_names); | 7227 v8::ExtensionConfiguration extensions(1, extension_names); |
7232 v8::Handle<Context> context = | 7228 v8::Handle<Context> context = |
7233 Context::New(CcTest::isolate(), &extensions); | 7229 Context::New(CcTest::isolate(), &extensions); |
7234 if (source_len == kEmbeddedExtensionSourceValidLen) { | 7230 if (source_len == kEmbeddedExtensionSourceValidLen) { |
7235 Context::Scope lock(context); | 7231 Context::Scope lock(context); |
7236 v8::Handle<Value> result = CompileRun("Ret54321()"); | 7232 v8::Handle<Value> result = CompileRun("Ret54321()"); |
7237 CHECK(v8::Integer::New(CcTest::isolate(), 54321)->Equals(result)); | 7233 CHECK_EQ(v8::Integer::New(CcTest::isolate(), 54321), result); |
7238 } else { | 7234 } else { |
7239 // Anything but exactly the right length should fail to compile. | 7235 // Anything but exactly the right length should fail to compile. |
7240 CHECK(0 == *context); | 7236 CHECK_EQ(0, *context); |
7241 } | 7237 } |
7242 } | 7238 } |
7243 } | 7239 } |
7244 | 7240 |
7245 | 7241 |
7246 static const char* kEvalExtensionSource1 = | 7242 static const char* kEvalExtensionSource1 = |
7247 "function UseEval1() {" | 7243 "function UseEval1() {" |
7248 " var x = 42;" | 7244 " var x = 42;" |
7249 " return eval('x');" | 7245 " return eval('x');" |
7250 "}"; | 7246 "}"; |
(...skipping 12 matching lines...) Expand all Loading... |
7263 TEST(UseEvalFromExtension) { | 7259 TEST(UseEvalFromExtension) { |
7264 v8::HandleScope handle_scope(CcTest::isolate()); | 7260 v8::HandleScope handle_scope(CcTest::isolate()); |
7265 v8::RegisterExtension(new Extension("evaltest1", kEvalExtensionSource1)); | 7261 v8::RegisterExtension(new Extension("evaltest1", kEvalExtensionSource1)); |
7266 v8::RegisterExtension(new Extension("evaltest2", kEvalExtensionSource2)); | 7262 v8::RegisterExtension(new Extension("evaltest2", kEvalExtensionSource2)); |
7267 const char* extension_names[] = { "evaltest1", "evaltest2" }; | 7263 const char* extension_names[] = { "evaltest1", "evaltest2" }; |
7268 v8::ExtensionConfiguration extensions(2, extension_names); | 7264 v8::ExtensionConfiguration extensions(2, extension_names); |
7269 v8::Handle<Context> context = | 7265 v8::Handle<Context> context = |
7270 Context::New(CcTest::isolate(), &extensions); | 7266 Context::New(CcTest::isolate(), &extensions); |
7271 Context::Scope lock(context); | 7267 Context::Scope lock(context); |
7272 v8::Handle<Value> result = CompileRun("UseEval1()"); | 7268 v8::Handle<Value> result = CompileRun("UseEval1()"); |
7273 CHECK(result->Equals(v8::Integer::New(CcTest::isolate(), 42))); | 7269 CHECK_EQ(result, v8::Integer::New(CcTest::isolate(), 42)); |
7274 result = CompileRun("UseEval2()"); | 7270 result = CompileRun("UseEval2()"); |
7275 CHECK(result->Equals(v8::Integer::New(CcTest::isolate(), 42))); | 7271 CHECK_EQ(result, v8::Integer::New(CcTest::isolate(), 42)); |
7276 } | 7272 } |
7277 | 7273 |
7278 | 7274 |
7279 static const char* kWithExtensionSource1 = | 7275 static const char* kWithExtensionSource1 = |
7280 "function UseWith1() {" | 7276 "function UseWith1() {" |
7281 " var x = 42;" | 7277 " var x = 42;" |
7282 " with({x:87}) { return x; }" | 7278 " with({x:87}) { return x; }" |
7283 "}"; | 7279 "}"; |
7284 | 7280 |
7285 | 7281 |
(...skipping 11 matching lines...) Expand all Loading... |
7297 TEST(UseWithFromExtension) { | 7293 TEST(UseWithFromExtension) { |
7298 v8::HandleScope handle_scope(CcTest::isolate()); | 7294 v8::HandleScope handle_scope(CcTest::isolate()); |
7299 v8::RegisterExtension(new Extension("withtest1", kWithExtensionSource1)); | 7295 v8::RegisterExtension(new Extension("withtest1", kWithExtensionSource1)); |
7300 v8::RegisterExtension(new Extension("withtest2", kWithExtensionSource2)); | 7296 v8::RegisterExtension(new Extension("withtest2", kWithExtensionSource2)); |
7301 const char* extension_names[] = { "withtest1", "withtest2" }; | 7297 const char* extension_names[] = { "withtest1", "withtest2" }; |
7302 v8::ExtensionConfiguration extensions(2, extension_names); | 7298 v8::ExtensionConfiguration extensions(2, extension_names); |
7303 v8::Handle<Context> context = | 7299 v8::Handle<Context> context = |
7304 Context::New(CcTest::isolate(), &extensions); | 7300 Context::New(CcTest::isolate(), &extensions); |
7305 Context::Scope lock(context); | 7301 Context::Scope lock(context); |
7306 v8::Handle<Value> result = CompileRun("UseWith1()"); | 7302 v8::Handle<Value> result = CompileRun("UseWith1()"); |
7307 CHECK(result->Equals(v8::Integer::New(CcTest::isolate(), 87))); | 7303 CHECK_EQ(result, v8::Integer::New(CcTest::isolate(), 87)); |
7308 result = CompileRun("UseWith2()"); | 7304 result = CompileRun("UseWith2()"); |
7309 CHECK(result->Equals(v8::Integer::New(CcTest::isolate(), 87))); | 7305 CHECK_EQ(result, v8::Integer::New(CcTest::isolate(), 87)); |
7310 } | 7306 } |
7311 | 7307 |
7312 | 7308 |
7313 TEST(AutoExtensions) { | 7309 TEST(AutoExtensions) { |
7314 v8::HandleScope handle_scope(CcTest::isolate()); | 7310 v8::HandleScope handle_scope(CcTest::isolate()); |
7315 Extension* extension = new Extension("autotest", kSimpleExtensionSource); | 7311 Extension* extension = new Extension("autotest", kSimpleExtensionSource); |
7316 extension->set_auto_enable(true); | 7312 extension->set_auto_enable(true); |
7317 v8::RegisterExtension(extension); | 7313 v8::RegisterExtension(extension); |
7318 v8::Handle<Context> context = | 7314 v8::Handle<Context> context = |
7319 Context::New(CcTest::isolate()); | 7315 Context::New(CcTest::isolate()); |
7320 Context::Scope lock(context); | 7316 Context::Scope lock(context); |
7321 v8::Handle<Value> result = CompileRun("Foo()"); | 7317 v8::Handle<Value> result = CompileRun("Foo()"); |
7322 CHECK(result->Equals(v8::Integer::New(CcTest::isolate(), 4))); | 7318 CHECK_EQ(result, v8::Integer::New(CcTest::isolate(), 4)); |
7323 } | 7319 } |
7324 | 7320 |
7325 | 7321 |
7326 static const char* kSyntaxErrorInExtensionSource = | 7322 static const char* kSyntaxErrorInExtensionSource = |
7327 "["; | 7323 "["; |
7328 | 7324 |
7329 | 7325 |
7330 // Test that a syntax error in an extension does not cause a fatal | 7326 // Test that a syntax error in an extension does not cause a fatal |
7331 // error but results in an empty context. | 7327 // error but results in an empty context. |
7332 TEST(SyntaxErrorExtensions) { | 7328 TEST(SyntaxErrorExtensions) { |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7372 TEST(NativeCallInExtensions) { | 7368 TEST(NativeCallInExtensions) { |
7373 v8::HandleScope handle_scope(CcTest::isolate()); | 7369 v8::HandleScope handle_scope(CcTest::isolate()); |
7374 v8::RegisterExtension(new Extension("nativecall", | 7370 v8::RegisterExtension(new Extension("nativecall", |
7375 kNativeCallInExtensionSource)); | 7371 kNativeCallInExtensionSource)); |
7376 const char* extension_names[] = { "nativecall" }; | 7372 const char* extension_names[] = { "nativecall" }; |
7377 v8::ExtensionConfiguration extensions(1, extension_names); | 7373 v8::ExtensionConfiguration extensions(1, extension_names); |
7378 v8::Handle<Context> context = | 7374 v8::Handle<Context> context = |
7379 Context::New(CcTest::isolate(), &extensions); | 7375 Context::New(CcTest::isolate(), &extensions); |
7380 Context::Scope lock(context); | 7376 Context::Scope lock(context); |
7381 v8::Handle<Value> result = CompileRun(kNativeCallTest); | 7377 v8::Handle<Value> result = CompileRun(kNativeCallTest); |
7382 CHECK(result->Equals(v8::Integer::New(CcTest::isolate(), 3))); | 7378 CHECK_EQ(result, v8::Integer::New(CcTest::isolate(), 3)); |
7383 } | 7379 } |
7384 | 7380 |
7385 | 7381 |
7386 class NativeFunctionExtension : public Extension { | 7382 class NativeFunctionExtension : public Extension { |
7387 public: | 7383 public: |
7388 NativeFunctionExtension(const char* name, | 7384 NativeFunctionExtension(const char* name, |
7389 const char* source, | 7385 const char* source, |
7390 v8::FunctionCallback fun = &Echo) | 7386 v8::FunctionCallback fun = &Echo) |
7391 : Extension(name, source), | 7387 : Extension(name, source), |
7392 function_(fun) { } | 7388 function_(fun) { } |
(...skipping 16 matching lines...) Expand all Loading... |
7409 v8::HandleScope handle_scope(CcTest::isolate()); | 7405 v8::HandleScope handle_scope(CcTest::isolate()); |
7410 const char* name = "nativedecl"; | 7406 const char* name = "nativedecl"; |
7411 v8::RegisterExtension(new NativeFunctionExtension(name, | 7407 v8::RegisterExtension(new NativeFunctionExtension(name, |
7412 "native function foo();")); | 7408 "native function foo();")); |
7413 const char* extension_names[] = { name }; | 7409 const char* extension_names[] = { name }; |
7414 v8::ExtensionConfiguration extensions(1, extension_names); | 7410 v8::ExtensionConfiguration extensions(1, extension_names); |
7415 v8::Handle<Context> context = | 7411 v8::Handle<Context> context = |
7416 Context::New(CcTest::isolate(), &extensions); | 7412 Context::New(CcTest::isolate(), &extensions); |
7417 Context::Scope lock(context); | 7413 Context::Scope lock(context); |
7418 v8::Handle<Value> result = CompileRun("foo(42);"); | 7414 v8::Handle<Value> result = CompileRun("foo(42);"); |
7419 CHECK(result->Equals(v8::Integer::New(CcTest::isolate(), 42))); | 7415 CHECK_EQ(result, v8::Integer::New(CcTest::isolate(), 42)); |
7420 } | 7416 } |
7421 | 7417 |
7422 | 7418 |
7423 TEST(NativeFunctionDeclarationError) { | 7419 TEST(NativeFunctionDeclarationError) { |
7424 v8::HandleScope handle_scope(CcTest::isolate()); | 7420 v8::HandleScope handle_scope(CcTest::isolate()); |
7425 const char* name = "nativedeclerr"; | 7421 const char* name = "nativedeclerr"; |
7426 // Syntax error in extension code. | 7422 // Syntax error in extension code. |
7427 v8::RegisterExtension(new NativeFunctionExtension(name, | 7423 v8::RegisterExtension(new NativeFunctionExtension(name, |
7428 "native\nfunction foo();")); | 7424 "native\nfunction foo();")); |
7429 const char* extension_names[] = { name }; | 7425 const char* extension_names[] = { name }; |
(...skipping 17 matching lines...) Expand all Loading... |
7447 v8::Handle<Context> context = | 7443 v8::Handle<Context> context = |
7448 Context::New(CcTest::isolate(), &extensions); | 7444 Context::New(CcTest::isolate(), &extensions); |
7449 CHECK(context.IsEmpty()); | 7445 CHECK(context.IsEmpty()); |
7450 } | 7446 } |
7451 | 7447 |
7452 | 7448 |
7453 static void CheckDependencies(const char* name, const char* expected) { | 7449 static void CheckDependencies(const char* name, const char* expected) { |
7454 v8::HandleScope handle_scope(CcTest::isolate()); | 7450 v8::HandleScope handle_scope(CcTest::isolate()); |
7455 v8::ExtensionConfiguration config(1, &name); | 7451 v8::ExtensionConfiguration config(1, &name); |
7456 LocalContext context(&config); | 7452 LocalContext context(&config); |
7457 CHECK(String::NewFromUtf8(CcTest::isolate(), expected) | 7453 CHECK_EQ(String::NewFromUtf8(CcTest::isolate(), expected), |
7458 ->Equals(context->Global()->Get(v8_str("loaded")))); | 7454 context->Global()->Get(v8_str("loaded"))); |
7459 } | 7455 } |
7460 | 7456 |
7461 | 7457 |
7462 /* | 7458 /* |
7463 * Configuration: | 7459 * Configuration: |
7464 * | 7460 * |
7465 * /-- B <--\ | 7461 * /-- B <--\ |
7466 * A <- -- D <-- E | 7462 * A <- -- D <-- E |
7467 * \-- C <--/ | 7463 * \-- C <--/ |
7468 */ | 7464 */ |
7469 THREADED_TEST(ExtensionDependency) { | 7465 THREADED_TEST(ExtensionDependency) { |
7470 static const char* kEDeps[] = { "D" }; | 7466 static const char* kEDeps[] = { "D" }; |
7471 v8::RegisterExtension(new Extension("E", "this.loaded += 'E';", 1, kEDeps)); | 7467 v8::RegisterExtension(new Extension("E", "this.loaded += 'E';", 1, kEDeps)); |
7472 static const char* kDDeps[] = { "B", "C" }; | 7468 static const char* kDDeps[] = { "B", "C" }; |
7473 v8::RegisterExtension(new Extension("D", "this.loaded += 'D';", 2, kDDeps)); | 7469 v8::RegisterExtension(new Extension("D", "this.loaded += 'D';", 2, kDDeps)); |
7474 static const char* kBCDeps[] = { "A" }; | 7470 static const char* kBCDeps[] = { "A" }; |
7475 v8::RegisterExtension(new Extension("B", "this.loaded += 'B';", 1, kBCDeps)); | 7471 v8::RegisterExtension(new Extension("B", "this.loaded += 'B';", 1, kBCDeps)); |
7476 v8::RegisterExtension(new Extension("C", "this.loaded += 'C';", 1, kBCDeps)); | 7472 v8::RegisterExtension(new Extension("C", "this.loaded += 'C';", 1, kBCDeps)); |
7477 v8::RegisterExtension(new Extension("A", "this.loaded += 'A';")); | 7473 v8::RegisterExtension(new Extension("A", "this.loaded += 'A';")); |
7478 CheckDependencies("A", "undefinedA"); | 7474 CheckDependencies("A", "undefinedA"); |
7479 CheckDependencies("B", "undefinedAB"); | 7475 CheckDependencies("B", "undefinedAB"); |
7480 CheckDependencies("C", "undefinedAC"); | 7476 CheckDependencies("C", "undefinedAC"); |
7481 CheckDependencies("D", "undefinedABCD"); | 7477 CheckDependencies("D", "undefinedABCD"); |
7482 CheckDependencies("E", "undefinedABCDE"); | 7478 CheckDependencies("E", "undefinedABCDE"); |
7483 v8::HandleScope handle_scope(CcTest::isolate()); | 7479 v8::HandleScope handle_scope(CcTest::isolate()); |
7484 static const char* exts[2] = { "C", "E" }; | 7480 static const char* exts[2] = { "C", "E" }; |
7485 v8::ExtensionConfiguration config(2, exts); | 7481 v8::ExtensionConfiguration config(2, exts); |
7486 LocalContext context(&config); | 7482 LocalContext context(&config); |
7487 CHECK(v8_str("undefinedACBDE") | 7483 CHECK_EQ(v8_str("undefinedACBDE"), context->Global()->Get(v8_str("loaded"))); |
7488 ->Equals(context->Global()->Get(v8_str("loaded")))); | |
7489 } | 7484 } |
7490 | 7485 |
7491 | 7486 |
7492 static const char* kExtensionTestScript = | 7487 static const char* kExtensionTestScript = |
7493 "native function A();" | 7488 "native function A();" |
7494 "native function B();" | 7489 "native function B();" |
7495 "native function C();" | 7490 "native function C();" |
7496 "function Foo(i) {" | 7491 "function Foo(i) {" |
7497 " if (i == 0) return A();" | 7492 " if (i == 0) return A();" |
7498 " if (i == 1) return B();" | 7493 " if (i == 1) return B();" |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7539 } | 7534 } |
7540 | 7535 |
7541 | 7536 |
7542 THREADED_TEST(FunctionLookup) { | 7537 THREADED_TEST(FunctionLookup) { |
7543 v8::RegisterExtension(new FunctionExtension()); | 7538 v8::RegisterExtension(new FunctionExtension()); |
7544 v8::HandleScope handle_scope(CcTest::isolate()); | 7539 v8::HandleScope handle_scope(CcTest::isolate()); |
7545 static const char* exts[1] = { "functiontest" }; | 7540 static const char* exts[1] = { "functiontest" }; |
7546 v8::ExtensionConfiguration config(1, exts); | 7541 v8::ExtensionConfiguration config(1, exts); |
7547 LocalContext context(&config); | 7542 LocalContext context(&config); |
7548 CHECK_EQ(3, lookup_count); | 7543 CHECK_EQ(3, lookup_count); |
7549 CHECK(v8::Integer::New(CcTest::isolate(), 8)->Equals(CompileRun("Foo(0)"))); | 7544 CHECK_EQ(v8::Integer::New(CcTest::isolate(), 8), |
7550 CHECK(v8::Integer::New(CcTest::isolate(), 7)->Equals(CompileRun("Foo(1)"))); | 7545 CompileRun("Foo(0)")); |
7551 CHECK(v8::Integer::New(CcTest::isolate(), 6)->Equals(CompileRun("Foo(2)"))); | 7546 CHECK_EQ(v8::Integer::New(CcTest::isolate(), 7), |
| 7547 CompileRun("Foo(1)")); |
| 7548 CHECK_EQ(v8::Integer::New(CcTest::isolate(), 6), |
| 7549 CompileRun("Foo(2)")); |
7552 } | 7550 } |
7553 | 7551 |
7554 | 7552 |
7555 THREADED_TEST(NativeFunctionConstructCall) { | 7553 THREADED_TEST(NativeFunctionConstructCall) { |
7556 v8::RegisterExtension(new FunctionExtension()); | 7554 v8::RegisterExtension(new FunctionExtension()); |
7557 v8::HandleScope handle_scope(CcTest::isolate()); | 7555 v8::HandleScope handle_scope(CcTest::isolate()); |
7558 static const char* exts[1] = { "functiontest" }; | 7556 static const char* exts[1] = { "functiontest" }; |
7559 v8::ExtensionConfiguration config(1, exts); | 7557 v8::ExtensionConfiguration config(1, exts); |
7560 LocalContext context(&config); | 7558 LocalContext context(&config); |
7561 for (int i = 0; i < 10; i++) { | 7559 for (int i = 0; i < 10; i++) { |
7562 // Run a few times to ensure that allocation of objects doesn't | 7560 // Run a few times to ensure that allocation of objects doesn't |
7563 // change behavior of a constructor function. | 7561 // change behavior of a constructor function. |
7564 CHECK(v8::Integer::New(CcTest::isolate(), 8) | 7562 CHECK_EQ(v8::Integer::New(CcTest::isolate(), 8), |
7565 ->Equals(CompileRun("(new A()).data"))); | 7563 CompileRun("(new A()).data")); |
7566 CHECK(v8::Integer::New(CcTest::isolate(), 7) | 7564 CHECK_EQ(v8::Integer::New(CcTest::isolate(), 7), |
7567 ->Equals(CompileRun("(new B()).data"))); | 7565 CompileRun("(new B()).data")); |
7568 CHECK(v8::Integer::New(CcTest::isolate(), 6) | 7566 CHECK_EQ(v8::Integer::New(CcTest::isolate(), 6), |
7569 ->Equals(CompileRun("(new C()).data"))); | 7567 CompileRun("(new C()).data")); |
7570 } | 7568 } |
7571 } | 7569 } |
7572 | 7570 |
7573 | 7571 |
7574 static const char* last_location; | 7572 static const char* last_location; |
7575 static const char* last_message; | 7573 static const char* last_message; |
7576 void StoringErrorCallback(const char* location, const char* message) { | 7574 void StoringErrorCallback(const char* location, const char* message) { |
7577 if (last_location == NULL) { | 7575 if (last_location == NULL) { |
7578 last_location = location; | 7576 last_location = location; |
7579 last_message = message; | 7577 last_message = message; |
7580 } | 7578 } |
7581 } | 7579 } |
7582 | 7580 |
7583 | 7581 |
7584 // ErrorReporting creates a circular extensions configuration and | 7582 // ErrorReporting creates a circular extensions configuration and |
7585 // tests that the fatal error handler gets called. This renders V8 | 7583 // tests that the fatal error handler gets called. This renders V8 |
7586 // unusable and therefore this test cannot be run in parallel. | 7584 // unusable and therefore this test cannot be run in parallel. |
7587 TEST(ErrorReporting) { | 7585 TEST(ErrorReporting) { |
7588 v8::V8::SetFatalErrorHandler(StoringErrorCallback); | 7586 v8::V8::SetFatalErrorHandler(StoringErrorCallback); |
7589 static const char* aDeps[] = { "B" }; | 7587 static const char* aDeps[] = { "B" }; |
7590 v8::RegisterExtension(new Extension("A", "", 1, aDeps)); | 7588 v8::RegisterExtension(new Extension("A", "", 1, aDeps)); |
7591 static const char* bDeps[] = { "A" }; | 7589 static const char* bDeps[] = { "A" }; |
7592 v8::RegisterExtension(new Extension("B", "", 1, bDeps)); | 7590 v8::RegisterExtension(new Extension("B", "", 1, bDeps)); |
7593 last_location = NULL; | 7591 last_location = NULL; |
7594 v8::ExtensionConfiguration config(1, bDeps); | 7592 v8::ExtensionConfiguration config(1, bDeps); |
7595 v8::Handle<Context> context = | 7593 v8::Handle<Context> context = |
7596 Context::New(CcTest::isolate(), &config); | 7594 Context::New(CcTest::isolate(), &config); |
7597 CHECK(context.IsEmpty()); | 7595 CHECK(context.IsEmpty()); |
7598 CHECK(last_location); | 7596 CHECK_NE(last_location, NULL); |
7599 } | 7597 } |
7600 | 7598 |
7601 | 7599 |
7602 static void MissingScriptInfoMessageListener(v8::Handle<v8::Message> message, | 7600 static void MissingScriptInfoMessageListener(v8::Handle<v8::Message> message, |
7603 v8::Handle<Value> data) { | 7601 v8::Handle<Value> data) { |
7604 CHECK(message->GetScriptOrigin().ResourceName()->IsUndefined()); | 7602 CHECK(message->GetScriptOrigin().ResourceName()->IsUndefined()); |
7605 CHECK(v8::Undefined(CcTest::isolate()) | 7603 CHECK_EQ(v8::Undefined(CcTest::isolate()), |
7606 ->Equals(message->GetScriptOrigin().ResourceName())); | 7604 message->GetScriptOrigin().ResourceName()); |
7607 message->GetLineNumber(); | 7605 message->GetLineNumber(); |
7608 message->GetSourceLine(); | 7606 message->GetSourceLine(); |
7609 } | 7607 } |
7610 | 7608 |
7611 | 7609 |
7612 THREADED_TEST(ErrorWithMissingScriptInfo) { | 7610 THREADED_TEST(ErrorWithMissingScriptInfo) { |
7613 LocalContext context; | 7611 LocalContext context; |
7614 v8::HandleScope scope(context->GetIsolate()); | 7612 v8::HandleScope scope(context->GetIsolate()); |
7615 v8::V8::AddMessageListener(MissingScriptInfoMessageListener); | 7613 v8::V8::AddMessageListener(MissingScriptInfoMessageListener); |
7616 CompileRun("throw Error()"); | 7614 CompileRun("throw Error()"); |
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7927 object.handle.SetWeak(&object, &RevivingCallback); | 7925 object.handle.SetWeak(&object, &RevivingCallback); |
7928 object.handle.MarkIndependent(); | 7926 object.handle.MarkIndependent(); |
7929 CcTest::heap()->CollectGarbage(i::NEW_SPACE); | 7927 CcTest::heap()->CollectGarbage(i::NEW_SPACE); |
7930 CHECK(object.flag); | 7928 CHECK(object.flag); |
7931 CcTest::heap()->CollectAllGarbage(i::Heap::kAbortIncrementalMarkingMask); | 7929 CcTest::heap()->CollectAllGarbage(i::Heap::kAbortIncrementalMarkingMask); |
7932 { | 7930 { |
7933 v8::HandleScope handle_scope(isolate); | 7931 v8::HandleScope handle_scope(isolate); |
7934 v8::Local<v8::Object> o = | 7932 v8::Local<v8::Object> o = |
7935 v8::Local<v8::Object>::New(isolate, object.handle); | 7933 v8::Local<v8::Object>::New(isolate, object.handle); |
7936 v8::Local<String> y_str = v8_str("y"); | 7934 v8::Local<String> y_str = v8_str("y"); |
7937 CHECK(v8::Integer::New(isolate, 1)->Equals(o->Get(v8_str("x")))); | 7935 CHECK_EQ(v8::Integer::New(isolate, 1), o->Get(v8_str("x"))); |
7938 CHECK(o->Get(y_str)->Equals(y_str)); | 7936 CHECK(o->Get(y_str)->Equals(y_str)); |
7939 } | 7937 } |
7940 } | 7938 } |
7941 | 7939 |
7942 | 7940 |
7943 v8::Handle<Function> args_fun; | 7941 v8::Handle<Function> args_fun; |
7944 | 7942 |
7945 | 7943 |
7946 static void ArgumentsTestCallback( | 7944 static void ArgumentsTestCallback( |
7947 const v8::FunctionCallbackInfo<v8::Value>& args) { | 7945 const v8::FunctionCallbackInfo<v8::Value>& args) { |
7948 ApiTestFuzzer::Fuzz(); | 7946 ApiTestFuzzer::Fuzz(); |
7949 v8::Isolate* isolate = args.GetIsolate(); | 7947 v8::Isolate* isolate = args.GetIsolate(); |
7950 CHECK(args_fun->Equals(args.Callee())); | 7948 CHECK_EQ(args_fun, args.Callee()); |
7951 CHECK_EQ(3, args.Length()); | 7949 CHECK_EQ(3, args.Length()); |
7952 CHECK(v8::Integer::New(isolate, 1)->Equals(args[0])); | 7950 CHECK_EQ(v8::Integer::New(isolate, 1), args[0]); |
7953 CHECK(v8::Integer::New(isolate, 2)->Equals(args[1])); | 7951 CHECK_EQ(v8::Integer::New(isolate, 2), args[1]); |
7954 CHECK(v8::Integer::New(isolate, 3)->Equals(args[2])); | 7952 CHECK_EQ(v8::Integer::New(isolate, 3), args[2]); |
7955 CHECK(v8::Undefined(isolate)->Equals(args[3])); | 7953 CHECK_EQ(v8::Undefined(isolate), args[3]); |
7956 v8::HandleScope scope(args.GetIsolate()); | 7954 v8::HandleScope scope(args.GetIsolate()); |
7957 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); | 7955 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); |
7958 } | 7956 } |
7959 | 7957 |
7960 | 7958 |
7961 THREADED_TEST(Arguments) { | 7959 THREADED_TEST(Arguments) { |
7962 v8::Isolate* isolate = CcTest::isolate(); | 7960 v8::Isolate* isolate = CcTest::isolate(); |
7963 v8::HandleScope scope(isolate); | 7961 v8::HandleScope scope(isolate); |
7964 v8::Handle<v8::ObjectTemplate> global = ObjectTemplate::New(isolate); | 7962 v8::Handle<v8::ObjectTemplate> global = ObjectTemplate::New(isolate); |
7965 global->Set(v8_str("f"), | 7963 global->Set(v8_str("f"), |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8010 LocalContext context; | 8008 LocalContext context; |
8011 context->Global()->Set(v8_str("k"), obj->NewInstance()); | 8009 context->Global()->Set(v8_str("k"), obj->NewInstance()); |
8012 CompileRun( | 8010 CompileRun( |
8013 "k.foo = 'foo';" | 8011 "k.foo = 'foo';" |
8014 "k.bar = 'bar';" | 8012 "k.bar = 'bar';" |
8015 "k[2] = 2;" | 8013 "k[2] = 2;" |
8016 "k[4] = 4;"); | 8014 "k[4] = 4;"); |
8017 CHECK(v8_compile("delete k.foo")->Run()->IsFalse()); | 8015 CHECK(v8_compile("delete k.foo")->Run()->IsFalse()); |
8018 CHECK(v8_compile("delete k.bar")->Run()->IsTrue()); | 8016 CHECK(v8_compile("delete k.bar")->Run()->IsTrue()); |
8019 | 8017 |
8020 CHECK(v8_compile("k.foo")->Run()->Equals(v8_str("foo"))); | 8018 CHECK_EQ(v8_compile("k.foo")->Run(), v8_str("foo")); |
8021 CHECK(v8_compile("k.bar")->Run()->IsUndefined()); | 8019 CHECK(v8_compile("k.bar")->Run()->IsUndefined()); |
8022 | 8020 |
8023 CHECK(v8_compile("delete k[2]")->Run()->IsFalse()); | 8021 CHECK(v8_compile("delete k[2]")->Run()->IsFalse()); |
8024 CHECK(v8_compile("delete k[4]")->Run()->IsTrue()); | 8022 CHECK(v8_compile("delete k[4]")->Run()->IsTrue()); |
8025 | 8023 |
8026 CHECK(v8_compile("k[2]")->Run()->Equals(v8_num(2))); | 8024 CHECK_EQ(v8_compile("k[2]")->Run(), v8_num(2)); |
8027 CHECK(v8_compile("k[4]")->Run()->IsUndefined()); | 8025 CHECK(v8_compile("k[4]")->Run()->IsUndefined()); |
8028 } | 8026 } |
8029 | 8027 |
8030 | 8028 |
8031 static void GetK(Local<Name> name, | 8029 static void GetK(Local<Name> name, |
8032 const v8::PropertyCallbackInfo<v8::Value>& info) { | 8030 const v8::PropertyCallbackInfo<v8::Value>& info) { |
8033 ApiTestFuzzer::Fuzz(); | 8031 ApiTestFuzzer::Fuzz(); |
8034 if (name->Equals(v8_str("foo")) || | 8032 if (name->Equals(v8_str("foo")) || |
8035 name->Equals(v8_str("bar")) || | 8033 name->Equals(v8_str("bar")) || |
8036 name->Equals(v8_str("baz"))) { | 8034 name->Equals(v8_str("baz"))) { |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8092 "for (var prop in k) {" | 8090 "for (var prop in k) {" |
8093 " result.push(prop);" | 8091 " result.push(prop);" |
8094 "}" | 8092 "}" |
8095 "result")); | 8093 "result")); |
8096 // Check that we get all the property names returned including the | 8094 // Check that we get all the property names returned including the |
8097 // ones from the enumerators in the right order: indexed properties | 8095 // ones from the enumerators in the right order: indexed properties |
8098 // in numerical order, indexed interceptor properties, named | 8096 // in numerical order, indexed interceptor properties, named |
8099 // properties in insertion order, named interceptor properties. | 8097 // properties in insertion order, named interceptor properties. |
8100 // This order is not mandated by the spec, so this test is just | 8098 // This order is not mandated by the spec, so this test is just |
8101 // documenting our behavior. | 8099 // documenting our behavior. |
8102 CHECK_EQ(17u, result->Length()); | 8100 CHECK_EQ(17, result->Length()); |
8103 // Indexed properties in numerical order. | 8101 // Indexed properties in numerical order. |
8104 CHECK(v8_str("5")->Equals(result->Get(v8::Integer::New(isolate, 0)))); | 8102 CHECK_EQ(v8_str("5"), result->Get(v8::Integer::New(isolate, 0))); |
8105 CHECK(v8_str("10")->Equals(result->Get(v8::Integer::New(isolate, 1)))); | 8103 CHECK_EQ(v8_str("10"), result->Get(v8::Integer::New(isolate, 1))); |
8106 CHECK(v8_str("140000")->Equals(result->Get(v8::Integer::New(isolate, 2)))); | 8104 CHECK_EQ(v8_str("140000"), result->Get(v8::Integer::New(isolate, 2))); |
8107 CHECK( | 8105 CHECK_EQ(v8_str("4294967295"), result->Get(v8::Integer::New(isolate, 3))); |
8108 v8_str("4294967295")->Equals(result->Get(v8::Integer::New(isolate, 3)))); | |
8109 // Indexed interceptor properties in the order they are returned | 8106 // Indexed interceptor properties in the order they are returned |
8110 // from the enumerator interceptor. | 8107 // from the enumerator interceptor. |
8111 CHECK(v8_str("0")->Equals(result->Get(v8::Integer::New(isolate, 4)))); | 8108 CHECK_EQ(v8_str("0"), result->Get(v8::Integer::New(isolate, 4))); |
8112 CHECK(v8_str("1")->Equals(result->Get(v8::Integer::New(isolate, 5)))); | 8109 CHECK_EQ(v8_str("1"), result->Get(v8::Integer::New(isolate, 5))); |
8113 // Named properties in insertion order. | 8110 // Named properties in insertion order. |
8114 CHECK(v8_str("a")->Equals(result->Get(v8::Integer::New(isolate, 6)))); | 8111 CHECK_EQ(v8_str("a"), result->Get(v8::Integer::New(isolate, 6))); |
8115 CHECK(v8_str("b")->Equals(result->Get(v8::Integer::New(isolate, 7)))); | 8112 CHECK_EQ(v8_str("b"), result->Get(v8::Integer::New(isolate, 7))); |
8116 CHECK(v8_str("c")->Equals(result->Get(v8::Integer::New(isolate, 8)))); | 8113 CHECK_EQ(v8_str("c"), result->Get(v8::Integer::New(isolate, 8))); |
8117 CHECK( | 8114 CHECK_EQ(v8_str("4294967296"), result->Get(v8::Integer::New(isolate, 9))); |
8118 v8_str("4294967296")->Equals(result->Get(v8::Integer::New(isolate, 9)))); | 8115 CHECK_EQ(v8_str("d"), result->Get(v8::Integer::New(isolate, 10))); |
8119 CHECK(v8_str("d")->Equals(result->Get(v8::Integer::New(isolate, 10)))); | 8116 CHECK_EQ(v8_str("e"), result->Get(v8::Integer::New(isolate, 11))); |
8120 CHECK(v8_str("e")->Equals(result->Get(v8::Integer::New(isolate, 11)))); | 8117 CHECK_EQ(v8_str("30000000000"), result->Get(v8::Integer::New(isolate, 12))); |
8121 CHECK(v8_str("30000000000") | 8118 CHECK_EQ(v8_str("f"), result->Get(v8::Integer::New(isolate, 13))); |
8122 ->Equals(result->Get(v8::Integer::New(isolate, 12)))); | |
8123 CHECK(v8_str("f")->Equals(result->Get(v8::Integer::New(isolate, 13)))); | |
8124 // Named interceptor properties. | 8119 // Named interceptor properties. |
8125 CHECK(v8_str("foo")->Equals(result->Get(v8::Integer::New(isolate, 14)))); | 8120 CHECK_EQ(v8_str("foo"), result->Get(v8::Integer::New(isolate, 14))); |
8126 CHECK(v8_str("bar")->Equals(result->Get(v8::Integer::New(isolate, 15)))); | 8121 CHECK_EQ(v8_str("bar"), result->Get(v8::Integer::New(isolate, 15))); |
8127 CHECK(v8_str("baz")->Equals(result->Get(v8::Integer::New(isolate, 16)))); | 8122 CHECK_EQ(v8_str("baz"), result->Get(v8::Integer::New(isolate, 16))); |
8128 } | 8123 } |
8129 | 8124 |
8130 | 8125 |
8131 int p_getter_count; | 8126 int p_getter_count; |
8132 int p_getter_count2; | 8127 int p_getter_count2; |
8133 | 8128 |
8134 | 8129 |
8135 static void PGetter(Local<String> name, | 8130 static void PGetter(Local<String> name, |
8136 const v8::PropertyCallbackInfo<v8::Value>& info) { | 8131 const v8::PropertyCallbackInfo<v8::Value>& info) { |
8137 ApiTestFuzzer::Fuzz(); | 8132 ApiTestFuzzer::Fuzz(); |
8138 p_getter_count++; | 8133 p_getter_count++; |
8139 v8::Handle<v8::Object> global = | 8134 v8::Handle<v8::Object> global = |
8140 info.GetIsolate()->GetCurrentContext()->Global(); | 8135 info.GetIsolate()->GetCurrentContext()->Global(); |
8141 CHECK(info.Holder()->Equals(global->Get(v8_str("o1")))); | 8136 CHECK_EQ(info.Holder(), global->Get(v8_str("o1"))); |
8142 if (name->Equals(v8_str("p1"))) { | 8137 if (name->Equals(v8_str("p1"))) { |
8143 CHECK(info.This()->Equals(global->Get(v8_str("o1")))); | 8138 CHECK_EQ(info.This(), global->Get(v8_str("o1"))); |
8144 } else if (name->Equals(v8_str("p2"))) { | 8139 } else if (name->Equals(v8_str("p2"))) { |
8145 CHECK(info.This()->Equals(global->Get(v8_str("o2")))); | 8140 CHECK_EQ(info.This(), global->Get(v8_str("o2"))); |
8146 } else if (name->Equals(v8_str("p3"))) { | 8141 } else if (name->Equals(v8_str("p3"))) { |
8147 CHECK(info.This()->Equals(global->Get(v8_str("o3")))); | 8142 CHECK_EQ(info.This(), global->Get(v8_str("o3"))); |
8148 } else if (name->Equals(v8_str("p4"))) { | 8143 } else if (name->Equals(v8_str("p4"))) { |
8149 CHECK(info.This()->Equals(global->Get(v8_str("o4")))); | 8144 CHECK_EQ(info.This(), global->Get(v8_str("o4"))); |
8150 } | 8145 } |
8151 } | 8146 } |
8152 | 8147 |
8153 | 8148 |
8154 static void RunHolderTest(v8::Handle<v8::ObjectTemplate> obj) { | 8149 static void RunHolderTest(v8::Handle<v8::ObjectTemplate> obj) { |
8155 ApiTestFuzzer::Fuzz(); | 8150 ApiTestFuzzer::Fuzz(); |
8156 LocalContext context; | 8151 LocalContext context; |
8157 context->Global()->Set(v8_str("o1"), obj->NewInstance()); | 8152 context->Global()->Set(v8_str("o1"), obj->NewInstance()); |
8158 CompileRun( | 8153 CompileRun( |
8159 "o1.__proto__ = { };" | 8154 "o1.__proto__ = { };" |
8160 "var o2 = { __proto__: o1 };" | 8155 "var o2 = { __proto__: o1 };" |
8161 "var o3 = { __proto__: o2 };" | 8156 "var o3 = { __proto__: o2 };" |
8162 "var o4 = { __proto__: o3 };" | 8157 "var o4 = { __proto__: o3 };" |
8163 "for (var i = 0; i < 10; i++) o4.p4;" | 8158 "for (var i = 0; i < 10; i++) o4.p4;" |
8164 "for (var i = 0; i < 10; i++) o3.p3;" | 8159 "for (var i = 0; i < 10; i++) o3.p3;" |
8165 "for (var i = 0; i < 10; i++) o2.p2;" | 8160 "for (var i = 0; i < 10; i++) o2.p2;" |
8166 "for (var i = 0; i < 10; i++) o1.p1;"); | 8161 "for (var i = 0; i < 10; i++) o1.p1;"); |
8167 } | 8162 } |
8168 | 8163 |
8169 | 8164 |
8170 static void PGetter2(Local<Name> name, | 8165 static void PGetter2(Local<Name> name, |
8171 const v8::PropertyCallbackInfo<v8::Value>& info) { | 8166 const v8::PropertyCallbackInfo<v8::Value>& info) { |
8172 ApiTestFuzzer::Fuzz(); | 8167 ApiTestFuzzer::Fuzz(); |
8173 p_getter_count2++; | 8168 p_getter_count2++; |
8174 v8::Handle<v8::Object> global = | 8169 v8::Handle<v8::Object> global = |
8175 info.GetIsolate()->GetCurrentContext()->Global(); | 8170 info.GetIsolate()->GetCurrentContext()->Global(); |
8176 CHECK(info.Holder()->Equals(global->Get(v8_str("o1")))); | 8171 CHECK_EQ(info.Holder(), global->Get(v8_str("o1"))); |
8177 if (name->Equals(v8_str("p1"))) { | 8172 if (name->Equals(v8_str("p1"))) { |
8178 CHECK(info.This()->Equals(global->Get(v8_str("o1")))); | 8173 CHECK_EQ(info.This(), global->Get(v8_str("o1"))); |
8179 } else if (name->Equals(v8_str("p2"))) { | 8174 } else if (name->Equals(v8_str("p2"))) { |
8180 CHECK(info.This()->Equals(global->Get(v8_str("o2")))); | 8175 CHECK_EQ(info.This(), global->Get(v8_str("o2"))); |
8181 } else if (name->Equals(v8_str("p3"))) { | 8176 } else if (name->Equals(v8_str("p3"))) { |
8182 CHECK(info.This()->Equals(global->Get(v8_str("o3")))); | 8177 CHECK_EQ(info.This(), global->Get(v8_str("o3"))); |
8183 } else if (name->Equals(v8_str("p4"))) { | 8178 } else if (name->Equals(v8_str("p4"))) { |
8184 CHECK(info.This()->Equals(global->Get(v8_str("o4")))); | 8179 CHECK_EQ(info.This(), global->Get(v8_str("o4"))); |
8185 } | 8180 } |
8186 } | 8181 } |
8187 | 8182 |
8188 | 8183 |
8189 THREADED_TEST(GetterHolders) { | 8184 THREADED_TEST(GetterHolders) { |
8190 v8::Isolate* isolate = CcTest::isolate(); | 8185 v8::Isolate* isolate = CcTest::isolate(); |
8191 v8::HandleScope scope(isolate); | 8186 v8::HandleScope scope(isolate); |
8192 v8::Handle<v8::ObjectTemplate> obj = ObjectTemplate::New(isolate); | 8187 v8::Handle<v8::ObjectTemplate> obj = ObjectTemplate::New(isolate); |
8193 obj->SetAccessor(v8_str("p1"), PGetter); | 8188 obj->SetAccessor(v8_str("p1"), PGetter); |
8194 obj->SetAccessor(v8_str("p2"), PGetter); | 8189 obj->SetAccessor(v8_str("p2"), PGetter); |
(...skipping 19 matching lines...) Expand all Loading... |
8214 THREADED_TEST(ObjectInstantiation) { | 8209 THREADED_TEST(ObjectInstantiation) { |
8215 v8::Isolate* isolate = CcTest::isolate(); | 8210 v8::Isolate* isolate = CcTest::isolate(); |
8216 v8::HandleScope scope(isolate); | 8211 v8::HandleScope scope(isolate); |
8217 v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New(isolate); | 8212 v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New(isolate); |
8218 templ->SetAccessor(v8_str("t"), PGetter2); | 8213 templ->SetAccessor(v8_str("t"), PGetter2); |
8219 LocalContext context; | 8214 LocalContext context; |
8220 context->Global()->Set(v8_str("o"), templ->NewInstance()); | 8215 context->Global()->Set(v8_str("o"), templ->NewInstance()); |
8221 for (int i = 0; i < 100; i++) { | 8216 for (int i = 0; i < 100; i++) { |
8222 v8::HandleScope inner_scope(CcTest::isolate()); | 8217 v8::HandleScope inner_scope(CcTest::isolate()); |
8223 v8::Handle<v8::Object> obj = templ->NewInstance(); | 8218 v8::Handle<v8::Object> obj = templ->NewInstance(); |
8224 CHECK(!obj->Equals(context->Global()->Get(v8_str("o")))); | 8219 CHECK_NE(obj, context->Global()->Get(v8_str("o"))); |
8225 context->Global()->Set(v8_str("o2"), obj); | 8220 context->Global()->Set(v8_str("o2"), obj); |
8226 v8::Handle<Value> value = | 8221 v8::Handle<Value> value = |
8227 CompileRun("o.__proto__ === o2.__proto__"); | 8222 CompileRun("o.__proto__ === o2.__proto__"); |
8228 CHECK(v8::True(isolate)->Equals(value)); | 8223 CHECK_EQ(v8::True(isolate), value); |
8229 context->Global()->Set(v8_str("o"), obj); | 8224 context->Global()->Set(v8_str("o"), obj); |
8230 } | 8225 } |
8231 } | 8226 } |
8232 | 8227 |
8233 | 8228 |
8234 static int StrCmp16(uint16_t* a, uint16_t* b) { | 8229 static int StrCmp16(uint16_t* a, uint16_t* b) { |
8235 while (true) { | 8230 while (true) { |
8236 if (*a == 0 && *b == 0) return 0; | 8231 if (*a == 0 && *b == 0) return 0; |
8237 if (*a != *b) return 0 + *a - *b; | 8232 if (*a != *b) return 0 + *a - *b; |
8238 a++; | 8233 a++; |
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8642 CHECK(roundtrip->Equals(string)); | 8637 CHECK(roundtrip->Equals(string)); |
8643 } else { | 8638 } else { |
8644 if (utf8_written != 0) CHECK_NE(buffer[utf8_written - 1], 42); | 8639 if (utf8_written != 0) CHECK_NE(buffer[utf8_written - 1], 42); |
8645 } | 8640 } |
8646 if (utf8_written2 != 0) CHECK_NE(buffer[utf8_written - 1], 42); | 8641 if (utf8_written2 != 0) CHECK_NE(buffer[utf8_written - 1], 42); |
8647 if (nchars >= 2) { | 8642 if (nchars >= 2) { |
8648 uint16_t trail = StringGet(string, nchars - 1); | 8643 uint16_t trail = StringGet(string, nchars - 1); |
8649 uint16_t lead = StringGet(string, nchars - 2); | 8644 uint16_t lead = StringGet(string, nchars - 2); |
8650 if (((lead & 0xfc00) == 0xd800) && | 8645 if (((lead & 0xfc00) == 0xd800) && |
8651 ((trail & 0xfc00) == 0xdc00)) { | 8646 ((trail & 0xfc00) == 0xdc00)) { |
8652 unsigned u1 = buffer2[utf8_written2 - 4]; | 8647 unsigned char u1 = buffer2[utf8_written2 - 4]; |
8653 unsigned u2 = buffer2[utf8_written2 - 3]; | 8648 unsigned char u2 = buffer2[utf8_written2 - 3]; |
8654 unsigned u3 = buffer2[utf8_written2 - 2]; | 8649 unsigned char u3 = buffer2[utf8_written2 - 2]; |
8655 unsigned u4 = buffer2[utf8_written2 - 1]; | 8650 unsigned char u4 = buffer2[utf8_written2 - 1]; |
8656 CHECK_EQ((u1 & 0xf8), 0xf0u); | 8651 CHECK_EQ((u1 & 0xf8), 0xf0); |
8657 CHECK_EQ((u2 & 0xc0), 0x80u); | 8652 CHECK_EQ((u2 & 0xc0), 0x80); |
8658 CHECK_EQ((u3 & 0xc0), 0x80u); | 8653 CHECK_EQ((u3 & 0xc0), 0x80); |
8659 CHECK_EQ((u4 & 0xc0), 0x80u); | 8654 CHECK_EQ((u4 & 0xc0), 0x80); |
8660 uint32_t c = 0x10000 + ((lead & 0x3ff) << 10) + (trail & 0x3ff); | 8655 uint32_t c = 0x10000 + ((lead & 0x3ff) << 10) + (trail & 0x3ff); |
8661 CHECK_EQ((u4 & 0x3f), (c & 0x3f)); | 8656 CHECK_EQ((u4 & 0x3f), (c & 0x3f)); |
8662 CHECK_EQ((u3 & 0x3f), ((c >> 6) & 0x3f)); | 8657 CHECK_EQ((u3 & 0x3f), ((c >> 6) & 0x3f)); |
8663 CHECK_EQ((u2 & 0x3f), ((c >> 12) & 0x3f)); | 8658 CHECK_EQ((u2 & 0x3f), ((c >> 12) & 0x3f)); |
8664 CHECK_EQ((u1 & 0x3), c >> 18); | 8659 CHECK_EQ((u1 & 0x3), c >> 18); |
8665 } | 8660 } |
8666 } | 8661 } |
8667 } | 8662 } |
8668 } | 8663 } |
8669 } | 8664 } |
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8960 THREADED_TEST(DeleteAccessor) { | 8955 THREADED_TEST(DeleteAccessor) { |
8961 v8::Isolate* isolate = CcTest::isolate(); | 8956 v8::Isolate* isolate = CcTest::isolate(); |
8962 v8::HandleScope scope(isolate); | 8957 v8::HandleScope scope(isolate); |
8963 v8::Handle<v8::ObjectTemplate> obj = ObjectTemplate::New(isolate); | 8958 v8::Handle<v8::ObjectTemplate> obj = ObjectTemplate::New(isolate); |
8964 obj->SetAccessor(v8_str("y"), YGetter, YSetter); | 8959 obj->SetAccessor(v8_str("y"), YGetter, YSetter); |
8965 LocalContext context; | 8960 LocalContext context; |
8966 v8::Handle<v8::Object> holder = obj->NewInstance(); | 8961 v8::Handle<v8::Object> holder = obj->NewInstance(); |
8967 context->Global()->Set(v8_str("holder"), holder); | 8962 context->Global()->Set(v8_str("holder"), holder); |
8968 v8::Handle<Value> result = CompileRun( | 8963 v8::Handle<Value> result = CompileRun( |
8969 "holder.y = 11; holder.y = 12; holder.y"); | 8964 "holder.y = 11; holder.y = 12; holder.y"); |
8970 CHECK_EQ(12u, result->Uint32Value()); | 8965 CHECK_EQ(12, result->Uint32Value()); |
8971 } | 8966 } |
8972 | 8967 |
8973 | 8968 |
8974 THREADED_TEST(TypeSwitch) { | 8969 THREADED_TEST(TypeSwitch) { |
8975 v8::Isolate* isolate = CcTest::isolate(); | 8970 v8::Isolate* isolate = CcTest::isolate(); |
8976 v8::HandleScope scope(isolate); | 8971 v8::HandleScope scope(isolate); |
8977 v8::Handle<v8::FunctionTemplate> templ1 = v8::FunctionTemplate::New(isolate); | 8972 v8::Handle<v8::FunctionTemplate> templ1 = v8::FunctionTemplate::New(isolate); |
8978 v8::Handle<v8::FunctionTemplate> templ2 = v8::FunctionTemplate::New(isolate); | 8973 v8::Handle<v8::FunctionTemplate> templ2 = v8::FunctionTemplate::New(isolate); |
8979 v8::Handle<v8::FunctionTemplate> templ3 = v8::FunctionTemplate::New(isolate); | 8974 v8::Handle<v8::FunctionTemplate> templ3 = v8::FunctionTemplate::New(isolate); |
8980 v8::Handle<v8::FunctionTemplate> templs[3] = { templ1, templ2, templ3 }; | 8975 v8::Handle<v8::FunctionTemplate> templs[3] = { templ1, templ2, templ3 }; |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9080 v8::V8::RemoveMessageListeners(ApiUncaughtExceptionTestListener); | 9075 v8::V8::RemoveMessageListeners(ApiUncaughtExceptionTestListener); |
9081 } | 9076 } |
9082 | 9077 |
9083 | 9078 |
9084 static const char* script_resource_name = "ExceptionInNativeScript.js"; | 9079 static const char* script_resource_name = "ExceptionInNativeScript.js"; |
9085 static void ExceptionInNativeScriptTestListener(v8::Handle<v8::Message> message, | 9080 static void ExceptionInNativeScriptTestListener(v8::Handle<v8::Message> message, |
9086 v8::Handle<Value>) { | 9081 v8::Handle<Value>) { |
9087 v8::Handle<v8::Value> name_val = message->GetScriptOrigin().ResourceName(); | 9082 v8::Handle<v8::Value> name_val = message->GetScriptOrigin().ResourceName(); |
9088 CHECK(!name_val.IsEmpty() && name_val->IsString()); | 9083 CHECK(!name_val.IsEmpty() && name_val->IsString()); |
9089 v8::String::Utf8Value name(message->GetScriptOrigin().ResourceName()); | 9084 v8::String::Utf8Value name(message->GetScriptOrigin().ResourceName()); |
9090 CHECK_EQ(0, strcmp(script_resource_name, *name)); | 9085 CHECK_EQ(script_resource_name, *name); |
9091 CHECK_EQ(3, message->GetLineNumber()); | 9086 CHECK_EQ(3, message->GetLineNumber()); |
9092 v8::String::Utf8Value source_line(message->GetSourceLine()); | 9087 v8::String::Utf8Value source_line(message->GetSourceLine()); |
9093 CHECK_EQ(0, strcmp(" new o.foo();", *source_line)); | 9088 CHECK_EQ(" new o.foo();", *source_line); |
9094 } | 9089 } |
9095 | 9090 |
9096 | 9091 |
9097 TEST(ExceptionInNativeScript) { | 9092 TEST(ExceptionInNativeScript) { |
9098 LocalContext env; | 9093 LocalContext env; |
9099 v8::Isolate* isolate = env->GetIsolate(); | 9094 v8::Isolate* isolate = env->GetIsolate(); |
9100 v8::HandleScope scope(isolate); | 9095 v8::HandleScope scope(isolate); |
9101 v8::V8::AddMessageListener(ExceptionInNativeScriptTestListener); | 9096 v8::V8::AddMessageListener(ExceptionInNativeScriptTestListener); |
9102 | 9097 |
9103 Local<v8::FunctionTemplate> fun = | 9098 Local<v8::FunctionTemplate> fun = |
(...skipping 12 matching lines...) Expand all Loading... |
9116 Function::Cast(*trouble)->Call(global, 0, NULL); | 9111 Function::Cast(*trouble)->Call(global, 0, NULL); |
9117 v8::V8::RemoveMessageListeners(ExceptionInNativeScriptTestListener); | 9112 v8::V8::RemoveMessageListeners(ExceptionInNativeScriptTestListener); |
9118 } | 9113 } |
9119 | 9114 |
9120 | 9115 |
9121 TEST(CompilationErrorUsingTryCatchHandler) { | 9116 TEST(CompilationErrorUsingTryCatchHandler) { |
9122 LocalContext env; | 9117 LocalContext env; |
9123 v8::HandleScope scope(env->GetIsolate()); | 9118 v8::HandleScope scope(env->GetIsolate()); |
9124 v8::TryCatch try_catch; | 9119 v8::TryCatch try_catch; |
9125 v8_compile("This doesn't &*&@#$&*^ compile."); | 9120 v8_compile("This doesn't &*&@#$&*^ compile."); |
9126 CHECK(*try_catch.Exception()); | 9121 CHECK_NE(NULL, *try_catch.Exception()); |
9127 CHECK(try_catch.HasCaught()); | 9122 CHECK(try_catch.HasCaught()); |
9128 } | 9123 } |
9129 | 9124 |
9130 | 9125 |
9131 TEST(TryCatchFinallyUsingTryCatchHandler) { | 9126 TEST(TryCatchFinallyUsingTryCatchHandler) { |
9132 LocalContext env; | 9127 LocalContext env; |
9133 v8::HandleScope scope(env->GetIsolate()); | 9128 v8::HandleScope scope(env->GetIsolate()); |
9134 v8::TryCatch try_catch; | 9129 v8::TryCatch try_catch; |
9135 CompileRun("try { throw ''; } catch (e) {}"); | 9130 CompileRun("try { throw ''; } catch (e) {}"); |
9136 CHECK(!try_catch.HasCaught()); | 9131 CHECK(!try_catch.HasCaught()); |
(...skipping 27 matching lines...) Expand all Loading... |
9164 v8::FunctionTemplate::New(isolate, CEvaluate)); | 9159 v8::FunctionTemplate::New(isolate, CEvaluate)); |
9165 LocalContext context(0, templ); | 9160 LocalContext context(0, templ); |
9166 v8::TryCatch try_catch; | 9161 v8::TryCatch try_catch; |
9167 CompileRun("try {" | 9162 CompileRun("try {" |
9168 " CEvaluate('throw 1;');" | 9163 " CEvaluate('throw 1;');" |
9169 "} finally {" | 9164 "} finally {" |
9170 "}"); | 9165 "}"); |
9171 CHECK(try_catch.HasCaught()); | 9166 CHECK(try_catch.HasCaught()); |
9172 CHECK(!try_catch.Message().IsEmpty()); | 9167 CHECK(!try_catch.Message().IsEmpty()); |
9173 String::Utf8Value exception_value(try_catch.Exception()); | 9168 String::Utf8Value exception_value(try_catch.Exception()); |
9174 CHECK_EQ(0, strcmp(*exception_value, "1")); | 9169 CHECK_EQ(*exception_value, "1"); |
9175 try_catch.Reset(); | 9170 try_catch.Reset(); |
9176 CompileRun("try {" | 9171 CompileRun("try {" |
9177 " CEvaluate('throw 1;');" | 9172 " CEvaluate('throw 1;');" |
9178 "} finally {" | 9173 "} finally {" |
9179 " throw 2;" | 9174 " throw 2;" |
9180 "}"); | 9175 "}"); |
9181 CHECK(try_catch.HasCaught()); | 9176 CHECK(try_catch.HasCaught()); |
9182 CHECK(!try_catch.Message().IsEmpty()); | 9177 CHECK(!try_catch.Message().IsEmpty()); |
9183 String::Utf8Value finally_exception_value(try_catch.Exception()); | 9178 String::Utf8Value finally_exception_value(try_catch.Exception()); |
9184 CHECK_EQ(0, strcmp(*finally_exception_value, "2")); | 9179 CHECK_EQ(*finally_exception_value, "2"); |
9185 } | 9180 } |
9186 | 9181 |
9187 | 9182 |
9188 // For use within the TestSecurityHandler() test. | 9183 // For use within the TestSecurityHandler() test. |
9189 static bool g_security_callback_result = false; | 9184 static bool g_security_callback_result = false; |
9190 static bool NamedSecurityTestCallback(Local<v8::Object> global, | 9185 static bool NamedSecurityTestCallback(Local<v8::Object> global, |
9191 Local<Value> name, | 9186 Local<Value> name, |
9192 v8::AccessType type, | 9187 v8::AccessType type, |
9193 Local<Value> data) { | 9188 Local<Value> data) { |
9194 printf("a\n"); | 9189 printf("a\n"); |
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9567 env2->DetachGlobal(); | 9562 env2->DetachGlobal(); |
9568 | 9563 |
9569 v8::Handle<Context> env3 = Context::New(env1->GetIsolate(), | 9564 v8::Handle<Context> env3 = Context::New(env1->GetIsolate(), |
9570 0, | 9565 0, |
9571 v8::Handle<v8::ObjectTemplate>(), | 9566 v8::Handle<v8::ObjectTemplate>(), |
9572 global2); | 9567 global2); |
9573 env3->SetSecurityToken(v8_str("bar")); | 9568 env3->SetSecurityToken(v8_str("bar")); |
9574 env3->Enter(); | 9569 env3->Enter(); |
9575 | 9570 |
9576 Local<v8::Object> global3 = env3->Global(); | 9571 Local<v8::Object> global3 = env3->Global(); |
9577 CHECK(global2->Equals(global3)); | 9572 CHECK_EQ(global2, global3); |
9578 CHECK(global3->Get(v8_str("prop"))->IsUndefined()); | 9573 CHECK(global3->Get(v8_str("prop"))->IsUndefined()); |
9579 CHECK(global3->Get(v8_str("getProp"))->IsUndefined()); | 9574 CHECK(global3->Get(v8_str("getProp"))->IsUndefined()); |
9580 global3->Set(v8_str("prop"), v8::Integer::New(env3->GetIsolate(), -1)); | 9575 global3->Set(v8_str("prop"), v8::Integer::New(env3->GetIsolate(), -1)); |
9581 global3->Set(v8_str("prop2"), v8::Integer::New(env3->GetIsolate(), 2)); | 9576 global3->Set(v8_str("prop2"), v8::Integer::New(env3->GetIsolate(), 2)); |
9582 env3->Exit(); | 9577 env3->Exit(); |
9583 | 9578 |
9584 // Call getProp in env1, and it should return the value 1 | 9579 // Call getProp in env1, and it should return the value 1 |
9585 { | 9580 { |
9586 Local<Value> get_prop = global1->Get(v8_str("getProp")); | 9581 Local<Value> get_prop = global1->Get(v8_str("getProp")); |
9587 CHECK(get_prop->IsFunction()); | 9582 CHECK(get_prop->IsFunction()); |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9633 // Check that the global has been detached. No other.p property can | 9628 // Check that the global has been detached. No other.p property can |
9634 // be found. | 9629 // be found. |
9635 result = CompileRun("other.p"); | 9630 result = CompileRun("other.p"); |
9636 CHECK(result.IsEmpty()); | 9631 CHECK(result.IsEmpty()); |
9637 | 9632 |
9638 // Reuse global2 for env3. | 9633 // Reuse global2 for env3. |
9639 v8::Handle<Context> env3 = Context::New(env1->GetIsolate(), | 9634 v8::Handle<Context> env3 = Context::New(env1->GetIsolate(), |
9640 0, | 9635 0, |
9641 v8::Handle<v8::ObjectTemplate>(), | 9636 v8::Handle<v8::ObjectTemplate>(), |
9642 global2); | 9637 global2); |
9643 CHECK(global2->Equals(env3->Global())); | 9638 CHECK_EQ(global2, env3->Global()); |
9644 | 9639 |
9645 // Start by using the same security token for env3 as for env1 and env2. | 9640 // Start by using the same security token for env3 as for env1 and env2. |
9646 env3->SetSecurityToken(foo); | 9641 env3->SetSecurityToken(foo); |
9647 | 9642 |
9648 // Create a property on the global object in env3. | 9643 // Create a property on the global object in env3. |
9649 { | 9644 { |
9650 v8::Context::Scope scope(env3); | 9645 v8::Context::Scope scope(env3); |
9651 env3->Global()->Set(v8_str("p"), v8::Integer::New(env3->GetIsolate(), 24)); | 9646 env3->Global()->Set(v8_str("p"), v8::Integer::New(env3->GetIsolate(), 24)); |
9652 } | 9647 } |
9653 | 9648 |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9707 v8_str("this_x"), | 9702 v8_str("this_x"), |
9708 CompileRun("Object.getOwnPropertyDescriptor(this, 'this_x').get")); | 9703 CompileRun("Object.getOwnPropertyDescriptor(this, 'this_x').get")); |
9709 } | 9704 } |
9710 | 9705 |
9711 Local<Object> env2_global = env2->Global(); | 9706 Local<Object> env2_global = env2->Global(); |
9712 env2_global->TurnOnAccessCheck(); | 9707 env2_global->TurnOnAccessCheck(); |
9713 env2->DetachGlobal(); | 9708 env2->DetachGlobal(); |
9714 | 9709 |
9715 Local<Value> result; | 9710 Local<Value> result; |
9716 result = CompileRun("bound_x()"); | 9711 result = CompileRun("bound_x()"); |
9717 CHECK(v8_str("env2_x")->Equals(result)); | 9712 CHECK_EQ(v8_str("env2_x"), result); |
9718 result = CompileRun("get_x()"); | 9713 result = CompileRun("get_x()"); |
9719 CHECK(result.IsEmpty()); | 9714 CHECK(result.IsEmpty()); |
9720 result = CompileRun("get_x_w()"); | 9715 result = CompileRun("get_x_w()"); |
9721 CHECK(result.IsEmpty()); | 9716 CHECK(result.IsEmpty()); |
9722 result = CompileRun("this_x()"); | 9717 result = CompileRun("this_x()"); |
9723 CHECK(v8_str("env2_x")->Equals(result)); | 9718 CHECK_EQ(v8_str("env2_x"), result); |
9724 | 9719 |
9725 // Reattach env2's proxy | 9720 // Reattach env2's proxy |
9726 env2 = Context::New(env1->GetIsolate(), | 9721 env2 = Context::New(env1->GetIsolate(), |
9727 0, | 9722 0, |
9728 v8::Handle<v8::ObjectTemplate>(), | 9723 v8::Handle<v8::ObjectTemplate>(), |
9729 env2_global); | 9724 env2_global); |
9730 env2->SetSecurityToken(foo); | 9725 env2->SetSecurityToken(foo); |
9731 { | 9726 { |
9732 v8::Context::Scope scope(env2); | 9727 v8::Context::Scope scope(env2); |
9733 env2->Global()->Set(v8_str("x"), v8_str("env3_x")); | 9728 env2->Global()->Set(v8_str("x"), v8_str("env3_x")); |
9734 env2->Global()->Set(v8_str("env1"), env1->Global()); | 9729 env2->Global()->Set(v8_str("env1"), env1->Global()); |
9735 result = CompileRun( | 9730 result = CompileRun( |
9736 "results = [];" | 9731 "results = [];" |
9737 "for (var i = 0; i < 4; i++ ) {" | 9732 "for (var i = 0; i < 4; i++ ) {" |
9738 " results.push(env1.bound_x());" | 9733 " results.push(env1.bound_x());" |
9739 " results.push(env1.get_x());" | 9734 " results.push(env1.get_x());" |
9740 " results.push(env1.get_x_w());" | 9735 " results.push(env1.get_x_w());" |
9741 " results.push(env1.this_x());" | 9736 " results.push(env1.this_x());" |
9742 "}" | 9737 "}" |
9743 "results"); | 9738 "results"); |
9744 Local<v8::Array> results = Local<v8::Array>::Cast(result); | 9739 Local<v8::Array> results = Local<v8::Array>::Cast(result); |
9745 CHECK_EQ(16u, results->Length()); | 9740 CHECK_EQ(16, results->Length()); |
9746 for (int i = 0; i < 16; i += 4) { | 9741 for (int i = 0; i < 16; i += 4) { |
9747 CHECK(v8_str("env2_x")->Equals(results->Get(i + 0))); | 9742 CHECK_EQ(v8_str("env2_x"), results->Get(i + 0)); |
9748 CHECK(v8_str("env1_x")->Equals(results->Get(i + 1))); | 9743 CHECK_EQ(v8_str("env1_x"), results->Get(i + 1)); |
9749 CHECK(v8_str("env3_x")->Equals(results->Get(i + 2))); | 9744 CHECK_EQ(v8_str("env3_x"), results->Get(i + 2)); |
9750 CHECK(v8_str("env2_x")->Equals(results->Get(i + 3))); | 9745 CHECK_EQ(v8_str("env2_x"), results->Get(i + 3)); |
9751 } | 9746 } |
9752 } | 9747 } |
9753 | 9748 |
9754 result = CompileRun( | 9749 result = CompileRun( |
9755 "results = [];" | 9750 "results = [];" |
9756 "for (var i = 0; i < 4; i++ ) {" | 9751 "for (var i = 0; i < 4; i++ ) {" |
9757 " results.push(bound_x());" | 9752 " results.push(bound_x());" |
9758 " results.push(get_x());" | 9753 " results.push(get_x());" |
9759 " results.push(get_x_w());" | 9754 " results.push(get_x_w());" |
9760 " results.push(this_x());" | 9755 " results.push(this_x());" |
9761 "}" | 9756 "}" |
9762 "results"); | 9757 "results"); |
9763 Local<v8::Array> results = Local<v8::Array>::Cast(result); | 9758 Local<v8::Array> results = Local<v8::Array>::Cast(result); |
9764 CHECK_EQ(16u, results->Length()); | 9759 CHECK_EQ(16, results->Length()); |
9765 for (int i = 0; i < 16; i += 4) { | 9760 for (int i = 0; i < 16; i += 4) { |
9766 CHECK(v8_str("env2_x")->Equals(results->Get(i + 0))); | 9761 CHECK_EQ(v8_str("env2_x"), results->Get(i + 0)); |
9767 CHECK(v8_str("env3_x")->Equals(results->Get(i + 1))); | 9762 CHECK_EQ(v8_str("env3_x"), results->Get(i + 1)); |
9768 CHECK(v8_str("env3_x")->Equals(results->Get(i + 2))); | 9763 CHECK_EQ(v8_str("env3_x"), results->Get(i + 2)); |
9769 CHECK(v8_str("env2_x")->Equals(results->Get(i + 3))); | 9764 CHECK_EQ(v8_str("env2_x"), results->Get(i + 3)); |
9770 } | 9765 } |
9771 | 9766 |
9772 result = CompileRun( | 9767 result = CompileRun( |
9773 "results = [];" | 9768 "results = [];" |
9774 "for (var i = 0; i < 4; i++ ) {" | 9769 "for (var i = 0; i < 4; i++ ) {" |
9775 " results.push(this.bound_x());" | 9770 " results.push(this.bound_x());" |
9776 " results.push(this.get_x());" | 9771 " results.push(this.get_x());" |
9777 " results.push(this.get_x_w());" | 9772 " results.push(this.get_x_w());" |
9778 " results.push(this.this_x());" | 9773 " results.push(this.this_x());" |
9779 "}" | 9774 "}" |
9780 "results"); | 9775 "results"); |
9781 results = Local<v8::Array>::Cast(result); | 9776 results = Local<v8::Array>::Cast(result); |
9782 CHECK_EQ(16u, results->Length()); | 9777 CHECK_EQ(16, results->Length()); |
9783 for (int i = 0; i < 16; i += 4) { | 9778 for (int i = 0; i < 16; i += 4) { |
9784 CHECK(v8_str("env2_x")->Equals(results->Get(i + 0))); | 9779 CHECK_EQ(v8_str("env2_x"), results->Get(i + 0)); |
9785 CHECK(v8_str("env1_x")->Equals(results->Get(i + 1))); | 9780 CHECK_EQ(v8_str("env1_x"), results->Get(i + 1)); |
9786 CHECK(v8_str("env3_x")->Equals(results->Get(i + 2))); | 9781 CHECK_EQ(v8_str("env3_x"), results->Get(i + 2)); |
9787 CHECK(v8_str("env2_x")->Equals(results->Get(i + 3))); | 9782 CHECK_EQ(v8_str("env2_x"), results->Get(i + 3)); |
9788 } | 9783 } |
9789 } | 9784 } |
9790 | 9785 |
9791 | 9786 |
9792 static bool allowed_access_type[v8::ACCESS_KEYS + 1] = { false }; | 9787 static bool allowed_access_type[v8::ACCESS_KEYS + 1] = { false }; |
9793 static bool NamedAccessBlocker(Local<v8::Object> global, | 9788 static bool NamedAccessBlocker(Local<v8::Object> global, |
9794 Local<Value> name, | 9789 Local<Value> name, |
9795 v8::AccessType type, | 9790 v8::AccessType type, |
9796 Local<Value> data) { | 9791 Local<Value> data) { |
9797 return CcTest::isolate()->GetCurrentContext()->Global()->Equals(global) || | 9792 return CcTest::isolate()->GetCurrentContext()->Global()->Equals(global) || |
(...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10231 NULL, NULL, NULL, NULL, NamedPropertyEnumerator)); | 10226 NULL, NULL, NULL, NULL, NamedPropertyEnumerator)); |
10232 | 10227 |
10233 LocalContext context; | 10228 LocalContext context; |
10234 v8::Handle<v8::Object> global = context->Global(); | 10229 v8::Handle<v8::Object> global = context->Global(); |
10235 global->Set(v8_str("object"), obj_template->NewInstance()); | 10230 global->Set(v8_str("object"), obj_template->NewInstance()); |
10236 | 10231 |
10237 v8::Handle<v8::Value> result = | 10232 v8::Handle<v8::Value> result = |
10238 CompileRun("Object.getOwnPropertyNames(object)"); | 10233 CompileRun("Object.getOwnPropertyNames(object)"); |
10239 CHECK(result->IsArray()); | 10234 CHECK(result->IsArray()); |
10240 v8::Handle<v8::Array> result_array = v8::Handle<v8::Array>::Cast(result); | 10235 v8::Handle<v8::Array> result_array = v8::Handle<v8::Array>::Cast(result); |
10241 CHECK_EQ(2u, result_array->Length()); | 10236 CHECK_EQ(2, result_array->Length()); |
10242 CHECK(result_array->Get(0)->IsString()); | 10237 CHECK(result_array->Get(0)->IsString()); |
10243 CHECK(result_array->Get(1)->IsString()); | 10238 CHECK(result_array->Get(1)->IsString()); |
10244 CHECK(v8_str("7")->Equals(result_array->Get(0))); | 10239 CHECK_EQ(v8_str("7"), result_array->Get(0)); |
10245 CHECK(v8_str("x")->Equals(result_array->Get(1))); | 10240 CHECK_EQ(v8_str("x"), result_array->Get(1)); |
10246 | 10241 |
10247 result = CompileRun("var ret = []; for (var k in object) ret.push(k); ret"); | 10242 result = CompileRun("var ret = []; for (var k in object) ret.push(k); ret"); |
10248 CHECK(result->IsArray()); | 10243 CHECK(result->IsArray()); |
10249 result_array = v8::Handle<v8::Array>::Cast(result); | 10244 result_array = v8::Handle<v8::Array>::Cast(result); |
10250 CHECK_EQ(2u, result_array->Length()); | 10245 CHECK_EQ(2, result_array->Length()); |
10251 CHECK(result_array->Get(0)->IsString()); | 10246 CHECK(result_array->Get(0)->IsString()); |
10252 CHECK(result_array->Get(1)->IsString()); | 10247 CHECK(result_array->Get(1)->IsString()); |
10253 CHECK(v8_str("7")->Equals(result_array->Get(0))); | 10248 CHECK_EQ(v8_str("7"), result_array->Get(0)); |
10254 CHECK(v8_str("x")->Equals(result_array->Get(1))); | 10249 CHECK_EQ(v8_str("x"), result_array->Get(1)); |
10255 | 10250 |
10256 result = CompileRun("Object.getOwnPropertySymbols(object)"); | 10251 result = CompileRun("Object.getOwnPropertySymbols(object)"); |
10257 CHECK(result->IsArray()); | 10252 CHECK(result->IsArray()); |
10258 result_array = v8::Handle<v8::Array>::Cast(result); | 10253 result_array = v8::Handle<v8::Array>::Cast(result); |
10259 CHECK_EQ(1u, result_array->Length()); | 10254 CHECK_EQ(1, result_array->Length()); |
10260 CHECK(result_array->Get(0)->Equals(v8::Symbol::GetIterator(isolate))); | 10255 CHECK_EQ(result_array->Get(0), v8::Symbol::GetIterator(isolate)); |
10261 } | 10256 } |
10262 | 10257 |
10263 | 10258 |
10264 static void ConstTenGetter(Local<String> name, | 10259 static void ConstTenGetter(Local<String> name, |
10265 const v8::PropertyCallbackInfo<v8::Value>& info) { | 10260 const v8::PropertyCallbackInfo<v8::Value>& info) { |
10266 info.GetReturnValue().Set(v8_num(10)); | 10261 info.GetReturnValue().Set(v8_num(10)); |
10267 } | 10262 } |
10268 | 10263 |
10269 | 10264 |
10270 THREADED_TEST(CrossDomainAccessors) { | 10265 THREADED_TEST(CrossDomainAccessors) { |
(...skipping 717 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10988 CHECK_EQ(0, o0->Get(v8_str("x"))->Int32Value()); | 10983 CHECK_EQ(0, o0->Get(v8_str("x"))->Int32Value()); |
10989 CHECK_EQ(1, o0->Get(v8_str("y"))->Int32Value()); | 10984 CHECK_EQ(1, o0->Get(v8_str("y"))->Int32Value()); |
10990 CHECK_EQ(2, o0->Get(v8_str("z"))->Int32Value()); | 10985 CHECK_EQ(2, o0->Get(v8_str("z"))->Int32Value()); |
10991 CHECK_EQ(3, o0->Get(v8_str("u"))->Int32Value()); | 10986 CHECK_EQ(3, o0->Get(v8_str("u"))->Int32Value()); |
10992 | 10987 |
10993 // Getting the prototype of o0 should get the first visible one | 10988 // Getting the prototype of o0 should get the first visible one |
10994 // which is o3. Therefore, z should not be defined on the prototype | 10989 // which is o3. Therefore, z should not be defined on the prototype |
10995 // object. | 10990 // object. |
10996 Local<Value> proto = o0->Get(v8_str("__proto__")); | 10991 Local<Value> proto = o0->Get(v8_str("__proto__")); |
10997 CHECK(proto->IsObject()); | 10992 CHECK(proto->IsObject()); |
10998 CHECK(proto.As<v8::Object>()->Equals(o3)); | 10993 CHECK_EQ(proto.As<v8::Object>(), o3); |
10999 | 10994 |
11000 // However, Object::GetPrototype ignores hidden prototype. | 10995 // However, Object::GetPrototype ignores hidden prototype. |
11001 Local<Value> proto0 = o0->GetPrototype(); | 10996 Local<Value> proto0 = o0->GetPrototype(); |
11002 CHECK(proto0->IsObject()); | 10997 CHECK(proto0->IsObject()); |
11003 CHECK(proto0.As<v8::Object>()->Equals(o1)); | 10998 CHECK_EQ(proto0.As<v8::Object>(), o1); |
11004 | 10999 |
11005 Local<Value> proto1 = o1->GetPrototype(); | 11000 Local<Value> proto1 = o1->GetPrototype(); |
11006 CHECK(proto1->IsObject()); | 11001 CHECK(proto1->IsObject()); |
11007 CHECK(proto1.As<v8::Object>()->Equals(o2)); | 11002 CHECK_EQ(proto1.As<v8::Object>(), o2); |
11008 | 11003 |
11009 Local<Value> proto2 = o2->GetPrototype(); | 11004 Local<Value> proto2 = o2->GetPrototype(); |
11010 CHECK(proto2->IsObject()); | 11005 CHECK(proto2->IsObject()); |
11011 CHECK(proto2.As<v8::Object>()->Equals(o3)); | 11006 CHECK_EQ(proto2.As<v8::Object>(), o3); |
11012 } | 11007 } |
11013 | 11008 |
11014 | 11009 |
11015 // Getting property names of an object with a prototype chain that | 11010 // Getting property names of an object with a prototype chain that |
11016 // triggers dictionary elements in GetOwnPropertyNames() shouldn't | 11011 // triggers dictionary elements in GetOwnPropertyNames() shouldn't |
11017 // crash the runtime. | 11012 // crash the runtime. |
11018 THREADED_TEST(Regress91517) { | 11013 THREADED_TEST(Regress91517) { |
11019 i::FLAG_allow_natives_syntax = true; | 11014 i::FLAG_allow_natives_syntax = true; |
11020 LocalContext context; | 11015 LocalContext context; |
11021 v8::Isolate* isolate = context->GetIsolate(); | 11016 v8::Isolate* isolate = context->GetIsolate(); |
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11295 CHECK(value->IsInt32()); | 11290 CHECK(value->IsInt32()); |
11296 CHECK(!try_catch.HasCaught()); | 11291 CHECK(!try_catch.HasCaught()); |
11297 CHECK_EQ(28, value->Int32Value()); | 11292 CHECK_EQ(28, value->Int32Value()); |
11298 | 11293 |
11299 // Call the Object's constructor with a String. | 11294 // Call the Object's constructor with a String. |
11300 value = CompileRun( | 11295 value = CompileRun( |
11301 "(function() { var o = new obj('tipli'); return o.a; })()"); | 11296 "(function() { var o = new obj('tipli'); return o.a; })()"); |
11302 CHECK(!try_catch.HasCaught()); | 11297 CHECK(!try_catch.HasCaught()); |
11303 CHECK(value->IsString()); | 11298 CHECK(value->IsString()); |
11304 String::Utf8Value string_value1(value->ToString(isolate)); | 11299 String::Utf8Value string_value1(value->ToString(isolate)); |
11305 CHECK_EQ(0, strcmp("tipli", *string_value1)); | 11300 CHECK_EQ("tipli", *string_value1); |
11306 | 11301 |
11307 Local<Value> args2[] = { v8_str("tipli") }; | 11302 Local<Value> args2[] = { v8_str("tipli") }; |
11308 Local<Value> value_obj2 = instance->CallAsConstructor(1, args2); | 11303 Local<Value> value_obj2 = instance->CallAsConstructor(1, args2); |
11309 CHECK(value_obj2->IsObject()); | 11304 CHECK(value_obj2->IsObject()); |
11310 Local<Object> object2 = Local<Object>::Cast(value_obj2); | 11305 Local<Object> object2 = Local<Object>::Cast(value_obj2); |
11311 value = object2->Get(v8_str("a")); | 11306 value = object2->Get(v8_str("a")); |
11312 CHECK(!try_catch.HasCaught()); | 11307 CHECK(!try_catch.HasCaught()); |
11313 CHECK(value->IsString()); | 11308 CHECK(value->IsString()); |
11314 String::Utf8Value string_value2(value->ToString(isolate)); | 11309 String::Utf8Value string_value2(value->ToString(isolate)); |
11315 CHECK_EQ(0, strcmp("tipli", *string_value2)); | 11310 CHECK_EQ("tipli", *string_value2); |
11316 | 11311 |
11317 // Call the Object's constructor with a Boolean. | 11312 // Call the Object's constructor with a Boolean. |
11318 value = CompileRun("(function() { var o = new obj(true); return o.a; })()"); | 11313 value = CompileRun("(function() { var o = new obj(true); return o.a; })()"); |
11319 CHECK(!try_catch.HasCaught()); | 11314 CHECK(!try_catch.HasCaught()); |
11320 CHECK(value->IsBoolean()); | 11315 CHECK(value->IsBoolean()); |
11321 CHECK_EQ(true, value->BooleanValue()); | 11316 CHECK_EQ(true, value->BooleanValue()); |
11322 | 11317 |
11323 Handle<Value> args3[] = { v8::True(isolate) }; | 11318 Handle<Value> args3[] = { v8::True(isolate) }; |
11324 Local<Value> value_obj3 = instance->CallAsConstructor(1, args3); | 11319 Local<Value> value_obj3 = instance->CallAsConstructor(1, args3); |
11325 CHECK(value_obj3->IsObject()); | 11320 CHECK(value_obj3->IsObject()); |
(...skipping 26 matching lines...) Expand all Loading... |
11352 { Local<ObjectTemplate> instance_template = ObjectTemplate::New(isolate); | 11347 { Local<ObjectTemplate> instance_template = ObjectTemplate::New(isolate); |
11353 Local<Object> instance = instance_template->NewInstance(); | 11348 Local<Object> instance = instance_template->NewInstance(); |
11354 context->Global()->Set(v8_str("obj2"), instance); | 11349 context->Global()->Set(v8_str("obj2"), instance); |
11355 v8::TryCatch try_catch; | 11350 v8::TryCatch try_catch; |
11356 Local<Value> value; | 11351 Local<Value> value; |
11357 CHECK(!try_catch.HasCaught()); | 11352 CHECK(!try_catch.HasCaught()); |
11358 | 11353 |
11359 value = CompileRun("new obj2(28)"); | 11354 value = CompileRun("new obj2(28)"); |
11360 CHECK(try_catch.HasCaught()); | 11355 CHECK(try_catch.HasCaught()); |
11361 String::Utf8Value exception_value1(try_catch.Exception()); | 11356 String::Utf8Value exception_value1(try_catch.Exception()); |
11362 CHECK_EQ(0, strcmp("TypeError: obj2 is not a function", *exception_value1)); | 11357 CHECK_EQ("TypeError: obj2 is not a function", *exception_value1); |
11363 try_catch.Reset(); | 11358 try_catch.Reset(); |
11364 | 11359 |
11365 Local<Value> args[] = { v8_num(29) }; | 11360 Local<Value> args[] = { v8_num(29) }; |
11366 value = instance->CallAsConstructor(1, args); | 11361 value = instance->CallAsConstructor(1, args); |
11367 CHECK(try_catch.HasCaught()); | 11362 CHECK(try_catch.HasCaught()); |
11368 String::Utf8Value exception_value2(try_catch.Exception()); | 11363 String::Utf8Value exception_value2(try_catch.Exception()); |
11369 CHECK_EQ( | 11364 CHECK_EQ("TypeError: #<Object> is not a function", *exception_value2); |
11370 0, strcmp("TypeError: #<Object> is not a function", *exception_value2)); | |
11371 try_catch.Reset(); | 11365 try_catch.Reset(); |
11372 } | 11366 } |
11373 | 11367 |
11374 // Check the case when constructor throws exception. | 11368 // Check the case when constructor throws exception. |
11375 { Local<ObjectTemplate> instance_template = ObjectTemplate::New(isolate); | 11369 { Local<ObjectTemplate> instance_template = ObjectTemplate::New(isolate); |
11376 instance_template->SetCallAsFunctionHandler(ThrowValue); | 11370 instance_template->SetCallAsFunctionHandler(ThrowValue); |
11377 Local<Object> instance = instance_template->NewInstance(); | 11371 Local<Object> instance = instance_template->NewInstance(); |
11378 context->Global()->Set(v8_str("obj3"), instance); | 11372 context->Global()->Set(v8_str("obj3"), instance); |
11379 v8::TryCatch try_catch; | 11373 v8::TryCatch try_catch; |
11380 Local<Value> value; | 11374 Local<Value> value; |
11381 CHECK(!try_catch.HasCaught()); | 11375 CHECK(!try_catch.HasCaught()); |
11382 | 11376 |
11383 value = CompileRun("new obj3(22)"); | 11377 value = CompileRun("new obj3(22)"); |
11384 CHECK(try_catch.HasCaught()); | 11378 CHECK(try_catch.HasCaught()); |
11385 String::Utf8Value exception_value1(try_catch.Exception()); | 11379 String::Utf8Value exception_value1(try_catch.Exception()); |
11386 CHECK_EQ(0, strcmp("22", *exception_value1)); | 11380 CHECK_EQ("22", *exception_value1); |
11387 try_catch.Reset(); | 11381 try_catch.Reset(); |
11388 | 11382 |
11389 Local<Value> args[] = { v8_num(23) }; | 11383 Local<Value> args[] = { v8_num(23) }; |
11390 value = instance->CallAsConstructor(1, args); | 11384 value = instance->CallAsConstructor(1, args); |
11391 CHECK(try_catch.HasCaught()); | 11385 CHECK(try_catch.HasCaught()); |
11392 String::Utf8Value exception_value2(try_catch.Exception()); | 11386 String::Utf8Value exception_value2(try_catch.Exception()); |
11393 CHECK_EQ(0, strcmp("23", *exception_value2)); | 11387 CHECK_EQ("23", *exception_value2); |
11394 try_catch.Reset(); | 11388 try_catch.Reset(); |
11395 } | 11389 } |
11396 | 11390 |
11397 // Check whether constructor returns with an object or non-object. | 11391 // Check whether constructor returns with an object or non-object. |
11398 { Local<FunctionTemplate> function_template = | 11392 { Local<FunctionTemplate> function_template = |
11399 FunctionTemplate::New(isolate, FakeConstructorCallback); | 11393 FunctionTemplate::New(isolate, FakeConstructorCallback); |
11400 Local<Function> function = function_template->GetFunction(); | 11394 Local<Function> function = function_template->GetFunction(); |
11401 Local<Object> instance1 = function; | 11395 Local<Object> instance1 = function; |
11402 context->Global()->Set(v8_str("obj4"), instance1); | 11396 context->Global()->Set(v8_str("obj4"), instance1); |
11403 v8::TryCatch try_catch; | 11397 v8::TryCatch try_catch; |
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11714 v8::TryCatch try_catch; | 11708 v8::TryCatch try_catch; |
11715 Local<Value> value; | 11709 Local<Value> value; |
11716 CHECK(!try_catch.HasCaught()); | 11710 CHECK(!try_catch.HasCaught()); |
11717 | 11711 |
11718 // Call an object without call-as-function handler through the JS | 11712 // Call an object without call-as-function handler through the JS |
11719 value = CompileRun("obj2(28)"); | 11713 value = CompileRun("obj2(28)"); |
11720 CHECK(value.IsEmpty()); | 11714 CHECK(value.IsEmpty()); |
11721 CHECK(try_catch.HasCaught()); | 11715 CHECK(try_catch.HasCaught()); |
11722 String::Utf8Value exception_value1(try_catch.Exception()); | 11716 String::Utf8Value exception_value1(try_catch.Exception()); |
11723 // TODO(verwaest): Better message | 11717 // TODO(verwaest): Better message |
11724 CHECK_EQ(0, strcmp("TypeError: obj2 is not a function", *exception_value1)); | 11718 CHECK_EQ("TypeError: obj2 is not a function", *exception_value1); |
11725 try_catch.Reset(); | 11719 try_catch.Reset(); |
11726 | 11720 |
11727 // Call an object without call-as-function handler through the API | 11721 // Call an object without call-as-function handler through the API |
11728 value = CompileRun("obj2(28)"); | 11722 value = CompileRun("obj2(28)"); |
11729 v8::Handle<Value> args[] = { v8_num(28) }; | 11723 v8::Handle<Value> args[] = { v8_num(28) }; |
11730 value = instance->CallAsFunction(instance, 1, args); | 11724 value = instance->CallAsFunction(instance, 1, args); |
11731 CHECK(value.IsEmpty()); | 11725 CHECK(value.IsEmpty()); |
11732 CHECK(try_catch.HasCaught()); | 11726 CHECK(try_catch.HasCaught()); |
11733 String::Utf8Value exception_value2(try_catch.Exception()); | 11727 String::Utf8Value exception_value2(try_catch.Exception()); |
11734 CHECK_EQ(0, strcmp("TypeError: [object Object] is not a function", | 11728 CHECK_EQ("TypeError: [object Object] is not a function", *exception_value2); |
11735 *exception_value2)); | |
11736 try_catch.Reset(); | 11729 try_catch.Reset(); |
11737 } | 11730 } |
11738 | 11731 |
11739 { Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New(isolate); | 11732 { Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New(isolate); |
11740 Local<ObjectTemplate> instance_template = t->InstanceTemplate(); | 11733 Local<ObjectTemplate> instance_template = t->InstanceTemplate(); |
11741 instance_template->SetCallAsFunctionHandler(ThrowValue); | 11734 instance_template->SetCallAsFunctionHandler(ThrowValue); |
11742 Local<v8::Object> instance = t->GetFunction()->NewInstance(); | 11735 Local<v8::Object> instance = t->GetFunction()->NewInstance(); |
11743 context->Global()->Set(v8_str("obj3"), instance); | 11736 context->Global()->Set(v8_str("obj3"), instance); |
11744 v8::TryCatch try_catch; | 11737 v8::TryCatch try_catch; |
11745 Local<Value> value; | 11738 Local<Value> value; |
11746 CHECK(!try_catch.HasCaught()); | 11739 CHECK(!try_catch.HasCaught()); |
11747 | 11740 |
11748 // Catch the exception which is thrown by call-as-function handler | 11741 // Catch the exception which is thrown by call-as-function handler |
11749 value = CompileRun("obj3(22)"); | 11742 value = CompileRun("obj3(22)"); |
11750 CHECK(try_catch.HasCaught()); | 11743 CHECK(try_catch.HasCaught()); |
11751 String::Utf8Value exception_value1(try_catch.Exception()); | 11744 String::Utf8Value exception_value1(try_catch.Exception()); |
11752 CHECK_EQ(0, strcmp("22", *exception_value1)); | 11745 CHECK_EQ("22", *exception_value1); |
11753 try_catch.Reset(); | 11746 try_catch.Reset(); |
11754 | 11747 |
11755 v8::Handle<Value> args[] = { v8_num(23) }; | 11748 v8::Handle<Value> args[] = { v8_num(23) }; |
11756 value = instance->CallAsFunction(instance, 1, args); | 11749 value = instance->CallAsFunction(instance, 1, args); |
11757 CHECK(try_catch.HasCaught()); | 11750 CHECK(try_catch.HasCaught()); |
11758 String::Utf8Value exception_value2(try_catch.Exception()); | 11751 String::Utf8Value exception_value2(try_catch.Exception()); |
11759 CHECK_EQ(0, strcmp("23", *exception_value2)); | 11752 CHECK_EQ("23", *exception_value2); |
11760 try_catch.Reset(); | 11753 try_catch.Reset(); |
11761 } | 11754 } |
11762 | 11755 |
11763 { Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New(isolate); | 11756 { Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New(isolate); |
11764 Local<ObjectTemplate> instance_template = t->InstanceTemplate(); | 11757 Local<ObjectTemplate> instance_template = t->InstanceTemplate(); |
11765 instance_template->SetCallAsFunctionHandler(ReturnThis); | 11758 instance_template->SetCallAsFunctionHandler(ReturnThis); |
11766 Local<v8::Object> instance = t->GetFunction()->NewInstance(); | 11759 Local<v8::Object> instance = t->GetFunction()->NewInstance(); |
11767 | 11760 |
11768 Local<v8::Value> a1 = | 11761 Local<v8::Value> a1 = |
11769 instance->CallAsFunction(v8::Undefined(isolate), 0, NULL); | 11762 instance->CallAsFunction(v8::Undefined(isolate), 0, NULL); |
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12002 v8::Handle<Value> value = CompileRun(source); | 11995 v8::Handle<Value> value = CompileRun(source); |
12003 CHECK_EQ(expected, value->Int32Value()); | 11996 CHECK_EQ(expected, value->Int32Value()); |
12004 } | 11997 } |
12005 | 11998 |
12006 | 11999 |
12007 static void InterceptorLoadICGetter( | 12000 static void InterceptorLoadICGetter( |
12008 Local<Name> name, const v8::PropertyCallbackInfo<v8::Value>& info) { | 12001 Local<Name> name, const v8::PropertyCallbackInfo<v8::Value>& info) { |
12009 ApiTestFuzzer::Fuzz(); | 12002 ApiTestFuzzer::Fuzz(); |
12010 v8::Isolate* isolate = CcTest::isolate(); | 12003 v8::Isolate* isolate = CcTest::isolate(); |
12011 CHECK_EQ(isolate, info.GetIsolate()); | 12004 CHECK_EQ(isolate, info.GetIsolate()); |
12012 CHECK(v8_str("data")->Equals(info.Data())); | 12005 CHECK_EQ(v8_str("data"), info.Data()); |
12013 CHECK(v8_str("x")->Equals(name)); | 12006 CHECK_EQ(v8_str("x"), name); |
12014 info.GetReturnValue().Set(v8::Integer::New(isolate, 42)); | 12007 info.GetReturnValue().Set(v8::Integer::New(isolate, 42)); |
12015 } | 12008 } |
12016 | 12009 |
12017 | 12010 |
12018 // This test should hit the load IC for the interceptor case. | 12011 // This test should hit the load IC for the interceptor case. |
12019 THREADED_TEST(InterceptorLoadIC) { | 12012 THREADED_TEST(InterceptorLoadIC) { |
12020 CheckInterceptorLoadIC(InterceptorLoadICGetter, | 12013 CheckInterceptorLoadIC(InterceptorLoadICGetter, |
12021 "var result = 0;" | 12014 "var result = 0;" |
12022 "for (var i = 0; i < 1000; i++) {" | 12015 "for (var i = 0; i < 1000; i++) {" |
12023 " result = o.x;" | 12016 " result = o.x;" |
(...skipping 735 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12759 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); | 12752 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); |
12760 } | 12753 } |
12761 } | 12754 } |
12762 | 12755 |
12763 static void FastApiCallback_TrivialSignature( | 12756 static void FastApiCallback_TrivialSignature( |
12764 const v8::FunctionCallbackInfo<v8::Value>& args) { | 12757 const v8::FunctionCallbackInfo<v8::Value>& args) { |
12765 ApiTestFuzzer::Fuzz(); | 12758 ApiTestFuzzer::Fuzz(); |
12766 CheckReturnValue(args, FUNCTION_ADDR(FastApiCallback_TrivialSignature)); | 12759 CheckReturnValue(args, FUNCTION_ADDR(FastApiCallback_TrivialSignature)); |
12767 v8::Isolate* isolate = CcTest::isolate(); | 12760 v8::Isolate* isolate = CcTest::isolate(); |
12768 CHECK_EQ(isolate, args.GetIsolate()); | 12761 CHECK_EQ(isolate, args.GetIsolate()); |
12769 CHECK(args.This()->Equals(args.Holder())); | 12762 CHECK_EQ(args.This(), args.Holder()); |
12770 CHECK(args.Data()->Equals(v8_str("method_data"))); | 12763 CHECK(args.Data()->Equals(v8_str("method_data"))); |
12771 args.GetReturnValue().Set(args[0]->Int32Value() + 1); | 12764 args.GetReturnValue().Set(args[0]->Int32Value() + 1); |
12772 } | 12765 } |
12773 | 12766 |
12774 static void FastApiCallback_SimpleSignature( | 12767 static void FastApiCallback_SimpleSignature( |
12775 const v8::FunctionCallbackInfo<v8::Value>& args) { | 12768 const v8::FunctionCallbackInfo<v8::Value>& args) { |
12776 ApiTestFuzzer::Fuzz(); | 12769 ApiTestFuzzer::Fuzz(); |
12777 CheckReturnValue(args, FUNCTION_ADDR(FastApiCallback_SimpleSignature)); | 12770 CheckReturnValue(args, FUNCTION_ADDR(FastApiCallback_SimpleSignature)); |
12778 v8::Isolate* isolate = CcTest::isolate(); | 12771 v8::Isolate* isolate = CcTest::isolate(); |
12779 CHECK_EQ(isolate, args.GetIsolate()); | 12772 CHECK_EQ(isolate, args.GetIsolate()); |
12780 CHECK(args.This()->GetPrototype()->Equals(args.Holder())); | 12773 CHECK_EQ(args.This()->GetPrototype(), args.Holder()); |
12781 CHECK(args.Data()->Equals(v8_str("method_data"))); | 12774 CHECK(args.Data()->Equals(v8_str("method_data"))); |
12782 // Note, we're using HasRealNamedProperty instead of Has to avoid | 12775 // Note, we're using HasRealNamedProperty instead of Has to avoid |
12783 // invoking the interceptor again. | 12776 // invoking the interceptor again. |
12784 CHECK(args.Holder()->HasRealNamedProperty(v8_str("foo"))); | 12777 CHECK(args.Holder()->HasRealNamedProperty(v8_str("foo"))); |
12785 args.GetReturnValue().Set(args[0]->Int32Value() + 1); | 12778 args.GetReturnValue().Set(args[0]->Int32Value() + 1); |
12786 } | 12779 } |
12787 | 12780 |
12788 | 12781 |
12789 // Helper to maximize the odds of object moving. | 12782 // Helper to maximize the odds of object moving. |
12790 static void GenerateSomeGarbage() { | 12783 static void GenerateSomeGarbage() { |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12848 context->Global()->Set(v8_str("nativeobject"), nativeobject_obj); | 12841 context->Global()->Set(v8_str("nativeobject"), nativeobject_obj); |
12849 // call the api function multiple times to ensure direct call stub creation. | 12842 // call the api function multiple times to ensure direct call stub creation. |
12850 v8::Handle<Value> result = CompileRun( | 12843 v8::Handle<Value> result = CompileRun( |
12851 "var result = '';" | 12844 "var result = '';" |
12852 "function f() {" | 12845 "function f() {" |
12853 " for (var i = 1; i <= 5; i++) {" | 12846 " for (var i = 1; i <= 5; i++) {" |
12854 " try { nativeobject.callback(); } catch (e) { result += e; }" | 12847 " try { nativeobject.callback(); } catch (e) { result += e; }" |
12855 " }" | 12848 " }" |
12856 "}" | 12849 "}" |
12857 "f(); result;"); | 12850 "f(); result;"); |
12858 CHECK(v8_str("ggggg")->Equals(result)); | 12851 CHECK_EQ(v8_str("ggggg"), result); |
12859 } | 12852 } |
12860 | 12853 |
12861 | 12854 |
12862 static Handle<Value> DoDirectGetter() { | 12855 static Handle<Value> DoDirectGetter() { |
12863 if (++p_getter_count % 3 == 0) { | 12856 if (++p_getter_count % 3 == 0) { |
12864 CcTest::heap()->CollectAllGarbage(i::Heap::kAbortIncrementalMarkingMask); | 12857 CcTest::heap()->CollectAllGarbage(i::Heap::kAbortIncrementalMarkingMask); |
12865 GenerateSomeGarbage(); | 12858 GenerateSomeGarbage(); |
12866 } | 12859 } |
12867 return v8_str("Direct Getter Result"); | 12860 return v8_str("Direct Getter Result"); |
12868 } | 12861 } |
(...skipping 14 matching lines...) Expand all Loading... |
12883 v8::Handle<v8::ObjectTemplate> obj = v8::ObjectTemplate::New(isolate); | 12876 v8::Handle<v8::ObjectTemplate> obj = v8::ObjectTemplate::New(isolate); |
12884 obj->SetAccessor(v8_str("p1"), accessor); | 12877 obj->SetAccessor(v8_str("p1"), accessor); |
12885 context->Global()->Set(v8_str("o1"), obj->NewInstance()); | 12878 context->Global()->Set(v8_str("o1"), obj->NewInstance()); |
12886 p_getter_count = 0; | 12879 p_getter_count = 0; |
12887 v8::Handle<v8::Value> result = CompileRun( | 12880 v8::Handle<v8::Value> result = CompileRun( |
12888 "function f() {" | 12881 "function f() {" |
12889 " for (var i = 0; i < 30; i++) o1.p1;" | 12882 " for (var i = 0; i < 30; i++) o1.p1;" |
12890 " return o1.p1" | 12883 " return o1.p1" |
12891 "}" | 12884 "}" |
12892 "f();"); | 12885 "f();"); |
12893 CHECK(v8_str("Direct Getter Result")->Equals(result)); | 12886 CHECK_EQ(v8_str("Direct Getter Result"), result); |
12894 CHECK_EQ(31, p_getter_count); | 12887 CHECK_EQ(31, p_getter_count); |
12895 } | 12888 } |
12896 | 12889 |
12897 | 12890 |
12898 THREADED_PROFILED_TEST(LoadICFastApi_DirectCall_GCMoveStub) { | 12891 THREADED_PROFILED_TEST(LoadICFastApi_DirectCall_GCMoveStub) { |
12899 LoadICFastApi_DirectCall_GCMoveStub(DirectGetterCallback); | 12892 LoadICFastApi_DirectCall_GCMoveStub(DirectGetterCallback); |
12900 } | 12893 } |
12901 | 12894 |
12902 | 12895 |
12903 void ThrowingDirectGetterCallback( | 12896 void ThrowingDirectGetterCallback( |
12904 Local<String> name, | 12897 Local<String> name, |
12905 const v8::PropertyCallbackInfo<v8::Value>& info) { | 12898 const v8::PropertyCallbackInfo<v8::Value>& info) { |
12906 info.GetIsolate()->ThrowException(v8_str("g")); | 12899 info.GetIsolate()->ThrowException(v8_str("g")); |
12907 } | 12900 } |
12908 | 12901 |
12909 | 12902 |
12910 THREADED_TEST(LoadICFastApi_DirectCall_Throw) { | 12903 THREADED_TEST(LoadICFastApi_DirectCall_Throw) { |
12911 LocalContext context; | 12904 LocalContext context; |
12912 v8::Isolate* isolate = context->GetIsolate(); | 12905 v8::Isolate* isolate = context->GetIsolate(); |
12913 v8::HandleScope scope(isolate); | 12906 v8::HandleScope scope(isolate); |
12914 v8::Handle<v8::ObjectTemplate> obj = v8::ObjectTemplate::New(isolate); | 12907 v8::Handle<v8::ObjectTemplate> obj = v8::ObjectTemplate::New(isolate); |
12915 obj->SetAccessor(v8_str("p1"), ThrowingDirectGetterCallback); | 12908 obj->SetAccessor(v8_str("p1"), ThrowingDirectGetterCallback); |
12916 context->Global()->Set(v8_str("o1"), obj->NewInstance()); | 12909 context->Global()->Set(v8_str("o1"), obj->NewInstance()); |
12917 v8::Handle<Value> result = CompileRun( | 12910 v8::Handle<Value> result = CompileRun( |
12918 "var result = '';" | 12911 "var result = '';" |
12919 "for (var i = 0; i < 5; i++) {" | 12912 "for (var i = 0; i < 5; i++) {" |
12920 " try { o1.p1; } catch (e) { result += e; }" | 12913 " try { o1.p1; } catch (e) { result += e; }" |
12921 "}" | 12914 "}" |
12922 "result;"); | 12915 "result;"); |
12923 CHECK(v8_str("ggggg")->Equals(result)); | 12916 CHECK_EQ(v8_str("ggggg"), result); |
12924 } | 12917 } |
12925 | 12918 |
12926 | 12919 |
12927 THREADED_PROFILED_TEST(InterceptorCallICFastApi_TrivialSignature) { | 12920 THREADED_PROFILED_TEST(InterceptorCallICFastApi_TrivialSignature) { |
12928 int interceptor_call_count = 0; | 12921 int interceptor_call_count = 0; |
12929 v8::Isolate* isolate = CcTest::isolate(); | 12922 v8::Isolate* isolate = CcTest::isolate(); |
12930 v8::HandleScope scope(isolate); | 12923 v8::HandleScope scope(isolate); |
12931 v8::Handle<v8::FunctionTemplate> fun_templ = | 12924 v8::Handle<v8::FunctionTemplate> fun_templ = |
12932 v8::FunctionTemplate::New(isolate); | 12925 v8::FunctionTemplate::New(isolate); |
12933 v8::Handle<v8::FunctionTemplate> method_templ = | 12926 v8::Handle<v8::FunctionTemplate> method_templ = |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13095 "var saved_result = 0;" | 13088 "var saved_result = 0;" |
13096 "for (var i = 0; i < 100; i++) {" | 13089 "for (var i = 0; i < 100; i++) {" |
13097 " result = receiver.method(41);" | 13090 " result = receiver.method(41);" |
13098 " if (i == 50) {" | 13091 " if (i == 50) {" |
13099 " saved_result = result;" | 13092 " saved_result = result;" |
13100 " receiver = 333;" | 13093 " receiver = 333;" |
13101 " }" | 13094 " }" |
13102 "}"); | 13095 "}"); |
13103 CHECK(try_catch.HasCaught()); | 13096 CHECK(try_catch.HasCaught()); |
13104 // TODO(verwaest): Adjust message. | 13097 // TODO(verwaest): Adjust message. |
13105 CHECK(v8_str("TypeError: receiver.method is not a function") | 13098 CHECK_EQ(v8_str("TypeError: receiver.method is not a function"), |
13106 ->Equals(try_catch.Exception()->ToString(isolate))); | 13099 try_catch.Exception()->ToString(isolate)); |
13107 CHECK_EQ(42, context->Global()->Get(v8_str("saved_result"))->Int32Value()); | 13100 CHECK_EQ(42, context->Global()->Get(v8_str("saved_result"))->Int32Value()); |
13108 CHECK_GE(interceptor_call_count, 50); | 13101 CHECK_GE(interceptor_call_count, 50); |
13109 } | 13102 } |
13110 | 13103 |
13111 | 13104 |
13112 THREADED_PROFILED_TEST(InterceptorCallICFastApi_SimpleSignature_TypeError) { | 13105 THREADED_PROFILED_TEST(InterceptorCallICFastApi_SimpleSignature_TypeError) { |
13113 int interceptor_call_count = 0; | 13106 int interceptor_call_count = 0; |
13114 v8::Isolate* isolate = CcTest::isolate(); | 13107 v8::Isolate* isolate = CcTest::isolate(); |
13115 v8::HandleScope scope(isolate); | 13108 v8::HandleScope scope(isolate); |
13116 v8::Handle<v8::FunctionTemplate> fun_templ = | 13109 v8::Handle<v8::FunctionTemplate> fun_templ = |
(...skipping 20 matching lines...) Expand all Loading... |
13137 "var result = 0;" | 13130 "var result = 0;" |
13138 "var saved_result = 0;" | 13131 "var saved_result = 0;" |
13139 "for (var i = 0; i < 100; i++) {" | 13132 "for (var i = 0; i < 100; i++) {" |
13140 " result = receiver.method(41);" | 13133 " result = receiver.method(41);" |
13141 " if (i == 50) {" | 13134 " if (i == 50) {" |
13142 " saved_result = result;" | 13135 " saved_result = result;" |
13143 " receiver = {method: receiver.method};" | 13136 " receiver = {method: receiver.method};" |
13144 " }" | 13137 " }" |
13145 "}"); | 13138 "}"); |
13146 CHECK(try_catch.HasCaught()); | 13139 CHECK(try_catch.HasCaught()); |
13147 CHECK(v8_str("TypeError: Illegal invocation") | 13140 CHECK_EQ(v8_str("TypeError: Illegal invocation"), |
13148 ->Equals(try_catch.Exception()->ToString(isolate))); | 13141 try_catch.Exception()->ToString(isolate)); |
13149 CHECK_EQ(42, context->Global()->Get(v8_str("saved_result"))->Int32Value()); | 13142 CHECK_EQ(42, context->Global()->Get(v8_str("saved_result"))->Int32Value()); |
13150 CHECK_GE(interceptor_call_count, 50); | 13143 CHECK_GE(interceptor_call_count, 50); |
13151 } | 13144 } |
13152 | 13145 |
13153 | 13146 |
13154 THREADED_PROFILED_TEST(CallICFastApi_TrivialSignature) { | 13147 THREADED_PROFILED_TEST(CallICFastApi_TrivialSignature) { |
13155 v8::Isolate* isolate = CcTest::isolate(); | 13148 v8::Isolate* isolate = CcTest::isolate(); |
13156 v8::HandleScope scope(isolate); | 13149 v8::HandleScope scope(isolate); |
13157 v8::Handle<v8::FunctionTemplate> fun_templ = | 13150 v8::Handle<v8::FunctionTemplate> fun_templ = |
13158 v8::FunctionTemplate::New(isolate); | 13151 v8::FunctionTemplate::New(isolate); |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13270 "var saved_result = 0;" | 13263 "var saved_result = 0;" |
13271 "for (var i = 0; i < 100; i++) {" | 13264 "for (var i = 0; i < 100; i++) {" |
13272 " result = receiver.method(41);" | 13265 " result = receiver.method(41);" |
13273 " if (i == 50) {" | 13266 " if (i == 50) {" |
13274 " saved_result = result;" | 13267 " saved_result = result;" |
13275 " receiver = 333;" | 13268 " receiver = 333;" |
13276 " }" | 13269 " }" |
13277 "}"); | 13270 "}"); |
13278 CHECK(try_catch.HasCaught()); | 13271 CHECK(try_catch.HasCaught()); |
13279 // TODO(verwaest): Adjust message. | 13272 // TODO(verwaest): Adjust message. |
13280 CHECK(v8_str("TypeError: receiver.method is not a function") | 13273 CHECK_EQ(v8_str("TypeError: receiver.method is not a function"), |
13281 ->Equals(try_catch.Exception()->ToString(isolate))); | 13274 try_catch.Exception()->ToString(isolate)); |
13282 CHECK_EQ(42, context->Global()->Get(v8_str("saved_result"))->Int32Value()); | 13275 CHECK_EQ(42, context->Global()->Get(v8_str("saved_result"))->Int32Value()); |
13283 } | 13276 } |
13284 | 13277 |
13285 | 13278 |
13286 THREADED_PROFILED_TEST(CallICFastApi_SimpleSignature_TypeError) { | 13279 THREADED_PROFILED_TEST(CallICFastApi_SimpleSignature_TypeError) { |
13287 v8::Isolate* isolate = CcTest::isolate(); | 13280 v8::Isolate* isolate = CcTest::isolate(); |
13288 v8::HandleScope scope(isolate); | 13281 v8::HandleScope scope(isolate); |
13289 v8::Handle<v8::FunctionTemplate> fun_templ = | 13282 v8::Handle<v8::FunctionTemplate> fun_templ = |
13290 v8::FunctionTemplate::New(isolate); | 13283 v8::FunctionTemplate::New(isolate); |
13291 v8::Handle<v8::FunctionTemplate> method_templ = v8::FunctionTemplate::New( | 13284 v8::Handle<v8::FunctionTemplate> method_templ = v8::FunctionTemplate::New( |
(...skipping 16 matching lines...) Expand all Loading... |
13308 "var result = 0;" | 13301 "var result = 0;" |
13309 "var saved_result = 0;" | 13302 "var saved_result = 0;" |
13310 "for (var i = 0; i < 100; i++) {" | 13303 "for (var i = 0; i < 100; i++) {" |
13311 " result = receiver.method(41);" | 13304 " result = receiver.method(41);" |
13312 " if (i == 50) {" | 13305 " if (i == 50) {" |
13313 " saved_result = result;" | 13306 " saved_result = result;" |
13314 " receiver = Object.create(receiver);" | 13307 " receiver = Object.create(receiver);" |
13315 " }" | 13308 " }" |
13316 "}"); | 13309 "}"); |
13317 CHECK(try_catch.HasCaught()); | 13310 CHECK(try_catch.HasCaught()); |
13318 CHECK(v8_str("TypeError: Illegal invocation") | 13311 CHECK_EQ(v8_str("TypeError: Illegal invocation"), |
13319 ->Equals(try_catch.Exception()->ToString(isolate))); | 13312 try_catch.Exception()->ToString(isolate)); |
13320 CHECK_EQ(42, context->Global()->Get(v8_str("saved_result"))->Int32Value()); | 13313 CHECK_EQ(42, context->Global()->Get(v8_str("saved_result"))->Int32Value()); |
13321 } | 13314 } |
13322 | 13315 |
13323 | 13316 |
13324 v8::Handle<Value> keyed_call_ic_function; | 13317 v8::Handle<Value> keyed_call_ic_function; |
13325 | 13318 |
13326 static void InterceptorKeyedCallICGetter( | 13319 static void InterceptorKeyedCallICGetter( |
13327 Local<Name> name, const v8::PropertyCallbackInfo<v8::Value>& info) { | 13320 Local<Name> name, const v8::PropertyCallbackInfo<v8::Value>& info) { |
13328 ApiTestFuzzer::Fuzz(); | 13321 ApiTestFuzzer::Fuzz(); |
13329 if (v8_str("x")->Equals(name)) { | 13322 if (v8_str("x")->Equals(name)) { |
(...skipping 1852 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
15182 | 15175 |
15183 isolate->SetJitCodeEventHandler(v8::kJitCodeEventEnumExisting, | 15176 isolate->SetJitCodeEventHandler(v8::kJitCodeEventEnumExisting, |
15184 event_handler); | 15177 event_handler); |
15185 isolate->SetJitCodeEventHandler(v8::kJitCodeEventDefault, NULL); | 15178 isolate->SetJitCodeEventHandler(v8::kJitCodeEventDefault, NULL); |
15186 | 15179 |
15187 jitcode_line_info = NULL; | 15180 jitcode_line_info = NULL; |
15188 // We expect that we got some events. Note that if we could get code removal | 15181 // We expect that we got some events. Note that if we could get code removal |
15189 // notifications, we could compare two collections, one created by listening | 15182 // notifications, we could compare two collections, one created by listening |
15190 // from the time of creation of an isolate, and the other by subscribing | 15183 // from the time of creation of an isolate, and the other by subscribing |
15191 // with EnumExisting. | 15184 // with EnumExisting. |
15192 CHECK_LT(0u, code.occupancy()); | 15185 CHECK_LT(0, code.occupancy()); |
15193 | 15186 |
15194 code_map = NULL; | 15187 code_map = NULL; |
15195 } | 15188 } |
15196 | 15189 |
15197 isolate->Exit(); | 15190 isolate->Exit(); |
15198 isolate->Dispose(); | 15191 isolate->Dispose(); |
15199 } | 15192 } |
15200 | 15193 |
15201 | 15194 |
15202 THREADED_TEST(ExternalAllocatedMemory) { | 15195 THREADED_TEST(ExternalAllocatedMemory) { |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
15264 CHECK(result.IsEmpty()); | 15257 CHECK(result.IsEmpty()); |
15265 CHECK(try_catch.HasCaught()); | 15258 CHECK(try_catch.HasCaught()); |
15266 v8::Handle<v8::Message> message = try_catch.Message(); | 15259 v8::Handle<v8::Message> message = try_catch.Message(); |
15267 CHECK(!message.IsEmpty()); | 15260 CHECK(!message.IsEmpty()); |
15268 CHECK_EQ(10 + line_offset, message->GetLineNumber()); | 15261 CHECK_EQ(10 + line_offset, message->GetLineNumber()); |
15269 CHECK_EQ(91, message->GetStartPosition()); | 15262 CHECK_EQ(91, message->GetStartPosition()); |
15270 CHECK_EQ(92, message->GetEndPosition()); | 15263 CHECK_EQ(92, message->GetEndPosition()); |
15271 CHECK_EQ(2, message->GetStartColumn()); | 15264 CHECK_EQ(2, message->GetStartColumn()); |
15272 CHECK_EQ(3, message->GetEndColumn()); | 15265 CHECK_EQ(3, message->GetEndColumn()); |
15273 v8::String::Utf8Value line(message->GetSourceLine()); | 15266 v8::String::Utf8Value line(message->GetSourceLine()); |
15274 CHECK_EQ(0, strcmp(" throw 'nirk';", *line)); | 15267 CHECK_EQ(" throw 'nirk';", *line); |
15275 v8::String::Utf8Value name(message->GetScriptOrigin().ResourceName()); | 15268 v8::String::Utf8Value name(message->GetScriptOrigin().ResourceName()); |
15276 CHECK_EQ(0, strcmp(resource_name, *name)); | 15269 CHECK_EQ(resource_name, *name); |
15277 } | 15270 } |
15278 | 15271 |
15279 | 15272 |
15280 THREADED_TEST(TryCatchSourceInfo) { | 15273 THREADED_TEST(TryCatchSourceInfo) { |
15281 LocalContext context; | 15274 LocalContext context; |
15282 v8::HandleScope scope(context->GetIsolate()); | 15275 v8::HandleScope scope(context->GetIsolate()); |
15283 v8::Local<v8::String> source = v8_str( | 15276 v8::Local<v8::String> source = v8_str( |
15284 "function Foo() {\n" | 15277 "function Foo() {\n" |
15285 " return Bar();\n" | 15278 " return Bar();\n" |
15286 "}\n" | 15279 "}\n" |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
15344 LocalContext context; | 15337 LocalContext context; |
15345 v8::Isolate* isolate = context->GetIsolate(); | 15338 v8::Isolate* isolate = context->GetIsolate(); |
15346 v8::HandleScope scope(isolate); | 15339 v8::HandleScope scope(isolate); |
15347 Local<ObjectTemplate> t = ObjectTemplate::New(isolate); | 15340 Local<ObjectTemplate> t = ObjectTemplate::New(isolate); |
15348 t->Set(v8_str("asdf"), | 15341 t->Set(v8_str("asdf"), |
15349 v8::FunctionTemplate::New(isolate, FunctionNameCallback)); | 15342 v8::FunctionTemplate::New(isolate, FunctionNameCallback)); |
15350 context->Global()->Set(v8_str("obj"), t->NewInstance()); | 15343 context->Global()->Set(v8_str("obj"), t->NewInstance()); |
15351 v8::Handle<v8::Value> value = CompileRun("obj.asdf.name"); | 15344 v8::Handle<v8::Value> value = CompileRun("obj.asdf.name"); |
15352 CHECK(value->IsString()); | 15345 CHECK(value->IsString()); |
15353 v8::String::Utf8Value name(value); | 15346 v8::String::Utf8Value name(value); |
15354 CHECK_EQ(0, strcmp("asdf", *name)); | 15347 CHECK_EQ("asdf", *name); |
15355 } | 15348 } |
15356 | 15349 |
15357 | 15350 |
15358 THREADED_TEST(DateAccess) { | 15351 THREADED_TEST(DateAccess) { |
15359 LocalContext context; | 15352 LocalContext context; |
15360 v8::HandleScope scope(context->GetIsolate()); | 15353 v8::HandleScope scope(context->GetIsolate()); |
15361 v8::Handle<v8::Value> date = | 15354 v8::Handle<v8::Value> date = |
15362 v8::Date::New(context->GetIsolate(), 1224744689038.0); | 15355 v8::Date::New(context->GetIsolate(), 1224744689038.0); |
15363 CHECK(date->IsDate()); | 15356 CHECK(date->IsDate()); |
15364 CHECK_EQ(1224744689038.0, date.As<v8::Date>()->ValueOf()); | 15357 CHECK_EQ(1224744689038.0, date.As<v8::Date>()->ValueOf()); |
15365 } | 15358 } |
15366 | 15359 |
15367 | 15360 |
15368 void CheckProperties(v8::Isolate* isolate, v8::Handle<v8::Value> val, | 15361 void CheckProperties(v8::Isolate* isolate, |
15369 unsigned elmc, const char* elmv[]) { | 15362 v8::Handle<v8::Value> val, |
| 15363 int elmc, |
| 15364 const char* elmv[]) { |
15370 v8::Handle<v8::Object> obj = val.As<v8::Object>(); | 15365 v8::Handle<v8::Object> obj = val.As<v8::Object>(); |
15371 v8::Handle<v8::Array> props = obj->GetPropertyNames(); | 15366 v8::Handle<v8::Array> props = obj->GetPropertyNames(); |
15372 CHECK_EQ(elmc, props->Length()); | 15367 CHECK_EQ(elmc, props->Length()); |
15373 for (unsigned i = 0; i < elmc; i++) { | 15368 for (int i = 0; i < elmc; i++) { |
15374 v8::String::Utf8Value elm(props->Get(v8::Integer::New(isolate, i))); | 15369 v8::String::Utf8Value elm(props->Get(v8::Integer::New(isolate, i))); |
15375 CHECK_EQ(0, strcmp(elmv[i], *elm)); | 15370 CHECK_EQ(elmv[i], *elm); |
15376 } | 15371 } |
15377 } | 15372 } |
15378 | 15373 |
15379 | 15374 |
15380 void CheckOwnProperties(v8::Isolate* isolate, v8::Handle<v8::Value> val, | 15375 void CheckOwnProperties(v8::Isolate* isolate, |
15381 unsigned elmc, const char* elmv[]) { | 15376 v8::Handle<v8::Value> val, |
| 15377 int elmc, |
| 15378 const char* elmv[]) { |
15382 v8::Handle<v8::Object> obj = val.As<v8::Object>(); | 15379 v8::Handle<v8::Object> obj = val.As<v8::Object>(); |
15383 v8::Handle<v8::Array> props = obj->GetOwnPropertyNames(); | 15380 v8::Handle<v8::Array> props = obj->GetOwnPropertyNames(); |
15384 CHECK_EQ(elmc, props->Length()); | 15381 CHECK_EQ(elmc, props->Length()); |
15385 for (unsigned i = 0; i < elmc; i++) { | 15382 for (int i = 0; i < elmc; i++) { |
15386 v8::String::Utf8Value elm(props->Get(v8::Integer::New(isolate, i))); | 15383 v8::String::Utf8Value elm(props->Get(v8::Integer::New(isolate, i))); |
15387 CHECK_EQ(0, strcmp(elmv[i], *elm)); | 15384 CHECK_EQ(elmv[i], *elm); |
15388 } | 15385 } |
15389 } | 15386 } |
15390 | 15387 |
15391 | 15388 |
15392 THREADED_TEST(PropertyEnumeration) { | 15389 THREADED_TEST(PropertyEnumeration) { |
15393 LocalContext context; | 15390 LocalContext context; |
15394 v8::Isolate* isolate = context->GetIsolate(); | 15391 v8::Isolate* isolate = context->GetIsolate(); |
15395 v8::HandleScope scope(isolate); | 15392 v8::HandleScope scope(isolate); |
15396 v8::Handle<v8::Value> obj = CompileRun( | 15393 v8::Handle<v8::Value> obj = CompileRun( |
15397 "var result = [];" | 15394 "var result = [];" |
15398 "result[0] = {};" | 15395 "result[0] = {};" |
15399 "result[1] = {a: 1, b: 2};" | 15396 "result[1] = {a: 1, b: 2};" |
15400 "result[2] = [1, 2, 3];" | 15397 "result[2] = [1, 2, 3];" |
15401 "var proto = {x: 1, y: 2, z: 3};" | 15398 "var proto = {x: 1, y: 2, z: 3};" |
15402 "var x = { __proto__: proto, w: 0, z: 1 };" | 15399 "var x = { __proto__: proto, w: 0, z: 1 };" |
15403 "result[3] = x;" | 15400 "result[3] = x;" |
15404 "result;"); | 15401 "result;"); |
15405 v8::Handle<v8::Array> elms = obj.As<v8::Array>(); | 15402 v8::Handle<v8::Array> elms = obj.As<v8::Array>(); |
15406 CHECK_EQ(4u, elms->Length()); | 15403 CHECK_EQ(4, elms->Length()); |
15407 int elmc0 = 0; | 15404 int elmc0 = 0; |
15408 const char** elmv0 = NULL; | 15405 const char** elmv0 = NULL; |
15409 CheckProperties( | 15406 CheckProperties( |
15410 isolate, elms->Get(v8::Integer::New(isolate, 0)), elmc0, elmv0); | 15407 isolate, elms->Get(v8::Integer::New(isolate, 0)), elmc0, elmv0); |
15411 CheckOwnProperties( | 15408 CheckOwnProperties( |
15412 isolate, elms->Get(v8::Integer::New(isolate, 0)), elmc0, elmv0); | 15409 isolate, elms->Get(v8::Integer::New(isolate, 0)), elmc0, elmv0); |
15413 int elmc1 = 2; | 15410 int elmc1 = 2; |
15414 const char* elmv1[] = {"a", "b"}; | 15411 const char* elmv1[] = {"a", "b"}; |
15415 CheckProperties( | 15412 CheckProperties( |
15416 isolate, elms->Get(v8::Integer::New(isolate, 1)), elmc1, elmv1); | 15413 isolate, elms->Get(v8::Integer::New(isolate, 1)), elmc1, elmv1); |
(...skipping 23 matching lines...) Expand all Loading... |
15440 v8::Handle<v8::Value> obj = CompileRun( | 15437 v8::Handle<v8::Value> obj = CompileRun( |
15441 "var result = [];" | 15438 "var result = [];" |
15442 "result[0] = {};" | 15439 "result[0] = {};" |
15443 "result[1] = {a: 1, b: 2};" | 15440 "result[1] = {a: 1, b: 2};" |
15444 "result[2] = [1, 2, 3];" | 15441 "result[2] = [1, 2, 3];" |
15445 "var proto = {x: 1, y: 2, z: 3};" | 15442 "var proto = {x: 1, y: 2, z: 3};" |
15446 "var x = { __proto__: proto, w: 0, z: 1 };" | 15443 "var x = { __proto__: proto, w: 0, z: 1 };" |
15447 "result[3] = x;" | 15444 "result[3] = x;" |
15448 "result;"); | 15445 "result;"); |
15449 v8::Handle<v8::Array> elms = obj.As<v8::Array>(); | 15446 v8::Handle<v8::Array> elms = obj.As<v8::Array>(); |
15450 CHECK_EQ(4u, elms->Length()); | 15447 CHECK_EQ(4, elms->Length()); |
15451 int elmc0 = 0; | 15448 int elmc0 = 0; |
15452 const char** elmv0 = NULL; | 15449 const char** elmv0 = NULL; |
15453 CheckProperties(isolate, | 15450 CheckProperties(isolate, |
15454 elms->Get(v8::Integer::New(isolate, 0)), elmc0, elmv0); | 15451 elms->Get(v8::Integer::New(isolate, 0)), elmc0, elmv0); |
15455 | 15452 |
15456 v8::Handle<v8::Value> val = elms->Get(v8::Integer::New(isolate, 0)); | 15453 v8::Handle<v8::Value> val = elms->Get(v8::Integer::New(isolate, 0)); |
15457 v8::Handle<v8::Array> props = val.As<v8::Object>()->GetPropertyNames(); | 15454 v8::Handle<v8::Array> props = val.As<v8::Object>()->GetPropertyNames(); |
15458 CHECK_EQ(0u, props->Length()); | 15455 CHECK_EQ(0, props->Length()); |
15459 for (uint32_t i = 0; i < props->Length(); i++) { | 15456 for (uint32_t i = 0; i < props->Length(); i++) { |
15460 printf("p[%u]\n", i); | 15457 printf("p[%u]\n", i); |
15461 } | 15458 } |
15462 } | 15459 } |
15463 | 15460 |
15464 static bool NamedSetAccessBlocker(Local<v8::Object> obj, | 15461 static bool NamedSetAccessBlocker(Local<v8::Object> obj, |
15465 Local<Value> name, | 15462 Local<Value> name, |
15466 v8::AccessType type, | 15463 v8::AccessType type, |
15467 Local<Value> data) { | 15464 Local<Value> data) { |
15468 return type != v8::ACCESS_SET; | 15465 return type != v8::ACCESS_SET; |
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
15832 "rv.alpha = 'hello';" \ | 15829 "rv.alpha = 'hello';" \ |
15833 "rv.beta = 123;" \ | 15830 "rv.beta = 123;" \ |
15834 "rv;"; | 15831 "rv;"; |
15835 | 15832 |
15836 // Create an object, verify basics. | 15833 // Create an object, verify basics. |
15837 Local<Value> val = CompileRun(sample); | 15834 Local<Value> val = CompileRun(sample); |
15838 CHECK(val->IsObject()); | 15835 CHECK(val->IsObject()); |
15839 Local<v8::Object> obj = val.As<v8::Object>(); | 15836 Local<v8::Object> obj = val.As<v8::Object>(); |
15840 obj->Set(v8_str("gamma"), v8_str("cloneme")); | 15837 obj->Set(v8_str("gamma"), v8_str("cloneme")); |
15841 | 15838 |
15842 CHECK(v8_str("hello")->Equals(obj->Get(v8_str("alpha")))); | 15839 CHECK_EQ(v8_str("hello"), obj->Get(v8_str("alpha"))); |
15843 CHECK(v8::Integer::New(isolate, 123)->Equals(obj->Get(v8_str("beta")))); | 15840 CHECK_EQ(v8::Integer::New(isolate, 123), obj->Get(v8_str("beta"))); |
15844 CHECK(v8_str("cloneme")->Equals(obj->Get(v8_str("gamma")))); | 15841 CHECK_EQ(v8_str("cloneme"), obj->Get(v8_str("gamma"))); |
15845 | 15842 |
15846 // Clone it. | 15843 // Clone it. |
15847 Local<v8::Object> clone = obj->Clone(); | 15844 Local<v8::Object> clone = obj->Clone(); |
15848 CHECK(v8_str("hello")->Equals(clone->Get(v8_str("alpha")))); | 15845 CHECK_EQ(v8_str("hello"), clone->Get(v8_str("alpha"))); |
15849 CHECK(v8::Integer::New(isolate, 123)->Equals(clone->Get(v8_str("beta")))); | 15846 CHECK_EQ(v8::Integer::New(isolate, 123), clone->Get(v8_str("beta"))); |
15850 CHECK(v8_str("cloneme")->Equals(clone->Get(v8_str("gamma")))); | 15847 CHECK_EQ(v8_str("cloneme"), clone->Get(v8_str("gamma"))); |
15851 | 15848 |
15852 // Set a property on the clone, verify each object. | 15849 // Set a property on the clone, verify each object. |
15853 clone->Set(v8_str("beta"), v8::Integer::New(isolate, 456)); | 15850 clone->Set(v8_str("beta"), v8::Integer::New(isolate, 456)); |
15854 CHECK(v8::Integer::New(isolate, 123)->Equals(obj->Get(v8_str("beta")))); | 15851 CHECK_EQ(v8::Integer::New(isolate, 123), obj->Get(v8_str("beta"))); |
15855 CHECK(v8::Integer::New(isolate, 456)->Equals(clone->Get(v8_str("beta")))); | 15852 CHECK_EQ(v8::Integer::New(isolate, 456), clone->Get(v8_str("beta"))); |
15856 } | 15853 } |
15857 | 15854 |
15858 | 15855 |
15859 class OneByteVectorResource : public v8::String::ExternalOneByteStringResource { | 15856 class OneByteVectorResource : public v8::String::ExternalOneByteStringResource { |
15860 public: | 15857 public: |
15861 explicit OneByteVectorResource(i::Vector<const char> vector) | 15858 explicit OneByteVectorResource(i::Vector<const char> vector) |
15862 : data_(vector) {} | 15859 : data_(vector) {} |
15863 virtual ~OneByteVectorResource() {} | 15860 virtual ~OneByteVectorResource() {} |
15864 virtual size_t length() const { return data_.length(); } | 15861 virtual size_t length() const { return data_.length(); } |
15865 virtual const char* data() const { return data_.start(); } | 15862 virtual const char* data() const { return data_.start(); } |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
15960 "/[^a-z]/.test(slice);" | 15957 "/[^a-z]/.test(slice);" |
15961 "/[^a-z]/.test(slice_on_cons);"); | 15958 "/[^a-z]/.test(slice_on_cons);"); |
15962 const char* expected_cons = | 15959 const char* expected_cons = |
15963 "Now is the time for all good men to come to the aid of the party" | 15960 "Now is the time for all good men to come to the aid of the party" |
15964 "Now is the time for all good men to come to the aid of the party"; | 15961 "Now is the time for all good men to come to the aid of the party"; |
15965 const char* expected_slice = | 15962 const char* expected_slice = |
15966 "ow is the time for all good men to come to the aid of the part"; | 15963 "ow is the time for all good men to come to the aid of the part"; |
15967 const char* expected_slice_on_cons = | 15964 const char* expected_slice_on_cons = |
15968 "ow is the time for all good men to come to the aid of the party" | 15965 "ow is the time for all good men to come to the aid of the party" |
15969 "Now is the time for all good men to come to the aid of the part"; | 15966 "Now is the time for all good men to come to the aid of the part"; |
15970 CHECK(String::NewFromUtf8(env->GetIsolate(), expected_cons) | 15967 CHECK_EQ(String::NewFromUtf8(env->GetIsolate(), expected_cons), |
15971 ->Equals(env->Global()->Get(v8_str("cons")))); | 15968 env->Global()->Get(v8_str("cons"))); |
15972 CHECK(String::NewFromUtf8(env->GetIsolate(), expected_slice) | 15969 CHECK_EQ(String::NewFromUtf8(env->GetIsolate(), expected_slice), |
15973 ->Equals(env->Global()->Get(v8_str("slice")))); | 15970 env->Global()->Get(v8_str("slice"))); |
15974 CHECK(String::NewFromUtf8(env->GetIsolate(), expected_slice_on_cons) | 15971 CHECK_EQ(String::NewFromUtf8(env->GetIsolate(), expected_slice_on_cons), |
15975 ->Equals(env->Global()->Get(v8_str("slice_on_cons")))); | 15972 env->Global()->Get(v8_str("slice_on_cons"))); |
15976 } | 15973 } |
15977 i::DeleteArray(two_byte_string); | 15974 i::DeleteArray(two_byte_string); |
15978 } | 15975 } |
15979 | 15976 |
15980 | 15977 |
15981 TEST(CompileExternalTwoByteSource) { | 15978 TEST(CompileExternalTwoByteSource) { |
15982 LocalContext context; | 15979 LocalContext context; |
15983 v8::HandleScope scope(context->GetIsolate()); | 15980 v8::HandleScope scope(context->GetIsolate()); |
15984 | 15981 |
15985 // This is a very short list of sources, which currently is to check for a | 15982 // This is a very short list of sources, which currently is to check for a |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
16088 v8::Handle<v8::Object> global = context->Global(); | 16085 v8::Handle<v8::Object> global = context->Global(); |
16089 v8::Handle<v8::Object> global_proto = | 16086 v8::Handle<v8::Object> global_proto = |
16090 v8::Handle<v8::Object>::Cast(global->Get(v8_str("__proto__"))); | 16087 v8::Handle<v8::Object>::Cast(global->Get(v8_str("__proto__"))); |
16091 global_proto->ForceSet(v8_str("x"), v8::Integer::New(isolate, 0), | 16088 global_proto->ForceSet(v8_str("x"), v8::Integer::New(isolate, 0), |
16092 v8::ReadOnly); | 16089 v8::ReadOnly); |
16093 global_proto->ForceSet(v8_str("y"), v8::Integer::New(isolate, 0), | 16090 global_proto->ForceSet(v8_str("y"), v8::Integer::New(isolate, 0), |
16094 v8::ReadOnly); | 16091 v8::ReadOnly); |
16095 // Check without 'eval' or 'with'. | 16092 // Check without 'eval' or 'with'. |
16096 v8::Handle<v8::Value> res = | 16093 v8::Handle<v8::Value> res = |
16097 CompileRun("function f() { x = 42; return x; }; f()"); | 16094 CompileRun("function f() { x = 42; return x; }; f()"); |
16098 CHECK(v8::Integer::New(isolate, 0)->Equals(res)); | 16095 CHECK_EQ(v8::Integer::New(isolate, 0), res); |
16099 // Check with 'eval'. | 16096 // Check with 'eval'. |
16100 res = CompileRun("function f() { eval('1'); y = 43; return y; }; f()"); | 16097 res = CompileRun("function f() { eval('1'); y = 43; return y; }; f()"); |
16101 CHECK(v8::Integer::New(isolate, 0)->Equals(res)); | 16098 CHECK_EQ(v8::Integer::New(isolate, 0), res); |
16102 // Check with 'with'. | 16099 // Check with 'with'. |
16103 res = CompileRun("function f() { with (this) { y = 44 }; return y; }; f()"); | 16100 res = CompileRun("function f() { with (this) { y = 44 }; return y; }; f()"); |
16104 CHECK(v8::Integer::New(isolate, 0)->Equals(res)); | 16101 CHECK_EQ(v8::Integer::New(isolate, 0), res); |
16105 } | 16102 } |
16106 | 16103 |
16107 static int force_set_set_count = 0; | 16104 static int force_set_set_count = 0; |
16108 static int force_set_get_count = 0; | 16105 static int force_set_get_count = 0; |
16109 bool pass_on_get = false; | 16106 bool pass_on_get = false; |
16110 | 16107 |
16111 static void ForceSetGetter(v8::Local<v8::String> name, | 16108 static void ForceSetGetter(v8::Local<v8::String> name, |
16112 const v8::PropertyCallbackInfo<v8::Value>& info) { | 16109 const v8::PropertyCallbackInfo<v8::Value>& info) { |
16113 force_set_get_count++; | 16110 force_set_get_count++; |
16114 if (pass_on_get) { | 16111 if (pass_on_get) { |
(...skipping 1460 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
17575 | 17572 |
17576 | 17573 |
17577 void ExtArrayLimitsHelper(v8::Isolate* isolate, | 17574 void ExtArrayLimitsHelper(v8::Isolate* isolate, |
17578 v8::ExternalArrayType array_type, | 17575 v8::ExternalArrayType array_type, |
17579 int size) { | 17576 int size) { |
17580 v8::Handle<v8::Object> obj = v8::Object::New(isolate); | 17577 v8::Handle<v8::Object> obj = v8::Object::New(isolate); |
17581 v8::V8::SetFatalErrorHandler(StoringErrorCallback); | 17578 v8::V8::SetFatalErrorHandler(StoringErrorCallback); |
17582 last_location = last_message = NULL; | 17579 last_location = last_message = NULL; |
17583 obj->SetIndexedPropertiesToExternalArrayData(NULL, array_type, size); | 17580 obj->SetIndexedPropertiesToExternalArrayData(NULL, array_type, size); |
17584 CHECK(!obj->HasIndexedPropertiesInExternalArrayData()); | 17581 CHECK(!obj->HasIndexedPropertiesInExternalArrayData()); |
17585 CHECK(last_location); | 17582 CHECK_NE(NULL, last_location); |
17586 CHECK(last_message); | 17583 CHECK_NE(NULL, last_message); |
17587 } | 17584 } |
17588 | 17585 |
17589 | 17586 |
17590 TEST(ExternalArrayLimits) { | 17587 TEST(ExternalArrayLimits) { |
17591 LocalContext context; | 17588 LocalContext context; |
17592 v8::Isolate* isolate = context->GetIsolate(); | 17589 v8::Isolate* isolate = context->GetIsolate(); |
17593 v8::HandleScope scope(isolate); | 17590 v8::HandleScope scope(isolate); |
17594 ExtArrayLimitsHelper(isolate, v8::kExternalInt8Array, 0x40000000); | 17591 ExtArrayLimitsHelper(isolate, v8::kExternalInt8Array, 0x40000000); |
17595 ExtArrayLimitsHelper(isolate, v8::kExternalInt8Array, 0xffffffff); | 17592 ExtArrayLimitsHelper(isolate, v8::kExternalInt8Array, 0xffffffff); |
17596 ExtArrayLimitsHelper(isolate, v8::kExternalUint8Array, 0x40000000); | 17593 ExtArrayLimitsHelper(isolate, v8::kExternalUint8Array, 0x40000000); |
(...skipping 27 matching lines...) Expand all Loading... |
17624 v8::Isolate* isolate = env->GetIsolate(); | 17621 v8::Isolate* isolate = env->GetIsolate(); |
17625 v8::HandleScope handle_scope(isolate); | 17622 v8::HandleScope handle_scope(isolate); |
17626 | 17623 |
17627 Local<v8::ArrayBuffer> ab = | 17624 Local<v8::ArrayBuffer> ab = |
17628 v8::ArrayBuffer::New(isolate, backing_store.start(), | 17625 v8::ArrayBuffer::New(isolate, backing_store.start(), |
17629 (kElementCount + 2) * sizeof(ElementType)); | 17626 (kElementCount + 2) * sizeof(ElementType)); |
17630 Local<TypedArray> ta = | 17627 Local<TypedArray> ta = |
17631 TypedArray::New(ab, 2*sizeof(ElementType), kElementCount); | 17628 TypedArray::New(ab, 2*sizeof(ElementType), kElementCount); |
17632 CheckInternalFieldsAreZero<v8::ArrayBufferView>(ta); | 17629 CheckInternalFieldsAreZero<v8::ArrayBufferView>(ta); |
17633 CHECK_EQ(kElementCount, static_cast<int>(ta->Length())); | 17630 CHECK_EQ(kElementCount, static_cast<int>(ta->Length())); |
17634 CHECK_EQ(2 * sizeof(ElementType), ta->ByteOffset()); | 17631 CHECK_EQ(2*sizeof(ElementType), static_cast<int>(ta->ByteOffset())); |
17635 CHECK_EQ(kElementCount * sizeof(ElementType), ta->ByteLength()); | 17632 CHECK_EQ(kElementCount*sizeof(ElementType), |
17636 CHECK(ab->Equals(ta->Buffer())); | 17633 static_cast<int>(ta->ByteLength())); |
| 17634 CHECK_EQ(ab, ta->Buffer()); |
17637 | 17635 |
17638 ElementType* data = backing_store.start() + 2; | 17636 ElementType* data = backing_store.start() + 2; |
17639 for (int i = 0; i < kElementCount; i++) { | 17637 for (int i = 0; i < kElementCount; i++) { |
17640 data[i] = static_cast<ElementType>(i); | 17638 data[i] = static_cast<ElementType>(i); |
17641 } | 17639 } |
17642 | 17640 |
17643 ObjectWithExternalArrayTestHelper<ExternalArrayClass, ElementType>( | 17641 ObjectWithExternalArrayTestHelper<ExternalArrayClass, ElementType>( |
17644 env.local(), ta, kElementCount, array_type, low, high); | 17642 env.local(), ta, kElementCount, array_type, low, high); |
17645 } | 17643 } |
17646 | 17644 |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
17709 | 17707 |
17710 LocalContext env; | 17708 LocalContext env; |
17711 v8::Isolate* isolate = env->GetIsolate(); | 17709 v8::Isolate* isolate = env->GetIsolate(); |
17712 v8::HandleScope handle_scope(isolate); | 17710 v8::HandleScope handle_scope(isolate); |
17713 | 17711 |
17714 Local<v8::ArrayBuffer> ab = | 17712 Local<v8::ArrayBuffer> ab = |
17715 v8::ArrayBuffer::New(isolate, backing_store.start(), 2 + kSize); | 17713 v8::ArrayBuffer::New(isolate, backing_store.start(), 2 + kSize); |
17716 Local<v8::DataView> dv = | 17714 Local<v8::DataView> dv = |
17717 v8::DataView::New(ab, 2, kSize); | 17715 v8::DataView::New(ab, 2, kSize); |
17718 CheckInternalFieldsAreZero<v8::ArrayBufferView>(dv); | 17716 CheckInternalFieldsAreZero<v8::ArrayBufferView>(dv); |
17719 CHECK_EQ(2u, dv->ByteOffset()); | 17717 CHECK_EQ(2, static_cast<int>(dv->ByteOffset())); |
17720 CHECK_EQ(kSize, static_cast<int>(dv->ByteLength())); | 17718 CHECK_EQ(kSize, static_cast<int>(dv->ByteLength())); |
17721 CHECK(ab->Equals(dv->Buffer())); | 17719 CHECK_EQ(ab, dv->Buffer()); |
17722 } | 17720 } |
17723 | 17721 |
17724 | 17722 |
17725 #define IS_ARRAY_BUFFER_VIEW_TEST(View) \ | 17723 #define IS_ARRAY_BUFFER_VIEW_TEST(View) \ |
17726 THREADED_TEST(Is##View) { \ | 17724 THREADED_TEST(Is##View) { \ |
17727 LocalContext env; \ | 17725 LocalContext env; \ |
17728 v8::Isolate* isolate = env->GetIsolate(); \ | 17726 v8::Isolate* isolate = env->GetIsolate(); \ |
17729 v8::HandleScope handle_scope(isolate); \ | 17727 v8::HandleScope handle_scope(isolate); \ |
17730 \ | 17728 \ |
17731 Handle<Value> result = CompileRun( \ | 17729 Handle<Value> result = CompileRun( \ |
(...skipping 748 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
18480 const v8::FunctionCallbackInfo<v8::Value>& args) { | 18478 const v8::FunctionCallbackInfo<v8::Value>& args) { |
18481 v8::HandleScope scope(args.GetIsolate()); | 18479 v8::HandleScope scope(args.GetIsolate()); |
18482 v8::Handle<v8::StackTrace> stackTrace = v8::StackTrace::CurrentStackTrace( | 18480 v8::Handle<v8::StackTrace> stackTrace = v8::StackTrace::CurrentStackTrace( |
18483 args.GetIsolate(), 10, v8::StackTrace::kDetailed); | 18481 args.GetIsolate(), 10, v8::StackTrace::kDetailed); |
18484 CHECK_EQ(5, stackTrace->GetFrameCount()); | 18482 CHECK_EQ(5, stackTrace->GetFrameCount()); |
18485 v8::Handle<v8::String> url = v8_str("eval_url"); | 18483 v8::Handle<v8::String> url = v8_str("eval_url"); |
18486 for (int i = 0; i < 3; i++) { | 18484 for (int i = 0; i < 3; i++) { |
18487 v8::Handle<v8::String> name = | 18485 v8::Handle<v8::String> name = |
18488 stackTrace->GetFrame(i)->GetScriptNameOrSourceURL(); | 18486 stackTrace->GetFrame(i)->GetScriptNameOrSourceURL(); |
18489 CHECK(!name.IsEmpty()); | 18487 CHECK(!name.IsEmpty()); |
18490 CHECK(url->Equals(name)); | 18488 CHECK_EQ(url, name); |
18491 } | 18489 } |
18492 } | 18490 } |
18493 | 18491 |
18494 | 18492 |
18495 TEST(SourceURLInStackTrace) { | 18493 TEST(SourceURLInStackTrace) { |
18496 v8::Isolate* isolate = CcTest::isolate(); | 18494 v8::Isolate* isolate = CcTest::isolate(); |
18497 v8::HandleScope scope(isolate); | 18495 v8::HandleScope scope(isolate); |
18498 Local<ObjectTemplate> templ = ObjectTemplate::New(isolate); | 18496 Local<ObjectTemplate> templ = ObjectTemplate::New(isolate); |
18499 templ->Set(v8_str("AnalyzeStackOfEvalWithSourceURL"), | 18497 templ->Set(v8_str("AnalyzeStackOfEvalWithSourceURL"), |
18500 v8::FunctionTemplate::New(isolate, | 18498 v8::FunctionTemplate::New(isolate, |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
18563 const v8::FunctionCallbackInfo<v8::Value>& args) { | 18561 const v8::FunctionCallbackInfo<v8::Value>& args) { |
18564 v8::HandleScope scope(args.GetIsolate()); | 18562 v8::HandleScope scope(args.GetIsolate()); |
18565 v8::Handle<v8::StackTrace> stackTrace = v8::StackTrace::CurrentStackTrace( | 18563 v8::Handle<v8::StackTrace> stackTrace = v8::StackTrace::CurrentStackTrace( |
18566 args.GetIsolate(), 10, v8::StackTrace::kDetailed); | 18564 args.GetIsolate(), 10, v8::StackTrace::kDetailed); |
18567 CHECK_EQ(4, stackTrace->GetFrameCount()); | 18565 CHECK_EQ(4, stackTrace->GetFrameCount()); |
18568 v8::Handle<v8::String> url = v8_str("url"); | 18566 v8::Handle<v8::String> url = v8_str("url"); |
18569 for (int i = 0; i < 3; i++) { | 18567 for (int i = 0; i < 3; i++) { |
18570 v8::Handle<v8::String> name = | 18568 v8::Handle<v8::String> name = |
18571 stackTrace->GetFrame(i)->GetScriptNameOrSourceURL(); | 18569 stackTrace->GetFrame(i)->GetScriptNameOrSourceURL(); |
18572 CHECK(!name.IsEmpty()); | 18570 CHECK(!name.IsEmpty()); |
18573 CHECK(url->Equals(name)); | 18571 CHECK_EQ(url, name); |
18574 } | 18572 } |
18575 } | 18573 } |
18576 | 18574 |
18577 | 18575 |
18578 TEST(InlineScriptWithSourceURLInStackTrace) { | 18576 TEST(InlineScriptWithSourceURLInStackTrace) { |
18579 v8::Isolate* isolate = CcTest::isolate(); | 18577 v8::Isolate* isolate = CcTest::isolate(); |
18580 v8::HandleScope scope(isolate); | 18578 v8::HandleScope scope(isolate); |
18581 Local<ObjectTemplate> templ = ObjectTemplate::New(isolate); | 18579 Local<ObjectTemplate> templ = ObjectTemplate::New(isolate); |
18582 templ->Set(v8_str("AnalyzeStackOfInlineScriptWithSourceURL"), | 18580 templ->Set(v8_str("AnalyzeStackOfInlineScriptWithSourceURL"), |
18583 v8::FunctionTemplate::New( | 18581 v8::FunctionTemplate::New( |
(...skipping 25 matching lines...) Expand all Loading... |
18609 const v8::FunctionCallbackInfo<v8::Value>& args) { | 18607 const v8::FunctionCallbackInfo<v8::Value>& args) { |
18610 v8::HandleScope scope(args.GetIsolate()); | 18608 v8::HandleScope scope(args.GetIsolate()); |
18611 v8::Handle<v8::StackTrace> stackTrace = v8::StackTrace::CurrentStackTrace( | 18609 v8::Handle<v8::StackTrace> stackTrace = v8::StackTrace::CurrentStackTrace( |
18612 args.GetIsolate(), 10, v8::StackTrace::kDetailed); | 18610 args.GetIsolate(), 10, v8::StackTrace::kDetailed); |
18613 CHECK_EQ(4, stackTrace->GetFrameCount()); | 18611 CHECK_EQ(4, stackTrace->GetFrameCount()); |
18614 v8::Handle<v8::String> url = v8_str("source_url"); | 18612 v8::Handle<v8::String> url = v8_str("source_url"); |
18615 for (int i = 0; i < 3; i++) { | 18613 for (int i = 0; i < 3; i++) { |
18616 v8::Handle<v8::String> name = | 18614 v8::Handle<v8::String> name = |
18617 stackTrace->GetFrame(i)->GetScriptNameOrSourceURL(); | 18615 stackTrace->GetFrame(i)->GetScriptNameOrSourceURL(); |
18618 CHECK(!name.IsEmpty()); | 18616 CHECK(!name.IsEmpty()); |
18619 CHECK(url->Equals(name)); | 18617 CHECK_EQ(url, name); |
18620 } | 18618 } |
18621 } | 18619 } |
18622 | 18620 |
18623 | 18621 |
18624 TEST(DynamicWithSourceURLInStackTrace) { | 18622 TEST(DynamicWithSourceURLInStackTrace) { |
18625 v8::Isolate* isolate = CcTest::isolate(); | 18623 v8::Isolate* isolate = CcTest::isolate(); |
18626 v8::HandleScope scope(isolate); | 18624 v8::HandleScope scope(isolate); |
18627 Local<ObjectTemplate> templ = ObjectTemplate::New(isolate); | 18625 Local<ObjectTemplate> templ = ObjectTemplate::New(isolate); |
18628 templ->Set(v8_str("AnalyzeStackOfDynamicScriptWithSourceURL"), | 18626 templ->Set(v8_str("AnalyzeStackOfDynamicScriptWithSourceURL"), |
18629 v8::FunctionTemplate::New( | 18627 v8::FunctionTemplate::New( |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
18687 "outer();\n" | 18685 "outer();\n" |
18688 "//# sourceURL=outer_url"; | 18686 "//# sourceURL=outer_url"; |
18689 | 18687 |
18690 v8::TryCatch try_catch; | 18688 v8::TryCatch try_catch; |
18691 CompileRun(source); | 18689 CompileRun(source); |
18692 CHECK(try_catch.HasCaught()); | 18690 CHECK(try_catch.HasCaught()); |
18693 | 18691 |
18694 Local<v8::Message> message = try_catch.Message(); | 18692 Local<v8::Message> message = try_catch.Message(); |
18695 Handle<Value> sourceURL = | 18693 Handle<Value> sourceURL = |
18696 message->GetScriptOrigin().ResourceName(); | 18694 message->GetScriptOrigin().ResourceName(); |
18697 CHECK_EQ(0, strcmp(*v8::String::Utf8Value(sourceURL), "source_url")); | 18695 CHECK_EQ(*v8::String::Utf8Value(sourceURL), "source_url"); |
18698 } | 18696 } |
18699 | 18697 |
18700 | 18698 |
18701 TEST(RecursionWithSourceURLInMessageScriptResourceNameOrSourceURL) { | 18699 TEST(RecursionWithSourceURLInMessageScriptResourceNameOrSourceURL) { |
18702 LocalContext context; | 18700 LocalContext context; |
18703 v8::HandleScope scope(context->GetIsolate()); | 18701 v8::HandleScope scope(context->GetIsolate()); |
18704 | 18702 |
18705 const char *source = | 18703 const char *source = |
18706 "function outer() {\n" | 18704 "function outer() {\n" |
18707 " var scriptContents = \"function boo(){ boo(); }\\\n" | 18705 " var scriptContents = \"function boo(){ boo(); }\\\n" |
18708 " //# sourceURL=source_url\";\n" | 18706 " //# sourceURL=source_url\";\n" |
18709 " eval(scriptContents);\n" | 18707 " eval(scriptContents);\n" |
18710 " boo(); }\n" | 18708 " boo(); }\n" |
18711 "outer();\n" | 18709 "outer();\n" |
18712 "//# sourceURL=outer_url"; | 18710 "//# sourceURL=outer_url"; |
18713 | 18711 |
18714 v8::TryCatch try_catch; | 18712 v8::TryCatch try_catch; |
18715 CompileRun(source); | 18713 CompileRun(source); |
18716 CHECK(try_catch.HasCaught()); | 18714 CHECK(try_catch.HasCaught()); |
18717 | 18715 |
18718 Local<v8::Message> message = try_catch.Message(); | 18716 Local<v8::Message> message = try_catch.Message(); |
18719 Handle<Value> sourceURL = | 18717 Handle<Value> sourceURL = |
18720 message->GetScriptOrigin().ResourceName(); | 18718 message->GetScriptOrigin().ResourceName(); |
18721 CHECK_EQ(0, strcmp(*v8::String::Utf8Value(sourceURL), "source_url")); | 18719 CHECK_EQ(*v8::String::Utf8Value(sourceURL), "source_url"); |
18722 } | 18720 } |
18723 | 18721 |
18724 | 18722 |
18725 static void CreateGarbageInOldSpace() { | 18723 static void CreateGarbageInOldSpace() { |
18726 i::Factory* factory = CcTest::i_isolate()->factory(); | 18724 i::Factory* factory = CcTest::i_isolate()->factory(); |
18727 v8::HandleScope scope(CcTest::isolate()); | 18725 v8::HandleScope scope(CcTest::isolate()); |
18728 i::AlwaysAllocateScope always_allocate(CcTest::i_isolate()); | 18726 i::AlwaysAllocateScope always_allocate(CcTest::i_isolate()); |
18729 for (int i = 0; i < 1000; i++) { | 18727 for (int i = 0; i < 1000; i++) { |
18730 factory->NewFixedArray(1000, i::TENURED); | 18728 factory->NewFixedArray(1000, i::TENURED); |
18731 } | 18729 } |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
18869 v8::Locker locker(CcTest::isolate()); | 18867 v8::Locker locker(CcTest::isolate()); |
18870 CHECK(stack_limit == set_limit); | 18868 CHECK(stack_limit == set_limit); |
18871 } | 18869 } |
18872 } | 18870 } |
18873 | 18871 |
18874 | 18872 |
18875 THREADED_TEST(GetHeapStatistics) { | 18873 THREADED_TEST(GetHeapStatistics) { |
18876 LocalContext c1; | 18874 LocalContext c1; |
18877 v8::HandleScope scope(c1->GetIsolate()); | 18875 v8::HandleScope scope(c1->GetIsolate()); |
18878 v8::HeapStatistics heap_statistics; | 18876 v8::HeapStatistics heap_statistics; |
18879 CHECK_EQ(0u, heap_statistics.total_heap_size()); | 18877 CHECK_EQ(static_cast<int>(heap_statistics.total_heap_size()), 0); |
18880 CHECK_EQ(0u, heap_statistics.used_heap_size()); | 18878 CHECK_EQ(static_cast<int>(heap_statistics.used_heap_size()), 0); |
18881 c1->GetIsolate()->GetHeapStatistics(&heap_statistics); | 18879 c1->GetIsolate()->GetHeapStatistics(&heap_statistics); |
18882 CHECK_NE(static_cast<int>(heap_statistics.total_heap_size()), 0); | 18880 CHECK_NE(static_cast<int>(heap_statistics.total_heap_size()), 0); |
18883 CHECK_NE(static_cast<int>(heap_statistics.used_heap_size()), 0); | 18881 CHECK_NE(static_cast<int>(heap_statistics.used_heap_size()), 0); |
18884 } | 18882 } |
18885 | 18883 |
18886 | 18884 |
18887 class VisitorImpl : public v8::ExternalResourceVisitor { | 18885 class VisitorImpl : public v8::ExternalResourceVisitor { |
18888 public: | 18886 public: |
18889 explicit VisitorImpl(TestResource** resource) { | 18887 explicit VisitorImpl(TestResource** resource) { |
18890 for (int i = 0; i < 4; i++) { | 18888 for (int i = 0; i < 4; i++) { |
(...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
19337 v8::Handle<v8::Integer>(), v8::True(env->GetIsolate())); | 19335 v8::Handle<v8::Integer>(), v8::True(env->GetIsolate())); |
19338 v8::Handle<v8::String> script = v8::String::NewFromUtf8( | 19336 v8::Handle<v8::String> script = v8::String::NewFromUtf8( |
19339 env->GetIsolate(), "function f() {}\n\nfunction g() {}"); | 19337 env->GetIsolate(), "function f() {}\n\nfunction g() {}"); |
19340 v8::Script::Compile(script, &origin)->Run(); | 19338 v8::Script::Compile(script, &origin)->Run(); |
19341 v8::Local<v8::Function> f = v8::Local<v8::Function>::Cast( | 19339 v8::Local<v8::Function> f = v8::Local<v8::Function>::Cast( |
19342 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "f"))); | 19340 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "f"))); |
19343 v8::Local<v8::Function> g = v8::Local<v8::Function>::Cast( | 19341 v8::Local<v8::Function> g = v8::Local<v8::Function>::Cast( |
19344 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "g"))); | 19342 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "g"))); |
19345 | 19343 |
19346 v8::ScriptOrigin script_origin_f = f->GetScriptOrigin(); | 19344 v8::ScriptOrigin script_origin_f = f->GetScriptOrigin(); |
19347 CHECK_EQ(0, strcmp("test", | 19345 CHECK_EQ("test", *v8::String::Utf8Value(script_origin_f.ResourceName())); |
19348 *v8::String::Utf8Value(script_origin_f.ResourceName()))); | |
19349 CHECK_EQ(1, script_origin_f.ResourceLineOffset()->Int32Value()); | 19346 CHECK_EQ(1, script_origin_f.ResourceLineOffset()->Int32Value()); |
19350 CHECK(script_origin_f.ResourceIsSharedCrossOrigin()->Value()); | 19347 CHECK(script_origin_f.ResourceIsSharedCrossOrigin()->Value()); |
19351 CHECK(script_origin_f.ResourceIsEmbedderDebugScript()->Value()); | 19348 CHECK(script_origin_f.ResourceIsEmbedderDebugScript()->Value()); |
19352 | 19349 |
19353 v8::ScriptOrigin script_origin_g = g->GetScriptOrigin(); | 19350 v8::ScriptOrigin script_origin_g = g->GetScriptOrigin(); |
19354 CHECK_EQ(0, strcmp("test", | 19351 CHECK_EQ("test", *v8::String::Utf8Value(script_origin_g.ResourceName())); |
19355 *v8::String::Utf8Value(script_origin_g.ResourceName()))); | |
19356 CHECK_EQ(1, script_origin_g.ResourceLineOffset()->Int32Value()); | 19352 CHECK_EQ(1, script_origin_g.ResourceLineOffset()->Int32Value()); |
19357 CHECK(script_origin_g.ResourceIsSharedCrossOrigin()->Value()); | 19353 CHECK(script_origin_g.ResourceIsSharedCrossOrigin()->Value()); |
19358 CHECK(script_origin_g.ResourceIsEmbedderDebugScript()->Value()); | 19354 CHECK(script_origin_g.ResourceIsEmbedderDebugScript()->Value()); |
19359 } | 19355 } |
19360 | 19356 |
19361 | 19357 |
19362 THREADED_TEST(FunctionGetInferredName) { | 19358 THREADED_TEST(FunctionGetInferredName) { |
19363 LocalContext env; | 19359 LocalContext env; |
19364 v8::HandleScope scope(env->GetIsolate()); | 19360 v8::HandleScope scope(env->GetIsolate()); |
19365 v8::ScriptOrigin origin = | 19361 v8::ScriptOrigin origin = |
19366 v8::ScriptOrigin(v8::String::NewFromUtf8(env->GetIsolate(), "test")); | 19362 v8::ScriptOrigin(v8::String::NewFromUtf8(env->GetIsolate(), "test")); |
19367 v8::Handle<v8::String> script = v8::String::NewFromUtf8( | 19363 v8::Handle<v8::String> script = v8::String::NewFromUtf8( |
19368 env->GetIsolate(), | 19364 env->GetIsolate(), |
19369 "var foo = { bar : { baz : function() {}}}; var f = foo.bar.baz;"); | 19365 "var foo = { bar : { baz : function() {}}}; var f = foo.bar.baz;"); |
19370 v8::Script::Compile(script, &origin)->Run(); | 19366 v8::Script::Compile(script, &origin)->Run(); |
19371 v8::Local<v8::Function> f = v8::Local<v8::Function>::Cast( | 19367 v8::Local<v8::Function> f = v8::Local<v8::Function>::Cast( |
19372 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "f"))); | 19368 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "f"))); |
19373 CHECK_EQ(0, | 19369 CHECK_EQ("foo.bar.baz", *v8::String::Utf8Value(f->GetInferredName())); |
19374 strcmp("foo.bar.baz", *v8::String::Utf8Value(f->GetInferredName()))); | |
19375 } | 19370 } |
19376 | 19371 |
19377 | 19372 |
19378 THREADED_TEST(FunctionGetDisplayName) { | 19373 THREADED_TEST(FunctionGetDisplayName) { |
19379 LocalContext env; | 19374 LocalContext env; |
19380 v8::HandleScope scope(env->GetIsolate()); | 19375 v8::HandleScope scope(env->GetIsolate()); |
19381 const char* code = "var error = false;" | 19376 const char* code = "var error = false;" |
19382 "function a() { this.x = 1; };" | 19377 "function a() { this.x = 1; };" |
19383 "a.displayName = 'display_a';" | 19378 "a.displayName = 'display_a';" |
19384 "var b = (function() {" | 19379 "var b = (function() {" |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
19425 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "c"))); | 19420 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "c"))); |
19426 v8::Local<v8::Function> d = v8::Local<v8::Function>::Cast( | 19421 v8::Local<v8::Function> d = v8::Local<v8::Function>::Cast( |
19427 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "d"))); | 19422 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "d"))); |
19428 v8::Local<v8::Function> e = v8::Local<v8::Function>::Cast( | 19423 v8::Local<v8::Function> e = v8::Local<v8::Function>::Cast( |
19429 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "e"))); | 19424 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "e"))); |
19430 v8::Local<v8::Function> f = v8::Local<v8::Function>::Cast( | 19425 v8::Local<v8::Function> f = v8::Local<v8::Function>::Cast( |
19431 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "f"))); | 19426 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "f"))); |
19432 v8::Local<v8::Function> g = v8::Local<v8::Function>::Cast( | 19427 v8::Local<v8::Function> g = v8::Local<v8::Function>::Cast( |
19433 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "g"))); | 19428 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "g"))); |
19434 CHECK_EQ(false, error->BooleanValue()); | 19429 CHECK_EQ(false, error->BooleanValue()); |
19435 CHECK_EQ(0, strcmp("display_a", *v8::String::Utf8Value(a->GetDisplayName()))); | 19430 CHECK_EQ("display_a", *v8::String::Utf8Value(a->GetDisplayName())); |
19436 CHECK_EQ(0, strcmp("display_b", *v8::String::Utf8Value(b->GetDisplayName()))); | 19431 CHECK_EQ("display_b", *v8::String::Utf8Value(b->GetDisplayName())); |
19437 CHECK(c->GetDisplayName()->IsUndefined()); | 19432 CHECK(c->GetDisplayName()->IsUndefined()); |
19438 CHECK(d->GetDisplayName()->IsUndefined()); | 19433 CHECK(d->GetDisplayName()->IsUndefined()); |
19439 CHECK(e->GetDisplayName()->IsUndefined()); | 19434 CHECK(e->GetDisplayName()->IsUndefined()); |
19440 CHECK(f->GetDisplayName()->IsUndefined()); | 19435 CHECK(f->GetDisplayName()->IsUndefined()); |
19441 CHECK_EQ( | 19436 CHECK_EQ("set_in_runtime", *v8::String::Utf8Value(g->GetDisplayName())); |
19442 0, strcmp("set_in_runtime", *v8::String::Utf8Value(g->GetDisplayName()))); | |
19443 } | 19437 } |
19444 | 19438 |
19445 | 19439 |
19446 THREADED_TEST(ScriptLineNumber) { | 19440 THREADED_TEST(ScriptLineNumber) { |
19447 LocalContext env; | 19441 LocalContext env; |
19448 v8::HandleScope scope(env->GetIsolate()); | 19442 v8::HandleScope scope(env->GetIsolate()); |
19449 v8::ScriptOrigin origin = | 19443 v8::ScriptOrigin origin = |
19450 v8::ScriptOrigin(v8::String::NewFromUtf8(env->GetIsolate(), "test")); | 19444 v8::ScriptOrigin(v8::String::NewFromUtf8(env->GetIsolate(), "test")); |
19451 v8::Handle<v8::String> script = v8::String::NewFromUtf8( | 19445 v8::Handle<v8::String> script = v8::String::NewFromUtf8( |
19452 env->GetIsolate(), "function f() {}\n\nfunction g() {}"); | 19446 env->GetIsolate(), "function f() {}\n\nfunction g() {}"); |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
19532 "var g = f.bind(a);\n" | 19526 "var g = f.bind(a);\n" |
19533 "var b = g();"); | 19527 "var b = g();"); |
19534 v8::Script::Compile(script, &origin)->Run(); | 19528 v8::Script::Compile(script, &origin)->Run(); |
19535 v8::Local<v8::Function> f = v8::Local<v8::Function>::Cast( | 19529 v8::Local<v8::Function> f = v8::Local<v8::Function>::Cast( |
19536 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "f"))); | 19530 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "f"))); |
19537 v8::Local<v8::Function> g = v8::Local<v8::Function>::Cast( | 19531 v8::Local<v8::Function> g = v8::Local<v8::Function>::Cast( |
19538 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "g"))); | 19532 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "g"))); |
19539 CHECK(g->GetBoundFunction()->IsFunction()); | 19533 CHECK(g->GetBoundFunction()->IsFunction()); |
19540 Local<v8::Function> original_function = Local<v8::Function>::Cast( | 19534 Local<v8::Function> original_function = Local<v8::Function>::Cast( |
19541 g->GetBoundFunction()); | 19535 g->GetBoundFunction()); |
19542 CHECK(f->GetName()->Equals(original_function->GetName())); | 19536 CHECK_EQ(f->GetName(), original_function->GetName()); |
19543 CHECK_EQ(f->GetScriptLineNumber(), original_function->GetScriptLineNumber()); | 19537 CHECK_EQ(f->GetScriptLineNumber(), original_function->GetScriptLineNumber()); |
19544 CHECK_EQ(f->GetScriptColumnNumber(), | 19538 CHECK_EQ(f->GetScriptColumnNumber(), |
19545 original_function->GetScriptColumnNumber()); | 19539 original_function->GetScriptColumnNumber()); |
19546 } | 19540 } |
19547 | 19541 |
19548 | 19542 |
19549 static void GetterWhichReturns42( | 19543 static void GetterWhichReturns42( |
19550 Local<String> name, | 19544 Local<String> name, |
19551 const v8::PropertyCallbackInfo<v8::Value>& info) { | 19545 const v8::PropertyCallbackInfo<v8::Value>& info) { |
19552 CHECK(v8::Utils::OpenHandle(*info.This())->IsJSObject()); | 19546 CHECK(v8::Utils::OpenHandle(*info.This())->IsJSObject()); |
(...skipping 714 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
20267 TEST(IsolateNewDispose) { | 20261 TEST(IsolateNewDispose) { |
20268 v8::Isolate* current_isolate = CcTest::isolate(); | 20262 v8::Isolate* current_isolate = CcTest::isolate(); |
20269 v8::Isolate* isolate = v8::Isolate::New(); | 20263 v8::Isolate* isolate = v8::Isolate::New(); |
20270 CHECK(isolate != NULL); | 20264 CHECK(isolate != NULL); |
20271 CHECK(current_isolate != isolate); | 20265 CHECK(current_isolate != isolate); |
20272 CHECK(current_isolate == CcTest::isolate()); | 20266 CHECK(current_isolate == CcTest::isolate()); |
20273 | 20267 |
20274 v8::V8::SetFatalErrorHandler(StoringErrorCallback); | 20268 v8::V8::SetFatalErrorHandler(StoringErrorCallback); |
20275 last_location = last_message = NULL; | 20269 last_location = last_message = NULL; |
20276 isolate->Dispose(); | 20270 isolate->Dispose(); |
20277 CHECK(!last_location); | 20271 CHECK_EQ(last_location, NULL); |
20278 CHECK(!last_message); | 20272 CHECK_EQ(last_message, NULL); |
20279 } | 20273 } |
20280 | 20274 |
20281 | 20275 |
20282 UNINITIALIZED_TEST(DisposeIsolateWhenInUse) { | 20276 UNINITIALIZED_TEST(DisposeIsolateWhenInUse) { |
20283 v8::Isolate* isolate = v8::Isolate::New(); | 20277 v8::Isolate* isolate = v8::Isolate::New(); |
20284 { | 20278 { |
20285 v8::Isolate::Scope i_scope(isolate); | 20279 v8::Isolate::Scope i_scope(isolate); |
20286 v8::HandleScope scope(isolate); | 20280 v8::HandleScope scope(isolate); |
20287 LocalContext context(isolate); | 20281 LocalContext context(isolate); |
20288 // Run something in this isolate. | 20282 // Run something in this isolate. |
20289 ExpectTrue("true"); | 20283 ExpectTrue("true"); |
20290 v8::V8::SetFatalErrorHandler(StoringErrorCallback); | 20284 v8::V8::SetFatalErrorHandler(StoringErrorCallback); |
20291 last_location = last_message = NULL; | 20285 last_location = last_message = NULL; |
20292 // Still entered, should fail. | 20286 // Still entered, should fail. |
20293 isolate->Dispose(); | 20287 isolate->Dispose(); |
20294 CHECK(last_location); | 20288 CHECK_NE(last_location, NULL); |
20295 CHECK(last_message); | 20289 CHECK_NE(last_message, NULL); |
20296 } | 20290 } |
20297 isolate->Dispose(); | 20291 isolate->Dispose(); |
20298 } | 20292 } |
20299 | 20293 |
20300 | 20294 |
20301 TEST(RunTwoIsolatesOnSingleThread) { | 20295 TEST(RunTwoIsolatesOnSingleThread) { |
20302 // Run isolate 1. | 20296 // Run isolate 1. |
20303 v8::Isolate* isolate1 = v8::Isolate::New(); | 20297 v8::Isolate* isolate1 = v8::Isolate::New(); |
20304 isolate1->Enter(); | 20298 isolate1->Enter(); |
20305 v8::Persistent<v8::Context> context1; | 20299 v8::Persistent<v8::Context> context1; |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
20398 context2.Reset(); | 20392 context2.Reset(); |
20399 } | 20393 } |
20400 | 20394 |
20401 context1.Reset(); | 20395 context1.Reset(); |
20402 isolate1->Exit(); | 20396 isolate1->Exit(); |
20403 | 20397 |
20404 v8::V8::SetFatalErrorHandler(StoringErrorCallback); | 20398 v8::V8::SetFatalErrorHandler(StoringErrorCallback); |
20405 last_location = last_message = NULL; | 20399 last_location = last_message = NULL; |
20406 | 20400 |
20407 isolate1->Dispose(); | 20401 isolate1->Dispose(); |
20408 CHECK(!last_location); | 20402 CHECK_EQ(last_location, NULL); |
20409 CHECK(!last_message); | 20403 CHECK_EQ(last_message, NULL); |
20410 | 20404 |
20411 isolate2->Dispose(); | 20405 isolate2->Dispose(); |
20412 CHECK(!last_location); | 20406 CHECK_EQ(last_location, NULL); |
20413 CHECK(!last_message); | 20407 CHECK_EQ(last_message, NULL); |
20414 | 20408 |
20415 // Check that default isolate still runs. | 20409 // Check that default isolate still runs. |
20416 { | 20410 { |
20417 v8::HandleScope scope(CcTest::isolate()); | 20411 v8::HandleScope scope(CcTest::isolate()); |
20418 v8::Local<v8::Context> context = | 20412 v8::Local<v8::Context> context = |
20419 v8::Local<v8::Context>::New(CcTest::isolate(), context_default); | 20413 v8::Local<v8::Context>::New(CcTest::isolate(), context_default); |
20420 v8::Context::Scope context_scope(context); | 20414 v8::Context::Scope context_scope(context); |
20421 ExpectTrue("function f() { return isDefaultIsolate; }; f()"); | 20415 ExpectTrue("function f() { return isDefaultIsolate; }; f()"); |
20422 } | 20416 } |
20423 } | 20417 } |
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
20716 virtual void VisitPersistentHandle(Persistent<Value>* value, | 20710 virtual void VisitPersistentHandle(Persistent<Value>* value, |
20717 uint16_t class_id) { | 20711 uint16_t class_id) { |
20718 if (class_id != 42) return; | 20712 if (class_id != 42) return; |
20719 CHECK_EQ(42, value->WrapperClassId()); | 20713 CHECK_EQ(42, value->WrapperClassId()); |
20720 v8::Isolate* isolate = CcTest::isolate(); | 20714 v8::Isolate* isolate = CcTest::isolate(); |
20721 v8::HandleScope handle_scope(isolate); | 20715 v8::HandleScope handle_scope(isolate); |
20722 v8::Handle<v8::Value> handle = v8::Local<v8::Value>::New(isolate, *value); | 20716 v8::Handle<v8::Value> handle = v8::Local<v8::Value>::New(isolate, *value); |
20723 v8::Handle<v8::Value> object = | 20717 v8::Handle<v8::Value> object = |
20724 v8::Local<v8::Object>::New(isolate, *object_); | 20718 v8::Local<v8::Object>::New(isolate, *object_); |
20725 CHECK(handle->IsObject()); | 20719 CHECK(handle->IsObject()); |
20726 CHECK(Handle<Object>::Cast(handle)->Equals(object)); | 20720 CHECK_EQ(Handle<Object>::Cast(handle), object); |
20727 ++counter_; | 20721 ++counter_; |
20728 } | 20722 } |
20729 | 20723 |
20730 int counter_; | 20724 int counter_; |
20731 v8::Persistent<v8::Object>* object_; | 20725 v8::Persistent<v8::Object>* object_; |
20732 }; | 20726 }; |
20733 | 20727 |
20734 | 20728 |
20735 TEST(PersistentHandleVisitor) { | 20729 TEST(PersistentHandleVisitor) { |
20736 LocalContext context; | 20730 LocalContext context; |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
20894 v8::Isolate* isolate = context->GetIsolate(); | 20888 v8::Isolate* isolate = context->GetIsolate(); |
20895 v8::HandleScope handle_scope(isolate); | 20889 v8::HandleScope handle_scope(isolate); |
20896 v8::Context::Scope context_scope(context.local()); | 20890 v8::Context::Scope context_scope(context.local()); |
20897 | 20891 |
20898 v8::Handle<v8::ObjectTemplate> tmpl = v8::ObjectTemplate::New(isolate); | 20892 v8::Handle<v8::ObjectTemplate> tmpl = v8::ObjectTemplate::New(isolate); |
20899 tmpl->SetHandler(v8::NamedPropertyHandlerConfiguration(Getter, NULL, NULL, | 20893 tmpl->SetHandler(v8::NamedPropertyHandlerConfiguration(Getter, NULL, NULL, |
20900 NULL, Enumerator)); | 20894 NULL, Enumerator)); |
20901 context->Global()->Set(v8_str("o"), tmpl->NewInstance()); | 20895 context->Global()->Set(v8_str("o"), tmpl->NewInstance()); |
20902 v8::Handle<v8::Array> result = v8::Handle<v8::Array>::Cast(CompileRun( | 20896 v8::Handle<v8::Array> result = v8::Handle<v8::Array>::Cast(CompileRun( |
20903 "var result = []; for (var k in o) result.push(k); result")); | 20897 "var result = []; for (var k in o) result.push(k); result")); |
20904 CHECK_EQ(1u, result->Length()); | 20898 CHECK_EQ(1, result->Length()); |
20905 CHECK(v8_str("universalAnswer")->Equals(result->Get(0))); | 20899 CHECK_EQ(v8_str("universalAnswer"), result->Get(0)); |
20906 } | 20900 } |
20907 | 20901 |
20908 | 20902 |
20909 TEST(DefinePropertyPostDetach) { | 20903 TEST(DefinePropertyPostDetach) { |
20910 LocalContext context; | 20904 LocalContext context; |
20911 v8::HandleScope scope(context->GetIsolate()); | 20905 v8::HandleScope scope(context->GetIsolate()); |
20912 v8::Handle<v8::Object> proxy = context->Global(); | 20906 v8::Handle<v8::Object> proxy = context->Global(); |
20913 v8::Handle<v8::Function> define_property = | 20907 v8::Handle<v8::Function> define_property = |
20914 CompileRun("(function() {" | 20908 CompileRun("(function() {" |
20915 " Object.defineProperty(" | 20909 " Object.defineProperty(" |
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
21281 THREADED_TEST(ReadOnlyIndexedProperties) { | 21275 THREADED_TEST(ReadOnlyIndexedProperties) { |
21282 v8::Isolate* isolate = CcTest::isolate(); | 21276 v8::Isolate* isolate = CcTest::isolate(); |
21283 v8::HandleScope scope(isolate); | 21277 v8::HandleScope scope(isolate); |
21284 Local<ObjectTemplate> templ = ObjectTemplate::New(isolate); | 21278 Local<ObjectTemplate> templ = ObjectTemplate::New(isolate); |
21285 | 21279 |
21286 LocalContext context; | 21280 LocalContext context; |
21287 Local<v8::Object> obj = templ->NewInstance(); | 21281 Local<v8::Object> obj = templ->NewInstance(); |
21288 context->Global()->Set(v8_str("obj"), obj); | 21282 context->Global()->Set(v8_str("obj"), obj); |
21289 obj->ForceSet(v8_str("1"), v8_str("DONT_CHANGE"), v8::ReadOnly); | 21283 obj->ForceSet(v8_str("1"), v8_str("DONT_CHANGE"), v8::ReadOnly); |
21290 obj->Set(v8_str("1"), v8_str("foobar")); | 21284 obj->Set(v8_str("1"), v8_str("foobar")); |
21291 CHECK(v8_str("DONT_CHANGE")->Equals(obj->Get(v8_str("1")))); | 21285 CHECK_EQ(v8_str("DONT_CHANGE"), obj->Get(v8_str("1"))); |
21292 obj->ForceSet(v8_num(2), v8_str("DONT_CHANGE"), v8::ReadOnly); | 21286 obj->ForceSet(v8_num(2), v8_str("DONT_CHANGE"), v8::ReadOnly); |
21293 obj->Set(v8_num(2), v8_str("foobar")); | 21287 obj->Set(v8_num(2), v8_str("foobar")); |
21294 CHECK(v8_str("DONT_CHANGE")->Equals(obj->Get(v8_num(2)))); | 21288 CHECK_EQ(v8_str("DONT_CHANGE"), obj->Get(v8_num(2))); |
21295 | 21289 |
21296 // Test non-smi case. | 21290 // Test non-smi case. |
21297 obj->ForceSet(v8_str("2000000000"), v8_str("DONT_CHANGE"), v8::ReadOnly); | 21291 obj->ForceSet(v8_str("2000000000"), v8_str("DONT_CHANGE"), v8::ReadOnly); |
21298 obj->Set(v8_str("2000000000"), v8_str("foobar")); | 21292 obj->Set(v8_str("2000000000"), v8_str("foobar")); |
21299 CHECK(v8_str("DONT_CHANGE")->Equals(obj->Get(v8_str("2000000000")))); | 21293 CHECK_EQ(v8_str("DONT_CHANGE"), obj->Get(v8_str("2000000000"))); |
21300 } | 21294 } |
21301 | 21295 |
21302 | 21296 |
21303 static int CountLiveMapsInMapCache(i::Context* context) { | 21297 static int CountLiveMapsInMapCache(i::Context* context) { |
21304 i::FixedArray* map_cache = i::FixedArray::cast(context->map_cache()); | 21298 i::FixedArray* map_cache = i::FixedArray::cast(context->map_cache()); |
21305 int length = map_cache->length(); | 21299 int length = map_cache->length(); |
21306 int count = 0; | 21300 int count = 0; |
21307 for (int i = 0; i < length; i++) { | 21301 for (int i = 0; i < length; i++) { |
21308 i::Object* value = map_cache->get(i); | 21302 i::Object* value = map_cache->get(i); |
21309 if (value->IsWeakCell() && !i::WeakCell::cast(value)->cleared()) count++; | 21303 if (value->IsWeakCell() && !i::WeakCell::cast(value)->cleared()) count++; |
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
21714 CHECK_EQ(2, CompileRun("ext1Calls")->Int32Value()); | 21708 CHECK_EQ(2, CompileRun("ext1Calls")->Int32Value()); |
21715 CHECK_EQ(2, CompileRun("ext2Calls")->Int32Value()); | 21709 CHECK_EQ(2, CompileRun("ext2Calls")->Int32Value()); |
21716 | 21710 |
21717 CompileRun("1+1;"); | 21711 CompileRun("1+1;"); |
21718 CHECK_EQ(2, CompileRun("ext1Calls")->Int32Value()); | 21712 CHECK_EQ(2, CompileRun("ext1Calls")->Int32Value()); |
21719 CHECK_EQ(2, CompileRun("ext2Calls")->Int32Value()); | 21713 CHECK_EQ(2, CompileRun("ext2Calls")->Int32Value()); |
21720 | 21714 |
21721 g_passed_to_three = NULL; | 21715 g_passed_to_three = NULL; |
21722 env->GetIsolate()->EnqueueMicrotask(MicrotaskThree); | 21716 env->GetIsolate()->EnqueueMicrotask(MicrotaskThree); |
21723 CompileRun("1+1;"); | 21717 CompileRun("1+1;"); |
21724 CHECK(!g_passed_to_three); | 21718 CHECK_EQ(NULL, g_passed_to_three); |
21725 CHECK_EQ(2, CompileRun("ext1Calls")->Int32Value()); | 21719 CHECK_EQ(2, CompileRun("ext1Calls")->Int32Value()); |
21726 CHECK_EQ(2, CompileRun("ext2Calls")->Int32Value()); | 21720 CHECK_EQ(2, CompileRun("ext2Calls")->Int32Value()); |
21727 | 21721 |
21728 int dummy; | 21722 int dummy; |
21729 env->GetIsolate()->EnqueueMicrotask( | 21723 env->GetIsolate()->EnqueueMicrotask( |
21730 Function::New(env->GetIsolate(), MicrotaskOne)); | 21724 Function::New(env->GetIsolate(), MicrotaskOne)); |
21731 env->GetIsolate()->EnqueueMicrotask(MicrotaskThree, &dummy); | 21725 env->GetIsolate()->EnqueueMicrotask(MicrotaskThree, &dummy); |
21732 env->GetIsolate()->EnqueueMicrotask( | 21726 env->GetIsolate()->EnqueueMicrotask( |
21733 Function::New(env->GetIsolate(), MicrotaskTwo)); | 21727 Function::New(env->GetIsolate(), MicrotaskTwo)); |
21734 CompileRun("1+1;"); | 21728 CompileRun("1+1;"); |
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
22005 CHECK(*v8::Utils::OpenHandle(*v8::False(isolate)) == *false_value); | 21999 CHECK(*v8::Utils::OpenHandle(*v8::False(isolate)) == *false_value); |
22006 } | 22000 } |
22007 | 22001 |
22008 | 22002 |
22009 UNINITIALIZED_TEST(IsolateEmbedderData) { | 22003 UNINITIALIZED_TEST(IsolateEmbedderData) { |
22010 CcTest::DisableAutomaticDispose(); | 22004 CcTest::DisableAutomaticDispose(); |
22011 v8::Isolate* isolate = v8::Isolate::New(); | 22005 v8::Isolate* isolate = v8::Isolate::New(); |
22012 isolate->Enter(); | 22006 isolate->Enter(); |
22013 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); | 22007 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
22014 for (uint32_t slot = 0; slot < v8::Isolate::GetNumberOfDataSlots(); ++slot) { | 22008 for (uint32_t slot = 0; slot < v8::Isolate::GetNumberOfDataSlots(); ++slot) { |
22015 CHECK(!isolate->GetData(slot)); | 22009 CHECK_EQ(NULL, isolate->GetData(slot)); |
22016 CHECK(!i_isolate->GetData(slot)); | 22010 CHECK_EQ(NULL, i_isolate->GetData(slot)); |
22017 } | 22011 } |
22018 for (uint32_t slot = 0; slot < v8::Isolate::GetNumberOfDataSlots(); ++slot) { | 22012 for (uint32_t slot = 0; slot < v8::Isolate::GetNumberOfDataSlots(); ++slot) { |
22019 void* data = reinterpret_cast<void*>(0xacce55ed + slot); | 22013 void* data = reinterpret_cast<void*>(0xacce55ed + slot); |
22020 isolate->SetData(slot, data); | 22014 isolate->SetData(slot, data); |
22021 } | 22015 } |
22022 for (uint32_t slot = 0; slot < v8::Isolate::GetNumberOfDataSlots(); ++slot) { | 22016 for (uint32_t slot = 0; slot < v8::Isolate::GetNumberOfDataSlots(); ++slot) { |
22023 void* data = reinterpret_cast<void*>(0xacce55ed + slot); | 22017 void* data = reinterpret_cast<void*>(0xacce55ed + slot); |
22024 CHECK_EQ(data, isolate->GetData(slot)); | 22018 CHECK_EQ(data, isolate->GetData(slot)); |
22025 CHECK_EQ(data, i_isolate->GetData(slot)); | 22019 CHECK_EQ(data, i_isolate->GetData(slot)); |
22026 } | 22020 } |
(...skipping 18 matching lines...) Expand all Loading... |
22045 v8::HandleScope scope(isolate); | 22039 v8::HandleScope scope(isolate); |
22046 i::Handle<i::Object> empty_string = factory->empty_string(); | 22040 i::Handle<i::Object> empty_string = factory->empty_string(); |
22047 CHECK(*v8::Utils::OpenHandle(*v8::String::Empty(isolate)) == *empty_string); | 22041 CHECK(*v8::Utils::OpenHandle(*v8::String::Empty(isolate)) == *empty_string); |
22048 } | 22042 } |
22049 | 22043 |
22050 | 22044 |
22051 static int instance_checked_getter_count = 0; | 22045 static int instance_checked_getter_count = 0; |
22052 static void InstanceCheckedGetter( | 22046 static void InstanceCheckedGetter( |
22053 Local<String> name, | 22047 Local<String> name, |
22054 const v8::PropertyCallbackInfo<v8::Value>& info) { | 22048 const v8::PropertyCallbackInfo<v8::Value>& info) { |
22055 CHECK(name->Equals(v8_str("foo"))); | 22049 CHECK_EQ(name, v8_str("foo")); |
22056 instance_checked_getter_count++; | 22050 instance_checked_getter_count++; |
22057 info.GetReturnValue().Set(v8_num(11)); | 22051 info.GetReturnValue().Set(v8_num(11)); |
22058 } | 22052 } |
22059 | 22053 |
22060 | 22054 |
22061 static int instance_checked_setter_count = 0; | 22055 static int instance_checked_setter_count = 0; |
22062 static void InstanceCheckedSetter(Local<String> name, | 22056 static void InstanceCheckedSetter(Local<String> name, |
22063 Local<Value> value, | 22057 Local<Value> value, |
22064 const v8::PropertyCallbackInfo<void>& info) { | 22058 const v8::PropertyCallbackInfo<void>& info) { |
22065 CHECK(name->Equals(v8_str("foo"))); | 22059 CHECK_EQ(name, v8_str("foo")); |
22066 CHECK(value->Equals(v8_num(23))); | 22060 CHECK_EQ(value, v8_num(23)); |
22067 instance_checked_setter_count++; | 22061 instance_checked_setter_count++; |
22068 } | 22062 } |
22069 | 22063 |
22070 | 22064 |
22071 static void CheckInstanceCheckedResult(int getters, int setters, | 22065 static void CheckInstanceCheckedResult(int getters, int setters, |
22072 bool expects_callbacks, | 22066 bool expects_callbacks, |
22073 TryCatch* try_catch) { | 22067 TryCatch* try_catch) { |
22074 if (expects_callbacks) { | 22068 if (expects_callbacks) { |
22075 CHECK(!try_catch->HasCaught()); | 22069 CHECK(!try_catch->HasCaught()); |
22076 CHECK_EQ(getters, instance_checked_getter_count); | 22070 CHECK_EQ(getters, instance_checked_getter_count); |
(...skipping 1106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
23183 InterruptThread i_thread; | 23177 InterruptThread i_thread; |
23184 int counter_; | 23178 int counter_; |
23185 }; | 23179 }; |
23186 | 23180 |
23187 | 23181 |
23188 TEST(RequestMultipleInterrupts) { RequestMultipleInterrupts().RunTest(); } | 23182 TEST(RequestMultipleInterrupts) { RequestMultipleInterrupts().RunTest(); } |
23189 | 23183 |
23190 | 23184 |
23191 static Local<Value> function_new_expected_env; | 23185 static Local<Value> function_new_expected_env; |
23192 static void FunctionNewCallback(const v8::FunctionCallbackInfo<Value>& info) { | 23186 static void FunctionNewCallback(const v8::FunctionCallbackInfo<Value>& info) { |
23193 CHECK(function_new_expected_env->Equals(info.Data())); | 23187 CHECK_EQ(function_new_expected_env, info.Data()); |
23194 info.GetReturnValue().Set(17); | 23188 info.GetReturnValue().Set(17); |
23195 } | 23189 } |
23196 | 23190 |
23197 | 23191 |
23198 THREADED_TEST(FunctionNew) { | 23192 THREADED_TEST(FunctionNew) { |
23199 LocalContext env; | 23193 LocalContext env; |
23200 v8::Isolate* isolate = env->GetIsolate(); | 23194 v8::Isolate* isolate = env->GetIsolate(); |
23201 v8::HandleScope scope(isolate); | 23195 v8::HandleScope scope(isolate); |
23202 Local<Object> data = v8::Object::New(isolate); | 23196 Local<Object> data = v8::Object::New(isolate); |
23203 function_new_expected_env = data; | 23197 function_new_expected_env = data; |
23204 Local<Function> func = Function::New(isolate, FunctionNewCallback, data); | 23198 Local<Function> func = Function::New(isolate, FunctionNewCallback, data); |
23205 env->Global()->Set(v8_str("func"), func); | 23199 env->Global()->Set(v8_str("func"), func); |
23206 Local<Value> result = CompileRun("func();"); | 23200 Local<Value> result = CompileRun("func();"); |
23207 CHECK(v8::Integer::New(isolate, 17)->Equals(result)); | 23201 CHECK_EQ(v8::Integer::New(isolate, 17), result); |
23208 // Verify function not cached | 23202 // Verify function not cached |
23209 int serial_number = | 23203 int serial_number = |
23210 i::Smi::cast(v8::Utils::OpenHandle(*func) | 23204 i::Smi::cast(v8::Utils::OpenHandle(*func) |
23211 ->shared()->get_api_func_data()->serial_number())->value(); | 23205 ->shared()->get_api_func_data()->serial_number())->value(); |
23212 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); | 23206 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
23213 i::Handle<i::JSObject> cache(i_isolate->native_context()->function_cache()); | 23207 i::Handle<i::JSObject> cache(i_isolate->native_context()->function_cache()); |
23214 i::Handle<i::Object> elm = | 23208 i::Handle<i::Object> elm = |
23215 i::Object::GetElement(i_isolate, cache, serial_number).ToHandleChecked(); | 23209 i::Object::GetElement(i_isolate, cache, serial_number).ToHandleChecked(); |
23216 CHECK(elm->IsUndefined()); | 23210 CHECK(elm->IsUndefined()); |
23217 // Verify that each Function::New creates a new function instance | 23211 // Verify that each Function::New creates a new function instance |
23218 Local<Object> data2 = v8::Object::New(isolate); | 23212 Local<Object> data2 = v8::Object::New(isolate); |
23219 function_new_expected_env = data2; | 23213 function_new_expected_env = data2; |
23220 Local<Function> func2 = Function::New(isolate, FunctionNewCallback, data2); | 23214 Local<Function> func2 = Function::New(isolate, FunctionNewCallback, data2); |
23221 CHECK(!func2->IsNull()); | 23215 CHECK(!func2->IsNull()); |
23222 CHECK(!func->Equals(func2)); | 23216 CHECK_NE(func, func2); |
23223 env->Global()->Set(v8_str("func2"), func2); | 23217 env->Global()->Set(v8_str("func2"), func2); |
23224 Local<Value> result2 = CompileRun("func2();"); | 23218 Local<Value> result2 = CompileRun("func2();"); |
23225 CHECK(v8::Integer::New(isolate, 17)->Equals(result2)); | 23219 CHECK_EQ(v8::Integer::New(isolate, 17), result2); |
23226 } | 23220 } |
23227 | 23221 |
23228 | 23222 |
23229 TEST(EscapeableHandleScope) { | 23223 TEST(EscapeableHandleScope) { |
23230 HandleScope outer_scope(CcTest::isolate()); | 23224 HandleScope outer_scope(CcTest::isolate()); |
23231 LocalContext context; | 23225 LocalContext context; |
23232 const int runs = 10; | 23226 const int runs = 10; |
23233 Local<String> values[runs]; | 23227 Local<String> values[runs]; |
23234 for (int i = 0; i < runs; i++) { | 23228 for (int i = 0; i < runs; i++) { |
23235 v8::EscapableHandleScope inner_scope(CcTest::isolate()); | 23229 v8::EscapableHandleScope inner_scope(CcTest::isolate()); |
23236 Local<String> value; | 23230 Local<String> value; |
23237 if (i != 0) value = v8_str("escape value"); | 23231 if (i != 0) value = v8_str("escape value"); |
23238 values[i] = inner_scope.Escape(value); | 23232 values[i] = inner_scope.Escape(value); |
23239 } | 23233 } |
23240 for (int i = 0; i < runs; i++) { | 23234 for (int i = 0; i < runs; i++) { |
23241 Local<String> expected; | 23235 Local<String> expected; |
23242 if (i != 0) { | 23236 if (i != 0) { |
23243 CHECK(v8_str("escape value")->Equals(values[i])); | 23237 CHECK_EQ(v8_str("escape value"), values[i]); |
23244 } else { | 23238 } else { |
23245 CHECK(values[i].IsEmpty()); | 23239 CHECK(values[i].IsEmpty()); |
23246 } | 23240 } |
23247 } | 23241 } |
23248 } | 23242 } |
23249 | 23243 |
23250 | 23244 |
23251 static void SetterWhichExpectsThisAndHolderToDiffer( | 23245 static void SetterWhichExpectsThisAndHolderToDiffer( |
23252 Local<String>, Local<Value>, const v8::PropertyCallbackInfo<void>& info) { | 23246 Local<String>, Local<Value>, const v8::PropertyCallbackInfo<void>& info) { |
23253 CHECK(info.Holder() != info.This()); | 23247 CHECK(info.Holder() != info.This()); |
(...skipping 25 matching lines...) Expand all Loading... |
23279 static Local<Object> holder; | 23273 static Local<Object> holder; |
23280 static Local<Object> callee; | 23274 static Local<Object> callee; |
23281 static int count; | 23275 static int count; |
23282 | 23276 |
23283 static void OptimizationCallback( | 23277 static void OptimizationCallback( |
23284 const v8::FunctionCallbackInfo<v8::Value>& info) { | 23278 const v8::FunctionCallbackInfo<v8::Value>& info) { |
23285 CHECK(callee == info.Callee()); | 23279 CHECK(callee == info.Callee()); |
23286 CHECK(data == info.Data()); | 23280 CHECK(data == info.Data()); |
23287 CHECK(receiver == info.This()); | 23281 CHECK(receiver == info.This()); |
23288 if (info.Length() == 1) { | 23282 if (info.Length() == 1) { |
23289 CHECK(v8_num(1)->Equals(info[0])); | 23283 CHECK_EQ(v8_num(1), info[0]); |
23290 } | 23284 } |
23291 CHECK(holder == info.Holder()); | 23285 CHECK(holder == info.Holder()); |
23292 count++; | 23286 count++; |
23293 info.GetReturnValue().Set(v8_str("returned")); | 23287 info.GetReturnValue().Set(v8_str("returned")); |
23294 } | 23288 } |
23295 | 23289 |
23296 public: | 23290 public: |
23297 enum SignatureType { | 23291 enum SignatureType { |
23298 kNoSignature, | 23292 kNoSignature, |
23299 kSignatureOnReceiver, | 23293 kSignatureOnReceiver, |
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
23659 } | 23653 } |
23660 | 23654 |
23661 | 23655 |
23662 TEST(EventLogging) { | 23656 TEST(EventLogging) { |
23663 v8::Isolate* isolate = CcTest::isolate(); | 23657 v8::Isolate* isolate = CcTest::isolate(); |
23664 isolate->SetEventLogger(StoringEventLoggerCallback); | 23658 isolate->SetEventLogger(StoringEventLoggerCallback); |
23665 v8::internal::HistogramTimer histogramTimer( | 23659 v8::internal::HistogramTimer histogramTimer( |
23666 "V8.Test", 0, 10000, v8::internal::HistogramTimer::MILLISECOND, 50, | 23660 "V8.Test", 0, 10000, v8::internal::HistogramTimer::MILLISECOND, 50, |
23667 reinterpret_cast<v8::internal::Isolate*>(isolate)); | 23661 reinterpret_cast<v8::internal::Isolate*>(isolate)); |
23668 histogramTimer.Start(); | 23662 histogramTimer.Start(); |
23669 CHECK_EQ(0, strcmp("V8.Test", last_event_message)); | 23663 CHECK_EQ("V8.Test", last_event_message); |
23670 CHECK_EQ(0, last_event_status); | 23664 CHECK_EQ(0, last_event_status); |
23671 histogramTimer.Stop(); | 23665 histogramTimer.Stop(); |
23672 CHECK_EQ(0, strcmp("V8.Test", last_event_message)); | 23666 CHECK_EQ("V8.Test", last_event_message); |
23673 CHECK_EQ(1, last_event_status); | 23667 CHECK_EQ(1, last_event_status); |
23674 } | 23668 } |
23675 | 23669 |
23676 | 23670 |
23677 TEST(Promises) { | 23671 TEST(Promises) { |
23678 LocalContext context; | 23672 LocalContext context; |
23679 v8::Isolate* isolate = context->GetIsolate(); | 23673 v8::Isolate* isolate = context->GetIsolate(); |
23680 v8::HandleScope scope(isolate); | 23674 v8::HandleScope scope(isolate); |
23681 Handle<Object> global = context->Global(); | 23675 Handle<Object> global = context->Global(); |
23682 | 23676 |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
23795 "function f2(x) { x2 = x; return x+1 };\n"); | 23789 "function f2(x) { x2 = x; return x+1 };\n"); |
23796 Handle<Function> f1 = Handle<Function>::Cast(global->Get(v8_str("f1"))); | 23790 Handle<Function> f1 = Handle<Function>::Cast(global->Get(v8_str("f1"))); |
23797 Handle<Function> f2 = Handle<Function>::Cast(global->Get(v8_str("f2"))); | 23791 Handle<Function> f2 = Handle<Function>::Cast(global->Get(v8_str("f2"))); |
23798 | 23792 |
23799 // Chain | 23793 // Chain |
23800 q->Chain(f1); | 23794 q->Chain(f1); |
23801 CHECK(global->Get(v8_str("x1"))->IsNumber()); | 23795 CHECK(global->Get(v8_str("x1"))->IsNumber()); |
23802 CHECK_EQ(0, global->Get(v8_str("x1"))->Int32Value()); | 23796 CHECK_EQ(0, global->Get(v8_str("x1"))->Int32Value()); |
23803 isolate->RunMicrotasks(); | 23797 isolate->RunMicrotasks(); |
23804 CHECK(!global->Get(v8_str("x1"))->IsNumber()); | 23798 CHECK(!global->Get(v8_str("x1"))->IsNumber()); |
23805 CHECK(p->Equals(global->Get(v8_str("x1")))); | 23799 CHECK_EQ(p, global->Get(v8_str("x1"))); |
23806 | 23800 |
23807 // Then | 23801 // Then |
23808 CompileRun("x1 = x2 = 0;"); | 23802 CompileRun("x1 = x2 = 0;"); |
23809 q->Then(f1); | 23803 q->Then(f1); |
23810 CHECK_EQ(0, global->Get(v8_str("x1"))->Int32Value()); | 23804 CHECK_EQ(0, global->Get(v8_str("x1"))->Int32Value()); |
23811 isolate->RunMicrotasks(); | 23805 isolate->RunMicrotasks(); |
23812 CHECK_EQ(1, global->Get(v8_str("x1"))->Int32Value()); | 23806 CHECK_EQ(1, global->Get(v8_str("x1"))->Int32Value()); |
23813 | 23807 |
23814 // Then | 23808 // Then |
23815 CompileRun("x1 = x2 = 0;"); | 23809 CompileRun("x1 = x2 = 0;"); |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
23935 v8::HandleScope scope(isolate); | 23929 v8::HandleScope scope(isolate); |
23936 const char* url = "http://www.foo.com/foo.js"; | 23930 const char* url = "http://www.foo.com/foo.js"; |
23937 v8::ScriptOrigin origin(v8_str(url), v8::Integer::New(isolate, 13)); | 23931 v8::ScriptOrigin origin(v8_str(url), v8::Integer::New(isolate, 13)); |
23938 v8::ScriptCompiler::Source script_source(v8_str("var foo;"), origin); | 23932 v8::ScriptCompiler::Source script_source(v8_str("var foo;"), origin); |
23939 Local<Script> script = v8::ScriptCompiler::Compile( | 23933 Local<Script> script = v8::ScriptCompiler::Compile( |
23940 isolate, &script_source); | 23934 isolate, &script_source); |
23941 Local<Value> script_name = script->GetUnboundScript()->GetScriptName(); | 23935 Local<Value> script_name = script->GetUnboundScript()->GetScriptName(); |
23942 CHECK(!script_name.IsEmpty()); | 23936 CHECK(!script_name.IsEmpty()); |
23943 CHECK(script_name->IsString()); | 23937 CHECK(script_name->IsString()); |
23944 String::Utf8Value utf8_name(script_name); | 23938 String::Utf8Value utf8_name(script_name); |
23945 CHECK_EQ(0, strcmp(url, *utf8_name)); | 23939 CHECK_EQ(url, *utf8_name); |
23946 int line_number = script->GetUnboundScript()->GetLineNumber(0); | 23940 int line_number = script->GetUnboundScript()->GetLineNumber(0); |
23947 CHECK_EQ(13, line_number); | 23941 CHECK_EQ(13, line_number); |
23948 } | 23942 } |
23949 | 23943 |
23950 void CheckMagicComments(Handle<Script> script, const char* expected_source_url, | 23944 void CheckMagicComments(Handle<Script> script, const char* expected_source_url, |
23951 const char* expected_source_mapping_url) { | 23945 const char* expected_source_mapping_url) { |
23952 if (expected_source_url != NULL) { | 23946 if (expected_source_url != NULL) { |
23953 v8::String::Utf8Value url(script->GetUnboundScript()->GetSourceURL()); | 23947 v8::String::Utf8Value url(script->GetUnboundScript()->GetSourceURL()); |
23954 CHECK_EQ(0, strcmp(expected_source_url, *url)); | 23948 CHECK_EQ(expected_source_url, *url); |
23955 } else { | 23949 } else { |
23956 CHECK(script->GetUnboundScript()->GetSourceURL()->IsUndefined()); | 23950 CHECK(script->GetUnboundScript()->GetSourceURL()->IsUndefined()); |
23957 } | 23951 } |
23958 if (expected_source_mapping_url != NULL) { | 23952 if (expected_source_mapping_url != NULL) { |
23959 v8::String::Utf8Value url( | 23953 v8::String::Utf8Value url( |
23960 script->GetUnboundScript()->GetSourceMappingURL()); | 23954 script->GetUnboundScript()->GetSourceMappingURL()); |
23961 CHECK_EQ(0, strcmp(expected_source_mapping_url, *url)); | 23955 CHECK_EQ(expected_source_mapping_url, *url); |
23962 } else { | 23956 } else { |
23963 CHECK(script->GetUnboundScript()->GetSourceMappingURL()->IsUndefined()); | 23957 CHECK(script->GetUnboundScript()->GetSourceMappingURL()->IsUndefined()); |
23964 } | 23958 } |
23965 } | 23959 } |
23966 | 23960 |
23967 void SourceURLHelper(const char* source, const char* expected_source_url, | 23961 void SourceURLHelper(const char* source, const char* expected_source_url, |
23968 const char* expected_source_mapping_url) { | 23962 const char* expected_source_mapping_url) { |
23969 Local<Script> script = v8_compile(source); | 23963 Local<Script> script = v8_compile(source); |
23970 CheckMagicComments(script, expected_source_url, expected_source_mapping_url); | 23964 CheckMagicComments(script, expected_source_url, expected_source_mapping_url); |
23971 } | 23965 } |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
24042 "var x = { value : 13};" | 24036 "var x = { value : 13};" |
24043 "Object.defineProperty(x, 'p0', {value : 12});" | 24037 "Object.defineProperty(x, 'p0', {value : 12});" |
24044 "Object.defineProperty(x, 'p1', {" | 24038 "Object.defineProperty(x, 'p1', {" |
24045 " set : function(value) { this.value = value; }," | 24039 " set : function(value) { this.value = value; }," |
24046 " get : function() { return this.value; }," | 24040 " get : function() { return this.value; }," |
24047 "});"); | 24041 "});"); |
24048 Local<Object> x = Local<Object>::Cast(env->Global()->Get(v8_str("x"))); | 24042 Local<Object> x = Local<Object>::Cast(env->Global()->Get(v8_str("x"))); |
24049 Local<Value> desc = x->GetOwnPropertyDescriptor(v8_str("no_prop")); | 24043 Local<Value> desc = x->GetOwnPropertyDescriptor(v8_str("no_prop")); |
24050 CHECK(desc->IsUndefined()); | 24044 CHECK(desc->IsUndefined()); |
24051 desc = x->GetOwnPropertyDescriptor(v8_str("p0")); | 24045 desc = x->GetOwnPropertyDescriptor(v8_str("p0")); |
24052 CHECK(v8_num(12)->Equals(Local<Object>::Cast(desc)->Get(v8_str("value")))); | 24046 CHECK_EQ(v8_num(12), Local<Object>::Cast(desc)->Get(v8_str("value"))); |
24053 desc = x->GetOwnPropertyDescriptor(v8_str("p1")); | 24047 desc = x->GetOwnPropertyDescriptor(v8_str("p1")); |
24054 Local<Function> set = | 24048 Local<Function> set = |
24055 Local<Function>::Cast(Local<Object>::Cast(desc)->Get(v8_str("set"))); | 24049 Local<Function>::Cast(Local<Object>::Cast(desc)->Get(v8_str("set"))); |
24056 Local<Function> get = | 24050 Local<Function> get = |
24057 Local<Function>::Cast(Local<Object>::Cast(desc)->Get(v8_str("get"))); | 24051 Local<Function>::Cast(Local<Object>::Cast(desc)->Get(v8_str("get"))); |
24058 CHECK(v8_num(13)->Equals(get->Call(x, 0, NULL))); | 24052 CHECK_EQ(v8_num(13), get->Call(x, 0, NULL)); |
24059 Handle<Value> args[] = { v8_num(14) }; | 24053 Handle<Value> args[] = { v8_num(14) }; |
24060 set->Call(x, 1, args); | 24054 set->Call(x, 1, args); |
24061 CHECK(v8_num(14)->Equals(get->Call(x, 0, NULL))); | 24055 CHECK_EQ(v8_num(14), get->Call(x, 0, NULL)); |
24062 } | 24056 } |
24063 | 24057 |
24064 | 24058 |
24065 TEST(Regress411877) { | 24059 TEST(Regress411877) { |
24066 v8::Isolate* isolate = CcTest::isolate(); | 24060 v8::Isolate* isolate = CcTest::isolate(); |
24067 v8::HandleScope handle_scope(isolate); | 24061 v8::HandleScope handle_scope(isolate); |
24068 v8::Handle<v8::ObjectTemplate> object_template = | 24062 v8::Handle<v8::ObjectTemplate> object_template = |
24069 v8::ObjectTemplate::New(isolate); | 24063 v8::ObjectTemplate::New(isolate); |
24070 object_template->SetAccessCheckCallbacks(NamedAccessCounter, | 24064 object_template->SetAccessCheckCallbacks(NamedAccessCounter, |
24071 IndexedAccessCounter); | 24065 IndexedAccessCounter); |
(...skipping 708 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
24780 "bar2.js"); | 24774 "bar2.js"); |
24781 } | 24775 } |
24782 | 24776 |
24783 | 24777 |
24784 TEST(StreamingScriptWithSourceMappingURLInTheMiddle) { | 24778 TEST(StreamingScriptWithSourceMappingURLInTheMiddle) { |
24785 const char* chunks[] = {"function foo() { ret", "urn 13; }\n//#", | 24779 const char* chunks[] = {"function foo() { ret", "urn 13; }\n//#", |
24786 " sourceMappingURL=bar2.js\n", "foo();", NULL}; | 24780 " sourceMappingURL=bar2.js\n", "foo();", NULL}; |
24787 RunStreamingTest(chunks, v8::ScriptCompiler::StreamedSource::UTF8, true, NULL, | 24781 RunStreamingTest(chunks, v8::ScriptCompiler::StreamedSource::UTF8, true, NULL, |
24788 "bar2.js"); | 24782 "bar2.js"); |
24789 } | 24783 } |
OLD | NEW |