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

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

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

Powered by Google App Engine
This is Rietveld 408576698