| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 static Local<Value> signature_expected_receiver; | 146 static Local<Value> signature_expected_receiver; |
| 147 static void IncrementingSignatureCallback( | 147 static void IncrementingSignatureCallback( |
| 148 const v8::FunctionCallbackInfo<v8::Value>& args) { | 148 const v8::FunctionCallbackInfo<v8::Value>& args) { |
| 149 ApiTestFuzzer::Fuzz(); | 149 ApiTestFuzzer::Fuzz(); |
| 150 signature_callback_count++; | 150 signature_callback_count++; |
| 151 CHECK_EQ(signature_expected_receiver, args.Holder()); | 151 CHECK_EQ(signature_expected_receiver, args.Holder()); |
| 152 CHECK_EQ(signature_expected_receiver, args.This()); | 152 CHECK_EQ(signature_expected_receiver, args.This()); |
| 153 v8::Handle<v8::Array> result = | 153 v8::Handle<v8::Array> result = |
| 154 v8::Array::New(args.GetIsolate(), args.Length()); | 154 v8::Array::New(args.GetIsolate(), args.Length()); |
| 155 for (int i = 0; i < args.Length(); i++) | 155 for (int i = 0; i < args.Length(); i++) |
| 156 result->Set(v8::Integer::New(i), args[i]); | 156 result->Set(v8::Integer::New(args.GetIsolate(), i), args[i]); |
| 157 args.GetReturnValue().Set(result); | 157 args.GetReturnValue().Set(result); |
| 158 } | 158 } |
| 159 | 159 |
| 160 | 160 |
| 161 static void SignatureCallback( | 161 static void SignatureCallback( |
| 162 const v8::FunctionCallbackInfo<v8::Value>& args) { | 162 const v8::FunctionCallbackInfo<v8::Value>& args) { |
| 163 ApiTestFuzzer::Fuzz(); | 163 ApiTestFuzzer::Fuzz(); |
| 164 v8::Handle<v8::Array> result = | 164 v8::Handle<v8::Array> result = |
| 165 v8::Array::New(args.GetIsolate(), args.Length()); | 165 v8::Array::New(args.GetIsolate(), args.Length()); |
| 166 for (int i = 0; i < args.Length(); i++) { | 166 for (int i = 0; i < args.Length(); i++) { |
| 167 result->Set(v8::Integer::New(i), args[i]); | 167 result->Set(v8::Integer::New(args.GetIsolate(), i), args[i]); |
| 168 } | 168 } |
| 169 args.GetReturnValue().Set(result); | 169 args.GetReturnValue().Set(result); |
| 170 } | 170 } |
| 171 | 171 |
| 172 | 172 |
| 173 // Tests that call v8::V8::Dispose() cannot be threaded. | 173 // Tests that call v8::V8::Dispose() cannot be threaded. |
| 174 TEST(InitializeAndDisposeOnce) { | 174 TEST(InitializeAndDisposeOnce) { |
| 175 CHECK(v8::V8::Initialize()); | 175 CHECK(v8::V8::Initialize()); |
| 176 CHECK(v8::V8::Dispose()); | 176 CHECK(v8::V8::Dispose()); |
| 177 } | 177 } |
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 404 undef_str->WriteUtf8(value); | 404 undef_str->WriteUtf8(value); |
| 405 CHECK_EQ(0, strcmp(value, "undefined")); | 405 CHECK_EQ(0, strcmp(value, "undefined")); |
| 406 i::DeleteArray(value); | 406 i::DeleteArray(value); |
| 407 } | 407 } |
| 408 | 408 |
| 409 | 409 |
| 410 THREADED_TEST(Access) { | 410 THREADED_TEST(Access) { |
| 411 LocalContext env; | 411 LocalContext env; |
| 412 v8::Isolate* isolate = env->GetIsolate(); | 412 v8::Isolate* isolate = env->GetIsolate(); |
| 413 v8::HandleScope scope(isolate); | 413 v8::HandleScope scope(isolate); |
| 414 Local<v8::Object> obj = v8::Object::New(); | 414 Local<v8::Object> obj = v8::Object::New(isolate); |
| 415 Local<Value> foo_before = obj->Get(v8_str("foo")); | 415 Local<Value> foo_before = obj->Get(v8_str("foo")); |
| 416 CHECK(foo_before->IsUndefined()); | 416 CHECK(foo_before->IsUndefined()); |
| 417 Local<String> bar_str = v8_str("bar"); | 417 Local<String> bar_str = v8_str("bar"); |
| 418 obj->Set(v8_str("foo"), bar_str); | 418 obj->Set(v8_str("foo"), bar_str); |
| 419 Local<Value> foo_after = obj->Get(v8_str("foo")); | 419 Local<Value> foo_after = obj->Get(v8_str("foo")); |
| 420 CHECK(!foo_after->IsUndefined()); | 420 CHECK(!foo_after->IsUndefined()); |
| 421 CHECK(foo_after->IsString()); | 421 CHECK(foo_after->IsString()); |
| 422 CHECK_EQ(bar_str, foo_after); | 422 CHECK_EQ(bar_str, foo_after); |
| 423 } | 423 } |
| 424 | 424 |
| 425 | 425 |
| 426 THREADED_TEST(AccessElement) { | 426 THREADED_TEST(AccessElement) { |
| 427 LocalContext env; | 427 LocalContext env; |
| 428 v8::HandleScope scope(env->GetIsolate()); | 428 v8::HandleScope scope(env->GetIsolate()); |
| 429 Local<v8::Object> obj = v8::Object::New(); | 429 Local<v8::Object> obj = v8::Object::New(env->GetIsolate()); |
| 430 Local<Value> before = obj->Get(1); | 430 Local<Value> before = obj->Get(1); |
| 431 CHECK(before->IsUndefined()); | 431 CHECK(before->IsUndefined()); |
| 432 Local<String> bar_str = v8_str("bar"); | 432 Local<String> bar_str = v8_str("bar"); |
| 433 obj->Set(1, bar_str); | 433 obj->Set(1, bar_str); |
| 434 Local<Value> after = obj->Get(1); | 434 Local<Value> after = obj->Get(1); |
| 435 CHECK(!after->IsUndefined()); | 435 CHECK(!after->IsUndefined()); |
| 436 CHECK(after->IsString()); | 436 CHECK(after->IsString()); |
| 437 CHECK_EQ(bar_str, after); | 437 CHECK_EQ(bar_str, after); |
| 438 | 438 |
| 439 Local<v8::Array> value = CompileRun("[\"a\", \"b\"]").As<v8::Array>(); | 439 Local<v8::Array> value = CompileRun("[\"a\", \"b\"]").As<v8::Array>(); |
| (...skipping 752 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1192 case kEmptyStringReturnValue: | 1192 case kEmptyStringReturnValue: |
| 1193 info.GetReturnValue().SetEmptyString(); | 1193 info.GetReturnValue().SetEmptyString(); |
| 1194 break; | 1194 break; |
| 1195 } | 1195 } |
| 1196 } | 1196 } |
| 1197 | 1197 |
| 1198 template<> | 1198 template<> |
| 1199 void FastReturnValueCallback<Object>( | 1199 void FastReturnValueCallback<Object>( |
| 1200 const v8::FunctionCallbackInfo<v8::Value>& info) { | 1200 const v8::FunctionCallbackInfo<v8::Value>& info) { |
| 1201 v8::Handle<v8::Object> object; | 1201 v8::Handle<v8::Object> object; |
| 1202 if (!fast_return_value_object_is_empty) object = Object::New(); | 1202 if (!fast_return_value_object_is_empty) { |
| 1203 object = Object::New(info.GetIsolate()); |
| 1204 } |
| 1203 info.GetReturnValue().Set(object); | 1205 info.GetReturnValue().Set(object); |
| 1204 } | 1206 } |
| 1205 | 1207 |
| 1206 template<typename T> | 1208 template<typename T> |
| 1207 Handle<Value> TestFastReturnValues() { | 1209 Handle<Value> TestFastReturnValues() { |
| 1208 LocalContext env; | 1210 LocalContext env; |
| 1209 v8::EscapableHandleScope scope(env->GetIsolate()); | 1211 v8::EscapableHandleScope scope(env->GetIsolate()); |
| 1210 v8::Handle<v8::ObjectTemplate> object_template = v8::ObjectTemplate::New(); | 1212 v8::Handle<v8::ObjectTemplate> object_template = v8::ObjectTemplate::New(); |
| 1211 v8::FunctionCallback callback = &FastReturnValueCallback<T>; | 1213 v8::FunctionCallback callback = &FastReturnValueCallback<T>; |
| 1212 object_template->Set(env->GetIsolate(), "callback", | 1214 object_template->Set(env->GetIsolate(), "callback", |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1330 | 1332 |
| 1331 | 1333 |
| 1332 static void TestExternalPointerWrapping() { | 1334 static void TestExternalPointerWrapping() { |
| 1333 LocalContext env; | 1335 LocalContext env; |
| 1334 v8::Isolate* isolate = env->GetIsolate(); | 1336 v8::Isolate* isolate = env->GetIsolate(); |
| 1335 v8::HandleScope scope(isolate); | 1337 v8::HandleScope scope(isolate); |
| 1336 | 1338 |
| 1337 v8::Handle<v8::Value> data = | 1339 v8::Handle<v8::Value> data = |
| 1338 v8::External::New(isolate, expected_ptr); | 1340 v8::External::New(isolate, expected_ptr); |
| 1339 | 1341 |
| 1340 v8::Handle<v8::Object> obj = v8::Object::New(); | 1342 v8::Handle<v8::Object> obj = v8::Object::New(isolate); |
| 1341 obj->Set(v8_str("func"), | 1343 obj->Set(v8_str("func"), |
| 1342 v8::FunctionTemplate::New(isolate, callback, data)->GetFunction()); | 1344 v8::FunctionTemplate::New(isolate, callback, data)->GetFunction()); |
| 1343 env->Global()->Set(v8_str("obj"), obj); | 1345 env->Global()->Set(v8_str("obj"), obj); |
| 1344 | 1346 |
| 1345 CHECK(CompileRun( | 1347 CHECK(CompileRun( |
| 1346 "function foo() {\n" | 1348 "function foo() {\n" |
| 1347 " for (var i = 0; i < 13; i++) obj.func();\n" | 1349 " for (var i = 0; i < 13; i++) obj.func();\n" |
| 1348 "}\n" | 1350 "}\n" |
| 1349 "foo(), true")->BooleanValue()); | 1351 "foo(), true")->BooleanValue()); |
| 1350 } | 1352 } |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1439 other_instance->FindInstanceInPrototypeChain(base)); | 1441 other_instance->FindInstanceInPrototypeChain(base)); |
| 1440 CHECK_EQ(derived_instance2, | 1442 CHECK_EQ(derived_instance2, |
| 1441 other_instance->FindInstanceInPrototypeChain(derived)); | 1443 other_instance->FindInstanceInPrototypeChain(derived)); |
| 1442 CHECK_EQ(other_instance, | 1444 CHECK_EQ(other_instance, |
| 1443 other_instance->FindInstanceInPrototypeChain(other)); | 1445 other_instance->FindInstanceInPrototypeChain(other)); |
| 1444 } | 1446 } |
| 1445 | 1447 |
| 1446 | 1448 |
| 1447 THREADED_TEST(TinyInteger) { | 1449 THREADED_TEST(TinyInteger) { |
| 1448 LocalContext env; | 1450 LocalContext env; |
| 1449 v8::HandleScope scope(env->GetIsolate()); | 1451 v8::Isolate* isolate = env->GetIsolate(); |
| 1450 v8::Isolate* isolate = CcTest::isolate(); | 1452 v8::HandleScope scope(isolate); |
| 1451 | 1453 |
| 1452 int32_t value = 239; | 1454 int32_t value = 239; |
| 1453 Local<v8::Integer> value_obj = v8::Integer::New(value); | 1455 Local<v8::Integer> value_obj = v8::Integer::New(isolate, value); |
| 1454 CHECK_EQ(static_cast<int64_t>(value), value_obj->Value()); | 1456 CHECK_EQ(static_cast<int64_t>(value), value_obj->Value()); |
| 1455 | 1457 |
| 1456 value_obj = v8::Integer::New(value, isolate); | 1458 value_obj = v8::Integer::New(isolate, value); |
| 1457 CHECK_EQ(static_cast<int64_t>(value), value_obj->Value()); | 1459 CHECK_EQ(static_cast<int64_t>(value), value_obj->Value()); |
| 1458 } | 1460 } |
| 1459 | 1461 |
| 1460 | 1462 |
| 1461 THREADED_TEST(BigSmiInteger) { | 1463 THREADED_TEST(BigSmiInteger) { |
| 1462 LocalContext env; | 1464 LocalContext env; |
| 1463 v8::HandleScope scope(env->GetIsolate()); | 1465 v8::HandleScope scope(env->GetIsolate()); |
| 1464 v8::Isolate* isolate = CcTest::isolate(); | 1466 v8::Isolate* isolate = CcTest::isolate(); |
| 1465 | 1467 |
| 1466 int32_t value = i::Smi::kMaxValue; | 1468 int32_t value = i::Smi::kMaxValue; |
| 1467 // We cannot add one to a Smi::kMaxValue without wrapping. | 1469 // We cannot add one to a Smi::kMaxValue without wrapping. |
| 1468 if (i::SmiValuesAre31Bits()) { | 1470 if (i::SmiValuesAre31Bits()) { |
| 1469 CHECK(i::Smi::IsValid(value)); | 1471 CHECK(i::Smi::IsValid(value)); |
| 1470 CHECK(!i::Smi::IsValid(value + 1)); | 1472 CHECK(!i::Smi::IsValid(value + 1)); |
| 1471 | 1473 |
| 1472 Local<v8::Integer> value_obj = v8::Integer::New(value); | 1474 Local<v8::Integer> value_obj = v8::Integer::New(isolate, value); |
| 1473 CHECK_EQ(static_cast<int64_t>(value), value_obj->Value()); | 1475 CHECK_EQ(static_cast<int64_t>(value), value_obj->Value()); |
| 1474 | 1476 |
| 1475 value_obj = v8::Integer::New(value, isolate); | 1477 value_obj = v8::Integer::New(isolate, value); |
| 1476 CHECK_EQ(static_cast<int64_t>(value), value_obj->Value()); | 1478 CHECK_EQ(static_cast<int64_t>(value), value_obj->Value()); |
| 1477 } | 1479 } |
| 1478 } | 1480 } |
| 1479 | 1481 |
| 1480 | 1482 |
| 1481 THREADED_TEST(BigInteger) { | 1483 THREADED_TEST(BigInteger) { |
| 1482 LocalContext env; | 1484 LocalContext env; |
| 1483 v8::HandleScope scope(env->GetIsolate()); | 1485 v8::HandleScope scope(env->GetIsolate()); |
| 1484 v8::Isolate* isolate = CcTest::isolate(); | 1486 v8::Isolate* isolate = CcTest::isolate(); |
| 1485 | 1487 |
| 1486 // We cannot add one to a Smi::kMaxValue without wrapping. | 1488 // We cannot add one to a Smi::kMaxValue without wrapping. |
| 1487 if (i::SmiValuesAre31Bits()) { | 1489 if (i::SmiValuesAre31Bits()) { |
| 1488 // The casts allow this to compile, even if Smi::kMaxValue is 2^31-1. | 1490 // The casts allow this to compile, even if Smi::kMaxValue is 2^31-1. |
| 1489 // The code will not be run in that case, due to the "if" guard. | 1491 // The code will not be run in that case, due to the "if" guard. |
| 1490 int32_t value = | 1492 int32_t value = |
| 1491 static_cast<int32_t>(static_cast<uint32_t>(i::Smi::kMaxValue) + 1); | 1493 static_cast<int32_t>(static_cast<uint32_t>(i::Smi::kMaxValue) + 1); |
| 1492 CHECK(value > i::Smi::kMaxValue); | 1494 CHECK(value > i::Smi::kMaxValue); |
| 1493 CHECK(!i::Smi::IsValid(value)); | 1495 CHECK(!i::Smi::IsValid(value)); |
| 1494 | 1496 |
| 1495 Local<v8::Integer> value_obj = v8::Integer::New(value); | 1497 Local<v8::Integer> value_obj = v8::Integer::New(isolate, value); |
| 1496 CHECK_EQ(static_cast<int64_t>(value), value_obj->Value()); | 1498 CHECK_EQ(static_cast<int64_t>(value), value_obj->Value()); |
| 1497 | 1499 |
| 1498 value_obj = v8::Integer::New(value, isolate); | 1500 value_obj = v8::Integer::New(isolate, value); |
| 1499 CHECK_EQ(static_cast<int64_t>(value), value_obj->Value()); | 1501 CHECK_EQ(static_cast<int64_t>(value), value_obj->Value()); |
| 1500 } | 1502 } |
| 1501 } | 1503 } |
| 1502 | 1504 |
| 1503 | 1505 |
| 1504 THREADED_TEST(TinyUnsignedInteger) { | 1506 THREADED_TEST(TinyUnsignedInteger) { |
| 1505 LocalContext env; | 1507 LocalContext env; |
| 1506 v8::HandleScope scope(env->GetIsolate()); | 1508 v8::HandleScope scope(env->GetIsolate()); |
| 1507 v8::Isolate* isolate = CcTest::isolate(); | 1509 v8::Isolate* isolate = CcTest::isolate(); |
| 1508 | 1510 |
| 1509 uint32_t value = 239; | 1511 uint32_t value = 239; |
| 1510 | 1512 |
| 1511 Local<v8::Integer> value_obj = v8::Integer::NewFromUnsigned(value); | 1513 Local<v8::Integer> value_obj = v8::Integer::NewFromUnsigned(isolate, value); |
| 1512 CHECK_EQ(static_cast<int64_t>(value), value_obj->Value()); | 1514 CHECK_EQ(static_cast<int64_t>(value), value_obj->Value()); |
| 1513 | 1515 |
| 1514 value_obj = v8::Integer::NewFromUnsigned(value, isolate); | 1516 value_obj = v8::Integer::NewFromUnsigned(isolate, value); |
| 1515 CHECK_EQ(static_cast<int64_t>(value), value_obj->Value()); | 1517 CHECK_EQ(static_cast<int64_t>(value), value_obj->Value()); |
| 1516 } | 1518 } |
| 1517 | 1519 |
| 1518 | 1520 |
| 1519 THREADED_TEST(BigUnsignedSmiInteger) { | 1521 THREADED_TEST(BigUnsignedSmiInteger) { |
| 1520 LocalContext env; | 1522 LocalContext env; |
| 1521 v8::HandleScope scope(env->GetIsolate()); | 1523 v8::HandleScope scope(env->GetIsolate()); |
| 1522 v8::Isolate* isolate = CcTest::isolate(); | 1524 v8::Isolate* isolate = CcTest::isolate(); |
| 1523 | 1525 |
| 1524 uint32_t value = static_cast<uint32_t>(i::Smi::kMaxValue); | 1526 uint32_t value = static_cast<uint32_t>(i::Smi::kMaxValue); |
| 1525 CHECK(i::Smi::IsValid(value)); | 1527 CHECK(i::Smi::IsValid(value)); |
| 1526 CHECK(!i::Smi::IsValid(value + 1)); | 1528 CHECK(!i::Smi::IsValid(value + 1)); |
| 1527 | 1529 |
| 1528 Local<v8::Integer> value_obj = v8::Integer::NewFromUnsigned(value); | 1530 Local<v8::Integer> value_obj = v8::Integer::NewFromUnsigned(isolate, value); |
| 1529 CHECK_EQ(static_cast<int64_t>(value), value_obj->Value()); | 1531 CHECK_EQ(static_cast<int64_t>(value), value_obj->Value()); |
| 1530 | 1532 |
| 1531 value_obj = v8::Integer::NewFromUnsigned(value, isolate); | 1533 value_obj = v8::Integer::NewFromUnsigned(isolate, value); |
| 1532 CHECK_EQ(static_cast<int64_t>(value), value_obj->Value()); | 1534 CHECK_EQ(static_cast<int64_t>(value), value_obj->Value()); |
| 1533 } | 1535 } |
| 1534 | 1536 |
| 1535 | 1537 |
| 1536 THREADED_TEST(BigUnsignedInteger) { | 1538 THREADED_TEST(BigUnsignedInteger) { |
| 1537 LocalContext env; | 1539 LocalContext env; |
| 1538 v8::HandleScope scope(env->GetIsolate()); | 1540 v8::HandleScope scope(env->GetIsolate()); |
| 1539 v8::Isolate* isolate = CcTest::isolate(); | 1541 v8::Isolate* isolate = CcTest::isolate(); |
| 1540 | 1542 |
| 1541 uint32_t value = static_cast<uint32_t>(i::Smi::kMaxValue) + 1; | 1543 uint32_t value = static_cast<uint32_t>(i::Smi::kMaxValue) + 1; |
| 1542 CHECK(value > static_cast<uint32_t>(i::Smi::kMaxValue)); | 1544 CHECK(value > static_cast<uint32_t>(i::Smi::kMaxValue)); |
| 1543 CHECK(!i::Smi::IsValid(value)); | 1545 CHECK(!i::Smi::IsValid(value)); |
| 1544 | 1546 |
| 1545 Local<v8::Integer> value_obj = v8::Integer::NewFromUnsigned(value); | 1547 Local<v8::Integer> value_obj = v8::Integer::NewFromUnsigned(isolate, value); |
| 1546 CHECK_EQ(static_cast<int64_t>(value), value_obj->Value()); | 1548 CHECK_EQ(static_cast<int64_t>(value), value_obj->Value()); |
| 1547 | 1549 |
| 1548 value_obj = v8::Integer::NewFromUnsigned(value, isolate); | 1550 value_obj = v8::Integer::NewFromUnsigned(isolate, value); |
| 1549 CHECK_EQ(static_cast<int64_t>(value), value_obj->Value()); | 1551 CHECK_EQ(static_cast<int64_t>(value), value_obj->Value()); |
| 1550 } | 1552 } |
| 1551 | 1553 |
| 1552 | 1554 |
| 1553 THREADED_TEST(OutOfSignedRangeUnsignedInteger) { | 1555 THREADED_TEST(OutOfSignedRangeUnsignedInteger) { |
| 1554 LocalContext env; | 1556 LocalContext env; |
| 1555 v8::HandleScope scope(env->GetIsolate()); | 1557 v8::HandleScope scope(env->GetIsolate()); |
| 1556 v8::Isolate* isolate = CcTest::isolate(); | 1558 v8::Isolate* isolate = CcTest::isolate(); |
| 1557 | 1559 |
| 1558 uint32_t INT32_MAX_AS_UINT = (1U << 31) - 1; | 1560 uint32_t INT32_MAX_AS_UINT = (1U << 31) - 1; |
| 1559 uint32_t value = INT32_MAX_AS_UINT + 1; | 1561 uint32_t value = INT32_MAX_AS_UINT + 1; |
| 1560 CHECK(value > INT32_MAX_AS_UINT); // No overflow. | 1562 CHECK(value > INT32_MAX_AS_UINT); // No overflow. |
| 1561 | 1563 |
| 1562 Local<v8::Integer> value_obj = v8::Integer::NewFromUnsigned(value); | 1564 Local<v8::Integer> value_obj = v8::Integer::NewFromUnsigned(isolate, value); |
| 1563 CHECK_EQ(static_cast<int64_t>(value), value_obj->Value()); | 1565 CHECK_EQ(static_cast<int64_t>(value), value_obj->Value()); |
| 1564 | 1566 |
| 1565 value_obj = v8::Integer::NewFromUnsigned(value, isolate); | 1567 value_obj = v8::Integer::NewFromUnsigned(isolate, value); |
| 1566 CHECK_EQ(static_cast<int64_t>(value), value_obj->Value()); | 1568 CHECK_EQ(static_cast<int64_t>(value), value_obj->Value()); |
| 1567 } | 1569 } |
| 1568 | 1570 |
| 1569 | 1571 |
| 1570 THREADED_TEST(IsNativeError) { | 1572 THREADED_TEST(IsNativeError) { |
| 1571 LocalContext env; | 1573 LocalContext env; |
| 1572 v8::HandleScope scope(env->GetIsolate()); | 1574 v8::HandleScope scope(env->GetIsolate()); |
| 1573 v8::Handle<Value> syntax_error = CompileRun( | 1575 v8::Handle<Value> syntax_error = CompileRun( |
| 1574 "var out = 0; try { eval(\"#\"); } catch(x) { out = x; } out; "); | 1576 "var out = 0; try { eval(\"#\"); } catch(x) { out = x; } out; "); |
| 1575 CHECK(syntax_error->IsNativeError()); | 1577 CHECK(syntax_error->IsNativeError()); |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1701 CHECK(true_boolean_object->ValueOf()); | 1703 CHECK(true_boolean_object->ValueOf()); |
| 1702 CHECK(!true_boolean_object->IsTrue()); | 1704 CHECK(!true_boolean_object->IsTrue()); |
| 1703 CHECK(!true_boolean_object->IsFalse()); | 1705 CHECK(!true_boolean_object->IsFalse()); |
| 1704 } | 1706 } |
| 1705 | 1707 |
| 1706 | 1708 |
| 1707 THREADED_TEST(Number) { | 1709 THREADED_TEST(Number) { |
| 1708 LocalContext env; | 1710 LocalContext env; |
| 1709 v8::HandleScope scope(env->GetIsolate()); | 1711 v8::HandleScope scope(env->GetIsolate()); |
| 1710 double PI = 3.1415926; | 1712 double PI = 3.1415926; |
| 1711 Local<v8::Number> pi_obj = v8::Number::New(PI); | 1713 Local<v8::Number> pi_obj = v8::Number::New(env->GetIsolate(), PI); |
| 1712 CHECK_EQ(PI, pi_obj->NumberValue()); | 1714 CHECK_EQ(PI, pi_obj->NumberValue()); |
| 1713 } | 1715 } |
| 1714 | 1716 |
| 1715 | 1717 |
| 1716 THREADED_TEST(ToNumber) { | 1718 THREADED_TEST(ToNumber) { |
| 1717 LocalContext env; | 1719 LocalContext env; |
| 1718 v8::Isolate* isolate = CcTest::isolate(); | 1720 v8::Isolate* isolate = CcTest::isolate(); |
| 1719 v8::HandleScope scope(isolate); | 1721 v8::HandleScope scope(isolate); |
| 1720 Local<String> str = v8_str("3.1415926"); | 1722 Local<String> str = v8_str("3.1415926"); |
| 1721 CHECK_EQ(3.1415926, str->NumberValue()); | 1723 CHECK_EQ(3.1415926, str->NumberValue()); |
| 1722 v8::Handle<v8::Boolean> t = v8::True(isolate); | 1724 v8::Handle<v8::Boolean> t = v8::True(isolate); |
| 1723 CHECK_EQ(1.0, t->NumberValue()); | 1725 CHECK_EQ(1.0, t->NumberValue()); |
| 1724 v8::Handle<v8::Boolean> f = v8::False(isolate); | 1726 v8::Handle<v8::Boolean> f = v8::False(isolate); |
| 1725 CHECK_EQ(0.0, f->NumberValue()); | 1727 CHECK_EQ(0.0, f->NumberValue()); |
| 1726 } | 1728 } |
| 1727 | 1729 |
| 1728 | 1730 |
| 1729 THREADED_TEST(Date) { | 1731 THREADED_TEST(Date) { |
| 1730 LocalContext env; | 1732 LocalContext env; |
| 1731 v8::HandleScope scope(env->GetIsolate()); | 1733 v8::HandleScope scope(env->GetIsolate()); |
| 1732 double PI = 3.1415926; | 1734 double PI = 3.1415926; |
| 1733 Local<Value> date = v8::Date::New(env->GetIsolate(), PI); | 1735 Local<Value> date = v8::Date::New(env->GetIsolate(), PI); |
| 1734 CHECK_EQ(3.0, date->NumberValue()); | 1736 CHECK_EQ(3.0, date->NumberValue()); |
| 1735 date.As<v8::Date>()->Set(v8_str("property"), v8::Integer::New(42)); | 1737 date.As<v8::Date>()->Set(v8_str("property"), |
| 1738 v8::Integer::New(env->GetIsolate(), 42)); |
| 1736 CHECK_EQ(42, date.As<v8::Date>()->Get(v8_str("property"))->Int32Value()); | 1739 CHECK_EQ(42, date.As<v8::Date>()->Get(v8_str("property"))->Int32Value()); |
| 1737 } | 1740 } |
| 1738 | 1741 |
| 1739 | 1742 |
| 1740 THREADED_TEST(Boolean) { | 1743 THREADED_TEST(Boolean) { |
| 1741 LocalContext env; | 1744 LocalContext env; |
| 1742 v8::HandleScope scope(env->GetIsolate()); | 1745 v8::Isolate* isolate = env->GetIsolate(); |
| 1743 v8::Handle<v8::Boolean> t = v8::True(CcTest::isolate()); | 1746 v8::HandleScope scope(isolate); |
| 1747 v8::Handle<v8::Boolean> t = v8::True(isolate); |
| 1744 CHECK(t->Value()); | 1748 CHECK(t->Value()); |
| 1745 v8::Handle<v8::Boolean> f = v8::False(CcTest::isolate()); | 1749 v8::Handle<v8::Boolean> f = v8::False(isolate); |
| 1746 CHECK(!f->Value()); | 1750 CHECK(!f->Value()); |
| 1747 v8::Handle<v8::Primitive> u = v8::Undefined(CcTest::isolate()); | 1751 v8::Handle<v8::Primitive> u = v8::Undefined(isolate); |
| 1748 CHECK(!u->BooleanValue()); | 1752 CHECK(!u->BooleanValue()); |
| 1749 v8::Handle<v8::Primitive> n = v8::Null(CcTest::isolate()); | 1753 v8::Handle<v8::Primitive> n = v8::Null(isolate); |
| 1750 CHECK(!n->BooleanValue()); | 1754 CHECK(!n->BooleanValue()); |
| 1751 v8::Handle<String> str1 = v8_str(""); | 1755 v8::Handle<String> str1 = v8_str(""); |
| 1752 CHECK(!str1->BooleanValue()); | 1756 CHECK(!str1->BooleanValue()); |
| 1753 v8::Handle<String> str2 = v8_str("x"); | 1757 v8::Handle<String> str2 = v8_str("x"); |
| 1754 CHECK(str2->BooleanValue()); | 1758 CHECK(str2->BooleanValue()); |
| 1755 CHECK(!v8::Number::New(0)->BooleanValue()); | 1759 CHECK(!v8::Number::New(isolate, 0)->BooleanValue()); |
| 1756 CHECK(v8::Number::New(-1)->BooleanValue()); | 1760 CHECK(v8::Number::New(isolate, -1)->BooleanValue()); |
| 1757 CHECK(v8::Number::New(1)->BooleanValue()); | 1761 CHECK(v8::Number::New(isolate, 1)->BooleanValue()); |
| 1758 CHECK(v8::Number::New(42)->BooleanValue()); | 1762 CHECK(v8::Number::New(isolate, 42)->BooleanValue()); |
| 1759 CHECK(!v8_compile("NaN")->Run()->BooleanValue()); | 1763 CHECK(!v8_compile("NaN")->Run()->BooleanValue()); |
| 1760 } | 1764 } |
| 1761 | 1765 |
| 1762 | 1766 |
| 1763 static void DummyCallHandler(const v8::FunctionCallbackInfo<v8::Value>& args) { | 1767 static void DummyCallHandler(const v8::FunctionCallbackInfo<v8::Value>& args) { |
| 1764 ApiTestFuzzer::Fuzz(); | 1768 ApiTestFuzzer::Fuzz(); |
| 1765 args.GetReturnValue().Set(v8_num(13.4)); | 1769 args.GetReturnValue().Set(v8_num(13.4)); |
| 1766 } | 1770 } |
| 1767 | 1771 |
| 1768 | 1772 |
| (...skipping 668 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2437 | 2441 |
| 2438 v8::Handle<Script> call_recursively_script; | 2442 v8::Handle<Script> call_recursively_script; |
| 2439 static const int kTargetRecursionDepth = 200; // near maximum | 2443 static const int kTargetRecursionDepth = 200; // near maximum |
| 2440 | 2444 |
| 2441 | 2445 |
| 2442 static void CallScriptRecursivelyCall( | 2446 static void CallScriptRecursivelyCall( |
| 2443 const v8::FunctionCallbackInfo<v8::Value>& args) { | 2447 const v8::FunctionCallbackInfo<v8::Value>& args) { |
| 2444 ApiTestFuzzer::Fuzz(); | 2448 ApiTestFuzzer::Fuzz(); |
| 2445 int depth = args.This()->Get(v8_str("depth"))->Int32Value(); | 2449 int depth = args.This()->Get(v8_str("depth"))->Int32Value(); |
| 2446 if (depth == kTargetRecursionDepth) return; | 2450 if (depth == kTargetRecursionDepth) return; |
| 2447 args.This()->Set(v8_str("depth"), v8::Integer::New(depth + 1)); | 2451 args.This()->Set(v8_str("depth"), |
| 2452 v8::Integer::New(args.GetIsolate(), depth + 1)); |
| 2448 args.GetReturnValue().Set(call_recursively_script->Run()); | 2453 args.GetReturnValue().Set(call_recursively_script->Run()); |
| 2449 } | 2454 } |
| 2450 | 2455 |
| 2451 | 2456 |
| 2452 static void CallFunctionRecursivelyCall( | 2457 static void CallFunctionRecursivelyCall( |
| 2453 const v8::FunctionCallbackInfo<v8::Value>& args) { | 2458 const v8::FunctionCallbackInfo<v8::Value>& args) { |
| 2454 ApiTestFuzzer::Fuzz(); | 2459 ApiTestFuzzer::Fuzz(); |
| 2455 int depth = args.This()->Get(v8_str("depth"))->Int32Value(); | 2460 int depth = args.This()->Get(v8_str("depth"))->Int32Value(); |
| 2456 if (depth == kTargetRecursionDepth) { | 2461 if (depth == kTargetRecursionDepth) { |
| 2457 printf("[depth = %d]\n", depth); | 2462 printf("[depth = %d]\n", depth); |
| 2458 return; | 2463 return; |
| 2459 } | 2464 } |
| 2460 args.This()->Set(v8_str("depth"), v8::Integer::New(depth + 1)); | 2465 args.This()->Set(v8_str("depth"), |
| 2466 v8::Integer::New(args.GetIsolate(), depth + 1)); |
| 2461 v8::Handle<Value> function = | 2467 v8::Handle<Value> function = |
| 2462 args.This()->Get(v8_str("callFunctionRecursively")); | 2468 args.This()->Get(v8_str("callFunctionRecursively")); |
| 2463 args.GetReturnValue().Set( | 2469 args.GetReturnValue().Set( |
| 2464 function.As<Function>()->Call(args.This(), 0, NULL)); | 2470 function.As<Function>()->Call(args.This(), 0, NULL)); |
| 2465 } | 2471 } |
| 2466 | 2472 |
| 2467 | 2473 |
| 2468 THREADED_TEST(DeepCrossLanguageRecursion) { | 2474 THREADED_TEST(DeepCrossLanguageRecursion) { |
| 2469 v8::Isolate* isolate = CcTest::isolate(); | 2475 v8::Isolate* isolate = CcTest::isolate(); |
| 2470 v8::HandleScope scope(isolate); | 2476 v8::HandleScope scope(isolate); |
| 2471 v8::Handle<v8::ObjectTemplate> global = ObjectTemplate::New(); | 2477 v8::Handle<v8::ObjectTemplate> global = ObjectTemplate::New(); |
| 2472 global->Set(v8_str("callScriptRecursively"), | 2478 global->Set(v8_str("callScriptRecursively"), |
| 2473 v8::FunctionTemplate::New(isolate, CallScriptRecursivelyCall)); | 2479 v8::FunctionTemplate::New(isolate, CallScriptRecursivelyCall)); |
| 2474 global->Set(v8_str("callFunctionRecursively"), | 2480 global->Set(v8_str("callFunctionRecursively"), |
| 2475 v8::FunctionTemplate::New(isolate, CallFunctionRecursivelyCall)); | 2481 v8::FunctionTemplate::New(isolate, CallFunctionRecursivelyCall)); |
| 2476 LocalContext env(NULL, global); | 2482 LocalContext env(NULL, global); |
| 2477 | 2483 |
| 2478 env->Global()->Set(v8_str("depth"), v8::Integer::New(0)); | 2484 env->Global()->Set(v8_str("depth"), v8::Integer::New(isolate, 0)); |
| 2479 call_recursively_script = v8_compile("callScriptRecursively()"); | 2485 call_recursively_script = v8_compile("callScriptRecursively()"); |
| 2480 call_recursively_script->Run(); | 2486 call_recursively_script->Run(); |
| 2481 call_recursively_script = v8::Handle<Script>(); | 2487 call_recursively_script = v8::Handle<Script>(); |
| 2482 | 2488 |
| 2483 env->Global()->Set(v8_str("depth"), v8::Integer::New(0)); | 2489 env->Global()->Set(v8_str("depth"), v8::Integer::New(isolate, 0)); |
| 2484 Script::Compile(v8_str("callFunctionRecursively()"))->Run(); | 2490 Script::Compile(v8_str("callFunctionRecursively()"))->Run(); |
| 2485 } | 2491 } |
| 2486 | 2492 |
| 2487 | 2493 |
| 2488 static void ThrowingPropertyHandlerGet( | 2494 static void ThrowingPropertyHandlerGet( |
| 2489 Local<String> key, | 2495 Local<String> key, |
| 2490 const v8::PropertyCallbackInfo<v8::Value>& info) { | 2496 const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 2491 ApiTestFuzzer::Fuzz(); | 2497 ApiTestFuzzer::Fuzz(); |
| 2492 info.GetReturnValue().Set(info.GetIsolate()->ThrowException(key)); | 2498 info.GetReturnValue().Set(info.GetIsolate()->ThrowException(key)); |
| 2493 } | 2499 } |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2649 static void CheckEmbedderData(LocalContext* env, | 2655 static void CheckEmbedderData(LocalContext* env, |
| 2650 int index, | 2656 int index, |
| 2651 v8::Handle<Value> data) { | 2657 v8::Handle<Value> data) { |
| 2652 (*env)->SetEmbedderData(index, data); | 2658 (*env)->SetEmbedderData(index, data); |
| 2653 CHECK((*env)->GetEmbedderData(index)->StrictEquals(data)); | 2659 CHECK((*env)->GetEmbedderData(index)->StrictEquals(data)); |
| 2654 } | 2660 } |
| 2655 | 2661 |
| 2656 | 2662 |
| 2657 THREADED_TEST(EmbedderData) { | 2663 THREADED_TEST(EmbedderData) { |
| 2658 LocalContext env; | 2664 LocalContext env; |
| 2659 v8::HandleScope scope(env->GetIsolate()); | 2665 v8::Isolate* isolate = env->GetIsolate(); |
| 2666 v8::HandleScope scope(isolate); |
| 2660 | 2667 |
| 2661 CheckEmbedderData( | 2668 CheckEmbedderData( |
| 2662 &env, 3, | 2669 &env, 3, |
| 2663 v8::String::NewFromUtf8(env->GetIsolate(), "The quick brown fox jumps")); | 2670 v8::String::NewFromUtf8(isolate, "The quick brown fox jumps")); |
| 2664 CheckEmbedderData(&env, 2, v8::String::NewFromUtf8(env->GetIsolate(), | 2671 CheckEmbedderData(&env, 2, v8::String::NewFromUtf8(isolate, |
| 2665 "over the lazy dog.")); | 2672 "over the lazy dog.")); |
| 2666 CheckEmbedderData(&env, 1, v8::Number::New(1.2345)); | 2673 CheckEmbedderData(&env, 1, v8::Number::New(isolate, 1.2345)); |
| 2667 CheckEmbedderData(&env, 0, v8::Boolean::New(env->GetIsolate(), true)); | 2674 CheckEmbedderData(&env, 0, v8::Boolean::New(isolate, true)); |
| 2668 } | 2675 } |
| 2669 | 2676 |
| 2670 | 2677 |
| 2671 THREADED_TEST(IdentityHash) { | 2678 THREADED_TEST(IdentityHash) { |
| 2672 LocalContext env; | 2679 LocalContext env; |
| 2673 v8::HandleScope scope(env->GetIsolate()); | 2680 v8::Isolate* isolate = env->GetIsolate(); |
| 2681 v8::HandleScope scope(isolate); |
| 2674 | 2682 |
| 2675 // Ensure that the test starts with an fresh heap to test whether the hash | 2683 // Ensure that the test starts with an fresh heap to test whether the hash |
| 2676 // code is based on the address. | 2684 // code is based on the address. |
| 2677 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); | 2685 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); |
| 2678 Local<v8::Object> obj = v8::Object::New(); | 2686 Local<v8::Object> obj = v8::Object::New(isolate); |
| 2679 int hash = obj->GetIdentityHash(); | 2687 int hash = obj->GetIdentityHash(); |
| 2680 int hash1 = obj->GetIdentityHash(); | 2688 int hash1 = obj->GetIdentityHash(); |
| 2681 CHECK_EQ(hash, hash1); | 2689 CHECK_EQ(hash, hash1); |
| 2682 int hash2 = v8::Object::New()->GetIdentityHash(); | 2690 int hash2 = v8::Object::New(isolate)->GetIdentityHash(); |
| 2683 // Since the identity hash is essentially a random number two consecutive | 2691 // Since the identity hash is essentially a random number two consecutive |
| 2684 // objects should not be assigned the same hash code. If the test below fails | 2692 // objects should not be assigned the same hash code. If the test below fails |
| 2685 // the random number generator should be evaluated. | 2693 // the random number generator should be evaluated. |
| 2686 CHECK_NE(hash, hash2); | 2694 CHECK_NE(hash, hash2); |
| 2687 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); | 2695 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); |
| 2688 int hash3 = v8::Object::New()->GetIdentityHash(); | 2696 int hash3 = v8::Object::New(isolate)->GetIdentityHash(); |
| 2689 // Make sure that the identity hash is not based on the initial address of | 2697 // Make sure that the identity hash is not based on the initial address of |
| 2690 // the object alone. If the test below fails the random number generator | 2698 // the object alone. If the test below fails the random number generator |
| 2691 // should be evaluated. | 2699 // should be evaluated. |
| 2692 CHECK_NE(hash, hash3); | 2700 CHECK_NE(hash, hash3); |
| 2693 int hash4 = obj->GetIdentityHash(); | 2701 int hash4 = obj->GetIdentityHash(); |
| 2694 CHECK_EQ(hash, hash4); | 2702 CHECK_EQ(hash, hash4); |
| 2695 | 2703 |
| 2696 // Check identity hashes behaviour in the presence of JS accessors. | 2704 // Check identity hashes behaviour in the presence of JS accessors. |
| 2697 // Put a getter for 'v8::IdentityHash' on the Object's prototype: | 2705 // Put a getter for 'v8::IdentityHash' on the Object's prototype: |
| 2698 { | 2706 { |
| 2699 CompileRun("Object.prototype['v8::IdentityHash'] = 42;\n"); | 2707 CompileRun("Object.prototype['v8::IdentityHash'] = 42;\n"); |
| 2700 Local<v8::Object> o1 = v8::Object::New(); | 2708 Local<v8::Object> o1 = v8::Object::New(isolate); |
| 2701 Local<v8::Object> o2 = v8::Object::New(); | 2709 Local<v8::Object> o2 = v8::Object::New(isolate); |
| 2702 CHECK_NE(o1->GetIdentityHash(), o2->GetIdentityHash()); | 2710 CHECK_NE(o1->GetIdentityHash(), o2->GetIdentityHash()); |
| 2703 } | 2711 } |
| 2704 { | 2712 { |
| 2705 CompileRun( | 2713 CompileRun( |
| 2706 "function cnst() { return 42; };\n" | 2714 "function cnst() { return 42; };\n" |
| 2707 "Object.prototype.__defineGetter__('v8::IdentityHash', cnst);\n"); | 2715 "Object.prototype.__defineGetter__('v8::IdentityHash', cnst);\n"); |
| 2708 Local<v8::Object> o1 = v8::Object::New(); | 2716 Local<v8::Object> o1 = v8::Object::New(isolate); |
| 2709 Local<v8::Object> o2 = v8::Object::New(); | 2717 Local<v8::Object> o2 = v8::Object::New(isolate); |
| 2710 CHECK_NE(o1->GetIdentityHash(), o2->GetIdentityHash()); | 2718 CHECK_NE(o1->GetIdentityHash(), o2->GetIdentityHash()); |
| 2711 } | 2719 } |
| 2712 } | 2720 } |
| 2713 | 2721 |
| 2714 | 2722 |
| 2715 THREADED_TEST(SymbolProperties) { | 2723 THREADED_TEST(SymbolProperties) { |
| 2716 i::FLAG_harmony_symbols = true; | 2724 i::FLAG_harmony_symbols = true; |
| 2717 | 2725 |
| 2718 LocalContext env; | 2726 LocalContext env; |
| 2719 v8::Isolate* isolate = env->GetIsolate(); | 2727 v8::Isolate* isolate = env->GetIsolate(); |
| 2720 v8::HandleScope scope(isolate); | 2728 v8::HandleScope scope(isolate); |
| 2721 | 2729 |
| 2722 v8::Local<v8::Object> obj = v8::Object::New(); | 2730 v8::Local<v8::Object> obj = v8::Object::New(isolate); |
| 2723 v8::Local<v8::Symbol> sym1 = v8::Symbol::New(isolate); | 2731 v8::Local<v8::Symbol> sym1 = v8::Symbol::New(isolate); |
| 2724 v8::Local<v8::Symbol> sym2 = v8::Symbol::New(isolate, "my-symbol"); | 2732 v8::Local<v8::Symbol> sym2 = v8::Symbol::New(isolate, "my-symbol"); |
| 2725 | 2733 |
| 2726 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); | 2734 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); |
| 2727 | 2735 |
| 2728 // Check basic symbol functionality. | 2736 // Check basic symbol functionality. |
| 2729 CHECK(sym1->IsSymbol()); | 2737 CHECK(sym1->IsSymbol()); |
| 2730 CHECK(sym2->IsSymbol()); | 2738 CHECK(sym2->IsSymbol()); |
| 2731 CHECK(!obj->IsSymbol()); | 2739 CHECK(!obj->IsSymbol()); |
| 2732 | 2740 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 2753 CHECK(!obj->IsSymbolObject()); | 2761 CHECK(!obj->IsSymbolObject()); |
| 2754 CHECK(sym_obj->Equals(sym2)); | 2762 CHECK(sym_obj->Equals(sym2)); |
| 2755 CHECK(!sym_obj->StrictEquals(sym2)); | 2763 CHECK(!sym_obj->StrictEquals(sym2)); |
| 2756 CHECK(v8::SymbolObject::Cast(*sym_obj)->Equals(sym_obj)); | 2764 CHECK(v8::SymbolObject::Cast(*sym_obj)->Equals(sym_obj)); |
| 2757 CHECK(v8::SymbolObject::Cast(*sym_obj)->ValueOf()->Equals(sym2)); | 2765 CHECK(v8::SymbolObject::Cast(*sym_obj)->ValueOf()->Equals(sym2)); |
| 2758 | 2766 |
| 2759 // Make sure delete of a non-existent symbol property works. | 2767 // Make sure delete of a non-existent symbol property works. |
| 2760 CHECK(obj->Delete(sym1)); | 2768 CHECK(obj->Delete(sym1)); |
| 2761 CHECK(!obj->Has(sym1)); | 2769 CHECK(!obj->Has(sym1)); |
| 2762 | 2770 |
| 2763 CHECK(obj->Set(sym1, v8::Integer::New(1503))); | 2771 CHECK(obj->Set(sym1, v8::Integer::New(isolate, 1503))); |
| 2764 CHECK(obj->Has(sym1)); | 2772 CHECK(obj->Has(sym1)); |
| 2765 CHECK_EQ(1503, obj->Get(sym1)->Int32Value()); | 2773 CHECK_EQ(1503, obj->Get(sym1)->Int32Value()); |
| 2766 CHECK(obj->Set(sym1, v8::Integer::New(2002))); | 2774 CHECK(obj->Set(sym1, v8::Integer::New(isolate, 2002))); |
| 2767 CHECK(obj->Has(sym1)); | 2775 CHECK(obj->Has(sym1)); |
| 2768 CHECK_EQ(2002, obj->Get(sym1)->Int32Value()); | 2776 CHECK_EQ(2002, obj->Get(sym1)->Int32Value()); |
| 2769 CHECK_EQ(v8::None, obj->GetPropertyAttributes(sym1)); | 2777 CHECK_EQ(v8::None, obj->GetPropertyAttributes(sym1)); |
| 2770 | 2778 |
| 2771 CHECK_EQ(0, obj->GetOwnPropertyNames()->Length()); | 2779 CHECK_EQ(0, obj->GetOwnPropertyNames()->Length()); |
| 2772 int num_props = obj->GetPropertyNames()->Length(); | 2780 int num_props = obj->GetPropertyNames()->Length(); |
| 2773 CHECK( | 2781 CHECK(obj->Set(v8::String::NewFromUtf8(isolate, "bla"), |
| 2774 obj->Set(v8::String::NewFromUtf8(isolate, "bla"), v8::Integer::New(20))); | 2782 v8::Integer::New(isolate, 20))); |
| 2775 CHECK_EQ(1, obj->GetOwnPropertyNames()->Length()); | 2783 CHECK_EQ(1, obj->GetOwnPropertyNames()->Length()); |
| 2776 CHECK_EQ(num_props + 1, obj->GetPropertyNames()->Length()); | 2784 CHECK_EQ(num_props + 1, obj->GetPropertyNames()->Length()); |
| 2777 | 2785 |
| 2778 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); | 2786 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); |
| 2779 | 2787 |
| 2780 // Add another property and delete it afterwards to force the object in | 2788 // Add another property and delete it afterwards to force the object in |
| 2781 // slow case. | 2789 // slow case. |
| 2782 CHECK(obj->Set(sym2, v8::Integer::New(2008))); | 2790 CHECK(obj->Set(sym2, v8::Integer::New(isolate, 2008))); |
| 2783 CHECK_EQ(2002, obj->Get(sym1)->Int32Value()); | 2791 CHECK_EQ(2002, obj->Get(sym1)->Int32Value()); |
| 2784 CHECK_EQ(2008, obj->Get(sym2)->Int32Value()); | 2792 CHECK_EQ(2008, obj->Get(sym2)->Int32Value()); |
| 2785 CHECK_EQ(2002, obj->Get(sym1)->Int32Value()); | 2793 CHECK_EQ(2002, obj->Get(sym1)->Int32Value()); |
| 2786 CHECK_EQ(1, obj->GetOwnPropertyNames()->Length()); | 2794 CHECK_EQ(1, obj->GetOwnPropertyNames()->Length()); |
| 2787 | 2795 |
| 2788 CHECK(obj->Has(sym1)); | 2796 CHECK(obj->Has(sym1)); |
| 2789 CHECK(obj->Has(sym2)); | 2797 CHECK(obj->Has(sym2)); |
| 2790 CHECK(obj->Delete(sym2)); | 2798 CHECK(obj->Delete(sym2)); |
| 2791 CHECK(obj->Has(sym1)); | 2799 CHECK(obj->Has(sym1)); |
| 2792 CHECK(!obj->Has(sym2)); | 2800 CHECK(!obj->Has(sym2)); |
| 2793 CHECK_EQ(2002, obj->Get(sym1)->Int32Value()); | 2801 CHECK_EQ(2002, obj->Get(sym1)->Int32Value()); |
| 2794 CHECK_EQ(1, obj->GetOwnPropertyNames()->Length()); | 2802 CHECK_EQ(1, obj->GetOwnPropertyNames()->Length()); |
| 2795 | 2803 |
| 2796 // Symbol properties are inherited. | 2804 // Symbol properties are inherited. |
| 2797 v8::Local<v8::Object> child = v8::Object::New(); | 2805 v8::Local<v8::Object> child = v8::Object::New(isolate); |
| 2798 child->SetPrototype(obj); | 2806 child->SetPrototype(obj); |
| 2799 CHECK(child->Has(sym1)); | 2807 CHECK(child->Has(sym1)); |
| 2800 CHECK_EQ(2002, child->Get(sym1)->Int32Value()); | 2808 CHECK_EQ(2002, child->Get(sym1)->Int32Value()); |
| 2801 CHECK_EQ(0, child->GetOwnPropertyNames()->Length()); | 2809 CHECK_EQ(0, child->GetOwnPropertyNames()->Length()); |
| 2802 } | 2810 } |
| 2803 | 2811 |
| 2804 | 2812 |
| 2805 THREADED_TEST(PrivateProperties) { | 2813 THREADED_TEST(PrivateProperties) { |
| 2806 LocalContext env; | 2814 LocalContext env; |
| 2807 v8::Isolate* isolate = env->GetIsolate(); | 2815 v8::Isolate* isolate = env->GetIsolate(); |
| 2808 v8::HandleScope scope(isolate); | 2816 v8::HandleScope scope(isolate); |
| 2809 | 2817 |
| 2810 v8::Local<v8::Object> obj = v8::Object::New(); | 2818 v8::Local<v8::Object> obj = v8::Object::New(isolate); |
| 2811 v8::Local<v8::Private> priv1 = v8::Private::New(isolate); | 2819 v8::Local<v8::Private> priv1 = v8::Private::New(isolate); |
| 2812 v8::Local<v8::Private> priv2 = v8::Private::New(isolate, "my-private"); | 2820 v8::Local<v8::Private> priv2 = v8::Private::New(isolate, "my-private"); |
| 2813 | 2821 |
| 2814 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); | 2822 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); |
| 2815 | 2823 |
| 2816 CHECK(priv2->Name()->Equals(v8::String::NewFromUtf8(isolate, "my-private"))); | 2824 CHECK(priv2->Name()->Equals(v8::String::NewFromUtf8(isolate, "my-private"))); |
| 2817 | 2825 |
| 2818 // Make sure delete of a non-existent private symbol property works. | 2826 // Make sure delete of a non-existent private symbol property works. |
| 2819 CHECK(obj->DeletePrivate(priv1)); | 2827 CHECK(obj->DeletePrivate(priv1)); |
| 2820 CHECK(!obj->HasPrivate(priv1)); | 2828 CHECK(!obj->HasPrivate(priv1)); |
| 2821 | 2829 |
| 2822 CHECK(obj->SetPrivate(priv1, v8::Integer::New(1503))); | 2830 CHECK(obj->SetPrivate(priv1, v8::Integer::New(isolate, 1503))); |
| 2823 CHECK(obj->HasPrivate(priv1)); | 2831 CHECK(obj->HasPrivate(priv1)); |
| 2824 CHECK_EQ(1503, obj->GetPrivate(priv1)->Int32Value()); | 2832 CHECK_EQ(1503, obj->GetPrivate(priv1)->Int32Value()); |
| 2825 CHECK(obj->SetPrivate(priv1, v8::Integer::New(2002))); | 2833 CHECK(obj->SetPrivate(priv1, v8::Integer::New(isolate, 2002))); |
| 2826 CHECK(obj->HasPrivate(priv1)); | 2834 CHECK(obj->HasPrivate(priv1)); |
| 2827 CHECK_EQ(2002, obj->GetPrivate(priv1)->Int32Value()); | 2835 CHECK_EQ(2002, obj->GetPrivate(priv1)->Int32Value()); |
| 2828 | 2836 |
| 2829 CHECK_EQ(0, obj->GetOwnPropertyNames()->Length()); | 2837 CHECK_EQ(0, obj->GetOwnPropertyNames()->Length()); |
| 2830 int num_props = obj->GetPropertyNames()->Length(); | 2838 int num_props = obj->GetPropertyNames()->Length(); |
| 2831 CHECK( | 2839 CHECK(obj->Set(v8::String::NewFromUtf8(isolate, "bla"), |
| 2832 obj->Set(v8::String::NewFromUtf8(isolate, "bla"), v8::Integer::New(20))); | 2840 v8::Integer::New(isolate, 20))); |
| 2833 CHECK_EQ(1, obj->GetOwnPropertyNames()->Length()); | 2841 CHECK_EQ(1, obj->GetOwnPropertyNames()->Length()); |
| 2834 CHECK_EQ(num_props + 1, obj->GetPropertyNames()->Length()); | 2842 CHECK_EQ(num_props + 1, obj->GetPropertyNames()->Length()); |
| 2835 | 2843 |
| 2836 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); | 2844 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); |
| 2837 | 2845 |
| 2838 // Add another property and delete it afterwards to force the object in | 2846 // Add another property and delete it afterwards to force the object in |
| 2839 // slow case. | 2847 // slow case. |
| 2840 CHECK(obj->SetPrivate(priv2, v8::Integer::New(2008))); | 2848 CHECK(obj->SetPrivate(priv2, v8::Integer::New(isolate, 2008))); |
| 2841 CHECK_EQ(2002, obj->GetPrivate(priv1)->Int32Value()); | 2849 CHECK_EQ(2002, obj->GetPrivate(priv1)->Int32Value()); |
| 2842 CHECK_EQ(2008, obj->GetPrivate(priv2)->Int32Value()); | 2850 CHECK_EQ(2008, obj->GetPrivate(priv2)->Int32Value()); |
| 2843 CHECK_EQ(2002, obj->GetPrivate(priv1)->Int32Value()); | 2851 CHECK_EQ(2002, obj->GetPrivate(priv1)->Int32Value()); |
| 2844 CHECK_EQ(1, obj->GetOwnPropertyNames()->Length()); | 2852 CHECK_EQ(1, obj->GetOwnPropertyNames()->Length()); |
| 2845 | 2853 |
| 2846 CHECK(obj->HasPrivate(priv1)); | 2854 CHECK(obj->HasPrivate(priv1)); |
| 2847 CHECK(obj->HasPrivate(priv2)); | 2855 CHECK(obj->HasPrivate(priv2)); |
| 2848 CHECK(obj->DeletePrivate(priv2)); | 2856 CHECK(obj->DeletePrivate(priv2)); |
| 2849 CHECK(obj->HasPrivate(priv1)); | 2857 CHECK(obj->HasPrivate(priv1)); |
| 2850 CHECK(!obj->HasPrivate(priv2)); | 2858 CHECK(!obj->HasPrivate(priv2)); |
| 2851 CHECK_EQ(2002, obj->GetPrivate(priv1)->Int32Value()); | 2859 CHECK_EQ(2002, obj->GetPrivate(priv1)->Int32Value()); |
| 2852 CHECK_EQ(1, obj->GetOwnPropertyNames()->Length()); | 2860 CHECK_EQ(1, obj->GetOwnPropertyNames()->Length()); |
| 2853 | 2861 |
| 2854 // Private properties are inherited (for the time being). | 2862 // Private properties are inherited (for the time being). |
| 2855 v8::Local<v8::Object> child = v8::Object::New(); | 2863 v8::Local<v8::Object> child = v8::Object::New(isolate); |
| 2856 child->SetPrototype(obj); | 2864 child->SetPrototype(obj); |
| 2857 CHECK(child->HasPrivate(priv1)); | 2865 CHECK(child->HasPrivate(priv1)); |
| 2858 CHECK_EQ(2002, child->GetPrivate(priv1)->Int32Value()); | 2866 CHECK_EQ(2002, child->GetPrivate(priv1)->Int32Value()); |
| 2859 CHECK_EQ(0, child->GetOwnPropertyNames()->Length()); | 2867 CHECK_EQ(0, child->GetOwnPropertyNames()->Length()); |
| 2860 } | 2868 } |
| 2861 | 2869 |
| 2862 | 2870 |
| 2863 class ScopedArrayBufferContents { | 2871 class ScopedArrayBufferContents { |
| 2864 public: | 2872 public: |
| 2865 explicit ScopedArrayBufferContents( | 2873 explicit ScopedArrayBufferContents( |
| (...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3119 CheckIsTypedArrayVarNeutered("f64a"); | 3127 CheckIsTypedArrayVarNeutered("f64a"); |
| 3120 | 3128 |
| 3121 CHECK(CompileRun("dv.byteLength == 0 && dv.byteOffset == 0")->IsTrue()); | 3129 CHECK(CompileRun("dv.byteLength == 0 && dv.byteOffset == 0")->IsTrue()); |
| 3122 CheckDataViewIsNeutered(dv); | 3130 CheckDataViewIsNeutered(dv); |
| 3123 } | 3131 } |
| 3124 | 3132 |
| 3125 | 3133 |
| 3126 | 3134 |
| 3127 THREADED_TEST(HiddenProperties) { | 3135 THREADED_TEST(HiddenProperties) { |
| 3128 LocalContext env; | 3136 LocalContext env; |
| 3129 v8::HandleScope scope(env->GetIsolate()); | 3137 v8::Isolate* isolate = env->GetIsolate(); |
| 3138 v8::HandleScope scope(isolate); |
| 3130 | 3139 |
| 3131 v8::Local<v8::Object> obj = v8::Object::New(); | 3140 v8::Local<v8::Object> obj = v8::Object::New(env->GetIsolate()); |
| 3132 v8::Local<v8::String> key = v8_str("api-test::hidden-key"); | 3141 v8::Local<v8::String> key = v8_str("api-test::hidden-key"); |
| 3133 v8::Local<v8::String> empty = v8_str(""); | 3142 v8::Local<v8::String> empty = v8_str(""); |
| 3134 v8::Local<v8::String> prop_name = v8_str("prop_name"); | 3143 v8::Local<v8::String> prop_name = v8_str("prop_name"); |
| 3135 | 3144 |
| 3136 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); | 3145 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); |
| 3137 | 3146 |
| 3138 // Make sure delete of a non-existent hidden value works | 3147 // Make sure delete of a non-existent hidden value works |
| 3139 CHECK(obj->DeleteHiddenValue(key)); | 3148 CHECK(obj->DeleteHiddenValue(key)); |
| 3140 | 3149 |
| 3141 CHECK(obj->SetHiddenValue(key, v8::Integer::New(1503))); | 3150 CHECK(obj->SetHiddenValue(key, v8::Integer::New(isolate, 1503))); |
| 3142 CHECK_EQ(1503, obj->GetHiddenValue(key)->Int32Value()); | 3151 CHECK_EQ(1503, obj->GetHiddenValue(key)->Int32Value()); |
| 3143 CHECK(obj->SetHiddenValue(key, v8::Integer::New(2002))); | 3152 CHECK(obj->SetHiddenValue(key, v8::Integer::New(isolate, 2002))); |
| 3144 CHECK_EQ(2002, obj->GetHiddenValue(key)->Int32Value()); | 3153 CHECK_EQ(2002, obj->GetHiddenValue(key)->Int32Value()); |
| 3145 | 3154 |
| 3146 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); | 3155 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); |
| 3147 | 3156 |
| 3148 // Make sure we do not find the hidden property. | 3157 // Make sure we do not find the hidden property. |
| 3149 CHECK(!obj->Has(empty)); | 3158 CHECK(!obj->Has(empty)); |
| 3150 CHECK_EQ(2002, obj->GetHiddenValue(key)->Int32Value()); | 3159 CHECK_EQ(2002, obj->GetHiddenValue(key)->Int32Value()); |
| 3151 CHECK(obj->Get(empty)->IsUndefined()); | 3160 CHECK(obj->Get(empty)->IsUndefined()); |
| 3152 CHECK_EQ(2002, obj->GetHiddenValue(key)->Int32Value()); | 3161 CHECK_EQ(2002, obj->GetHiddenValue(key)->Int32Value()); |
| 3153 CHECK(obj->Set(empty, v8::Integer::New(2003))); | 3162 CHECK(obj->Set(empty, v8::Integer::New(isolate, 2003))); |
| 3154 CHECK_EQ(2002, obj->GetHiddenValue(key)->Int32Value()); | 3163 CHECK_EQ(2002, obj->GetHiddenValue(key)->Int32Value()); |
| 3155 CHECK_EQ(2003, obj->Get(empty)->Int32Value()); | 3164 CHECK_EQ(2003, obj->Get(empty)->Int32Value()); |
| 3156 | 3165 |
| 3157 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); | 3166 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); |
| 3158 | 3167 |
| 3159 // Add another property and delete it afterwards to force the object in | 3168 // Add another property and delete it afterwards to force the object in |
| 3160 // slow case. | 3169 // slow case. |
| 3161 CHECK(obj->Set(prop_name, v8::Integer::New(2008))); | 3170 CHECK(obj->Set(prop_name, v8::Integer::New(isolate, 2008))); |
| 3162 CHECK_EQ(2002, obj->GetHiddenValue(key)->Int32Value()); | 3171 CHECK_EQ(2002, obj->GetHiddenValue(key)->Int32Value()); |
| 3163 CHECK_EQ(2008, obj->Get(prop_name)->Int32Value()); | 3172 CHECK_EQ(2008, obj->Get(prop_name)->Int32Value()); |
| 3164 CHECK_EQ(2002, obj->GetHiddenValue(key)->Int32Value()); | 3173 CHECK_EQ(2002, obj->GetHiddenValue(key)->Int32Value()); |
| 3165 CHECK(obj->Delete(prop_name)); | 3174 CHECK(obj->Delete(prop_name)); |
| 3166 CHECK_EQ(2002, obj->GetHiddenValue(key)->Int32Value()); | 3175 CHECK_EQ(2002, obj->GetHiddenValue(key)->Int32Value()); |
| 3167 | 3176 |
| 3168 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); | 3177 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); |
| 3169 | 3178 |
| 3170 CHECK(obj->SetHiddenValue(key, Handle<Value>())); | 3179 CHECK(obj->SetHiddenValue(key, Handle<Value>())); |
| 3171 CHECK(obj->GetHiddenValue(key).IsEmpty()); | 3180 CHECK(obj->GetHiddenValue(key).IsEmpty()); |
| 3172 | 3181 |
| 3173 CHECK(obj->SetHiddenValue(key, v8::Integer::New(2002))); | 3182 CHECK(obj->SetHiddenValue(key, v8::Integer::New(isolate, 2002))); |
| 3174 CHECK(obj->DeleteHiddenValue(key)); | 3183 CHECK(obj->DeleteHiddenValue(key)); |
| 3175 CHECK(obj->GetHiddenValue(key).IsEmpty()); | 3184 CHECK(obj->GetHiddenValue(key).IsEmpty()); |
| 3176 } | 3185 } |
| 3177 | 3186 |
| 3178 | 3187 |
| 3179 THREADED_TEST(Regress97784) { | 3188 THREADED_TEST(Regress97784) { |
| 3180 // Regression test for crbug.com/97784 | 3189 // Regression test for crbug.com/97784 |
| 3181 // Messing with the Object.prototype should not have effect on | 3190 // Messing with the Object.prototype should not have effect on |
| 3182 // hidden properties. | 3191 // hidden properties. |
| 3183 LocalContext env; | 3192 LocalContext env; |
| 3184 v8::HandleScope scope(env->GetIsolate()); | 3193 v8::HandleScope scope(env->GetIsolate()); |
| 3185 | 3194 |
| 3186 v8::Local<v8::Object> obj = v8::Object::New(); | 3195 v8::Local<v8::Object> obj = v8::Object::New(env->GetIsolate()); |
| 3187 v8::Local<v8::String> key = v8_str("hidden"); | 3196 v8::Local<v8::String> key = v8_str("hidden"); |
| 3188 | 3197 |
| 3189 CompileRun( | 3198 CompileRun( |
| 3190 "set_called = false;" | 3199 "set_called = false;" |
| 3191 "Object.defineProperty(" | 3200 "Object.defineProperty(" |
| 3192 " Object.prototype," | 3201 " Object.prototype," |
| 3193 " 'hidden'," | 3202 " 'hidden'," |
| 3194 " {get: function() { return 45; }," | 3203 " {get: function() { return 45; }," |
| 3195 " set: function() { set_called = true; }})"); | 3204 " set: function() { set_called = true; }})"); |
| 3196 | 3205 |
| 3197 CHECK(obj->GetHiddenValue(key).IsEmpty()); | 3206 CHECK(obj->GetHiddenValue(key).IsEmpty()); |
| 3198 // Make sure that the getter and setter from Object.prototype is not invoked. | 3207 // Make sure that the getter and setter from Object.prototype is not invoked. |
| 3199 // If it did we would have full access to the hidden properties in | 3208 // If it did we would have full access to the hidden properties in |
| 3200 // the accessor. | 3209 // the accessor. |
| 3201 CHECK(obj->SetHiddenValue(key, v8::Integer::New(42))); | 3210 CHECK(obj->SetHiddenValue(key, v8::Integer::New(env->GetIsolate(), 42))); |
| 3202 ExpectFalse("set_called"); | 3211 ExpectFalse("set_called"); |
| 3203 CHECK_EQ(42, obj->GetHiddenValue(key)->Int32Value()); | 3212 CHECK_EQ(42, obj->GetHiddenValue(key)->Int32Value()); |
| 3204 } | 3213 } |
| 3205 | 3214 |
| 3206 | 3215 |
| 3207 static bool interceptor_for_hidden_properties_called; | 3216 static bool interceptor_for_hidden_properties_called; |
| 3208 static void InterceptorForHiddenProperties( | 3217 static void InterceptorForHiddenProperties( |
| 3209 Local<String> name, const v8::PropertyCallbackInfo<v8::Value>& info) { | 3218 Local<String> name, const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 3210 interceptor_for_hidden_properties_called = true; | 3219 interceptor_for_hidden_properties_called = true; |
| 3211 } | 3220 } |
| 3212 | 3221 |
| 3213 | 3222 |
| 3214 THREADED_TEST(HiddenPropertiesWithInterceptors) { | 3223 THREADED_TEST(HiddenPropertiesWithInterceptors) { |
| 3215 LocalContext context; | 3224 LocalContext context; |
| 3216 v8::Isolate* isolate = context->GetIsolate(); | 3225 v8::Isolate* isolate = context->GetIsolate(); |
| 3217 v8::HandleScope scope(isolate); | 3226 v8::HandleScope scope(isolate); |
| 3218 | 3227 |
| 3219 interceptor_for_hidden_properties_called = false; | 3228 interceptor_for_hidden_properties_called = false; |
| 3220 | 3229 |
| 3221 v8::Local<v8::String> key = v8_str("api-test::hidden-key"); | 3230 v8::Local<v8::String> key = v8_str("api-test::hidden-key"); |
| 3222 | 3231 |
| 3223 // Associate an interceptor with an object and start setting hidden values. | 3232 // Associate an interceptor with an object and start setting hidden values. |
| 3224 Local<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New(isolate); | 3233 Local<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New(isolate); |
| 3225 Local<v8::ObjectTemplate> instance_templ = fun_templ->InstanceTemplate(); | 3234 Local<v8::ObjectTemplate> instance_templ = fun_templ->InstanceTemplate(); |
| 3226 instance_templ->SetNamedPropertyHandler(InterceptorForHiddenProperties); | 3235 instance_templ->SetNamedPropertyHandler(InterceptorForHiddenProperties); |
| 3227 Local<v8::Function> function = fun_templ->GetFunction(); | 3236 Local<v8::Function> function = fun_templ->GetFunction(); |
| 3228 Local<v8::Object> obj = function->NewInstance(); | 3237 Local<v8::Object> obj = function->NewInstance(); |
| 3229 CHECK(obj->SetHiddenValue(key, v8::Integer::New(2302))); | 3238 CHECK(obj->SetHiddenValue(key, v8::Integer::New(isolate, 2302))); |
| 3230 CHECK_EQ(2302, obj->GetHiddenValue(key)->Int32Value()); | 3239 CHECK_EQ(2302, obj->GetHiddenValue(key)->Int32Value()); |
| 3231 CHECK(!interceptor_for_hidden_properties_called); | 3240 CHECK(!interceptor_for_hidden_properties_called); |
| 3232 } | 3241 } |
| 3233 | 3242 |
| 3234 | 3243 |
| 3235 THREADED_TEST(External) { | 3244 THREADED_TEST(External) { |
| 3236 v8::HandleScope scope(CcTest::isolate()); | 3245 v8::HandleScope scope(CcTest::isolate()); |
| 3237 int x = 3; | 3246 int x = 3; |
| 3238 Local<v8::External> ext = v8::External::New(CcTest::isolate(), &x); | 3247 Local<v8::External> ext = v8::External::New(CcTest::isolate(), &x); |
| 3239 LocalContext env; | 3248 LocalContext env; |
| (...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3511 | 3520 |
| 3512 WeakCallCounterAndPersistent<Value> g1s1(&counter); | 3521 WeakCallCounterAndPersistent<Value> g1s1(&counter); |
| 3513 WeakCallCounterAndPersistent<Value> g1s2(&counter); | 3522 WeakCallCounterAndPersistent<Value> g1s2(&counter); |
| 3514 WeakCallCounterAndPersistent<Value> g1c1(&counter); | 3523 WeakCallCounterAndPersistent<Value> g1c1(&counter); |
| 3515 WeakCallCounterAndPersistent<Value> g2s1(&counter); | 3524 WeakCallCounterAndPersistent<Value> g2s1(&counter); |
| 3516 WeakCallCounterAndPersistent<Value> g2s2(&counter); | 3525 WeakCallCounterAndPersistent<Value> g2s2(&counter); |
| 3517 WeakCallCounterAndPersistent<Value> g2c1(&counter); | 3526 WeakCallCounterAndPersistent<Value> g2c1(&counter); |
| 3518 | 3527 |
| 3519 { | 3528 { |
| 3520 HandleScope scope(iso); | 3529 HandleScope scope(iso); |
| 3521 g1s1.handle.Reset(iso, Object::New()); | 3530 g1s1.handle.Reset(iso, Object::New(iso)); |
| 3522 g1s2.handle.Reset(iso, Object::New()); | 3531 g1s2.handle.Reset(iso, Object::New(iso)); |
| 3523 g1c1.handle.Reset(iso, Object::New()); | 3532 g1c1.handle.Reset(iso, Object::New(iso)); |
| 3524 g1s1.handle.SetWeak(&g1s1, &WeakPointerCallback); | 3533 g1s1.handle.SetWeak(&g1s1, &WeakPointerCallback); |
| 3525 g1s2.handle.SetWeak(&g1s2, &WeakPointerCallback); | 3534 g1s2.handle.SetWeak(&g1s2, &WeakPointerCallback); |
| 3526 g1c1.handle.SetWeak(&g1c1, &WeakPointerCallback); | 3535 g1c1.handle.SetWeak(&g1c1, &WeakPointerCallback); |
| 3527 | 3536 |
| 3528 g2s1.handle.Reset(iso, Object::New()); | 3537 g2s1.handle.Reset(iso, Object::New(iso)); |
| 3529 g2s2.handle.Reset(iso, Object::New()); | 3538 g2s2.handle.Reset(iso, Object::New(iso)); |
| 3530 g2c1.handle.Reset(iso, Object::New()); | 3539 g2c1.handle.Reset(iso, Object::New(iso)); |
| 3531 g2s1.handle.SetWeak(&g2s1, &WeakPointerCallback); | 3540 g2s1.handle.SetWeak(&g2s1, &WeakPointerCallback); |
| 3532 g2s2.handle.SetWeak(&g2s2, &WeakPointerCallback); | 3541 g2s2.handle.SetWeak(&g2s2, &WeakPointerCallback); |
| 3533 g2c1.handle.SetWeak(&g2c1, &WeakPointerCallback); | 3542 g2c1.handle.SetWeak(&g2c1, &WeakPointerCallback); |
| 3534 } | 3543 } |
| 3535 | 3544 |
| 3536 WeakCallCounterAndPersistent<Value> root(&counter); | 3545 WeakCallCounterAndPersistent<Value> root(&counter); |
| 3537 root.handle.Reset(iso, g1s1.handle); // make a root. | 3546 root.handle.Reset(iso, g1s1.handle); // make a root. |
| 3538 | 3547 |
| 3539 // Connect group 1 and 2, make a cycle. | 3548 // Connect group 1 and 2, make a cycle. |
| 3540 { | 3549 { |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3605 | 3614 |
| 3606 WeakCallCounterAndPersistent<Object> g1s1(&counter); | 3615 WeakCallCounterAndPersistent<Object> g1s1(&counter); |
| 3607 WeakCallCounterAndPersistent<String> g1s2(&counter); | 3616 WeakCallCounterAndPersistent<String> g1s2(&counter); |
| 3608 WeakCallCounterAndPersistent<String> g1c1(&counter); | 3617 WeakCallCounterAndPersistent<String> g1c1(&counter); |
| 3609 WeakCallCounterAndPersistent<Object> g2s1(&counter); | 3618 WeakCallCounterAndPersistent<Object> g2s1(&counter); |
| 3610 WeakCallCounterAndPersistent<String> g2s2(&counter); | 3619 WeakCallCounterAndPersistent<String> g2s2(&counter); |
| 3611 WeakCallCounterAndPersistent<String> g2c1(&counter); | 3620 WeakCallCounterAndPersistent<String> g2c1(&counter); |
| 3612 | 3621 |
| 3613 { | 3622 { |
| 3614 HandleScope scope(iso); | 3623 HandleScope scope(iso); |
| 3615 g1s1.handle.Reset(iso, Object::New()); | 3624 g1s1.handle.Reset(iso, Object::New(iso)); |
| 3616 g1s2.handle.Reset(iso, String::NewFromUtf8(iso, "foo1")); | 3625 g1s2.handle.Reset(iso, String::NewFromUtf8(iso, "foo1")); |
| 3617 g1c1.handle.Reset(iso, String::NewFromUtf8(iso, "foo2")); | 3626 g1c1.handle.Reset(iso, String::NewFromUtf8(iso, "foo2")); |
| 3618 g1s1.handle.SetWeak(&g1s1, &WeakPointerCallback); | 3627 g1s1.handle.SetWeak(&g1s1, &WeakPointerCallback); |
| 3619 g1s2.handle.SetWeak(&g1s2, &WeakPointerCallback); | 3628 g1s2.handle.SetWeak(&g1s2, &WeakPointerCallback); |
| 3620 g1c1.handle.SetWeak(&g1c1, &WeakPointerCallback); | 3629 g1c1.handle.SetWeak(&g1c1, &WeakPointerCallback); |
| 3621 | 3630 |
| 3622 g2s1.handle.Reset(iso, Object::New()); | 3631 g2s1.handle.Reset(iso, Object::New(iso)); |
| 3623 g2s2.handle.Reset(iso, String::NewFromUtf8(iso, "foo3")); | 3632 g2s2.handle.Reset(iso, String::NewFromUtf8(iso, "foo3")); |
| 3624 g2c1.handle.Reset(iso, String::NewFromUtf8(iso, "foo4")); | 3633 g2c1.handle.Reset(iso, String::NewFromUtf8(iso, "foo4")); |
| 3625 g2s1.handle.SetWeak(&g2s1, &WeakPointerCallback); | 3634 g2s1.handle.SetWeak(&g2s1, &WeakPointerCallback); |
| 3626 g2s2.handle.SetWeak(&g2s2, &WeakPointerCallback); | 3635 g2s2.handle.SetWeak(&g2s2, &WeakPointerCallback); |
| 3627 g2c1.handle.SetWeak(&g2c1, &WeakPointerCallback); | 3636 g2c1.handle.SetWeak(&g2c1, &WeakPointerCallback); |
| 3628 } | 3637 } |
| 3629 | 3638 |
| 3630 WeakCallCounterAndPersistent<Value> root(&counter); | 3639 WeakCallCounterAndPersistent<Value> root(&counter); |
| 3631 root.handle.Reset(iso, g1s1.handle); // make a root. | 3640 root.handle.Reset(iso, g1s1.handle); // make a root. |
| 3632 | 3641 |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3701 WeakCallCounterAndPersistent<Value> g1s2(&counter); | 3710 WeakCallCounterAndPersistent<Value> g1s2(&counter); |
| 3702 WeakCallCounterAndPersistent<Value> g2s1(&counter); | 3711 WeakCallCounterAndPersistent<Value> g2s1(&counter); |
| 3703 WeakCallCounterAndPersistent<Value> g2s2(&counter); | 3712 WeakCallCounterAndPersistent<Value> g2s2(&counter); |
| 3704 WeakCallCounterAndPersistent<Value> g3s1(&counter); | 3713 WeakCallCounterAndPersistent<Value> g3s1(&counter); |
| 3705 WeakCallCounterAndPersistent<Value> g3s2(&counter); | 3714 WeakCallCounterAndPersistent<Value> g3s2(&counter); |
| 3706 WeakCallCounterAndPersistent<Value> g4s1(&counter); | 3715 WeakCallCounterAndPersistent<Value> g4s1(&counter); |
| 3707 WeakCallCounterAndPersistent<Value> g4s2(&counter); | 3716 WeakCallCounterAndPersistent<Value> g4s2(&counter); |
| 3708 | 3717 |
| 3709 { | 3718 { |
| 3710 HandleScope scope(iso); | 3719 HandleScope scope(iso); |
| 3711 g1s1.handle.Reset(iso, Object::New()); | 3720 g1s1.handle.Reset(iso, Object::New(iso)); |
| 3712 g1s2.handle.Reset(iso, Object::New()); | 3721 g1s2.handle.Reset(iso, Object::New(iso)); |
| 3713 g1s1.handle.SetWeak(&g1s1, &WeakPointerCallback); | 3722 g1s1.handle.SetWeak(&g1s1, &WeakPointerCallback); |
| 3714 g1s2.handle.SetWeak(&g1s2, &WeakPointerCallback); | 3723 g1s2.handle.SetWeak(&g1s2, &WeakPointerCallback); |
| 3715 CHECK(g1s1.handle.IsWeak()); | 3724 CHECK(g1s1.handle.IsWeak()); |
| 3716 CHECK(g1s2.handle.IsWeak()); | 3725 CHECK(g1s2.handle.IsWeak()); |
| 3717 | 3726 |
| 3718 g2s1.handle.Reset(iso, Object::New()); | 3727 g2s1.handle.Reset(iso, Object::New(iso)); |
| 3719 g2s2.handle.Reset(iso, Object::New()); | 3728 g2s2.handle.Reset(iso, Object::New(iso)); |
| 3720 g2s1.handle.SetWeak(&g2s1, &WeakPointerCallback); | 3729 g2s1.handle.SetWeak(&g2s1, &WeakPointerCallback); |
| 3721 g2s2.handle.SetWeak(&g2s2, &WeakPointerCallback); | 3730 g2s2.handle.SetWeak(&g2s2, &WeakPointerCallback); |
| 3722 CHECK(g2s1.handle.IsWeak()); | 3731 CHECK(g2s1.handle.IsWeak()); |
| 3723 CHECK(g2s2.handle.IsWeak()); | 3732 CHECK(g2s2.handle.IsWeak()); |
| 3724 | 3733 |
| 3725 g3s1.handle.Reset(iso, Object::New()); | 3734 g3s1.handle.Reset(iso, Object::New(iso)); |
| 3726 g3s2.handle.Reset(iso, Object::New()); | 3735 g3s2.handle.Reset(iso, Object::New(iso)); |
| 3727 g3s1.handle.SetWeak(&g3s1, &WeakPointerCallback); | 3736 g3s1.handle.SetWeak(&g3s1, &WeakPointerCallback); |
| 3728 g3s2.handle.SetWeak(&g3s2, &WeakPointerCallback); | 3737 g3s2.handle.SetWeak(&g3s2, &WeakPointerCallback); |
| 3729 CHECK(g3s1.handle.IsWeak()); | 3738 CHECK(g3s1.handle.IsWeak()); |
| 3730 CHECK(g3s2.handle.IsWeak()); | 3739 CHECK(g3s2.handle.IsWeak()); |
| 3731 | 3740 |
| 3732 g4s1.handle.Reset(iso, Object::New()); | 3741 g4s1.handle.Reset(iso, Object::New(iso)); |
| 3733 g4s2.handle.Reset(iso, Object::New()); | 3742 g4s2.handle.Reset(iso, Object::New(iso)); |
| 3734 g4s1.handle.SetWeak(&g4s1, &WeakPointerCallback); | 3743 g4s1.handle.SetWeak(&g4s1, &WeakPointerCallback); |
| 3735 g4s2.handle.SetWeak(&g4s2, &WeakPointerCallback); | 3744 g4s2.handle.SetWeak(&g4s2, &WeakPointerCallback); |
| 3736 CHECK(g4s1.handle.IsWeak()); | 3745 CHECK(g4s1.handle.IsWeak()); |
| 3737 CHECK(g4s2.handle.IsWeak()); | 3746 CHECK(g4s2.handle.IsWeak()); |
| 3738 } | 3747 } |
| 3739 | 3748 |
| 3740 WeakCallCounterAndPersistent<Value> root(&counter); | 3749 WeakCallCounterAndPersistent<Value> root(&counter); |
| 3741 root.handle.Reset(iso, g1s1.handle); // make a root. | 3750 root.handle.Reset(iso, g1s1.handle); // make a root. |
| 3742 | 3751 |
| 3743 // Connect groups. We're building the following cycle: | 3752 // Connect groups. We're building the following cycle: |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3812 | 3821 |
| 3813 WeakCallCounterAndPersistent<Value> g1s1(&counter); | 3822 WeakCallCounterAndPersistent<Value> g1s1(&counter); |
| 3814 WeakCallCounterAndPersistent<Value> g1s2(&counter); | 3823 WeakCallCounterAndPersistent<Value> g1s2(&counter); |
| 3815 WeakCallCounterAndPersistent<Value> g2s1(&counter); | 3824 WeakCallCounterAndPersistent<Value> g2s1(&counter); |
| 3816 WeakCallCounterAndPersistent<Value> g2s2(&counter); | 3825 WeakCallCounterAndPersistent<Value> g2s2(&counter); |
| 3817 WeakCallCounterAndPersistent<Value> g3s1(&counter); | 3826 WeakCallCounterAndPersistent<Value> g3s1(&counter); |
| 3818 WeakCallCounterAndPersistent<Value> g3s2(&counter); | 3827 WeakCallCounterAndPersistent<Value> g3s2(&counter); |
| 3819 | 3828 |
| 3820 { | 3829 { |
| 3821 HandleScope scope(iso); | 3830 HandleScope scope(iso); |
| 3822 g1s1.handle.Reset(iso, Object::New()); | 3831 g1s1.handle.Reset(iso, Object::New(iso)); |
| 3823 g1s2.handle.Reset(iso, Object::New()); | 3832 g1s2.handle.Reset(iso, Object::New(iso)); |
| 3824 g1s1.handle.SetWeak(&g1s1, &WeakPointerCallback); | 3833 g1s1.handle.SetWeak(&g1s1, &WeakPointerCallback); |
| 3825 g1s2.handle.SetWeak(&g1s2, &WeakPointerCallback); | 3834 g1s2.handle.SetWeak(&g1s2, &WeakPointerCallback); |
| 3826 | 3835 |
| 3827 g2s1.handle.Reset(iso, Object::New()); | 3836 g2s1.handle.Reset(iso, Object::New(iso)); |
| 3828 g2s2.handle.Reset(iso, Object::New()); | 3837 g2s2.handle.Reset(iso, Object::New(iso)); |
| 3829 g2s1.handle.SetWeak(&g2s1, &WeakPointerCallback); | 3838 g2s1.handle.SetWeak(&g2s1, &WeakPointerCallback); |
| 3830 g2s2.handle.SetWeak(&g2s2, &WeakPointerCallback); | 3839 g2s2.handle.SetWeak(&g2s2, &WeakPointerCallback); |
| 3831 | 3840 |
| 3832 g3s1.handle.Reset(iso, Object::New()); | 3841 g3s1.handle.Reset(iso, Object::New(iso)); |
| 3833 g3s2.handle.Reset(iso, Object::New()); | 3842 g3s2.handle.Reset(iso, Object::New(iso)); |
| 3834 g3s1.handle.SetWeak(&g3s1, &WeakPointerCallback); | 3843 g3s1.handle.SetWeak(&g3s1, &WeakPointerCallback); |
| 3835 g3s2.handle.SetWeak(&g3s2, &WeakPointerCallback); | 3844 g3s2.handle.SetWeak(&g3s2, &WeakPointerCallback); |
| 3836 } | 3845 } |
| 3837 | 3846 |
| 3838 // Make a root. | 3847 // Make a root. |
| 3839 WeakCallCounterAndPersistent<Value> root(&counter); | 3848 WeakCallCounterAndPersistent<Value> root(&counter); |
| 3840 root.handle.Reset(iso, g1s1.handle); | 3849 root.handle.Reset(iso, g1s1.handle); |
| 3841 root.handle.MarkPartiallyDependent(); | 3850 root.handle.MarkPartiallyDependent(); |
| 3842 | 3851 |
| 3843 // Connect groups. We're building the following cycle: | 3852 // Connect groups. We're building the following cycle: |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3941 CHECK_EQ(7.56, message->GetScriptData()->NumberValue()); | 3950 CHECK_EQ(7.56, message->GetScriptData()->NumberValue()); |
| 3942 CHECK(!message->IsSharedCrossOrigin()); | 3951 CHECK(!message->IsSharedCrossOrigin()); |
| 3943 message_received = true; | 3952 message_received = true; |
| 3944 } | 3953 } |
| 3945 | 3954 |
| 3946 | 3955 |
| 3947 THREADED_TEST(MessageHandler0) { | 3956 THREADED_TEST(MessageHandler0) { |
| 3948 message_received = false; | 3957 message_received = false; |
| 3949 v8::HandleScope scope(CcTest::isolate()); | 3958 v8::HandleScope scope(CcTest::isolate()); |
| 3950 CHECK(!message_received); | 3959 CHECK(!message_received); |
| 3960 LocalContext context; |
| 3951 v8::V8::AddMessageListener(check_message_0, v8_num(5.76)); | 3961 v8::V8::AddMessageListener(check_message_0, v8_num(5.76)); |
| 3952 LocalContext context; | |
| 3953 v8::ScriptOrigin origin = | 3962 v8::ScriptOrigin origin = |
| 3954 v8::ScriptOrigin(v8_str("6.75")); | 3963 v8::ScriptOrigin(v8_str("6.75")); |
| 3955 v8::Handle<v8::Script> script = Script::Compile(v8_str("throw 'error'"), | 3964 v8::Handle<v8::Script> script = Script::Compile(v8_str("throw 'error'"), |
| 3956 &origin); | 3965 &origin); |
| 3957 script->SetData(v8_str("7.56")); | 3966 script->SetData(v8_str("7.56")); |
| 3958 script->Run(); | 3967 script->Run(); |
| 3959 CHECK(message_received); | 3968 CHECK(message_received); |
| 3960 // clear out the message listener | 3969 // clear out the message listener |
| 3961 v8::V8::RemoveMessageListeners(check_message_0); | 3970 v8::V8::RemoveMessageListeners(check_message_0); |
| 3962 } | 3971 } |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4023 | 4032 |
| 4024 TEST(MessageHandler3) { | 4033 TEST(MessageHandler3) { |
| 4025 message_received = false; | 4034 message_received = false; |
| 4026 v8::Isolate* isolate = CcTest::isolate(); | 4035 v8::Isolate* isolate = CcTest::isolate(); |
| 4027 v8::HandleScope scope(isolate); | 4036 v8::HandleScope scope(isolate); |
| 4028 CHECK(!message_received); | 4037 CHECK(!message_received); |
| 4029 v8::V8::AddMessageListener(check_message_3); | 4038 v8::V8::AddMessageListener(check_message_3); |
| 4030 LocalContext context; | 4039 LocalContext context; |
| 4031 v8::ScriptOrigin origin = | 4040 v8::ScriptOrigin origin = |
| 4032 v8::ScriptOrigin(v8_str("6.75"), | 4041 v8::ScriptOrigin(v8_str("6.75"), |
| 4033 v8::Integer::New(1, isolate), | 4042 v8::Integer::New(isolate, 1), |
| 4034 v8::Integer::New(2, isolate), | 4043 v8::Integer::New(isolate, 2), |
| 4035 v8::True(isolate)); | 4044 v8::True(isolate)); |
| 4036 v8::Handle<v8::Script> script = Script::Compile(v8_str("throw 'error'"), | 4045 v8::Handle<v8::Script> script = Script::Compile(v8_str("throw 'error'"), |
| 4037 &origin); | 4046 &origin); |
| 4038 script->Run(); | 4047 script->Run(); |
| 4039 CHECK(message_received); | 4048 CHECK(message_received); |
| 4040 // clear out the message listener | 4049 // clear out the message listener |
| 4041 v8::V8::RemoveMessageListeners(check_message_3); | 4050 v8::V8::RemoveMessageListeners(check_message_3); |
| 4042 } | 4051 } |
| 4043 | 4052 |
| 4044 | 4053 |
| 4045 static void check_message_4(v8::Handle<v8::Message> message, | 4054 static void check_message_4(v8::Handle<v8::Message> message, |
| 4046 v8::Handle<Value> data) { | 4055 v8::Handle<Value> data) { |
| 4047 CHECK(!message->IsSharedCrossOrigin()); | 4056 CHECK(!message->IsSharedCrossOrigin()); |
| 4048 CHECK_EQ(6.75, message->GetScriptResourceName()->NumberValue()); | 4057 CHECK_EQ(6.75, message->GetScriptResourceName()->NumberValue()); |
| 4049 message_received = true; | 4058 message_received = true; |
| 4050 } | 4059 } |
| 4051 | 4060 |
| 4052 | 4061 |
| 4053 TEST(MessageHandler4) { | 4062 TEST(MessageHandler4) { |
| 4054 message_received = false; | 4063 message_received = false; |
| 4055 v8::Isolate* isolate = CcTest::isolate(); | 4064 v8::Isolate* isolate = CcTest::isolate(); |
| 4056 v8::HandleScope scope(isolate); | 4065 v8::HandleScope scope(isolate); |
| 4057 CHECK(!message_received); | 4066 CHECK(!message_received); |
| 4058 v8::V8::AddMessageListener(check_message_4); | 4067 v8::V8::AddMessageListener(check_message_4); |
| 4059 LocalContext context; | 4068 LocalContext context; |
| 4060 v8::ScriptOrigin origin = | 4069 v8::ScriptOrigin origin = |
| 4061 v8::ScriptOrigin(v8_str("6.75"), | 4070 v8::ScriptOrigin(v8_str("6.75"), |
| 4062 v8::Integer::New(1, isolate), | 4071 v8::Integer::New(isolate, 1), |
| 4063 v8::Integer::New(2, isolate), | 4072 v8::Integer::New(isolate, 2), |
| 4064 v8::False(isolate)); | 4073 v8::False(isolate)); |
| 4065 v8::Handle<v8::Script> script = Script::Compile(v8_str("throw 'error'"), | 4074 v8::Handle<v8::Script> script = Script::Compile(v8_str("throw 'error'"), |
| 4066 &origin); | 4075 &origin); |
| 4067 script->Run(); | 4076 script->Run(); |
| 4068 CHECK(message_received); | 4077 CHECK(message_received); |
| 4069 // clear out the message listener | 4078 // clear out the message listener |
| 4070 v8::V8::RemoveMessageListeners(check_message_4); | 4079 v8::V8::RemoveMessageListeners(check_message_4); |
| 4071 } | 4080 } |
| 4072 | 4081 |
| 4073 | 4082 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 4089 | 4098 |
| 4090 TEST(MessageHandler5) { | 4099 TEST(MessageHandler5) { |
| 4091 message_received = false; | 4100 message_received = false; |
| 4092 v8::Isolate* isolate = CcTest::isolate(); | 4101 v8::Isolate* isolate = CcTest::isolate(); |
| 4093 v8::HandleScope scope(isolate); | 4102 v8::HandleScope scope(isolate); |
| 4094 CHECK(!message_received); | 4103 CHECK(!message_received); |
| 4095 v8::V8::AddMessageListener(check_message_5a); | 4104 v8::V8::AddMessageListener(check_message_5a); |
| 4096 LocalContext context; | 4105 LocalContext context; |
| 4097 v8::ScriptOrigin origin = | 4106 v8::ScriptOrigin origin = |
| 4098 v8::ScriptOrigin(v8_str("6.75"), | 4107 v8::ScriptOrigin(v8_str("6.75"), |
| 4099 v8::Integer::New(1, isolate), | 4108 v8::Integer::New(isolate, 1), |
| 4100 v8::Integer::New(2, isolate), | 4109 v8::Integer::New(isolate, 2), |
| 4101 v8::True(isolate)); | 4110 v8::True(isolate)); |
| 4102 v8::Handle<v8::Script> script = Script::Compile(v8_str("throw 'error'"), | 4111 v8::Handle<v8::Script> script = Script::Compile(v8_str("throw 'error'"), |
| 4103 &origin); | 4112 &origin); |
| 4104 script->Run(); | 4113 script->Run(); |
| 4105 CHECK(message_received); | 4114 CHECK(message_received); |
| 4106 // clear out the message listener | 4115 // clear out the message listener |
| 4107 v8::V8::RemoveMessageListeners(check_message_5a); | 4116 v8::V8::RemoveMessageListeners(check_message_5a); |
| 4108 | 4117 |
| 4109 message_received = false; | 4118 message_received = false; |
| 4110 v8::V8::AddMessageListener(check_message_5b); | 4119 v8::V8::AddMessageListener(check_message_5b); |
| 4111 origin = | 4120 origin = |
| 4112 v8::ScriptOrigin(v8_str("6.75"), | 4121 v8::ScriptOrigin(v8_str("6.75"), |
| 4113 v8::Integer::New(1, isolate), | 4122 v8::Integer::New(isolate, 1), |
| 4114 v8::Integer::New(2, isolate), | 4123 v8::Integer::New(isolate, 2), |
| 4115 v8::False(isolate)); | 4124 v8::False(isolate)); |
| 4116 script = Script::Compile(v8_str("throw 'error'"), | 4125 script = Script::Compile(v8_str("throw 'error'"), |
| 4117 &origin); | 4126 &origin); |
| 4118 script->Run(); | 4127 script->Run(); |
| 4119 CHECK(message_received); | 4128 CHECK(message_received); |
| 4120 // clear out the message listener | 4129 // clear out the message listener |
| 4121 v8::V8::RemoveMessageListeners(check_message_5b); | 4130 v8::V8::RemoveMessageListeners(check_message_5b); |
| 4122 } | 4131 } |
| 4123 | 4132 |
| 4124 | 4133 |
| 4125 THREADED_TEST(GetSetProperty) { | 4134 THREADED_TEST(GetSetProperty) { |
| 4126 LocalContext context; | 4135 LocalContext context; |
| 4127 v8::HandleScope scope(context->GetIsolate()); | 4136 v8::Isolate* isolate = context->GetIsolate(); |
| 4137 v8::HandleScope scope(isolate); |
| 4128 context->Global()->Set(v8_str("foo"), v8_num(14)); | 4138 context->Global()->Set(v8_str("foo"), v8_num(14)); |
| 4129 context->Global()->Set(v8_str("12"), v8_num(92)); | 4139 context->Global()->Set(v8_str("12"), v8_num(92)); |
| 4130 context->Global()->Set(v8::Integer::New(16), v8_num(32)); | 4140 context->Global()->Set(v8::Integer::New(isolate, 16), v8_num(32)); |
| 4131 context->Global()->Set(v8_num(13), v8_num(56)); | 4141 context->Global()->Set(v8_num(13), v8_num(56)); |
| 4132 Local<Value> foo = Script::Compile(v8_str("this.foo"))->Run(); | 4142 Local<Value> foo = Script::Compile(v8_str("this.foo"))->Run(); |
| 4133 CHECK_EQ(14, foo->Int32Value()); | 4143 CHECK_EQ(14, foo->Int32Value()); |
| 4134 Local<Value> twelve = Script::Compile(v8_str("this[12]"))->Run(); | 4144 Local<Value> twelve = Script::Compile(v8_str("this[12]"))->Run(); |
| 4135 CHECK_EQ(92, twelve->Int32Value()); | 4145 CHECK_EQ(92, twelve->Int32Value()); |
| 4136 Local<Value> sixteen = Script::Compile(v8_str("this[16]"))->Run(); | 4146 Local<Value> sixteen = Script::Compile(v8_str("this[16]"))->Run(); |
| 4137 CHECK_EQ(32, sixteen->Int32Value()); | 4147 CHECK_EQ(32, sixteen->Int32Value()); |
| 4138 Local<Value> thirteen = Script::Compile(v8_str("this[13]"))->Run(); | 4148 Local<Value> thirteen = Script::Compile(v8_str("this[13]"))->Run(); |
| 4139 CHECK_EQ(56, thirteen->Int32Value()); | 4149 CHECK_EQ(56, thirteen->Int32Value()); |
| 4140 CHECK_EQ(92, context->Global()->Get(v8::Integer::New(12))->Int32Value()); | 4150 CHECK_EQ(92, |
| 4151 context->Global()->Get(v8::Integer::New(isolate, 12))->Int32Value()); |
| 4141 CHECK_EQ(92, context->Global()->Get(v8_str("12"))->Int32Value()); | 4152 CHECK_EQ(92, context->Global()->Get(v8_str("12"))->Int32Value()); |
| 4142 CHECK_EQ(92, context->Global()->Get(v8_num(12))->Int32Value()); | 4153 CHECK_EQ(92, context->Global()->Get(v8_num(12))->Int32Value()); |
| 4143 CHECK_EQ(32, context->Global()->Get(v8::Integer::New(16))->Int32Value()); | 4154 CHECK_EQ(32, |
| 4155 context->Global()->Get(v8::Integer::New(isolate, 16))->Int32Value()); |
| 4144 CHECK_EQ(32, context->Global()->Get(v8_str("16"))->Int32Value()); | 4156 CHECK_EQ(32, context->Global()->Get(v8_str("16"))->Int32Value()); |
| 4145 CHECK_EQ(32, context->Global()->Get(v8_num(16))->Int32Value()); | 4157 CHECK_EQ(32, context->Global()->Get(v8_num(16))->Int32Value()); |
| 4146 CHECK_EQ(56, context->Global()->Get(v8::Integer::New(13))->Int32Value()); | 4158 CHECK_EQ(56, |
| 4159 context->Global()->Get(v8::Integer::New(isolate, 13))->Int32Value()); |
| 4147 CHECK_EQ(56, context->Global()->Get(v8_str("13"))->Int32Value()); | 4160 CHECK_EQ(56, context->Global()->Get(v8_str("13"))->Int32Value()); |
| 4148 CHECK_EQ(56, context->Global()->Get(v8_num(13))->Int32Value()); | 4161 CHECK_EQ(56, context->Global()->Get(v8_num(13))->Int32Value()); |
| 4149 } | 4162 } |
| 4150 | 4163 |
| 4151 | 4164 |
| 4152 THREADED_TEST(PropertyAttributes) { | 4165 THREADED_TEST(PropertyAttributes) { |
| 4153 LocalContext context; | 4166 LocalContext context; |
| 4154 v8::HandleScope scope(context->GetIsolate()); | 4167 v8::HandleScope scope(context->GetIsolate()); |
| 4155 // none | 4168 // none |
| 4156 Local<String> prop = v8_str("none"); | 4169 Local<String> prop = v8_str("none"); |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4296 Local<Function> ReturnThisStrict = | 4309 Local<Function> ReturnThisStrict = |
| 4297 Local<Function>::Cast(context->Global()->Get(v8_str("ReturnThisStrict"))); | 4310 Local<Function>::Cast(context->Global()->Get(v8_str("ReturnThisStrict"))); |
| 4298 | 4311 |
| 4299 v8::Handle<Value>* args0 = NULL; | 4312 v8::Handle<Value>* args0 = NULL; |
| 4300 Local<v8::Array> a0 = Local<v8::Array>::Cast(Foo->Call(Foo, 0, args0)); | 4313 Local<v8::Array> a0 = Local<v8::Array>::Cast(Foo->Call(Foo, 0, args0)); |
| 4301 CHECK_EQ(0, a0->Length()); | 4314 CHECK_EQ(0, a0->Length()); |
| 4302 | 4315 |
| 4303 v8::Handle<Value> args1[] = { v8_num(1.1) }; | 4316 v8::Handle<Value> args1[] = { v8_num(1.1) }; |
| 4304 Local<v8::Array> a1 = Local<v8::Array>::Cast(Foo->Call(Foo, 1, args1)); | 4317 Local<v8::Array> a1 = Local<v8::Array>::Cast(Foo->Call(Foo, 1, args1)); |
| 4305 CHECK_EQ(1, a1->Length()); | 4318 CHECK_EQ(1, a1->Length()); |
| 4306 CHECK_EQ(1.1, a1->Get(v8::Integer::New(0))->NumberValue()); | 4319 CHECK_EQ(1.1, a1->Get(v8::Integer::New(isolate, 0))->NumberValue()); |
| 4307 | 4320 |
| 4308 v8::Handle<Value> args2[] = { v8_num(2.2), | 4321 v8::Handle<Value> args2[] = { v8_num(2.2), |
| 4309 v8_num(3.3) }; | 4322 v8_num(3.3) }; |
| 4310 Local<v8::Array> a2 = Local<v8::Array>::Cast(Foo->Call(Foo, 2, args2)); | 4323 Local<v8::Array> a2 = Local<v8::Array>::Cast(Foo->Call(Foo, 2, args2)); |
| 4311 CHECK_EQ(2, a2->Length()); | 4324 CHECK_EQ(2, a2->Length()); |
| 4312 CHECK_EQ(2.2, a2->Get(v8::Integer::New(0))->NumberValue()); | 4325 CHECK_EQ(2.2, a2->Get(v8::Integer::New(isolate, 0))->NumberValue()); |
| 4313 CHECK_EQ(3.3, a2->Get(v8::Integer::New(1))->NumberValue()); | 4326 CHECK_EQ(3.3, a2->Get(v8::Integer::New(isolate, 1))->NumberValue()); |
| 4314 | 4327 |
| 4315 v8::Handle<Value> args3[] = { v8_num(4.4), | 4328 v8::Handle<Value> args3[] = { v8_num(4.4), |
| 4316 v8_num(5.5), | 4329 v8_num(5.5), |
| 4317 v8_num(6.6) }; | 4330 v8_num(6.6) }; |
| 4318 Local<v8::Array> a3 = Local<v8::Array>::Cast(Foo->Call(Foo, 3, args3)); | 4331 Local<v8::Array> a3 = Local<v8::Array>::Cast(Foo->Call(Foo, 3, args3)); |
| 4319 CHECK_EQ(3, a3->Length()); | 4332 CHECK_EQ(3, a3->Length()); |
| 4320 CHECK_EQ(4.4, a3->Get(v8::Integer::New(0))->NumberValue()); | 4333 CHECK_EQ(4.4, a3->Get(v8::Integer::New(isolate, 0))->NumberValue()); |
| 4321 CHECK_EQ(5.5, a3->Get(v8::Integer::New(1))->NumberValue()); | 4334 CHECK_EQ(5.5, a3->Get(v8::Integer::New(isolate, 1))->NumberValue()); |
| 4322 CHECK_EQ(6.6, a3->Get(v8::Integer::New(2))->NumberValue()); | 4335 CHECK_EQ(6.6, a3->Get(v8::Integer::New(isolate, 2))->NumberValue()); |
| 4323 | 4336 |
| 4324 v8::Handle<Value> args4[] = { v8_num(7.7), | 4337 v8::Handle<Value> args4[] = { v8_num(7.7), |
| 4325 v8_num(8.8), | 4338 v8_num(8.8), |
| 4326 v8_num(9.9), | 4339 v8_num(9.9), |
| 4327 v8_num(10.11) }; | 4340 v8_num(10.11) }; |
| 4328 Local<v8::Array> a4 = Local<v8::Array>::Cast(Foo->Call(Foo, 4, args4)); | 4341 Local<v8::Array> a4 = Local<v8::Array>::Cast(Foo->Call(Foo, 4, args4)); |
| 4329 CHECK_EQ(4, a4->Length()); | 4342 CHECK_EQ(4, a4->Length()); |
| 4330 CHECK_EQ(7.7, a4->Get(v8::Integer::New(0))->NumberValue()); | 4343 CHECK_EQ(7.7, a4->Get(v8::Integer::New(isolate, 0))->NumberValue()); |
| 4331 CHECK_EQ(8.8, a4->Get(v8::Integer::New(1))->NumberValue()); | 4344 CHECK_EQ(8.8, a4->Get(v8::Integer::New(isolate, 1))->NumberValue()); |
| 4332 CHECK_EQ(9.9, a4->Get(v8::Integer::New(2))->NumberValue()); | 4345 CHECK_EQ(9.9, a4->Get(v8::Integer::New(isolate, 2))->NumberValue()); |
| 4333 CHECK_EQ(10.11, a4->Get(v8::Integer::New(3))->NumberValue()); | 4346 CHECK_EQ(10.11, a4->Get(v8::Integer::New(isolate, 3))->NumberValue()); |
| 4334 | 4347 |
| 4335 Local<v8::Value> r1 = ReturnThisSloppy->Call(v8::Undefined(isolate), 0, NULL); | 4348 Local<v8::Value> r1 = ReturnThisSloppy->Call(v8::Undefined(isolate), 0, NULL); |
| 4336 CHECK(r1->StrictEquals(context->Global())); | 4349 CHECK(r1->StrictEquals(context->Global())); |
| 4337 Local<v8::Value> r2 = ReturnThisSloppy->Call(v8::Null(isolate), 0, NULL); | 4350 Local<v8::Value> r2 = ReturnThisSloppy->Call(v8::Null(isolate), 0, NULL); |
| 4338 CHECK(r2->StrictEquals(context->Global())); | 4351 CHECK(r2->StrictEquals(context->Global())); |
| 4339 Local<v8::Value> r3 = ReturnThisSloppy->Call(v8_num(42), 0, NULL); | 4352 Local<v8::Value> r3 = ReturnThisSloppy->Call(v8_num(42), 0, NULL); |
| 4340 CHECK(r3->IsNumberObject()); | 4353 CHECK(r3->IsNumberObject()); |
| 4341 CHECK_EQ(42.0, r3.As<v8::NumberObject>()->ValueOf()); | 4354 CHECK_EQ(42.0, r3.As<v8::NumberObject>()->ValueOf()); |
| 4342 Local<v8::Value> r4 = ReturnThisSloppy->Call(v8_str("hello"), 0, NULL); | 4355 Local<v8::Value> r4 = ReturnThisSloppy->Call(v8_str("hello"), 0, NULL); |
| 4343 CHECK(r4->IsStringObject()); | 4356 CHECK(r4->IsStringObject()); |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4457 "for (var i = 0; i < 22; i++) { str = str + str; }"); | 4470 "for (var i = 0; i < 22; i++) { str = str + str; }"); |
| 4458 | 4471 |
| 4459 // Check for out of memory state. | 4472 // Check for out of memory state. |
| 4460 CHECK(result.IsEmpty()); | 4473 CHECK(result.IsEmpty()); |
| 4461 CHECK(context->HasOutOfMemoryException()); | 4474 CHECK(context->HasOutOfMemoryException()); |
| 4462 } | 4475 } |
| 4463 | 4476 |
| 4464 | 4477 |
| 4465 THREADED_TEST(ConstructCall) { | 4478 THREADED_TEST(ConstructCall) { |
| 4466 LocalContext context; | 4479 LocalContext context; |
| 4467 v8::HandleScope scope(context->GetIsolate()); | 4480 v8::Isolate* isolate = context->GetIsolate(); |
| 4481 v8::HandleScope scope(isolate); |
| 4468 CompileRun( | 4482 CompileRun( |
| 4469 "function Foo() {" | 4483 "function Foo() {" |
| 4470 " var result = [];" | 4484 " var result = [];" |
| 4471 " for (var i = 0; i < arguments.length; i++) {" | 4485 " for (var i = 0; i < arguments.length; i++) {" |
| 4472 " result.push(arguments[i]);" | 4486 " result.push(arguments[i]);" |
| 4473 " }" | 4487 " }" |
| 4474 " return result;" | 4488 " return result;" |
| 4475 "}"); | 4489 "}"); |
| 4476 Local<Function> Foo = | 4490 Local<Function> Foo = |
| 4477 Local<Function>::Cast(context->Global()->Get(v8_str("Foo"))); | 4491 Local<Function>::Cast(context->Global()->Get(v8_str("Foo"))); |
| 4478 | 4492 |
| 4479 v8::Handle<Value>* args0 = NULL; | 4493 v8::Handle<Value>* args0 = NULL; |
| 4480 Local<v8::Array> a0 = Local<v8::Array>::Cast(Foo->NewInstance(0, args0)); | 4494 Local<v8::Array> a0 = Local<v8::Array>::Cast(Foo->NewInstance(0, args0)); |
| 4481 CHECK_EQ(0, a0->Length()); | 4495 CHECK_EQ(0, a0->Length()); |
| 4482 | 4496 |
| 4483 v8::Handle<Value> args1[] = { v8_num(1.1) }; | 4497 v8::Handle<Value> args1[] = { v8_num(1.1) }; |
| 4484 Local<v8::Array> a1 = Local<v8::Array>::Cast(Foo->NewInstance(1, args1)); | 4498 Local<v8::Array> a1 = Local<v8::Array>::Cast(Foo->NewInstance(1, args1)); |
| 4485 CHECK_EQ(1, a1->Length()); | 4499 CHECK_EQ(1, a1->Length()); |
| 4486 CHECK_EQ(1.1, a1->Get(v8::Integer::New(0))->NumberValue()); | 4500 CHECK_EQ(1.1, a1->Get(v8::Integer::New(isolate, 0))->NumberValue()); |
| 4487 | 4501 |
| 4488 v8::Handle<Value> args2[] = { v8_num(2.2), | 4502 v8::Handle<Value> args2[] = { v8_num(2.2), |
| 4489 v8_num(3.3) }; | 4503 v8_num(3.3) }; |
| 4490 Local<v8::Array> a2 = Local<v8::Array>::Cast(Foo->NewInstance(2, args2)); | 4504 Local<v8::Array> a2 = Local<v8::Array>::Cast(Foo->NewInstance(2, args2)); |
| 4491 CHECK_EQ(2, a2->Length()); | 4505 CHECK_EQ(2, a2->Length()); |
| 4492 CHECK_EQ(2.2, a2->Get(v8::Integer::New(0))->NumberValue()); | 4506 CHECK_EQ(2.2, a2->Get(v8::Integer::New(isolate, 0))->NumberValue()); |
| 4493 CHECK_EQ(3.3, a2->Get(v8::Integer::New(1))->NumberValue()); | 4507 CHECK_EQ(3.3, a2->Get(v8::Integer::New(isolate, 1))->NumberValue()); |
| 4494 | 4508 |
| 4495 v8::Handle<Value> args3[] = { v8_num(4.4), | 4509 v8::Handle<Value> args3[] = { v8_num(4.4), |
| 4496 v8_num(5.5), | 4510 v8_num(5.5), |
| 4497 v8_num(6.6) }; | 4511 v8_num(6.6) }; |
| 4498 Local<v8::Array> a3 = Local<v8::Array>::Cast(Foo->NewInstance(3, args3)); | 4512 Local<v8::Array> a3 = Local<v8::Array>::Cast(Foo->NewInstance(3, args3)); |
| 4499 CHECK_EQ(3, a3->Length()); | 4513 CHECK_EQ(3, a3->Length()); |
| 4500 CHECK_EQ(4.4, a3->Get(v8::Integer::New(0))->NumberValue()); | 4514 CHECK_EQ(4.4, a3->Get(v8::Integer::New(isolate, 0))->NumberValue()); |
| 4501 CHECK_EQ(5.5, a3->Get(v8::Integer::New(1))->NumberValue()); | 4515 CHECK_EQ(5.5, a3->Get(v8::Integer::New(isolate, 1))->NumberValue()); |
| 4502 CHECK_EQ(6.6, a3->Get(v8::Integer::New(2))->NumberValue()); | 4516 CHECK_EQ(6.6, a3->Get(v8::Integer::New(isolate, 2))->NumberValue()); |
| 4503 | 4517 |
| 4504 v8::Handle<Value> args4[] = { v8_num(7.7), | 4518 v8::Handle<Value> args4[] = { v8_num(7.7), |
| 4505 v8_num(8.8), | 4519 v8_num(8.8), |
| 4506 v8_num(9.9), | 4520 v8_num(9.9), |
| 4507 v8_num(10.11) }; | 4521 v8_num(10.11) }; |
| 4508 Local<v8::Array> a4 = Local<v8::Array>::Cast(Foo->NewInstance(4, args4)); | 4522 Local<v8::Array> a4 = Local<v8::Array>::Cast(Foo->NewInstance(4, args4)); |
| 4509 CHECK_EQ(4, a4->Length()); | 4523 CHECK_EQ(4, a4->Length()); |
| 4510 CHECK_EQ(7.7, a4->Get(v8::Integer::New(0))->NumberValue()); | 4524 CHECK_EQ(7.7, a4->Get(v8::Integer::New(isolate, 0))->NumberValue()); |
| 4511 CHECK_EQ(8.8, a4->Get(v8::Integer::New(1))->NumberValue()); | 4525 CHECK_EQ(8.8, a4->Get(v8::Integer::New(isolate, 1))->NumberValue()); |
| 4512 CHECK_EQ(9.9, a4->Get(v8::Integer::New(2))->NumberValue()); | 4526 CHECK_EQ(9.9, a4->Get(v8::Integer::New(isolate, 2))->NumberValue()); |
| 4513 CHECK_EQ(10.11, a4->Get(v8::Integer::New(3))->NumberValue()); | 4527 CHECK_EQ(10.11, a4->Get(v8::Integer::New(isolate, 3))->NumberValue()); |
| 4514 } | 4528 } |
| 4515 | 4529 |
| 4516 | 4530 |
| 4517 static void CheckUncle(v8::TryCatch* try_catch) { | 4531 static void CheckUncle(v8::TryCatch* try_catch) { |
| 4518 CHECK(try_catch->HasCaught()); | 4532 CHECK(try_catch->HasCaught()); |
| 4519 String::Utf8Value str_value(try_catch->Exception()); | 4533 String::Utf8Value str_value(try_catch->Exception()); |
| 4520 CHECK_EQ(*str_value, "uncle?"); | 4534 CHECK_EQ(*str_value, "uncle?"); |
| 4521 try_catch->Reset(); | 4535 try_catch->Reset(); |
| 4522 } | 4536 } |
| 4523 | 4537 |
| (...skipping 593 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5117 "function Run(obj) {" | 5131 "function Run(obj) {" |
| 5118 " try {" | 5132 " try {" |
| 5119 " Throw(obj);" | 5133 " Throw(obj);" |
| 5120 " } catch (e) {" | 5134 " } catch (e) {" |
| 5121 " return e;" | 5135 " return e;" |
| 5122 " }" | 5136 " }" |
| 5123 " return 'no exception';" | 5137 " return 'no exception';" |
| 5124 "}" | 5138 "}" |
| 5125 "[Run('str'), Run(1), Run(0), Run(null), Run(void 0)];")); | 5139 "[Run('str'), Run(1), Run(0), Run(null), Run(void 0)];")); |
| 5126 CHECK_EQ(5, result->Length()); | 5140 CHECK_EQ(5, result->Length()); |
| 5127 CHECK(result->Get(v8::Integer::New(0))->IsString()); | 5141 CHECK(result->Get(v8::Integer::New(isolate, 0))->IsString()); |
| 5128 CHECK(result->Get(v8::Integer::New(1))->IsNumber()); | 5142 CHECK(result->Get(v8::Integer::New(isolate, 1))->IsNumber()); |
| 5129 CHECK_EQ(1, result->Get(v8::Integer::New(1))->Int32Value()); | 5143 CHECK_EQ(1, result->Get(v8::Integer::New(isolate, 1))->Int32Value()); |
| 5130 CHECK(result->Get(v8::Integer::New(2))->IsNumber()); | 5144 CHECK(result->Get(v8::Integer::New(isolate, 2))->IsNumber()); |
| 5131 CHECK_EQ(0, result->Get(v8::Integer::New(2))->Int32Value()); | 5145 CHECK_EQ(0, result->Get(v8::Integer::New(isolate, 2))->Int32Value()); |
| 5132 CHECK(result->Get(v8::Integer::New(3))->IsNull()); | 5146 CHECK(result->Get(v8::Integer::New(isolate, 3))->IsNull()); |
| 5133 CHECK(result->Get(v8::Integer::New(4))->IsUndefined()); | 5147 CHECK(result->Get(v8::Integer::New(isolate, 4))->IsUndefined()); |
| 5134 } | 5148 } |
| 5135 | 5149 |
| 5136 | 5150 |
| 5137 THREADED_TEST(CatchZero) { | 5151 THREADED_TEST(CatchZero) { |
| 5138 LocalContext context; | 5152 LocalContext context; |
| 5139 v8::HandleScope scope(context->GetIsolate()); | 5153 v8::HandleScope scope(context->GetIsolate()); |
| 5140 v8::TryCatch try_catch; | 5154 v8::TryCatch try_catch; |
| 5141 CHECK(!try_catch.HasCaught()); | 5155 CHECK(!try_catch.HasCaught()); |
| 5142 Script::Compile(v8_str("throw 10"))->Run(); | 5156 Script::Compile(v8_str("throw 10"))->Run(); |
| 5143 CHECK(try_catch.HasCaught()); | 5157 CHECK(try_catch.HasCaught()); |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5280 CHECK(!v8_str("a")->StrictEquals(v8_str("b"))); | 5294 CHECK(!v8_str("a")->StrictEquals(v8_str("b"))); |
| 5281 CHECK(!v8_str("5")->StrictEquals(v8_num(5))); | 5295 CHECK(!v8_str("5")->StrictEquals(v8_num(5))); |
| 5282 CHECK(v8_num(1)->StrictEquals(v8_num(1))); | 5296 CHECK(v8_num(1)->StrictEquals(v8_num(1))); |
| 5283 CHECK(!v8_num(1)->StrictEquals(v8_num(2))); | 5297 CHECK(!v8_num(1)->StrictEquals(v8_num(2))); |
| 5284 CHECK(v8_num(0.0)->StrictEquals(v8_num(-0.0))); | 5298 CHECK(v8_num(0.0)->StrictEquals(v8_num(-0.0))); |
| 5285 Local<Value> not_a_number = v8_num(i::OS::nan_value()); | 5299 Local<Value> not_a_number = v8_num(i::OS::nan_value()); |
| 5286 CHECK(!not_a_number->StrictEquals(not_a_number)); | 5300 CHECK(!not_a_number->StrictEquals(not_a_number)); |
| 5287 CHECK(v8::False(isolate)->StrictEquals(v8::False(isolate))); | 5301 CHECK(v8::False(isolate)->StrictEquals(v8::False(isolate))); |
| 5288 CHECK(!v8::False(isolate)->StrictEquals(v8::Undefined(isolate))); | 5302 CHECK(!v8::False(isolate)->StrictEquals(v8::Undefined(isolate))); |
| 5289 | 5303 |
| 5290 v8::Handle<v8::Object> obj = v8::Object::New(); | 5304 v8::Handle<v8::Object> obj = v8::Object::New(isolate); |
| 5291 v8::Persistent<v8::Object> alias(isolate, obj); | 5305 v8::Persistent<v8::Object> alias(isolate, obj); |
| 5292 CHECK(v8::Local<v8::Object>::New(isolate, alias)->StrictEquals(obj)); | 5306 CHECK(v8::Local<v8::Object>::New(isolate, alias)->StrictEquals(obj)); |
| 5293 alias.Reset(); | 5307 alias.Reset(); |
| 5294 | 5308 |
| 5295 CHECK(v8_str("a")->SameValue(v8_str("a"))); | 5309 CHECK(v8_str("a")->SameValue(v8_str("a"))); |
| 5296 CHECK(!v8_str("a")->SameValue(v8_str("b"))); | 5310 CHECK(!v8_str("a")->SameValue(v8_str("b"))); |
| 5297 CHECK(!v8_str("5")->SameValue(v8_num(5))); | 5311 CHECK(!v8_str("5")->SameValue(v8_num(5))); |
| 5298 CHECK(v8_num(1)->SameValue(v8_num(1))); | 5312 CHECK(v8_num(1)->SameValue(v8_num(1))); |
| 5299 CHECK(!v8_num(1)->SameValue(v8_num(2))); | 5313 CHECK(!v8_num(1)->SameValue(v8_num(2))); |
| 5300 CHECK(!v8_num(0.0)->SameValue(v8_num(-0.0))); | 5314 CHECK(!v8_num(0.0)->SameValue(v8_num(-0.0))); |
| (...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5743 CompileRun("var obj = { x : 0 }; delete obj.x;"); | 5757 CompileRun("var obj = { x : 0 }; delete obj.x;"); |
| 5744 context1->Exit(); | 5758 context1->Exit(); |
| 5745 } | 5759 } |
| 5746 | 5760 |
| 5747 | 5761 |
| 5748 static void SetXOnPrototypeGetter( | 5762 static void SetXOnPrototypeGetter( |
| 5749 Local<String> property, | 5763 Local<String> property, |
| 5750 const v8::PropertyCallbackInfo<v8::Value>& info) { | 5764 const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 5751 // Set x on the prototype object and do not handle the get request. | 5765 // Set x on the prototype object and do not handle the get request. |
| 5752 v8::Handle<v8::Value> proto = info.Holder()->GetPrototype(); | 5766 v8::Handle<v8::Value> proto = info.Holder()->GetPrototype(); |
| 5753 proto.As<v8::Object>()->Set(v8_str("x"), v8::Integer::New(23)); | 5767 proto.As<v8::Object>()->Set(v8_str("x"), |
| 5768 v8::Integer::New(info.GetIsolate(), 23)); |
| 5754 } | 5769 } |
| 5755 | 5770 |
| 5756 | 5771 |
| 5757 // This is a regression test for http://crbug.com/20104. Map | 5772 // This is a regression test for http://crbug.com/20104. Map |
| 5758 // transitions should not interfere with post interceptor lookup. | 5773 // transitions should not interfere with post interceptor lookup. |
| 5759 THREADED_TEST(NamedInterceptorMapTransitionRead) { | 5774 THREADED_TEST(NamedInterceptorMapTransitionRead) { |
| 5760 v8::Isolate* isolate = CcTest::isolate(); | 5775 v8::Isolate* isolate = CcTest::isolate(); |
| 5761 v8::HandleScope scope(isolate); | 5776 v8::HandleScope scope(isolate); |
| 5762 Local<v8::FunctionTemplate> function_template = | 5777 Local<v8::FunctionTemplate> function_template = |
| 5763 v8::FunctionTemplate::New(isolate); | 5778 v8::FunctionTemplate::New(isolate); |
| (...skipping 636 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6400 desc->InstanceTemplate()->MarkAsUndetectable(); // undetectable | 6415 desc->InstanceTemplate()->MarkAsUndetectable(); // undetectable |
| 6401 | 6416 |
| 6402 Local<v8::Object> obj = desc->GetFunction()->NewInstance(); | 6417 Local<v8::Object> obj = desc->GetFunction()->NewInstance(); |
| 6403 env->Global()->Set(v8_str("undetectable"), obj); | 6418 env->Global()->Set(v8_str("undetectable"), obj); |
| 6404 | 6419 |
| 6405 Local<String> source = v8_str("undetectable.x = 42;" | 6420 Local<String> source = v8_str("undetectable.x = 42;" |
| 6406 "undetectable.x"); | 6421 "undetectable.x"); |
| 6407 | 6422 |
| 6408 Local<Script> script = Script::Compile(source); | 6423 Local<Script> script = Script::Compile(source); |
| 6409 | 6424 |
| 6410 CHECK_EQ(v8::Integer::New(42), script->Run()); | 6425 CHECK_EQ(v8::Integer::New(isolate, 42), script->Run()); |
| 6411 | 6426 |
| 6412 ExpectBoolean("Object.isExtensible(undetectable)", true); | 6427 ExpectBoolean("Object.isExtensible(undetectable)", true); |
| 6413 | 6428 |
| 6414 source = v8_str("Object.preventExtensions(undetectable);"); | 6429 source = v8_str("Object.preventExtensions(undetectable);"); |
| 6415 script = Script::Compile(source); | 6430 script = Script::Compile(source); |
| 6416 script->Run(); | 6431 script->Run(); |
| 6417 ExpectBoolean("Object.isExtensible(undetectable)", false); | 6432 ExpectBoolean("Object.isExtensible(undetectable)", false); |
| 6418 | 6433 |
| 6419 source = v8_str("undetectable.y = 2000;"); | 6434 source = v8_str("undetectable.y = 2000;"); |
| 6420 script = Script::Compile(source); | 6435 script = Script::Compile(source); |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6545 | 6560 |
| 6546 THREADED_TEST(SimpleExtensions) { | 6561 THREADED_TEST(SimpleExtensions) { |
| 6547 v8::HandleScope handle_scope(CcTest::isolate()); | 6562 v8::HandleScope handle_scope(CcTest::isolate()); |
| 6548 v8::RegisterExtension(new Extension("simpletest", kSimpleExtensionSource)); | 6563 v8::RegisterExtension(new Extension("simpletest", kSimpleExtensionSource)); |
| 6549 const char* extension_names[] = { "simpletest" }; | 6564 const char* extension_names[] = { "simpletest" }; |
| 6550 v8::ExtensionConfiguration extensions(1, extension_names); | 6565 v8::ExtensionConfiguration extensions(1, extension_names); |
| 6551 v8::Handle<Context> context = | 6566 v8::Handle<Context> context = |
| 6552 Context::New(CcTest::isolate(), &extensions); | 6567 Context::New(CcTest::isolate(), &extensions); |
| 6553 Context::Scope lock(context); | 6568 Context::Scope lock(context); |
| 6554 v8::Handle<Value> result = Script::Compile(v8_str("Foo()"))->Run(); | 6569 v8::Handle<Value> result = Script::Compile(v8_str("Foo()"))->Run(); |
| 6555 CHECK_EQ(result, v8::Integer::New(4)); | 6570 CHECK_EQ(result, v8::Integer::New(CcTest::isolate(), 4)); |
| 6556 } | 6571 } |
| 6557 | 6572 |
| 6558 | 6573 |
| 6559 THREADED_TEST(NullExtensions) { | 6574 THREADED_TEST(NullExtensions) { |
| 6560 v8::HandleScope handle_scope(CcTest::isolate()); | 6575 v8::HandleScope handle_scope(CcTest::isolate()); |
| 6561 v8::RegisterExtension(new Extension("nulltest", NULL)); | 6576 v8::RegisterExtension(new Extension("nulltest", NULL)); |
| 6562 const char* extension_names[] = { "nulltest" }; | 6577 const char* extension_names[] = { "nulltest" }; |
| 6563 v8::ExtensionConfiguration extensions(1, extension_names); | 6578 v8::ExtensionConfiguration extensions(1, extension_names); |
| 6564 v8::Handle<Context> context = | 6579 v8::Handle<Context> context = |
| 6565 Context::New(CcTest::isolate(), &extensions); | 6580 Context::New(CcTest::isolate(), &extensions); |
| 6566 Context::Scope lock(context); | 6581 Context::Scope lock(context); |
| 6567 v8::Handle<Value> result = Script::Compile(v8_str("1+3"))->Run(); | 6582 v8::Handle<Value> result = Script::Compile(v8_str("1+3"))->Run(); |
| 6568 CHECK_EQ(result, v8::Integer::New(4)); | 6583 CHECK_EQ(result, v8::Integer::New(CcTest::isolate(), 4)); |
| 6569 } | 6584 } |
| 6570 | 6585 |
| 6571 | 6586 |
| 6572 static const char* kEmbeddedExtensionSource = | 6587 static const char* kEmbeddedExtensionSource = |
| 6573 "function Ret54321(){return 54321;}~~@@$" | 6588 "function Ret54321(){return 54321;}~~@@$" |
| 6574 "$%% THIS IS A SERIES OF NON-NULL-TERMINATED STRINGS."; | 6589 "$%% THIS IS A SERIES OF NON-NULL-TERMINATED STRINGS."; |
| 6575 static const int kEmbeddedExtensionSourceValidLen = 34; | 6590 static const int kEmbeddedExtensionSourceValidLen = 34; |
| 6576 | 6591 |
| 6577 | 6592 |
| 6578 THREADED_TEST(ExtensionMissingSourceLength) { | 6593 THREADED_TEST(ExtensionMissingSourceLength) { |
| (...skipping 17 matching lines...) Expand all Loading... |
| 6596 v8::RegisterExtension(new Extension(extension_name.start(), | 6611 v8::RegisterExtension(new Extension(extension_name.start(), |
| 6597 kEmbeddedExtensionSource, 0, 0, | 6612 kEmbeddedExtensionSource, 0, 0, |
| 6598 source_len)); | 6613 source_len)); |
| 6599 const char* extension_names[1] = { extension_name.start() }; | 6614 const char* extension_names[1] = { extension_name.start() }; |
| 6600 v8::ExtensionConfiguration extensions(1, extension_names); | 6615 v8::ExtensionConfiguration extensions(1, extension_names); |
| 6601 v8::Handle<Context> context = | 6616 v8::Handle<Context> context = |
| 6602 Context::New(CcTest::isolate(), &extensions); | 6617 Context::New(CcTest::isolate(), &extensions); |
| 6603 if (source_len == kEmbeddedExtensionSourceValidLen) { | 6618 if (source_len == kEmbeddedExtensionSourceValidLen) { |
| 6604 Context::Scope lock(context); | 6619 Context::Scope lock(context); |
| 6605 v8::Handle<Value> result = Script::Compile(v8_str("Ret54321()"))->Run(); | 6620 v8::Handle<Value> result = Script::Compile(v8_str("Ret54321()"))->Run(); |
| 6606 CHECK_EQ(v8::Integer::New(54321), result); | 6621 CHECK_EQ(v8::Integer::New(CcTest::isolate(), 54321), result); |
| 6607 } else { | 6622 } else { |
| 6608 // Anything but exactly the right length should fail to compile. | 6623 // Anything but exactly the right length should fail to compile. |
| 6609 CHECK_EQ(0, *context); | 6624 CHECK_EQ(0, *context); |
| 6610 } | 6625 } |
| 6611 } | 6626 } |
| 6612 } | 6627 } |
| 6613 | 6628 |
| 6614 | 6629 |
| 6615 static const char* kEvalExtensionSource1 = | 6630 static const char* kEvalExtensionSource1 = |
| 6616 "function UseEval1() {" | 6631 "function UseEval1() {" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 6632 THREADED_TEST(UseEvalFromExtension) { | 6647 THREADED_TEST(UseEvalFromExtension) { |
| 6633 v8::HandleScope handle_scope(CcTest::isolate()); | 6648 v8::HandleScope handle_scope(CcTest::isolate()); |
| 6634 v8::RegisterExtension(new Extension("evaltest1", kEvalExtensionSource1)); | 6649 v8::RegisterExtension(new Extension("evaltest1", kEvalExtensionSource1)); |
| 6635 v8::RegisterExtension(new Extension("evaltest2", kEvalExtensionSource2)); | 6650 v8::RegisterExtension(new Extension("evaltest2", kEvalExtensionSource2)); |
| 6636 const char* extension_names[] = { "evaltest1", "evaltest2" }; | 6651 const char* extension_names[] = { "evaltest1", "evaltest2" }; |
| 6637 v8::ExtensionConfiguration extensions(2, extension_names); | 6652 v8::ExtensionConfiguration extensions(2, extension_names); |
| 6638 v8::Handle<Context> context = | 6653 v8::Handle<Context> context = |
| 6639 Context::New(CcTest::isolate(), &extensions); | 6654 Context::New(CcTest::isolate(), &extensions); |
| 6640 Context::Scope lock(context); | 6655 Context::Scope lock(context); |
| 6641 v8::Handle<Value> result = Script::Compile(v8_str("UseEval1()"))->Run(); | 6656 v8::Handle<Value> result = Script::Compile(v8_str("UseEval1()"))->Run(); |
| 6642 CHECK_EQ(result, v8::Integer::New(42)); | 6657 CHECK_EQ(result, v8::Integer::New(CcTest::isolate(), 42)); |
| 6643 result = Script::Compile(v8_str("UseEval2()"))->Run(); | 6658 result = Script::Compile(v8_str("UseEval2()"))->Run(); |
| 6644 CHECK_EQ(result, v8::Integer::New(42)); | 6659 CHECK_EQ(result, v8::Integer::New(CcTest::isolate(), 42)); |
| 6645 } | 6660 } |
| 6646 | 6661 |
| 6647 | 6662 |
| 6648 static const char* kWithExtensionSource1 = | 6663 static const char* kWithExtensionSource1 = |
| 6649 "function UseWith1() {" | 6664 "function UseWith1() {" |
| 6650 " var x = 42;" | 6665 " var x = 42;" |
| 6651 " with({x:87}) { return x; }" | 6666 " with({x:87}) { return x; }" |
| 6652 "}"; | 6667 "}"; |
| 6653 | 6668 |
| 6654 | 6669 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 6666 THREADED_TEST(UseWithFromExtension) { | 6681 THREADED_TEST(UseWithFromExtension) { |
| 6667 v8::HandleScope handle_scope(CcTest::isolate()); | 6682 v8::HandleScope handle_scope(CcTest::isolate()); |
| 6668 v8::RegisterExtension(new Extension("withtest1", kWithExtensionSource1)); | 6683 v8::RegisterExtension(new Extension("withtest1", kWithExtensionSource1)); |
| 6669 v8::RegisterExtension(new Extension("withtest2", kWithExtensionSource2)); | 6684 v8::RegisterExtension(new Extension("withtest2", kWithExtensionSource2)); |
| 6670 const char* extension_names[] = { "withtest1", "withtest2" }; | 6685 const char* extension_names[] = { "withtest1", "withtest2" }; |
| 6671 v8::ExtensionConfiguration extensions(2, extension_names); | 6686 v8::ExtensionConfiguration extensions(2, extension_names); |
| 6672 v8::Handle<Context> context = | 6687 v8::Handle<Context> context = |
| 6673 Context::New(CcTest::isolate(), &extensions); | 6688 Context::New(CcTest::isolate(), &extensions); |
| 6674 Context::Scope lock(context); | 6689 Context::Scope lock(context); |
| 6675 v8::Handle<Value> result = Script::Compile(v8_str("UseWith1()"))->Run(); | 6690 v8::Handle<Value> result = Script::Compile(v8_str("UseWith1()"))->Run(); |
| 6676 CHECK_EQ(result, v8::Integer::New(87)); | 6691 CHECK_EQ(result, v8::Integer::New(CcTest::isolate(), 87)); |
| 6677 result = Script::Compile(v8_str("UseWith2()"))->Run(); | 6692 result = Script::Compile(v8_str("UseWith2()"))->Run(); |
| 6678 CHECK_EQ(result, v8::Integer::New(87)); | 6693 CHECK_EQ(result, v8::Integer::New(CcTest::isolate(), 87)); |
| 6679 } | 6694 } |
| 6680 | 6695 |
| 6681 | 6696 |
| 6682 THREADED_TEST(AutoExtensions) { | 6697 THREADED_TEST(AutoExtensions) { |
| 6683 v8::HandleScope handle_scope(CcTest::isolate()); | 6698 v8::HandleScope handle_scope(CcTest::isolate()); |
| 6684 Extension* extension = new Extension("autotest", kSimpleExtensionSource); | 6699 Extension* extension = new Extension("autotest", kSimpleExtensionSource); |
| 6685 extension->set_auto_enable(true); | 6700 extension->set_auto_enable(true); |
| 6686 v8::RegisterExtension(extension); | 6701 v8::RegisterExtension(extension); |
| 6687 v8::Handle<Context> context = | 6702 v8::Handle<Context> context = |
| 6688 Context::New(CcTest::isolate()); | 6703 Context::New(CcTest::isolate()); |
| 6689 Context::Scope lock(context); | 6704 Context::Scope lock(context); |
| 6690 v8::Handle<Value> result = Script::Compile(v8_str("Foo()"))->Run(); | 6705 v8::Handle<Value> result = Script::Compile(v8_str("Foo()"))->Run(); |
| 6691 CHECK_EQ(result, v8::Integer::New(4)); | 6706 CHECK_EQ(result, v8::Integer::New(CcTest::isolate(), 4)); |
| 6692 } | 6707 } |
| 6693 | 6708 |
| 6694 | 6709 |
| 6695 static const char* kSyntaxErrorInExtensionSource = | 6710 static const char* kSyntaxErrorInExtensionSource = |
| 6696 "["; | 6711 "["; |
| 6697 | 6712 |
| 6698 | 6713 |
| 6699 // Test that a syntax error in an extension does not cause a fatal | 6714 // Test that a syntax error in an extension does not cause a fatal |
| 6700 // error but results in an empty context. | 6715 // error but results in an empty context. |
| 6701 THREADED_TEST(SyntaxErrorExtensions) { | 6716 THREADED_TEST(SyntaxErrorExtensions) { |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6741 THREADED_TEST(NativeCallInExtensions) { | 6756 THREADED_TEST(NativeCallInExtensions) { |
| 6742 v8::HandleScope handle_scope(CcTest::isolate()); | 6757 v8::HandleScope handle_scope(CcTest::isolate()); |
| 6743 v8::RegisterExtension(new Extension("nativecall", | 6758 v8::RegisterExtension(new Extension("nativecall", |
| 6744 kNativeCallInExtensionSource)); | 6759 kNativeCallInExtensionSource)); |
| 6745 const char* extension_names[] = { "nativecall" }; | 6760 const char* extension_names[] = { "nativecall" }; |
| 6746 v8::ExtensionConfiguration extensions(1, extension_names); | 6761 v8::ExtensionConfiguration extensions(1, extension_names); |
| 6747 v8::Handle<Context> context = | 6762 v8::Handle<Context> context = |
| 6748 Context::New(CcTest::isolate(), &extensions); | 6763 Context::New(CcTest::isolate(), &extensions); |
| 6749 Context::Scope lock(context); | 6764 Context::Scope lock(context); |
| 6750 v8::Handle<Value> result = Script::Compile(v8_str(kNativeCallTest))->Run(); | 6765 v8::Handle<Value> result = Script::Compile(v8_str(kNativeCallTest))->Run(); |
| 6751 CHECK_EQ(result, v8::Integer::New(3)); | 6766 CHECK_EQ(result, v8::Integer::New(CcTest::isolate(), 3)); |
| 6752 } | 6767 } |
| 6753 | 6768 |
| 6754 | 6769 |
| 6755 class NativeFunctionExtension : public Extension { | 6770 class NativeFunctionExtension : public Extension { |
| 6756 public: | 6771 public: |
| 6757 NativeFunctionExtension(const char* name, | 6772 NativeFunctionExtension(const char* name, |
| 6758 const char* source, | 6773 const char* source, |
| 6759 v8::FunctionCallback fun = &Echo) | 6774 v8::FunctionCallback fun = &Echo) |
| 6760 : Extension(name, source), | 6775 : Extension(name, source), |
| 6761 function_(fun) { } | 6776 function_(fun) { } |
| (...skipping 16 matching lines...) Expand all Loading... |
| 6778 v8::HandleScope handle_scope(CcTest::isolate()); | 6793 v8::HandleScope handle_scope(CcTest::isolate()); |
| 6779 const char* name = "nativedecl"; | 6794 const char* name = "nativedecl"; |
| 6780 v8::RegisterExtension(new NativeFunctionExtension(name, | 6795 v8::RegisterExtension(new NativeFunctionExtension(name, |
| 6781 "native function foo();")); | 6796 "native function foo();")); |
| 6782 const char* extension_names[] = { name }; | 6797 const char* extension_names[] = { name }; |
| 6783 v8::ExtensionConfiguration extensions(1, extension_names); | 6798 v8::ExtensionConfiguration extensions(1, extension_names); |
| 6784 v8::Handle<Context> context = | 6799 v8::Handle<Context> context = |
| 6785 Context::New(CcTest::isolate(), &extensions); | 6800 Context::New(CcTest::isolate(), &extensions); |
| 6786 Context::Scope lock(context); | 6801 Context::Scope lock(context); |
| 6787 v8::Handle<Value> result = Script::Compile(v8_str("foo(42);"))->Run(); | 6802 v8::Handle<Value> result = Script::Compile(v8_str("foo(42);"))->Run(); |
| 6788 CHECK_EQ(result, v8::Integer::New(42)); | 6803 CHECK_EQ(result, v8::Integer::New(CcTest::isolate(), 42)); |
| 6789 } | 6804 } |
| 6790 | 6805 |
| 6791 | 6806 |
| 6792 THREADED_TEST(NativeFunctionDeclarationError) { | 6807 THREADED_TEST(NativeFunctionDeclarationError) { |
| 6793 v8::HandleScope handle_scope(CcTest::isolate()); | 6808 v8::HandleScope handle_scope(CcTest::isolate()); |
| 6794 const char* name = "nativedeclerr"; | 6809 const char* name = "nativedeclerr"; |
| 6795 // Syntax error in extension code. | 6810 // Syntax error in extension code. |
| 6796 v8::RegisterExtension(new NativeFunctionExtension(name, | 6811 v8::RegisterExtension(new NativeFunctionExtension(name, |
| 6797 "native\nfunction foo();")); | 6812 "native\nfunction foo();")); |
| 6798 const char* extension_names[] = { name }; | 6813 const char* extension_names[] = { name }; |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6886 v8::Isolate* isolate, | 6901 v8::Isolate* isolate, |
| 6887 v8::Handle<String> name); | 6902 v8::Handle<String> name); |
| 6888 }; | 6903 }; |
| 6889 | 6904 |
| 6890 | 6905 |
| 6891 static int lookup_count = 0; | 6906 static int lookup_count = 0; |
| 6892 v8::Handle<v8::FunctionTemplate> FunctionExtension::GetNativeFunctionTemplate( | 6907 v8::Handle<v8::FunctionTemplate> FunctionExtension::GetNativeFunctionTemplate( |
| 6893 v8::Isolate* isolate, v8::Handle<String> name) { | 6908 v8::Isolate* isolate, v8::Handle<String> name) { |
| 6894 lookup_count++; | 6909 lookup_count++; |
| 6895 if (name->Equals(v8_str("A"))) { | 6910 if (name->Equals(v8_str("A"))) { |
| 6896 return v8::FunctionTemplate::New(isolate, CallFun, v8::Integer::New(8)); | 6911 return v8::FunctionTemplate::New( |
| 6912 isolate, CallFun, v8::Integer::New(isolate, 8)); |
| 6897 } else if (name->Equals(v8_str("B"))) { | 6913 } else if (name->Equals(v8_str("B"))) { |
| 6898 return v8::FunctionTemplate::New(isolate, CallFun, v8::Integer::New(7)); | 6914 return v8::FunctionTemplate::New( |
| 6915 isolate, CallFun, v8::Integer::New(isolate, 7)); |
| 6899 } else if (name->Equals(v8_str("C"))) { | 6916 } else if (name->Equals(v8_str("C"))) { |
| 6900 return v8::FunctionTemplate::New(isolate, CallFun, v8::Integer::New(6)); | 6917 return v8::FunctionTemplate::New( |
| 6918 isolate, CallFun, v8::Integer::New(isolate, 6)); |
| 6901 } else { | 6919 } else { |
| 6902 return v8::Handle<v8::FunctionTemplate>(); | 6920 return v8::Handle<v8::FunctionTemplate>(); |
| 6903 } | 6921 } |
| 6904 } | 6922 } |
| 6905 | 6923 |
| 6906 | 6924 |
| 6907 THREADED_TEST(FunctionLookup) { | 6925 THREADED_TEST(FunctionLookup) { |
| 6908 v8::RegisterExtension(new FunctionExtension()); | 6926 v8::RegisterExtension(new FunctionExtension()); |
| 6909 v8::HandleScope handle_scope(CcTest::isolate()); | 6927 v8::HandleScope handle_scope(CcTest::isolate()); |
| 6910 static const char* exts[1] = { "functiontest" }; | 6928 static const char* exts[1] = { "functiontest" }; |
| 6911 v8::ExtensionConfiguration config(1, exts); | 6929 v8::ExtensionConfiguration config(1, exts); |
| 6912 LocalContext context(&config); | 6930 LocalContext context(&config); |
| 6913 CHECK_EQ(3, lookup_count); | 6931 CHECK_EQ(3, lookup_count); |
| 6914 CHECK_EQ(v8::Integer::New(8), Script::Compile(v8_str("Foo(0)"))->Run()); | 6932 CHECK_EQ(v8::Integer::New(CcTest::isolate(), 8), |
| 6915 CHECK_EQ(v8::Integer::New(7), Script::Compile(v8_str("Foo(1)"))->Run()); | 6933 Script::Compile(v8_str("Foo(0)"))->Run()); |
| 6916 CHECK_EQ(v8::Integer::New(6), Script::Compile(v8_str("Foo(2)"))->Run()); | 6934 CHECK_EQ(v8::Integer::New(CcTest::isolate(), 7), |
| 6935 Script::Compile(v8_str("Foo(1)"))->Run()); |
| 6936 CHECK_EQ(v8::Integer::New(CcTest::isolate(), 6), |
| 6937 Script::Compile(v8_str("Foo(2)"))->Run()); |
| 6917 } | 6938 } |
| 6918 | 6939 |
| 6919 | 6940 |
| 6920 THREADED_TEST(NativeFunctionConstructCall) { | 6941 THREADED_TEST(NativeFunctionConstructCall) { |
| 6921 v8::RegisterExtension(new FunctionExtension()); | 6942 v8::RegisterExtension(new FunctionExtension()); |
| 6922 v8::HandleScope handle_scope(CcTest::isolate()); | 6943 v8::HandleScope handle_scope(CcTest::isolate()); |
| 6923 static const char* exts[1] = { "functiontest" }; | 6944 static const char* exts[1] = { "functiontest" }; |
| 6924 v8::ExtensionConfiguration config(1, exts); | 6945 v8::ExtensionConfiguration config(1, exts); |
| 6925 LocalContext context(&config); | 6946 LocalContext context(&config); |
| 6926 for (int i = 0; i < 10; i++) { | 6947 for (int i = 0; i < 10; i++) { |
| 6927 // Run a few times to ensure that allocation of objects doesn't | 6948 // Run a few times to ensure that allocation of objects doesn't |
| 6928 // change behavior of a constructor function. | 6949 // change behavior of a constructor function. |
| 6929 CHECK_EQ(v8::Integer::New(8), | 6950 CHECK_EQ(v8::Integer::New(CcTest::isolate(), 8), |
| 6930 Script::Compile(v8_str("(new A()).data"))->Run()); | 6951 Script::Compile(v8_str("(new A()).data"))->Run()); |
| 6931 CHECK_EQ(v8::Integer::New(7), | 6952 CHECK_EQ(v8::Integer::New(CcTest::isolate(), 7), |
| 6932 Script::Compile(v8_str("(new B()).data"))->Run()); | 6953 Script::Compile(v8_str("(new B()).data"))->Run()); |
| 6933 CHECK_EQ(v8::Integer::New(6), | 6954 CHECK_EQ(v8::Integer::New(CcTest::isolate(), 6), |
| 6934 Script::Compile(v8_str("(new C()).data"))->Run()); | 6955 Script::Compile(v8_str("(new C()).data"))->Run()); |
| 6935 } | 6956 } |
| 6936 } | 6957 } |
| 6937 | 6958 |
| 6938 | 6959 |
| 6939 static const char* last_location; | 6960 static const char* last_location; |
| 6940 static const char* last_message; | 6961 static const char* last_message; |
| 6941 void StoringErrorCallback(const char* location, const char* message) { | 6962 void StoringErrorCallback(const char* location, const char* message) { |
| 6942 if (last_location == NULL) { | 6963 if (last_location == NULL) { |
| 6943 last_location = location; | 6964 last_location = location; |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7044 delete data.GetParameter(); | 7065 delete data.GetParameter(); |
| 7045 } | 7066 } |
| 7046 | 7067 |
| 7047 void WhammyPropertyGetter(Local<String> name, | 7068 void WhammyPropertyGetter(Local<String> name, |
| 7048 const v8::PropertyCallbackInfo<v8::Value>& info) { | 7069 const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 7049 Whammy* whammy = | 7070 Whammy* whammy = |
| 7050 static_cast<Whammy*>(v8::Handle<v8::External>::Cast(info.Data())->Value()); | 7071 static_cast<Whammy*>(v8::Handle<v8::External>::Cast(info.Data())->Value()); |
| 7051 | 7072 |
| 7052 v8::Persistent<v8::Object>& prev = whammy->objects_[whammy->cursor_]; | 7073 v8::Persistent<v8::Object>& prev = whammy->objects_[whammy->cursor_]; |
| 7053 | 7074 |
| 7054 v8::Handle<v8::Object> obj = v8::Object::New(); | 7075 v8::Handle<v8::Object> obj = v8::Object::New(info.GetIsolate()); |
| 7055 if (!prev.IsEmpty()) { | 7076 if (!prev.IsEmpty()) { |
| 7056 v8::Local<v8::Object>::New(info.GetIsolate(), prev) | 7077 v8::Local<v8::Object>::New(info.GetIsolate(), prev) |
| 7057 ->Set(v8_str("next"), obj); | 7078 ->Set(v8_str("next"), obj); |
| 7058 prev.SetWeak<Value, Snorkel<Value> >(new Snorkel<Value>(&prev.As<Value>()), | 7079 prev.SetWeak<Value, Snorkel<Value> >(new Snorkel<Value>(&prev.As<Value>()), |
| 7059 &HandleWeakReference); | 7080 &HandleWeakReference); |
| 7060 } | 7081 } |
| 7061 whammy->objects_[whammy->cursor_].Reset(info.GetIsolate(), obj); | 7082 whammy->objects_[whammy->cursor_].Reset(info.GetIsolate(), obj); |
| 7062 whammy->cursor_ = (whammy->cursor_ + 1) % Whammy::kObjectCount; | 7083 whammy->cursor_ = (whammy->cursor_ + 1) % Whammy::kObjectCount; |
| 7063 info.GetReturnValue().Set(whammy->getScript()->Run()); | 7084 info.GetReturnValue().Set(whammy->getScript()->Run()); |
| 7064 } | 7085 } |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7110 THREADED_TEST(IndependentWeakHandle) { | 7131 THREADED_TEST(IndependentWeakHandle) { |
| 7111 v8::Isolate* iso = CcTest::isolate(); | 7132 v8::Isolate* iso = CcTest::isolate(); |
| 7112 v8::HandleScope scope(iso); | 7133 v8::HandleScope scope(iso); |
| 7113 v8::Handle<Context> context = Context::New(iso); | 7134 v8::Handle<Context> context = Context::New(iso); |
| 7114 Context::Scope context_scope(context); | 7135 Context::Scope context_scope(context); |
| 7115 | 7136 |
| 7116 FlagAndPersistent object_a, object_b; | 7137 FlagAndPersistent object_a, object_b; |
| 7117 | 7138 |
| 7118 { | 7139 { |
| 7119 v8::HandleScope handle_scope(iso); | 7140 v8::HandleScope handle_scope(iso); |
| 7120 object_a.handle.Reset(iso, v8::Object::New()); | 7141 object_a.handle.Reset(iso, v8::Object::New(iso)); |
| 7121 object_b.handle.Reset(iso, v8::Object::New()); | 7142 object_b.handle.Reset(iso, v8::Object::New(iso)); |
| 7122 } | 7143 } |
| 7123 | 7144 |
| 7124 object_a.flag = false; | 7145 object_a.flag = false; |
| 7125 object_b.flag = false; | 7146 object_b.flag = false; |
| 7126 object_a.handle.SetWeak(&object_a, &DisposeAndSetFlag); | 7147 object_a.handle.SetWeak(&object_a, &DisposeAndSetFlag); |
| 7127 object_b.handle.SetWeak(&object_b, &DisposeAndSetFlag); | 7148 object_b.handle.SetWeak(&object_b, &DisposeAndSetFlag); |
| 7128 CHECK(!object_b.handle.IsIndependent()); | 7149 CHECK(!object_b.handle.IsIndependent()); |
| 7129 object_a.handle.MarkIndependent(); | 7150 object_a.handle.MarkIndependent(); |
| 7130 object_b.handle.MarkIndependent(); | 7151 object_b.handle.MarkIndependent(); |
| 7131 CHECK(object_b.handle.IsIndependent()); | 7152 CHECK(object_b.handle.IsIndependent()); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7174 {&ForceScavenge, &ForceMarkSweep}; | 7195 {&ForceScavenge, &ForceMarkSweep}; |
| 7175 | 7196 |
| 7176 typedef void (*GCInvoker)(); | 7197 typedef void (*GCInvoker)(); |
| 7177 GCInvoker invoke_gc[kNumberOfGCTypes] = {&InvokeScavenge, &InvokeMarkSweep}; | 7198 GCInvoker invoke_gc[kNumberOfGCTypes] = {&InvokeScavenge, &InvokeMarkSweep}; |
| 7178 | 7199 |
| 7179 for (int outer_gc = 0; outer_gc < kNumberOfGCTypes; outer_gc++) { | 7200 for (int outer_gc = 0; outer_gc < kNumberOfGCTypes; outer_gc++) { |
| 7180 for (int inner_gc = 0; inner_gc < kNumberOfGCTypes; inner_gc++) { | 7201 for (int inner_gc = 0; inner_gc < kNumberOfGCTypes; inner_gc++) { |
| 7181 FlagAndPersistent object; | 7202 FlagAndPersistent object; |
| 7182 { | 7203 { |
| 7183 v8::HandleScope handle_scope(isolate); | 7204 v8::HandleScope handle_scope(isolate); |
| 7184 object.handle.Reset(isolate, v8::Object::New()); | 7205 object.handle.Reset(isolate, v8::Object::New(isolate)); |
| 7185 } | 7206 } |
| 7186 object.flag = false; | 7207 object.flag = false; |
| 7187 object.handle.SetWeak(&object, gc_forcing_callback[inner_gc]); | 7208 object.handle.SetWeak(&object, gc_forcing_callback[inner_gc]); |
| 7188 object.handle.MarkIndependent(); | 7209 object.handle.MarkIndependent(); |
| 7189 invoke_gc[outer_gc](); | 7210 invoke_gc[outer_gc](); |
| 7190 CHECK(object.flag); | 7211 CHECK(object.flag); |
| 7191 } | 7212 } |
| 7192 } | 7213 } |
| 7193 } | 7214 } |
| 7194 | 7215 |
| 7195 | 7216 |
| 7196 static void RevivingCallback( | 7217 static void RevivingCallback( |
| 7197 const v8::WeakCallbackData<v8::Object, FlagAndPersistent>& data) { | 7218 const v8::WeakCallbackData<v8::Object, FlagAndPersistent>& data) { |
| 7198 data.GetParameter()->handle.ClearWeak(); | 7219 data.GetParameter()->handle.ClearWeak(); |
| 7199 data.GetParameter()->flag = true; | 7220 data.GetParameter()->flag = true; |
| 7200 } | 7221 } |
| 7201 | 7222 |
| 7202 | 7223 |
| 7203 THREADED_TEST(IndependentHandleRevival) { | 7224 THREADED_TEST(IndependentHandleRevival) { |
| 7204 v8::Isolate* isolate = CcTest::isolate(); | 7225 v8::Isolate* isolate = CcTest::isolate(); |
| 7205 v8::HandleScope scope(isolate); | 7226 v8::HandleScope scope(isolate); |
| 7206 v8::Handle<Context> context = Context::New(isolate); | 7227 v8::Handle<Context> context = Context::New(isolate); |
| 7207 Context::Scope context_scope(context); | 7228 Context::Scope context_scope(context); |
| 7208 | 7229 |
| 7209 FlagAndPersistent object; | 7230 FlagAndPersistent object; |
| 7210 { | 7231 { |
| 7211 v8::HandleScope handle_scope(isolate); | 7232 v8::HandleScope handle_scope(isolate); |
| 7212 v8::Local<v8::Object> o = v8::Object::New(); | 7233 v8::Local<v8::Object> o = v8::Object::New(isolate); |
| 7213 object.handle.Reset(isolate, o); | 7234 object.handle.Reset(isolate, o); |
| 7214 o->Set(v8_str("x"), v8::Integer::New(1)); | 7235 o->Set(v8_str("x"), v8::Integer::New(isolate, 1)); |
| 7215 v8::Local<String> y_str = v8_str("y"); | 7236 v8::Local<String> y_str = v8_str("y"); |
| 7216 o->Set(y_str, y_str); | 7237 o->Set(y_str, y_str); |
| 7217 } | 7238 } |
| 7218 object.flag = false; | 7239 object.flag = false; |
| 7219 object.handle.SetWeak(&object, &RevivingCallback); | 7240 object.handle.SetWeak(&object, &RevivingCallback); |
| 7220 object.handle.MarkIndependent(); | 7241 object.handle.MarkIndependent(); |
| 7221 CcTest::heap()->PerformScavenge(); | 7242 CcTest::heap()->PerformScavenge(); |
| 7222 CHECK(object.flag); | 7243 CHECK(object.flag); |
| 7223 CcTest::heap()->CollectAllGarbage(i::Heap::kAbortIncrementalMarkingMask); | 7244 CcTest::heap()->CollectAllGarbage(i::Heap::kAbortIncrementalMarkingMask); |
| 7224 { | 7245 { |
| 7225 v8::HandleScope handle_scope(isolate); | 7246 v8::HandleScope handle_scope(isolate); |
| 7226 v8::Local<v8::Object> o = | 7247 v8::Local<v8::Object> o = |
| 7227 v8::Local<v8::Object>::New(isolate, object.handle); | 7248 v8::Local<v8::Object>::New(isolate, object.handle); |
| 7228 v8::Local<String> y_str = v8_str("y"); | 7249 v8::Local<String> y_str = v8_str("y"); |
| 7229 CHECK_EQ(v8::Integer::New(1), o->Get(v8_str("x"))); | 7250 CHECK_EQ(v8::Integer::New(isolate, 1), o->Get(v8_str("x"))); |
| 7230 CHECK(o->Get(y_str)->Equals(y_str)); | 7251 CHECK(o->Get(y_str)->Equals(y_str)); |
| 7231 } | 7252 } |
| 7232 } | 7253 } |
| 7233 | 7254 |
| 7234 | 7255 |
| 7235 v8::Handle<Function> args_fun; | 7256 v8::Handle<Function> args_fun; |
| 7236 | 7257 |
| 7237 | 7258 |
| 7238 static void ArgumentsTestCallback( | 7259 static void ArgumentsTestCallback( |
| 7239 const v8::FunctionCallbackInfo<v8::Value>& args) { | 7260 const v8::FunctionCallbackInfo<v8::Value>& args) { |
| 7240 ApiTestFuzzer::Fuzz(); | 7261 ApiTestFuzzer::Fuzz(); |
| 7241 v8::Isolate* isolate = args.GetIsolate(); | 7262 v8::Isolate* isolate = args.GetIsolate(); |
| 7242 CHECK_EQ(args_fun, args.Callee()); | 7263 CHECK_EQ(args_fun, args.Callee()); |
| 7243 CHECK_EQ(3, args.Length()); | 7264 CHECK_EQ(3, args.Length()); |
| 7244 CHECK_EQ(v8::Integer::New(1, isolate), args[0]); | 7265 CHECK_EQ(v8::Integer::New(isolate, 1), args[0]); |
| 7245 CHECK_EQ(v8::Integer::New(2, isolate), args[1]); | 7266 CHECK_EQ(v8::Integer::New(isolate, 2), args[1]); |
| 7246 CHECK_EQ(v8::Integer::New(3, isolate), args[2]); | 7267 CHECK_EQ(v8::Integer::New(isolate, 3), args[2]); |
| 7247 CHECK_EQ(v8::Undefined(isolate), args[3]); | 7268 CHECK_EQ(v8::Undefined(isolate), args[3]); |
| 7248 v8::HandleScope scope(args.GetIsolate()); | 7269 v8::HandleScope scope(args.GetIsolate()); |
| 7249 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); | 7270 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); |
| 7250 } | 7271 } |
| 7251 | 7272 |
| 7252 | 7273 |
| 7253 THREADED_TEST(Arguments) { | 7274 THREADED_TEST(Arguments) { |
| 7254 v8::Isolate* isolate = CcTest::isolate(); | 7275 v8::Isolate* isolate = CcTest::isolate(); |
| 7255 v8::HandleScope scope(isolate); | 7276 v8::HandleScope scope(isolate); |
| 7256 v8::Handle<v8::ObjectTemplate> global = ObjectTemplate::New(); | 7277 v8::Handle<v8::ObjectTemplate> global = ObjectTemplate::New(); |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7332 static void IndexedGetK(uint32_t index, | 7353 static void IndexedGetK(uint32_t index, |
| 7333 const v8::PropertyCallbackInfo<v8::Value>& info) { | 7354 const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 7334 ApiTestFuzzer::Fuzz(); | 7355 ApiTestFuzzer::Fuzz(); |
| 7335 if (index == 0 || index == 1) info.GetReturnValue().SetUndefined(); | 7356 if (index == 0 || index == 1) info.GetReturnValue().SetUndefined(); |
| 7336 } | 7357 } |
| 7337 | 7358 |
| 7338 | 7359 |
| 7339 static void NamedEnum(const v8::PropertyCallbackInfo<v8::Array>& info) { | 7360 static void NamedEnum(const v8::PropertyCallbackInfo<v8::Array>& info) { |
| 7340 ApiTestFuzzer::Fuzz(); | 7361 ApiTestFuzzer::Fuzz(); |
| 7341 v8::Handle<v8::Array> result = v8::Array::New(info.GetIsolate(), 3); | 7362 v8::Handle<v8::Array> result = v8::Array::New(info.GetIsolate(), 3); |
| 7342 result->Set(v8::Integer::New(0), v8_str("foo")); | 7363 result->Set(v8::Integer::New(info.GetIsolate(), 0), v8_str("foo")); |
| 7343 result->Set(v8::Integer::New(1), v8_str("bar")); | 7364 result->Set(v8::Integer::New(info.GetIsolate(), 1), v8_str("bar")); |
| 7344 result->Set(v8::Integer::New(2), v8_str("baz")); | 7365 result->Set(v8::Integer::New(info.GetIsolate(), 2), v8_str("baz")); |
| 7345 info.GetReturnValue().Set(result); | 7366 info.GetReturnValue().Set(result); |
| 7346 } | 7367 } |
| 7347 | 7368 |
| 7348 | 7369 |
| 7349 static void IndexedEnum(const v8::PropertyCallbackInfo<v8::Array>& info) { | 7370 static void IndexedEnum(const v8::PropertyCallbackInfo<v8::Array>& info) { |
| 7350 ApiTestFuzzer::Fuzz(); | 7371 ApiTestFuzzer::Fuzz(); |
| 7351 v8::Handle<v8::Array> result = v8::Array::New(info.GetIsolate(), 2); | 7372 v8::Handle<v8::Array> result = v8::Array::New(info.GetIsolate(), 2); |
| 7352 result->Set(v8::Integer::New(0), v8_str("0")); | 7373 result->Set(v8::Integer::New(info.GetIsolate(), 0), v8_str("0")); |
| 7353 result->Set(v8::Integer::New(1), v8_str("1")); | 7374 result->Set(v8::Integer::New(info.GetIsolate(), 1), v8_str("1")); |
| 7354 info.GetReturnValue().Set(result); | 7375 info.GetReturnValue().Set(result); |
| 7355 } | 7376 } |
| 7356 | 7377 |
| 7357 | 7378 |
| 7358 THREADED_TEST(Enumerators) { | 7379 THREADED_TEST(Enumerators) { |
| 7359 v8::HandleScope scope(CcTest::isolate()); | 7380 v8::Isolate* isolate = CcTest::isolate(); |
| 7381 v8::HandleScope scope(isolate); |
| 7360 v8::Handle<v8::ObjectTemplate> obj = ObjectTemplate::New(); | 7382 v8::Handle<v8::ObjectTemplate> obj = ObjectTemplate::New(); |
| 7361 obj->SetNamedPropertyHandler(GetK, NULL, NULL, NULL, NamedEnum); | 7383 obj->SetNamedPropertyHandler(GetK, NULL, NULL, NULL, NamedEnum); |
| 7362 obj->SetIndexedPropertyHandler(IndexedGetK, NULL, NULL, NULL, IndexedEnum); | 7384 obj->SetIndexedPropertyHandler(IndexedGetK, NULL, NULL, NULL, IndexedEnum); |
| 7363 LocalContext context; | 7385 LocalContext context; |
| 7364 context->Global()->Set(v8_str("k"), obj->NewInstance()); | 7386 context->Global()->Set(v8_str("k"), obj->NewInstance()); |
| 7365 v8::Handle<v8::Array> result = v8::Handle<v8::Array>::Cast(CompileRun( | 7387 v8::Handle<v8::Array> result = v8::Handle<v8::Array>::Cast(CompileRun( |
| 7366 "k[10] = 0;" | 7388 "k[10] = 0;" |
| 7367 "k.a = 0;" | 7389 "k.a = 0;" |
| 7368 "k[5] = 0;" | 7390 "k[5] = 0;" |
| 7369 "k.b = 0;" | 7391 "k.b = 0;" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 7381 "}" | 7403 "}" |
| 7382 "result")); | 7404 "result")); |
| 7383 // Check that we get all the property names returned including the | 7405 // Check that we get all the property names returned including the |
| 7384 // ones from the enumerators in the right order: indexed properties | 7406 // ones from the enumerators in the right order: indexed properties |
| 7385 // in numerical order, indexed interceptor properties, named | 7407 // in numerical order, indexed interceptor properties, named |
| 7386 // properties in insertion order, named interceptor properties. | 7408 // properties in insertion order, named interceptor properties. |
| 7387 // This order is not mandated by the spec, so this test is just | 7409 // This order is not mandated by the spec, so this test is just |
| 7388 // documenting our behavior. | 7410 // documenting our behavior. |
| 7389 CHECK_EQ(17, result->Length()); | 7411 CHECK_EQ(17, result->Length()); |
| 7390 // Indexed properties in numerical order. | 7412 // Indexed properties in numerical order. |
| 7391 CHECK_EQ(v8_str("5"), result->Get(v8::Integer::New(0))); | 7413 CHECK_EQ(v8_str("5"), result->Get(v8::Integer::New(isolate, 0))); |
| 7392 CHECK_EQ(v8_str("10"), result->Get(v8::Integer::New(1))); | 7414 CHECK_EQ(v8_str("10"), result->Get(v8::Integer::New(isolate, 1))); |
| 7393 CHECK_EQ(v8_str("140000"), result->Get(v8::Integer::New(2))); | 7415 CHECK_EQ(v8_str("140000"), result->Get(v8::Integer::New(isolate, 2))); |
| 7394 CHECK_EQ(v8_str("4294967295"), result->Get(v8::Integer::New(3))); | 7416 CHECK_EQ(v8_str("4294967295"), result->Get(v8::Integer::New(isolate, 3))); |
| 7395 // Indexed interceptor properties in the order they are returned | 7417 // Indexed interceptor properties in the order they are returned |
| 7396 // from the enumerator interceptor. | 7418 // from the enumerator interceptor. |
| 7397 CHECK_EQ(v8_str("0"), result->Get(v8::Integer::New(4))); | 7419 CHECK_EQ(v8_str("0"), result->Get(v8::Integer::New(isolate, 4))); |
| 7398 CHECK_EQ(v8_str("1"), result->Get(v8::Integer::New(5))); | 7420 CHECK_EQ(v8_str("1"), result->Get(v8::Integer::New(isolate, 5))); |
| 7399 // Named properties in insertion order. | 7421 // Named properties in insertion order. |
| 7400 CHECK_EQ(v8_str("a"), result->Get(v8::Integer::New(6))); | 7422 CHECK_EQ(v8_str("a"), result->Get(v8::Integer::New(isolate, 6))); |
| 7401 CHECK_EQ(v8_str("b"), result->Get(v8::Integer::New(7))); | 7423 CHECK_EQ(v8_str("b"), result->Get(v8::Integer::New(isolate, 7))); |
| 7402 CHECK_EQ(v8_str("c"), result->Get(v8::Integer::New(8))); | 7424 CHECK_EQ(v8_str("c"), result->Get(v8::Integer::New(isolate, 8))); |
| 7403 CHECK_EQ(v8_str("4294967296"), result->Get(v8::Integer::New(9))); | 7425 CHECK_EQ(v8_str("4294967296"), result->Get(v8::Integer::New(isolate, 9))); |
| 7404 CHECK_EQ(v8_str("d"), result->Get(v8::Integer::New(10))); | 7426 CHECK_EQ(v8_str("d"), result->Get(v8::Integer::New(isolate, 10))); |
| 7405 CHECK_EQ(v8_str("e"), result->Get(v8::Integer::New(11))); | 7427 CHECK_EQ(v8_str("e"), result->Get(v8::Integer::New(isolate, 11))); |
| 7406 CHECK_EQ(v8_str("30000000000"), result->Get(v8::Integer::New(12))); | 7428 CHECK_EQ(v8_str("30000000000"), result->Get(v8::Integer::New(isolate, 12))); |
| 7407 CHECK_EQ(v8_str("f"), result->Get(v8::Integer::New(13))); | 7429 CHECK_EQ(v8_str("f"), result->Get(v8::Integer::New(isolate, 13))); |
| 7408 // Named interceptor properties. | 7430 // Named interceptor properties. |
| 7409 CHECK_EQ(v8_str("foo"), result->Get(v8::Integer::New(14))); | 7431 CHECK_EQ(v8_str("foo"), result->Get(v8::Integer::New(isolate, 14))); |
| 7410 CHECK_EQ(v8_str("bar"), result->Get(v8::Integer::New(15))); | 7432 CHECK_EQ(v8_str("bar"), result->Get(v8::Integer::New(isolate, 15))); |
| 7411 CHECK_EQ(v8_str("baz"), result->Get(v8::Integer::New(16))); | 7433 CHECK_EQ(v8_str("baz"), result->Get(v8::Integer::New(isolate, 16))); |
| 7412 } | 7434 } |
| 7413 | 7435 |
| 7414 | 7436 |
| 7415 int p_getter_count; | 7437 int p_getter_count; |
| 7416 int p_getter_count2; | 7438 int p_getter_count2; |
| 7417 | 7439 |
| 7418 | 7440 |
| 7419 static void PGetter(Local<String> name, | 7441 static void PGetter(Local<String> name, |
| 7420 const v8::PropertyCallbackInfo<v8::Value>& info) { | 7442 const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 7421 ApiTestFuzzer::Fuzz(); | 7443 ApiTestFuzzer::Fuzz(); |
| (...skipping 598 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8020 CHECK(SameSymbol(sym0b, Handle<String>::Cast(s0b))); | 8042 CHECK(SameSymbol(sym0b, Handle<String>::Cast(s0b))); |
| 8021 CHECK(SameSymbol(sym1, Handle<String>::Cast(s1))); | 8043 CHECK(SameSymbol(sym1, Handle<String>::Cast(s1))); |
| 8022 CHECK(SameSymbol(sym2, Handle<String>::Cast(s2))); | 8044 CHECK(SameSymbol(sym2, Handle<String>::Cast(s2))); |
| 8023 CHECK(SameSymbol(sym3, Handle<String>::Cast(s3))); | 8045 CHECK(SameSymbol(sym3, Handle<String>::Cast(s3))); |
| 8024 CHECK(SameSymbol(sym4, Handle<String>::Cast(s4))); | 8046 CHECK(SameSymbol(sym4, Handle<String>::Cast(s4))); |
| 8025 } | 8047 } |
| 8026 | 8048 |
| 8027 | 8049 |
| 8028 THREADED_TEST(ToArrayIndex) { | 8050 THREADED_TEST(ToArrayIndex) { |
| 8029 LocalContext context; | 8051 LocalContext context; |
| 8030 v8::HandleScope scope(context->GetIsolate()); | 8052 v8::Isolate* isolate = context->GetIsolate(); |
| 8053 v8::HandleScope scope(isolate); |
| 8031 | 8054 |
| 8032 v8::Handle<String> str = v8_str("42"); | 8055 v8::Handle<String> str = v8_str("42"); |
| 8033 v8::Handle<v8::Uint32> index = str->ToArrayIndex(); | 8056 v8::Handle<v8::Uint32> index = str->ToArrayIndex(); |
| 8034 CHECK(!index.IsEmpty()); | 8057 CHECK(!index.IsEmpty()); |
| 8035 CHECK_EQ(42.0, index->Uint32Value()); | 8058 CHECK_EQ(42.0, index->Uint32Value()); |
| 8036 str = v8_str("42asdf"); | 8059 str = v8_str("42asdf"); |
| 8037 index = str->ToArrayIndex(); | 8060 index = str->ToArrayIndex(); |
| 8038 CHECK(index.IsEmpty()); | 8061 CHECK(index.IsEmpty()); |
| 8039 str = v8_str("-42"); | 8062 str = v8_str("-42"); |
| 8040 index = str->ToArrayIndex(); | 8063 index = str->ToArrayIndex(); |
| 8041 CHECK(index.IsEmpty()); | 8064 CHECK(index.IsEmpty()); |
| 8042 str = v8_str("4294967295"); | 8065 str = v8_str("4294967295"); |
| 8043 index = str->ToArrayIndex(); | 8066 index = str->ToArrayIndex(); |
| 8044 CHECK(!index.IsEmpty()); | 8067 CHECK(!index.IsEmpty()); |
| 8045 CHECK_EQ(4294967295.0, index->Uint32Value()); | 8068 CHECK_EQ(4294967295.0, index->Uint32Value()); |
| 8046 v8::Handle<v8::Number> num = v8::Number::New(1); | 8069 v8::Handle<v8::Number> num = v8::Number::New(isolate, 1); |
| 8047 index = num->ToArrayIndex(); | 8070 index = num->ToArrayIndex(); |
| 8048 CHECK(!index.IsEmpty()); | 8071 CHECK(!index.IsEmpty()); |
| 8049 CHECK_EQ(1.0, index->Uint32Value()); | 8072 CHECK_EQ(1.0, index->Uint32Value()); |
| 8050 num = v8::Number::New(-1); | 8073 num = v8::Number::New(isolate, -1); |
| 8051 index = num->ToArrayIndex(); | 8074 index = num->ToArrayIndex(); |
| 8052 CHECK(index.IsEmpty()); | 8075 CHECK(index.IsEmpty()); |
| 8053 v8::Handle<v8::Object> obj = v8::Object::New(); | 8076 v8::Handle<v8::Object> obj = v8::Object::New(isolate); |
| 8054 index = obj->ToArrayIndex(); | 8077 index = obj->ToArrayIndex(); |
| 8055 CHECK(index.IsEmpty()); | 8078 CHECK(index.IsEmpty()); |
| 8056 } | 8079 } |
| 8057 | 8080 |
| 8058 | 8081 |
| 8059 THREADED_TEST(ErrorConstruction) { | 8082 THREADED_TEST(ErrorConstruction) { |
| 8060 LocalContext context; | 8083 LocalContext context; |
| 8061 v8::HandleScope scope(context->GetIsolate()); | 8084 v8::HandleScope scope(context->GetIsolate()); |
| 8062 | 8085 |
| 8063 v8::Handle<String> foo = v8_str("foo"); | 8086 v8::Handle<String> foo = v8_str("foo"); |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8112 | 8135 |
| 8113 THREADED_TEST(TypeSwitch) { | 8136 THREADED_TEST(TypeSwitch) { |
| 8114 v8::Isolate* isolate = CcTest::isolate(); | 8137 v8::Isolate* isolate = CcTest::isolate(); |
| 8115 v8::HandleScope scope(isolate); | 8138 v8::HandleScope scope(isolate); |
| 8116 v8::Handle<v8::FunctionTemplate> templ1 = v8::FunctionTemplate::New(isolate); | 8139 v8::Handle<v8::FunctionTemplate> templ1 = v8::FunctionTemplate::New(isolate); |
| 8117 v8::Handle<v8::FunctionTemplate> templ2 = v8::FunctionTemplate::New(isolate); | 8140 v8::Handle<v8::FunctionTemplate> templ2 = v8::FunctionTemplate::New(isolate); |
| 8118 v8::Handle<v8::FunctionTemplate> templ3 = v8::FunctionTemplate::New(isolate); | 8141 v8::Handle<v8::FunctionTemplate> templ3 = v8::FunctionTemplate::New(isolate); |
| 8119 v8::Handle<v8::FunctionTemplate> templs[3] = { templ1, templ2, templ3 }; | 8142 v8::Handle<v8::FunctionTemplate> templs[3] = { templ1, templ2, templ3 }; |
| 8120 v8::Handle<v8::TypeSwitch> type_switch = v8::TypeSwitch::New(3, templs); | 8143 v8::Handle<v8::TypeSwitch> type_switch = v8::TypeSwitch::New(3, templs); |
| 8121 LocalContext context; | 8144 LocalContext context; |
| 8122 v8::Handle<v8::Object> obj0 = v8::Object::New(); | 8145 v8::Handle<v8::Object> obj0 = v8::Object::New(isolate); |
| 8123 v8::Handle<v8::Object> obj1 = templ1->GetFunction()->NewInstance(); | 8146 v8::Handle<v8::Object> obj1 = templ1->GetFunction()->NewInstance(); |
| 8124 v8::Handle<v8::Object> obj2 = templ2->GetFunction()->NewInstance(); | 8147 v8::Handle<v8::Object> obj2 = templ2->GetFunction()->NewInstance(); |
| 8125 v8::Handle<v8::Object> obj3 = templ3->GetFunction()->NewInstance(); | 8148 v8::Handle<v8::Object> obj3 = templ3->GetFunction()->NewInstance(); |
| 8126 for (int i = 0; i < 10; i++) { | 8149 for (int i = 0; i < 10; i++) { |
| 8127 CHECK_EQ(0, type_switch->match(obj0)); | 8150 CHECK_EQ(0, type_switch->match(obj0)); |
| 8128 CHECK_EQ(1, type_switch->match(obj1)); | 8151 CHECK_EQ(1, type_switch->match(obj1)); |
| 8129 CHECK_EQ(2, type_switch->match(obj2)); | 8152 CHECK_EQ(2, type_switch->match(obj2)); |
| 8130 CHECK_EQ(3, type_switch->match(obj3)); | 8153 CHECK_EQ(3, type_switch->match(obj3)); |
| 8131 CHECK_EQ(3, type_switch->match(obj3)); | 8154 CHECK_EQ(3, type_switch->match(obj3)); |
| 8132 CHECK_EQ(2, type_switch->match(obj2)); | 8155 CHECK_EQ(2, type_switch->match(obj2)); |
| (...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8565 | 8588 |
| 8566 // Set to the same domain. | 8589 // Set to the same domain. |
| 8567 env1->SetSecurityToken(foo); | 8590 env1->SetSecurityToken(foo); |
| 8568 env2->SetSecurityToken(foo); | 8591 env2->SetSecurityToken(foo); |
| 8569 | 8592 |
| 8570 // Enter env2 | 8593 // Enter env2 |
| 8571 env2->Enter(); | 8594 env2->Enter(); |
| 8572 | 8595 |
| 8573 // Create a function in env2 and add a reference to it in env1. | 8596 // Create a function in env2 and add a reference to it in env1. |
| 8574 Local<v8::Object> global2 = env2->Global(); | 8597 Local<v8::Object> global2 = env2->Global(); |
| 8575 global2->Set(v8_str("prop"), v8::Integer::New(1)); | 8598 global2->Set(v8_str("prop"), v8::Integer::New(env2->GetIsolate(), 1)); |
| 8576 CompileRun("function getProp() {return prop;}"); | 8599 CompileRun("function getProp() {return prop;}"); |
| 8577 | 8600 |
| 8578 env1->Global()->Set(v8_str("getProp"), | 8601 env1->Global()->Set(v8_str("getProp"), |
| 8579 global2->Get(v8_str("getProp"))); | 8602 global2->Get(v8_str("getProp"))); |
| 8580 | 8603 |
| 8581 // Detach env2's global, and reuse the global object of env2 | 8604 // Detach env2's global, and reuse the global object of env2 |
| 8582 env2->Exit(); | 8605 env2->Exit(); |
| 8583 env2->DetachGlobal(); | 8606 env2->DetachGlobal(); |
| 8584 | 8607 |
| 8585 v8::Handle<Context> env3 = Context::New(env1->GetIsolate(), | 8608 v8::Handle<Context> env3 = Context::New(env1->GetIsolate(), |
| 8586 0, | 8609 0, |
| 8587 v8::Handle<v8::ObjectTemplate>(), | 8610 v8::Handle<v8::ObjectTemplate>(), |
| 8588 global2); | 8611 global2); |
| 8589 env3->SetSecurityToken(v8_str("bar")); | 8612 env3->SetSecurityToken(v8_str("bar")); |
| 8590 env3->Enter(); | 8613 env3->Enter(); |
| 8591 | 8614 |
| 8592 Local<v8::Object> global3 = env3->Global(); | 8615 Local<v8::Object> global3 = env3->Global(); |
| 8593 CHECK_EQ(global2, global3); | 8616 CHECK_EQ(global2, global3); |
| 8594 CHECK(global3->Get(v8_str("prop"))->IsUndefined()); | 8617 CHECK(global3->Get(v8_str("prop"))->IsUndefined()); |
| 8595 CHECK(global3->Get(v8_str("getProp"))->IsUndefined()); | 8618 CHECK(global3->Get(v8_str("getProp"))->IsUndefined()); |
| 8596 global3->Set(v8_str("prop"), v8::Integer::New(-1)); | 8619 global3->Set(v8_str("prop"), v8::Integer::New(env3->GetIsolate(), -1)); |
| 8597 global3->Set(v8_str("prop2"), v8::Integer::New(2)); | 8620 global3->Set(v8_str("prop2"), v8::Integer::New(env3->GetIsolate(), 2)); |
| 8598 env3->Exit(); | 8621 env3->Exit(); |
| 8599 | 8622 |
| 8600 // Call getProp in env1, and it should return the value 1 | 8623 // Call getProp in env1, and it should return the value 1 |
| 8601 { | 8624 { |
| 8602 Local<Value> get_prop = global1->Get(v8_str("getProp")); | 8625 Local<Value> get_prop = global1->Get(v8_str("getProp")); |
| 8603 CHECK(get_prop->IsFunction()); | 8626 CHECK(get_prop->IsFunction()); |
| 8604 v8::TryCatch try_catch; | 8627 v8::TryCatch try_catch; |
| 8605 Local<Value> r = Function::Cast(*get_prop)->Call(global1, 0, NULL); | 8628 Local<Value> r = Function::Cast(*get_prop)->Call(global1, 0, NULL); |
| 8606 CHECK(!try_catch.HasCaught()); | 8629 CHECK(!try_catch.HasCaught()); |
| 8607 CHECK_EQ(1, r->Int32Value()); | 8630 CHECK_EQ(1, r->Int32Value()); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 8624 | 8647 |
| 8625 Local<Value> foo = v8_str("foo"); | 8648 Local<Value> foo = v8_str("foo"); |
| 8626 | 8649 |
| 8627 // Set same security token for env1 and env2. | 8650 // Set same security token for env1 and env2. |
| 8628 env1->SetSecurityToken(foo); | 8651 env1->SetSecurityToken(foo); |
| 8629 env2->SetSecurityToken(foo); | 8652 env2->SetSecurityToken(foo); |
| 8630 | 8653 |
| 8631 // Create a property on the global object in env2. | 8654 // Create a property on the global object in env2. |
| 8632 { | 8655 { |
| 8633 v8::Context::Scope scope(env2); | 8656 v8::Context::Scope scope(env2); |
| 8634 env2->Global()->Set(v8_str("p"), v8::Integer::New(42)); | 8657 env2->Global()->Set(v8_str("p"), v8::Integer::New(env2->GetIsolate(), 42)); |
| 8635 } | 8658 } |
| 8636 | 8659 |
| 8637 // Create a reference to env2 global from env1 global. | 8660 // Create a reference to env2 global from env1 global. |
| 8638 env1->Global()->Set(v8_str("other"), env2->Global()); | 8661 env1->Global()->Set(v8_str("other"), env2->Global()); |
| 8639 | 8662 |
| 8640 // Check that we have access to other.p in env2 from env1. | 8663 // Check that we have access to other.p in env2 from env1. |
| 8641 Local<Value> result = CompileRun("other.p"); | 8664 Local<Value> result = CompileRun("other.p"); |
| 8642 CHECK(result->IsInt32()); | 8665 CHECK(result->IsInt32()); |
| 8643 CHECK_EQ(42, result->Int32Value()); | 8666 CHECK_EQ(42, result->Int32Value()); |
| 8644 | 8667 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 8657 v8::Handle<v8::ObjectTemplate>(), | 8680 v8::Handle<v8::ObjectTemplate>(), |
| 8658 global2); | 8681 global2); |
| 8659 CHECK_EQ(global2, env3->Global()); | 8682 CHECK_EQ(global2, env3->Global()); |
| 8660 | 8683 |
| 8661 // Start by using the same security token for env3 as for env1 and env2. | 8684 // Start by using the same security token for env3 as for env1 and env2. |
| 8662 env3->SetSecurityToken(foo); | 8685 env3->SetSecurityToken(foo); |
| 8663 | 8686 |
| 8664 // Create a property on the global object in env3. | 8687 // Create a property on the global object in env3. |
| 8665 { | 8688 { |
| 8666 v8::Context::Scope scope(env3); | 8689 v8::Context::Scope scope(env3); |
| 8667 env3->Global()->Set(v8_str("p"), v8::Integer::New(24)); | 8690 env3->Global()->Set(v8_str("p"), v8::Integer::New(env3->GetIsolate(), 24)); |
| 8668 } | 8691 } |
| 8669 | 8692 |
| 8670 // Check that other.p is now the property in env3 and that we have access. | 8693 // Check that other.p is now the property in env3 and that we have access. |
| 8671 result = CompileRun("other.p"); | 8694 result = CompileRun("other.p"); |
| 8672 CHECK(result->IsInt32()); | 8695 CHECK(result->IsInt32()); |
| 8673 CHECK_EQ(24, result->Int32Value()); | 8696 CHECK_EQ(24, result->Int32Value()); |
| 8674 | 8697 |
| 8675 // Change security token for env3 to something different from env1 and env2. | 8698 // Change security token for env3 to something different from env1 and env2. |
| 8676 env3->SetSecurityToken(v8_str("bar")); | 8699 env3->SetSecurityToken(v8_str("bar")); |
| 8677 | 8700 |
| (...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9169 Local<Value> data) { | 9192 Local<Value> data) { |
| 9170 return false; | 9193 return false; |
| 9171 } | 9194 } |
| 9172 | 9195 |
| 9173 | 9196 |
| 9174 THREADED_TEST(AccessControlGetOwnPropertyNames) { | 9197 THREADED_TEST(AccessControlGetOwnPropertyNames) { |
| 9175 v8::Isolate* isolate = CcTest::isolate(); | 9198 v8::Isolate* isolate = CcTest::isolate(); |
| 9176 v8::HandleScope handle_scope(isolate); | 9199 v8::HandleScope handle_scope(isolate); |
| 9177 v8::Handle<v8::ObjectTemplate> obj_template = v8::ObjectTemplate::New(); | 9200 v8::Handle<v8::ObjectTemplate> obj_template = v8::ObjectTemplate::New(); |
| 9178 | 9201 |
| 9179 obj_template->Set(v8_str("x"), v8::Integer::New(42)); | 9202 obj_template->Set(v8_str("x"), v8::Integer::New(isolate, 42)); |
| 9180 obj_template->SetAccessCheckCallbacks(GetOwnPropertyNamesNamedBlocker, | 9203 obj_template->SetAccessCheckCallbacks(GetOwnPropertyNamesNamedBlocker, |
| 9181 GetOwnPropertyNamesIndexedBlocker); | 9204 GetOwnPropertyNamesIndexedBlocker); |
| 9182 | 9205 |
| 9183 // Create an environment | 9206 // Create an environment |
| 9184 v8::Local<Context> context0 = Context::New(isolate, NULL, obj_template); | 9207 v8::Local<Context> context0 = Context::New(isolate, NULL, obj_template); |
| 9185 context0->Enter(); | 9208 context0->Enter(); |
| 9186 | 9209 |
| 9187 v8::Handle<v8::Object> global0 = context0->Global(); | 9210 v8::Handle<v8::Object> global0 = context0->Global(); |
| 9188 | 9211 |
| 9189 v8::HandleScope scope1(CcTest::isolate()); | 9212 v8::HandleScope scope1(CcTest::isolate()); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 9209 CHECK(value->IsTrue()); | 9232 CHECK(value->IsTrue()); |
| 9210 | 9233 |
| 9211 context1->Exit(); | 9234 context1->Exit(); |
| 9212 context0->Exit(); | 9235 context0->Exit(); |
| 9213 } | 9236 } |
| 9214 | 9237 |
| 9215 | 9238 |
| 9216 static void IndexedPropertyEnumerator( | 9239 static void IndexedPropertyEnumerator( |
| 9217 const v8::PropertyCallbackInfo<v8::Array>& info) { | 9240 const v8::PropertyCallbackInfo<v8::Array>& info) { |
| 9218 v8::Handle<v8::Array> result = v8::Array::New(info.GetIsolate(), 2); | 9241 v8::Handle<v8::Array> result = v8::Array::New(info.GetIsolate(), 2); |
| 9219 result->Set(0, v8::Integer::New(7)); | 9242 result->Set(0, v8::Integer::New(info.GetIsolate(), 7)); |
| 9220 result->Set(1, v8::Object::New()); | 9243 result->Set(1, v8::Object::New(info.GetIsolate())); |
| 9221 info.GetReturnValue().Set(result); | 9244 info.GetReturnValue().Set(result); |
| 9222 } | 9245 } |
| 9223 | 9246 |
| 9224 | 9247 |
| 9225 static void NamedPropertyEnumerator( | 9248 static void NamedPropertyEnumerator( |
| 9226 const v8::PropertyCallbackInfo<v8::Array>& info) { | 9249 const v8::PropertyCallbackInfo<v8::Array>& info) { |
| 9227 v8::Handle<v8::Array> result = v8::Array::New(info.GetIsolate(), 2); | 9250 v8::Handle<v8::Array> result = v8::Array::New(info.GetIsolate(), 2); |
| 9228 result->Set(0, v8_str("x")); | 9251 result->Set(0, v8_str("x")); |
| 9229 result->Set(1, v8::Object::New()); | 9252 result->Set(1, v8::Object::New(info.GetIsolate())); |
| 9230 info.GetReturnValue().Set(result); | 9253 info.GetReturnValue().Set(result); |
| 9231 } | 9254 } |
| 9232 | 9255 |
| 9233 | 9256 |
| 9234 THREADED_TEST(GetOwnPropertyNamesWithInterceptor) { | 9257 THREADED_TEST(GetOwnPropertyNamesWithInterceptor) { |
| 9235 v8::HandleScope handle_scope(CcTest::isolate()); | 9258 v8::HandleScope handle_scope(CcTest::isolate()); |
| 9236 v8::Handle<v8::ObjectTemplate> obj_template = v8::ObjectTemplate::New(); | 9259 v8::Handle<v8::ObjectTemplate> obj_template = v8::ObjectTemplate::New(); |
| 9237 | 9260 |
| 9238 obj_template->Set(v8_str("7"), v8::Integer::New(7)); | 9261 obj_template->Set(v8_str("7"), v8::Integer::New(CcTest::isolate(), 7)); |
| 9239 obj_template->Set(v8_str("x"), v8::Integer::New(42)); | 9262 obj_template->Set(v8_str("x"), v8::Integer::New(CcTest::isolate(), 42)); |
| 9240 obj_template->SetIndexedPropertyHandler(NULL, NULL, NULL, NULL, | 9263 obj_template->SetIndexedPropertyHandler(NULL, NULL, NULL, NULL, |
| 9241 IndexedPropertyEnumerator); | 9264 IndexedPropertyEnumerator); |
| 9242 obj_template->SetNamedPropertyHandler(NULL, NULL, NULL, NULL, | 9265 obj_template->SetNamedPropertyHandler(NULL, NULL, NULL, NULL, |
| 9243 NamedPropertyEnumerator); | 9266 NamedPropertyEnumerator); |
| 9244 | 9267 |
| 9245 LocalContext context; | 9268 LocalContext context; |
| 9246 v8::Handle<v8::Object> global = context->Global(); | 9269 v8::Handle<v8::Object> global = context->Global(); |
| 9247 global->Set(v8_str("object"), obj_template->NewInstance()); | 9270 global->Set(v8_str("object"), obj_template->NewInstance()); |
| 9248 | 9271 |
| 9249 v8::Handle<v8::Value> result = | 9272 v8::Handle<v8::Value> result = |
| (...skipping 685 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9935 | 9958 |
| 9936 // Regression test for issue 2457. | 9959 // Regression test for issue 2457. |
| 9937 THREADED_TEST(HiddenPrototypeIdentityHash) { | 9960 THREADED_TEST(HiddenPrototypeIdentityHash) { |
| 9938 LocalContext context; | 9961 LocalContext context; |
| 9939 v8::HandleScope handle_scope(context->GetIsolate()); | 9962 v8::HandleScope handle_scope(context->GetIsolate()); |
| 9940 | 9963 |
| 9941 Handle<FunctionTemplate> t = FunctionTemplate::New(context->GetIsolate()); | 9964 Handle<FunctionTemplate> t = FunctionTemplate::New(context->GetIsolate()); |
| 9942 t->SetHiddenPrototype(true); | 9965 t->SetHiddenPrototype(true); |
| 9943 t->InstanceTemplate()->Set(v8_str("foo"), v8_num(75)); | 9966 t->InstanceTemplate()->Set(v8_str("foo"), v8_num(75)); |
| 9944 Handle<Object> p = t->GetFunction()->NewInstance(); | 9967 Handle<Object> p = t->GetFunction()->NewInstance(); |
| 9945 Handle<Object> o = Object::New(); | 9968 Handle<Object> o = Object::New(context->GetIsolate()); |
| 9946 o->SetPrototype(p); | 9969 o->SetPrototype(p); |
| 9947 | 9970 |
| 9948 int hash = o->GetIdentityHash(); | 9971 int hash = o->GetIdentityHash(); |
| 9949 USE(hash); | 9972 USE(hash); |
| 9950 o->Set(v8_str("foo"), v8_num(42)); | 9973 o->Set(v8_str("foo"), v8_num(42)); |
| 9951 ASSERT_EQ(hash, o->GetIdentityHash()); | 9974 ASSERT_EQ(hash, o->GetIdentityHash()); |
| 9952 } | 9975 } |
| 9953 | 9976 |
| 9954 | 9977 |
| 9955 THREADED_TEST(SetPrototype) { | 9978 THREADED_TEST(SetPrototype) { |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10018 LocalContext context; | 10041 LocalContext context; |
| 10019 v8::Isolate* isolate = context->GetIsolate(); | 10042 v8::Isolate* isolate = context->GetIsolate(); |
| 10020 v8::HandleScope handle_scope(isolate); | 10043 v8::HandleScope handle_scope(isolate); |
| 10021 | 10044 |
| 10022 Local<v8::FunctionTemplate> t1 = v8::FunctionTemplate::New(isolate); | 10045 Local<v8::FunctionTemplate> t1 = v8::FunctionTemplate::New(isolate); |
| 10023 t1->SetHiddenPrototype(true); | 10046 t1->SetHiddenPrototype(true); |
| 10024 t1->InstanceTemplate()->Set(v8_str("foo"), v8_num(1)); | 10047 t1->InstanceTemplate()->Set(v8_str("foo"), v8_num(1)); |
| 10025 Local<v8::FunctionTemplate> t2 = v8::FunctionTemplate::New(isolate); | 10048 Local<v8::FunctionTemplate> t2 = v8::FunctionTemplate::New(isolate); |
| 10026 t2->SetHiddenPrototype(true); | 10049 t2->SetHiddenPrototype(true); |
| 10027 t2->InstanceTemplate()->Set(v8_str("fuz1"), v8_num(2)); | 10050 t2->InstanceTemplate()->Set(v8_str("fuz1"), v8_num(2)); |
| 10028 t2->InstanceTemplate()->Set(v8_str("objects"), v8::Object::New()); | 10051 t2->InstanceTemplate()->Set(v8_str("objects"), v8::Object::New(isolate)); |
| 10029 t2->InstanceTemplate()->Set(v8_str("fuz2"), v8_num(2)); | 10052 t2->InstanceTemplate()->Set(v8_str("fuz2"), v8_num(2)); |
| 10030 Local<v8::FunctionTemplate> t3 = v8::FunctionTemplate::New(isolate); | 10053 Local<v8::FunctionTemplate> t3 = v8::FunctionTemplate::New(isolate); |
| 10031 t3->SetHiddenPrototype(true); | 10054 t3->SetHiddenPrototype(true); |
| 10032 t3->InstanceTemplate()->Set(v8_str("boo"), v8_num(3)); | 10055 t3->InstanceTemplate()->Set(v8_str("boo"), v8_num(3)); |
| 10033 Local<v8::FunctionTemplate> t4 = v8::FunctionTemplate::New(isolate); | 10056 Local<v8::FunctionTemplate> t4 = v8::FunctionTemplate::New(isolate); |
| 10034 t4->InstanceTemplate()->Set(v8_str("baz"), v8_num(4)); | 10057 t4->InstanceTemplate()->Set(v8_str("baz"), v8_num(4)); |
| 10035 | 10058 |
| 10036 // Force dictionary-based properties. | 10059 // Force dictionary-based properties. |
| 10037 i::ScopedVector<char> name_buf(1024); | 10060 i::ScopedVector<char> name_buf(1024); |
| 10038 for (int i = 1; i <= 1000; i++) { | 10061 for (int i = 1; i <= 1000; i++) { |
| (...skipping 25 matching lines...) Expand all Loading... |
| 10064 ExpectFalse("names[1005] == undefined"); | 10087 ExpectFalse("names[1005] == undefined"); |
| 10065 } | 10088 } |
| 10066 | 10089 |
| 10067 | 10090 |
| 10068 THREADED_TEST(FunctionReadOnlyPrototype) { | 10091 THREADED_TEST(FunctionReadOnlyPrototype) { |
| 10069 LocalContext context; | 10092 LocalContext context; |
| 10070 v8::Isolate* isolate = context->GetIsolate(); | 10093 v8::Isolate* isolate = context->GetIsolate(); |
| 10071 v8::HandleScope handle_scope(isolate); | 10094 v8::HandleScope handle_scope(isolate); |
| 10072 | 10095 |
| 10073 Local<v8::FunctionTemplate> t1 = v8::FunctionTemplate::New(isolate); | 10096 Local<v8::FunctionTemplate> t1 = v8::FunctionTemplate::New(isolate); |
| 10074 t1->PrototypeTemplate()->Set(v8_str("x"), v8::Integer::New(42)); | 10097 t1->PrototypeTemplate()->Set(v8_str("x"), v8::Integer::New(isolate, 42)); |
| 10075 t1->ReadOnlyPrototype(); | 10098 t1->ReadOnlyPrototype(); |
| 10076 context->Global()->Set(v8_str("func1"), t1->GetFunction()); | 10099 context->Global()->Set(v8_str("func1"), t1->GetFunction()); |
| 10077 // Configured value of ReadOnly flag. | 10100 // Configured value of ReadOnly flag. |
| 10078 CHECK(CompileRun( | 10101 CHECK(CompileRun( |
| 10079 "(function() {" | 10102 "(function() {" |
| 10080 " descriptor = Object.getOwnPropertyDescriptor(func1, 'prototype');" | 10103 " descriptor = Object.getOwnPropertyDescriptor(func1, 'prototype');" |
| 10081 " return (descriptor['writable'] == false);" | 10104 " return (descriptor['writable'] == false);" |
| 10082 "})()")->BooleanValue()); | 10105 "})()")->BooleanValue()); |
| 10083 CHECK_EQ(42, CompileRun("func1.prototype.x")->Int32Value()); | 10106 CHECK_EQ(42, CompileRun("func1.prototype.x")->Int32Value()); |
| 10084 CHECK_EQ(42, | 10107 CHECK_EQ(42, |
| 10085 CompileRun("func1.prototype = {}; func1.prototype.x")->Int32Value()); | 10108 CompileRun("func1.prototype = {}; func1.prototype.x")->Int32Value()); |
| 10086 | 10109 |
| 10087 Local<v8::FunctionTemplate> t2 = v8::FunctionTemplate::New(isolate); | 10110 Local<v8::FunctionTemplate> t2 = v8::FunctionTemplate::New(isolate); |
| 10088 t2->PrototypeTemplate()->Set(v8_str("x"), v8::Integer::New(42)); | 10111 t2->PrototypeTemplate()->Set(v8_str("x"), v8::Integer::New(isolate, 42)); |
| 10089 context->Global()->Set(v8_str("func2"), t2->GetFunction()); | 10112 context->Global()->Set(v8_str("func2"), t2->GetFunction()); |
| 10090 // Default value of ReadOnly flag. | 10113 // Default value of ReadOnly flag. |
| 10091 CHECK(CompileRun( | 10114 CHECK(CompileRun( |
| 10092 "(function() {" | 10115 "(function() {" |
| 10093 " descriptor = Object.getOwnPropertyDescriptor(func2, 'prototype');" | 10116 " descriptor = Object.getOwnPropertyDescriptor(func2, 'prototype');" |
| 10094 " return (descriptor['writable'] == true);" | 10117 " return (descriptor['writable'] == true);" |
| 10095 "})()")->BooleanValue()); | 10118 "})()")->BooleanValue()); |
| 10096 CHECK_EQ(42, CompileRun("func2.prototype.x")->Int32Value()); | 10119 CHECK_EQ(42, CompileRun("func2.prototype.x")->Int32Value()); |
| 10097 } | 10120 } |
| 10098 | 10121 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10135 CHECK(try_catch.HasCaught()); | 10158 CHECK(try_catch.HasCaught()); |
| 10136 | 10159 |
| 10137 try_catch.Reset(); | 10160 try_catch.Reset(); |
| 10138 fun->NewInstance(); | 10161 fun->NewInstance(); |
| 10139 CHECK(try_catch.HasCaught()); | 10162 CHECK(try_catch.HasCaught()); |
| 10140 } | 10163 } |
| 10141 | 10164 |
| 10142 | 10165 |
| 10143 THREADED_TEST(GetterSetterExceptions) { | 10166 THREADED_TEST(GetterSetterExceptions) { |
| 10144 LocalContext context; | 10167 LocalContext context; |
| 10145 v8::HandleScope handle_scope(context->GetIsolate()); | 10168 v8::Isolate* isolate = context->GetIsolate(); |
| 10169 v8::HandleScope handle_scope(isolate); |
| 10146 CompileRun( | 10170 CompileRun( |
| 10147 "function Foo() { };" | 10171 "function Foo() { };" |
| 10148 "function Throw() { throw 5; };" | 10172 "function Throw() { throw 5; };" |
| 10149 "var x = { };" | 10173 "var x = { };" |
| 10150 "x.__defineSetter__('set', Throw);" | 10174 "x.__defineSetter__('set', Throw);" |
| 10151 "x.__defineGetter__('get', Throw);"); | 10175 "x.__defineGetter__('get', Throw);"); |
| 10152 Local<v8::Object> x = | 10176 Local<v8::Object> x = |
| 10153 Local<v8::Object>::Cast(context->Global()->Get(v8_str("x"))); | 10177 Local<v8::Object>::Cast(context->Global()->Get(v8_str("x"))); |
| 10154 v8::TryCatch try_catch; | 10178 v8::TryCatch try_catch; |
| 10155 x->Set(v8_str("set"), v8::Integer::New(8)); | 10179 x->Set(v8_str("set"), v8::Integer::New(isolate, 8)); |
| 10156 x->Get(v8_str("get")); | 10180 x->Get(v8_str("get")); |
| 10157 x->Set(v8_str("set"), v8::Integer::New(8)); | 10181 x->Set(v8_str("set"), v8::Integer::New(isolate, 8)); |
| 10158 x->Get(v8_str("get")); | 10182 x->Get(v8_str("get")); |
| 10159 x->Set(v8_str("set"), v8::Integer::New(8)); | 10183 x->Set(v8_str("set"), v8::Integer::New(isolate, 8)); |
| 10160 x->Get(v8_str("get")); | 10184 x->Get(v8_str("get")); |
| 10161 x->Set(v8_str("set"), v8::Integer::New(8)); | 10185 x->Set(v8_str("set"), v8::Integer::New(isolate, 8)); |
| 10162 x->Get(v8_str("get")); | 10186 x->Get(v8_str("get")); |
| 10163 } | 10187 } |
| 10164 | 10188 |
| 10165 | 10189 |
| 10166 THREADED_TEST(Constructor) { | 10190 THREADED_TEST(Constructor) { |
| 10167 LocalContext context; | 10191 LocalContext context; |
| 10168 v8::Isolate* isolate = context->GetIsolate(); | 10192 v8::Isolate* isolate = context->GetIsolate(); |
| 10169 v8::HandleScope handle_scope(isolate); | 10193 v8::HandleScope handle_scope(isolate); |
| 10170 Local<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(isolate); | 10194 Local<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(isolate); |
| 10171 templ->SetClassName(v8_str("Fun")); | 10195 templ->SetClassName(v8_str("Fun")); |
| 10172 Local<Function> cons = templ->GetFunction(); | 10196 Local<Function> cons = templ->GetFunction(); |
| 10173 context->Global()->Set(v8_str("Fun"), cons); | 10197 context->Global()->Set(v8_str("Fun"), cons); |
| 10174 Local<v8::Object> inst = cons->NewInstance(); | 10198 Local<v8::Object> inst = cons->NewInstance(); |
| 10175 i::Handle<i::JSObject> obj(v8::Utils::OpenHandle(*inst)); | 10199 i::Handle<i::JSObject> obj(v8::Utils::OpenHandle(*inst)); |
| 10176 CHECK(obj->IsJSObject()); | 10200 CHECK(obj->IsJSObject()); |
| 10177 Local<Value> value = CompileRun("(new Fun()).constructor === Fun"); | 10201 Local<Value> value = CompileRun("(new Fun()).constructor === Fun"); |
| 10178 CHECK(value->BooleanValue()); | 10202 CHECK(value->BooleanValue()); |
| 10179 } | 10203 } |
| 10180 | 10204 |
| 10181 | 10205 |
| 10182 static void ConstructorCallback( | 10206 static void ConstructorCallback( |
| 10183 const v8::FunctionCallbackInfo<v8::Value>& args) { | 10207 const v8::FunctionCallbackInfo<v8::Value>& args) { |
| 10184 ApiTestFuzzer::Fuzz(); | 10208 ApiTestFuzzer::Fuzz(); |
| 10185 Local<Object> This; | 10209 Local<Object> This; |
| 10186 | 10210 |
| 10187 if (args.IsConstructCall()) { | 10211 if (args.IsConstructCall()) { |
| 10188 Local<Object> Holder = args.Holder(); | 10212 Local<Object> Holder = args.Holder(); |
| 10189 This = Object::New(); | 10213 This = Object::New(args.GetIsolate()); |
| 10190 Local<Value> proto = Holder->GetPrototype(); | 10214 Local<Value> proto = Holder->GetPrototype(); |
| 10191 if (proto->IsObject()) { | 10215 if (proto->IsObject()) { |
| 10192 This->SetPrototype(proto); | 10216 This->SetPrototype(proto); |
| 10193 } | 10217 } |
| 10194 } else { | 10218 } else { |
| 10195 This = args.This(); | 10219 This = args.This(); |
| 10196 } | 10220 } |
| 10197 | 10221 |
| 10198 This->Set(v8_str("a"), args[0]); | 10222 This->Set(v8_str("a"), args[0]); |
| 10199 args.GetReturnValue().Set(This); | 10223 args.GetReturnValue().Set(This); |
| (...skipping 626 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10826 | 10850 |
| 10827 static int CountHandles() { | 10851 static int CountHandles() { |
| 10828 return v8::HandleScope::NumberOfHandles(); | 10852 return v8::HandleScope::NumberOfHandles(); |
| 10829 } | 10853 } |
| 10830 | 10854 |
| 10831 | 10855 |
| 10832 static int Recurse(int depth, int iterations) { | 10856 static int Recurse(int depth, int iterations) { |
| 10833 v8::HandleScope scope(CcTest::isolate()); | 10857 v8::HandleScope scope(CcTest::isolate()); |
| 10834 if (depth == 0) return CountHandles(); | 10858 if (depth == 0) return CountHandles(); |
| 10835 for (int i = 0; i < iterations; i++) { | 10859 for (int i = 0; i < iterations; i++) { |
| 10836 Local<v8::Number> n(v8::Integer::New(42)); | 10860 Local<v8::Number> n(v8::Integer::New(CcTest::isolate(), 42)); |
| 10837 } | 10861 } |
| 10838 return Recurse(depth - 1, iterations); | 10862 return Recurse(depth - 1, iterations); |
| 10839 } | 10863 } |
| 10840 | 10864 |
| 10841 | 10865 |
| 10842 THREADED_TEST(HandleIteration) { | 10866 THREADED_TEST(HandleIteration) { |
| 10843 static const int kIterations = 500; | 10867 static const int kIterations = 500; |
| 10844 static const int kNesting = 200; | 10868 static const int kNesting = 200; |
| 10845 CHECK_EQ(0, CountHandles()); | 10869 CHECK_EQ(0, CountHandles()); |
| 10846 { | 10870 { |
| 10847 v8::HandleScope scope1(CcTest::isolate()); | 10871 v8::HandleScope scope1(CcTest::isolate()); |
| 10848 CHECK_EQ(0, CountHandles()); | 10872 CHECK_EQ(0, CountHandles()); |
| 10849 for (int i = 0; i < kIterations; i++) { | 10873 for (int i = 0; i < kIterations; i++) { |
| 10850 Local<v8::Number> n(v8::Integer::New(42)); | 10874 Local<v8::Number> n(v8::Integer::New(CcTest::isolate(), 42)); |
| 10851 CHECK_EQ(i + 1, CountHandles()); | 10875 CHECK_EQ(i + 1, CountHandles()); |
| 10852 } | 10876 } |
| 10853 | 10877 |
| 10854 CHECK_EQ(kIterations, CountHandles()); | 10878 CHECK_EQ(kIterations, CountHandles()); |
| 10855 { | 10879 { |
| 10856 v8::HandleScope scope2(CcTest::isolate()); | 10880 v8::HandleScope scope2(CcTest::isolate()); |
| 10857 for (int j = 0; j < kIterations; j++) { | 10881 for (int j = 0; j < kIterations; j++) { |
| 10858 Local<v8::Number> n(v8::Integer::New(42)); | 10882 Local<v8::Number> n(v8::Integer::New(CcTest::isolate(), 42)); |
| 10859 CHECK_EQ(j + 1 + kIterations, CountHandles()); | 10883 CHECK_EQ(j + 1 + kIterations, CountHandles()); |
| 10860 } | 10884 } |
| 10861 } | 10885 } |
| 10862 CHECK_EQ(kIterations, CountHandles()); | 10886 CHECK_EQ(kIterations, CountHandles()); |
| 10863 } | 10887 } |
| 10864 CHECK_EQ(0, CountHandles()); | 10888 CHECK_EQ(0, CountHandles()); |
| 10865 CHECK_EQ(kNesting * kIterations, Recurse(kNesting, kIterations)); | 10889 CHECK_EQ(kNesting * kIterations, Recurse(kNesting, kIterations)); |
| 10866 } | 10890 } |
| 10867 | 10891 |
| 10868 | 10892 |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10954 | 10978 |
| 10955 | 10979 |
| 10956 static void InterceptorLoadICGetter( | 10980 static void InterceptorLoadICGetter( |
| 10957 Local<String> name, | 10981 Local<String> name, |
| 10958 const v8::PropertyCallbackInfo<v8::Value>& info) { | 10982 const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 10959 ApiTestFuzzer::Fuzz(); | 10983 ApiTestFuzzer::Fuzz(); |
| 10960 v8::Isolate* isolate = CcTest::isolate(); | 10984 v8::Isolate* isolate = CcTest::isolate(); |
| 10961 CHECK_EQ(isolate, info.GetIsolate()); | 10985 CHECK_EQ(isolate, info.GetIsolate()); |
| 10962 CHECK_EQ(v8_str("data"), info.Data()); | 10986 CHECK_EQ(v8_str("data"), info.Data()); |
| 10963 CHECK_EQ(v8_str("x"), name); | 10987 CHECK_EQ(v8_str("x"), name); |
| 10964 info.GetReturnValue().Set(v8::Integer::New(42)); | 10988 info.GetReturnValue().Set(v8::Integer::New(isolate, 42)); |
| 10965 } | 10989 } |
| 10966 | 10990 |
| 10967 | 10991 |
| 10968 // This test should hit the load IC for the interceptor case. | 10992 // This test should hit the load IC for the interceptor case. |
| 10969 THREADED_TEST(InterceptorLoadIC) { | 10993 THREADED_TEST(InterceptorLoadIC) { |
| 10970 CheckInterceptorLoadIC(InterceptorLoadICGetter, | 10994 CheckInterceptorLoadIC(InterceptorLoadICGetter, |
| 10971 "var result = 0;" | 10995 "var result = 0;" |
| 10972 "for (var i = 0; i < 1000; i++) {" | 10996 "for (var i = 0; i < 1000; i++) {" |
| 10973 " result = o.x;" | 10997 " result = o.x;" |
| 10974 "}", | 10998 "}", |
| 10975 42); | 10999 42); |
| 10976 } | 11000 } |
| 10977 | 11001 |
| 10978 | 11002 |
| 10979 // Below go several tests which verify that JITing for various | 11003 // Below go several tests which verify that JITing for various |
| 10980 // configurations of interceptor and explicit fields works fine | 11004 // configurations of interceptor and explicit fields works fine |
| 10981 // (those cases are special cased to get better performance). | 11005 // (those cases are special cased to get better performance). |
| 10982 | 11006 |
| 10983 static void InterceptorLoadXICGetter( | 11007 static void InterceptorLoadXICGetter( |
| 10984 Local<String> name, | 11008 Local<String> name, |
| 10985 const v8::PropertyCallbackInfo<v8::Value>& info) { | 11009 const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 10986 ApiTestFuzzer::Fuzz(); | 11010 ApiTestFuzzer::Fuzz(); |
| 10987 info.GetReturnValue().Set( | 11011 info.GetReturnValue().Set( |
| 10988 v8_str("x")->Equals(name) ? | 11012 v8_str("x")->Equals(name) ? |
| 10989 v8::Handle<v8::Value>(v8::Integer::New(42)) : | 11013 v8::Handle<v8::Value>(v8::Integer::New(info.GetIsolate(), 42)) : |
| 10990 v8::Handle<v8::Value>()); | 11014 v8::Handle<v8::Value>()); |
| 10991 } | 11015 } |
| 10992 | 11016 |
| 10993 | 11017 |
| 10994 THREADED_TEST(InterceptorLoadICWithFieldOnHolder) { | 11018 THREADED_TEST(InterceptorLoadICWithFieldOnHolder) { |
| 10995 CheckInterceptorLoadIC(InterceptorLoadXICGetter, | 11019 CheckInterceptorLoadIC(InterceptorLoadXICGetter, |
| 10996 "var result = 0;" | 11020 "var result = 0;" |
| 10997 "o.y = 239;" | 11021 "o.y = 239;" |
| 10998 "for (var i = 0; i < 1000; i++) {" | 11022 "for (var i = 0; i < 1000; i++) {" |
| 10999 " result = o.y;" | 11023 " result = o.y;" |
| (...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11331 "result"); | 11355 "result"); |
| 11332 CHECK_EQ(42 * 10, value->Int32Value()); | 11356 CHECK_EQ(42 * 10, value->Int32Value()); |
| 11333 } | 11357 } |
| 11334 | 11358 |
| 11335 | 11359 |
| 11336 static void InterceptorLoadICGetter0( | 11360 static void InterceptorLoadICGetter0( |
| 11337 Local<String> name, | 11361 Local<String> name, |
| 11338 const v8::PropertyCallbackInfo<v8::Value>& info) { | 11362 const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 11339 ApiTestFuzzer::Fuzz(); | 11363 ApiTestFuzzer::Fuzz(); |
| 11340 CHECK(v8_str("x")->Equals(name)); | 11364 CHECK(v8_str("x")->Equals(name)); |
| 11341 info.GetReturnValue().Set(v8::Integer::New(0)); | 11365 info.GetReturnValue().Set(v8::Integer::New(info.GetIsolate(), 0)); |
| 11342 } | 11366 } |
| 11343 | 11367 |
| 11344 | 11368 |
| 11345 THREADED_TEST(InterceptorReturningZero) { | 11369 THREADED_TEST(InterceptorReturningZero) { |
| 11346 CheckInterceptorLoadIC(InterceptorLoadICGetter0, | 11370 CheckInterceptorLoadIC(InterceptorLoadICGetter0, |
| 11347 "o.x == undefined ? 1 : 0", | 11371 "o.x == undefined ? 1 : 0", |
| 11348 0); | 11372 0); |
| 11349 } | 11373 } |
| 11350 | 11374 |
| 11351 | 11375 |
| (...skipping 1225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12577 ApiTestFuzzer::Fuzz(); | 12601 ApiTestFuzzer::Fuzz(); |
| 12578 info.GetIsolate()->ThrowException(Handle<Value>()); | 12602 info.GetIsolate()->ThrowException(Handle<Value>()); |
| 12579 info.GetReturnValue().SetUndefined(); | 12603 info.GetReturnValue().SetUndefined(); |
| 12580 } | 12604 } |
| 12581 | 12605 |
| 12582 | 12606 |
| 12583 THREADED_TEST(VariousGetPropertiesAndThrowingCallbacks) { | 12607 THREADED_TEST(VariousGetPropertiesAndThrowingCallbacks) { |
| 12584 LocalContext context; | 12608 LocalContext context; |
| 12585 HandleScope scope(context->GetIsolate()); | 12609 HandleScope scope(context->GetIsolate()); |
| 12586 | 12610 |
| 12587 Local<FunctionTemplate> templ = FunctionTemplate::New(CcTest::isolate()); | 12611 Local<FunctionTemplate> templ = FunctionTemplate::New(context->GetIsolate()); |
| 12588 Local<ObjectTemplate> instance_templ = templ->InstanceTemplate(); | 12612 Local<ObjectTemplate> instance_templ = templ->InstanceTemplate(); |
| 12589 instance_templ->SetAccessor(v8_str("f"), ThrowingGetter); | 12613 instance_templ->SetAccessor(v8_str("f"), ThrowingGetter); |
| 12590 | 12614 |
| 12591 Local<Object> instance = templ->GetFunction()->NewInstance(); | 12615 Local<Object> instance = templ->GetFunction()->NewInstance(); |
| 12592 | 12616 |
| 12593 Local<Object> another = Object::New(); | 12617 Local<Object> another = Object::New(context->GetIsolate()); |
| 12594 another->SetPrototype(instance); | 12618 another->SetPrototype(instance); |
| 12595 | 12619 |
| 12596 Local<Object> with_js_getter = CompileRun( | 12620 Local<Object> with_js_getter = CompileRun( |
| 12597 "o = {};\n" | 12621 "o = {};\n" |
| 12598 "o.__defineGetter__('f', function() { throw undefined; });\n" | 12622 "o.__defineGetter__('f', function() { throw undefined; });\n" |
| 12599 "o\n").As<Object>(); | 12623 "o\n").As<Object>(); |
| 12600 CHECK(!with_js_getter.IsEmpty()); | 12624 CHECK(!with_js_getter.IsEmpty()); |
| 12601 | 12625 |
| 12602 TryCatch try_catch; | 12626 TryCatch try_catch; |
| 12603 | 12627 |
| (...skipping 620 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13224 v8::Isolate* isolate = context->GetIsolate(); | 13248 v8::Isolate* isolate = context->GetIsolate(); |
| 13225 i::GlobalHandles* globals = | 13249 i::GlobalHandles* globals = |
| 13226 reinterpret_cast<i::Isolate*>(isolate)->global_handles(); | 13250 reinterpret_cast<i::Isolate*>(isolate)->global_handles(); |
| 13227 int initial_handles = globals->global_handles_count(); | 13251 int initial_handles = globals->global_handles_count(); |
| 13228 typedef v8::Persistent<v8::Object, v8::CopyablePersistentTraits<v8::Object> > | 13252 typedef v8::Persistent<v8::Object, v8::CopyablePersistentTraits<v8::Object> > |
| 13229 CopyableObject; | 13253 CopyableObject; |
| 13230 { | 13254 { |
| 13231 CopyableObject handle1; | 13255 CopyableObject handle1; |
| 13232 { | 13256 { |
| 13233 v8::HandleScope scope(isolate); | 13257 v8::HandleScope scope(isolate); |
| 13234 handle1.Reset(isolate, v8::Object::New()); | 13258 handle1.Reset(isolate, v8::Object::New(isolate)); |
| 13235 } | 13259 } |
| 13236 CHECK_EQ(initial_handles + 1, globals->global_handles_count()); | 13260 CHECK_EQ(initial_handles + 1, globals->global_handles_count()); |
| 13237 CopyableObject handle2; | 13261 CopyableObject handle2; |
| 13238 handle2 = handle1; | 13262 handle2 = handle1; |
| 13239 CHECK(handle1 == handle2); | 13263 CHECK(handle1 == handle2); |
| 13240 CHECK_EQ(initial_handles + 2, globals->global_handles_count()); | 13264 CHECK_EQ(initial_handles + 2, globals->global_handles_count()); |
| 13241 CopyableObject handle3(handle2); | 13265 CopyableObject handle3(handle2); |
| 13242 CHECK(handle1 == handle3); | 13266 CHECK(handle1 == handle3); |
| 13243 CHECK_EQ(initial_handles + 3, globals->global_handles_count()); | 13267 CHECK_EQ(initial_handles + 3, globals->global_handles_count()); |
| 13244 } | 13268 } |
| (...skipping 12 matching lines...) Expand all Loading... |
| 13257 | 13281 |
| 13258 | 13282 |
| 13259 TEST(WeakCallbackApi) { | 13283 TEST(WeakCallbackApi) { |
| 13260 LocalContext context; | 13284 LocalContext context; |
| 13261 v8::Isolate* isolate = context->GetIsolate(); | 13285 v8::Isolate* isolate = context->GetIsolate(); |
| 13262 i::GlobalHandles* globals = | 13286 i::GlobalHandles* globals = |
| 13263 reinterpret_cast<i::Isolate*>(isolate)->global_handles(); | 13287 reinterpret_cast<i::Isolate*>(isolate)->global_handles(); |
| 13264 int initial_handles = globals->global_handles_count(); | 13288 int initial_handles = globals->global_handles_count(); |
| 13265 { | 13289 { |
| 13266 v8::HandleScope scope(isolate); | 13290 v8::HandleScope scope(isolate); |
| 13267 v8::Local<v8::Object> obj = v8::Object::New(); | 13291 v8::Local<v8::Object> obj = v8::Object::New(isolate); |
| 13268 obj->Set(v8_str("key"), v8::Integer::New(231, isolate)); | 13292 obj->Set(v8_str("key"), v8::Integer::New(isolate, 231)); |
| 13269 v8::Persistent<v8::Object>* handle = | 13293 v8::Persistent<v8::Object>* handle = |
| 13270 new v8::Persistent<v8::Object>(isolate, obj); | 13294 new v8::Persistent<v8::Object>(isolate, obj); |
| 13271 handle->SetWeak<v8::Object, v8::Persistent<v8::Object> >(handle, | 13295 handle->SetWeak<v8::Object, v8::Persistent<v8::Object> >(handle, |
| 13272 WeakApiCallback); | 13296 WeakApiCallback); |
| 13273 } | 13297 } |
| 13274 reinterpret_cast<i::Isolate*>(isolate)->heap()-> | 13298 reinterpret_cast<i::Isolate*>(isolate)->heap()-> |
| 13275 CollectAllGarbage(i::Heap::kNoGCFlags); | 13299 CollectAllGarbage(i::Heap::kNoGCFlags); |
| 13276 // Verify disposed. | 13300 // Verify disposed. |
| 13277 CHECK_EQ(initial_handles, globals->global_handles_count()); | 13301 CHECK_EQ(initial_handles, globals->global_handles_count()); |
| 13278 } | 13302 } |
| (...skipping 10 matching lines...) Expand all Loading... |
| 13289 } | 13313 } |
| 13290 | 13314 |
| 13291 | 13315 |
| 13292 THREADED_TEST(NewPersistentHandleFromWeakCallback) { | 13316 THREADED_TEST(NewPersistentHandleFromWeakCallback) { |
| 13293 LocalContext context; | 13317 LocalContext context; |
| 13294 v8::Isolate* isolate = context->GetIsolate(); | 13318 v8::Isolate* isolate = context->GetIsolate(); |
| 13295 | 13319 |
| 13296 v8::Persistent<v8::Object> handle1, handle2; | 13320 v8::Persistent<v8::Object> handle1, handle2; |
| 13297 { | 13321 { |
| 13298 v8::HandleScope scope(isolate); | 13322 v8::HandleScope scope(isolate); |
| 13299 some_object.Reset(isolate, v8::Object::New()); | 13323 some_object.Reset(isolate, v8::Object::New(isolate)); |
| 13300 handle1.Reset(isolate, v8::Object::New()); | 13324 handle1.Reset(isolate, v8::Object::New(isolate)); |
| 13301 handle2.Reset(isolate, v8::Object::New()); | 13325 handle2.Reset(isolate, v8::Object::New(isolate)); |
| 13302 } | 13326 } |
| 13303 // Note: order is implementation dependent alas: currently | 13327 // Note: order is implementation dependent alas: currently |
| 13304 // global handle nodes are processed by PostGarbageCollectionProcessing | 13328 // global handle nodes are processed by PostGarbageCollectionProcessing |
| 13305 // in reverse allocation order, so if second allocated handle is deleted, | 13329 // in reverse allocation order, so if second allocated handle is deleted, |
| 13306 // weak callback of the first handle would be able to 'reallocate' it. | 13330 // weak callback of the first handle would be able to 'reallocate' it. |
| 13307 handle1.SetWeak(&handle1, NewPersistentHandleCallback); | 13331 handle1.SetWeak(&handle1, NewPersistentHandleCallback); |
| 13308 handle2.Reset(); | 13332 handle2.Reset(); |
| 13309 CcTest::heap()->CollectAllGarbage(i::Heap::kAbortIncrementalMarkingMask); | 13333 CcTest::heap()->CollectAllGarbage(i::Heap::kAbortIncrementalMarkingMask); |
| 13310 } | 13334 } |
| 13311 | 13335 |
| 13312 | 13336 |
| 13313 v8::Persistent<v8::Object> to_be_disposed; | 13337 v8::Persistent<v8::Object> to_be_disposed; |
| 13314 | 13338 |
| 13315 void DisposeAndForceGcCallback( | 13339 void DisposeAndForceGcCallback( |
| 13316 const v8::WeakCallbackData<v8::Object, v8::Persistent<v8::Object> >& data) { | 13340 const v8::WeakCallbackData<v8::Object, v8::Persistent<v8::Object> >& data) { |
| 13317 to_be_disposed.Reset(); | 13341 to_be_disposed.Reset(); |
| 13318 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); | 13342 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); |
| 13319 data.GetParameter()->Reset(); | 13343 data.GetParameter()->Reset(); |
| 13320 } | 13344 } |
| 13321 | 13345 |
| 13322 | 13346 |
| 13323 THREADED_TEST(DoNotUseDeletedNodesInSecondLevelGc) { | 13347 THREADED_TEST(DoNotUseDeletedNodesInSecondLevelGc) { |
| 13324 LocalContext context; | 13348 LocalContext context; |
| 13325 v8::Isolate* isolate = context->GetIsolate(); | 13349 v8::Isolate* isolate = context->GetIsolate(); |
| 13326 | 13350 |
| 13327 v8::Persistent<v8::Object> handle1, handle2; | 13351 v8::Persistent<v8::Object> handle1, handle2; |
| 13328 { | 13352 { |
| 13329 v8::HandleScope scope(isolate); | 13353 v8::HandleScope scope(isolate); |
| 13330 handle1.Reset(isolate, v8::Object::New()); | 13354 handle1.Reset(isolate, v8::Object::New(isolate)); |
| 13331 handle2.Reset(isolate, v8::Object::New()); | 13355 handle2.Reset(isolate, v8::Object::New(isolate)); |
| 13332 } | 13356 } |
| 13333 handle1.SetWeak(&handle1, DisposeAndForceGcCallback); | 13357 handle1.SetWeak(&handle1, DisposeAndForceGcCallback); |
| 13334 to_be_disposed.Reset(isolate, handle2); | 13358 to_be_disposed.Reset(isolate, handle2); |
| 13335 CcTest::heap()->CollectAllGarbage(i::Heap::kAbortIncrementalMarkingMask); | 13359 CcTest::heap()->CollectAllGarbage(i::Heap::kAbortIncrementalMarkingMask); |
| 13336 } | 13360 } |
| 13337 | 13361 |
| 13338 void DisposingCallback( | 13362 void DisposingCallback( |
| 13339 const v8::WeakCallbackData<v8::Object, v8::Persistent<v8::Object> >& data) { | 13363 const v8::WeakCallbackData<v8::Object, v8::Persistent<v8::Object> >& data) { |
| 13340 data.GetParameter()->Reset(); | 13364 data.GetParameter()->Reset(); |
| 13341 } | 13365 } |
| 13342 | 13366 |
| 13343 void HandleCreatingCallback( | 13367 void HandleCreatingCallback( |
| 13344 const v8::WeakCallbackData<v8::Object, v8::Persistent<v8::Object> >& data) { | 13368 const v8::WeakCallbackData<v8::Object, v8::Persistent<v8::Object> >& data) { |
| 13345 v8::HandleScope scope(data.GetIsolate()); | 13369 v8::HandleScope scope(data.GetIsolate()); |
| 13346 v8::Persistent<v8::Object>(data.GetIsolate(), v8::Object::New()); | 13370 v8::Persistent<v8::Object>(data.GetIsolate(), |
| 13371 v8::Object::New(data.GetIsolate())); |
| 13347 data.GetParameter()->Reset(); | 13372 data.GetParameter()->Reset(); |
| 13348 } | 13373 } |
| 13349 | 13374 |
| 13350 | 13375 |
| 13351 THREADED_TEST(NoGlobalHandlesOrphaningDueToWeakCallback) { | 13376 THREADED_TEST(NoGlobalHandlesOrphaningDueToWeakCallback) { |
| 13352 LocalContext context; | 13377 LocalContext context; |
| 13353 v8::Isolate* isolate = context->GetIsolate(); | 13378 v8::Isolate* isolate = context->GetIsolate(); |
| 13354 | 13379 |
| 13355 v8::Persistent<v8::Object> handle1, handle2, handle3; | 13380 v8::Persistent<v8::Object> handle1, handle2, handle3; |
| 13356 { | 13381 { |
| 13357 v8::HandleScope scope(isolate); | 13382 v8::HandleScope scope(isolate); |
| 13358 handle3.Reset(isolate, v8::Object::New()); | 13383 handle3.Reset(isolate, v8::Object::New(isolate)); |
| 13359 handle2.Reset(isolate, v8::Object::New()); | 13384 handle2.Reset(isolate, v8::Object::New(isolate)); |
| 13360 handle1.Reset(isolate, v8::Object::New()); | 13385 handle1.Reset(isolate, v8::Object::New(isolate)); |
| 13361 } | 13386 } |
| 13362 handle2.SetWeak(&handle2, DisposingCallback); | 13387 handle2.SetWeak(&handle2, DisposingCallback); |
| 13363 handle3.SetWeak(&handle3, HandleCreatingCallback); | 13388 handle3.SetWeak(&handle3, HandleCreatingCallback); |
| 13364 CcTest::heap()->CollectAllGarbage(i::Heap::kAbortIncrementalMarkingMask); | 13389 CcTest::heap()->CollectAllGarbage(i::Heap::kAbortIncrementalMarkingMask); |
| 13365 } | 13390 } |
| 13366 | 13391 |
| 13367 | 13392 |
| 13368 THREADED_TEST(CheckForCrossContextObjectLiterals) { | 13393 THREADED_TEST(CheckForCrossContextObjectLiterals) { |
| 13369 v8::V8::Initialize(); | 13394 v8::V8::Initialize(); |
| 13370 | 13395 |
| (...skipping 726 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 14097 | 14122 |
| 14098 resource_name = "test1.js"; | 14123 resource_name = "test1.js"; |
| 14099 v8::ScriptOrigin origin1( | 14124 v8::ScriptOrigin origin1( |
| 14100 v8::String::NewFromUtf8(context->GetIsolate(), resource_name)); | 14125 v8::String::NewFromUtf8(context->GetIsolate(), resource_name)); |
| 14101 script = v8::Script::Compile(source, &origin1); | 14126 script = v8::Script::Compile(source, &origin1); |
| 14102 CheckTryCatchSourceInfo(script, resource_name, 0); | 14127 CheckTryCatchSourceInfo(script, resource_name, 0); |
| 14103 | 14128 |
| 14104 resource_name = "test2.js"; | 14129 resource_name = "test2.js"; |
| 14105 v8::ScriptOrigin origin2( | 14130 v8::ScriptOrigin origin2( |
| 14106 v8::String::NewFromUtf8(context->GetIsolate(), resource_name), | 14131 v8::String::NewFromUtf8(context->GetIsolate(), resource_name), |
| 14107 v8::Integer::New(7)); | 14132 v8::Integer::New(context->GetIsolate(), 7)); |
| 14108 script = v8::Script::Compile(source, &origin2); | 14133 script = v8::Script::Compile(source, &origin2); |
| 14109 CheckTryCatchSourceInfo(script, resource_name, 7); | 14134 CheckTryCatchSourceInfo(script, resource_name, 7); |
| 14110 } | 14135 } |
| 14111 | 14136 |
| 14112 | 14137 |
| 14113 THREADED_TEST(CompilationCache) { | 14138 THREADED_TEST(CompilationCache) { |
| 14114 LocalContext context; | 14139 LocalContext context; |
| 14115 v8::HandleScope scope(context->GetIsolate()); | 14140 v8::HandleScope scope(context->GetIsolate()); |
| 14116 v8::Handle<v8::String> source0 = | 14141 v8::Handle<v8::String> source0 = |
| 14117 v8::String::NewFromUtf8(context->GetIsolate(), "1234"); | 14142 v8::String::NewFromUtf8(context->GetIsolate(), "1234"); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 14154 THREADED_TEST(DateAccess) { | 14179 THREADED_TEST(DateAccess) { |
| 14155 LocalContext context; | 14180 LocalContext context; |
| 14156 v8::HandleScope scope(context->GetIsolate()); | 14181 v8::HandleScope scope(context->GetIsolate()); |
| 14157 v8::Handle<v8::Value> date = | 14182 v8::Handle<v8::Value> date = |
| 14158 v8::Date::New(context->GetIsolate(), 1224744689038.0); | 14183 v8::Date::New(context->GetIsolate(), 1224744689038.0); |
| 14159 CHECK(date->IsDate()); | 14184 CHECK(date->IsDate()); |
| 14160 CHECK_EQ(1224744689038.0, date.As<v8::Date>()->ValueOf()); | 14185 CHECK_EQ(1224744689038.0, date.As<v8::Date>()->ValueOf()); |
| 14161 } | 14186 } |
| 14162 | 14187 |
| 14163 | 14188 |
| 14164 void CheckProperties(v8::Handle<v8::Value> val, int elmc, const char* elmv[]) { | 14189 void CheckProperties(v8::Isolate* isolate, |
| 14190 v8::Handle<v8::Value> val, |
| 14191 int elmc, |
| 14192 const char* elmv[]) { |
| 14165 v8::Handle<v8::Object> obj = val.As<v8::Object>(); | 14193 v8::Handle<v8::Object> obj = val.As<v8::Object>(); |
| 14166 v8::Handle<v8::Array> props = obj->GetPropertyNames(); | 14194 v8::Handle<v8::Array> props = obj->GetPropertyNames(); |
| 14167 CHECK_EQ(elmc, props->Length()); | 14195 CHECK_EQ(elmc, props->Length()); |
| 14168 for (int i = 0; i < elmc; i++) { | 14196 for (int i = 0; i < elmc; i++) { |
| 14169 v8::String::Utf8Value elm(props->Get(v8::Integer::New(i))); | 14197 v8::String::Utf8Value elm(props->Get(v8::Integer::New(isolate, i))); |
| 14170 CHECK_EQ(elmv[i], *elm); | 14198 CHECK_EQ(elmv[i], *elm); |
| 14171 } | 14199 } |
| 14172 } | 14200 } |
| 14173 | 14201 |
| 14174 | 14202 |
| 14175 void CheckOwnProperties(v8::Handle<v8::Value> val, | 14203 void CheckOwnProperties(v8::Isolate* isolate, |
| 14204 v8::Handle<v8::Value> val, |
| 14176 int elmc, | 14205 int elmc, |
| 14177 const char* elmv[]) { | 14206 const char* elmv[]) { |
| 14178 v8::Handle<v8::Object> obj = val.As<v8::Object>(); | 14207 v8::Handle<v8::Object> obj = val.As<v8::Object>(); |
| 14179 v8::Handle<v8::Array> props = obj->GetOwnPropertyNames(); | 14208 v8::Handle<v8::Array> props = obj->GetOwnPropertyNames(); |
| 14180 CHECK_EQ(elmc, props->Length()); | 14209 CHECK_EQ(elmc, props->Length()); |
| 14181 for (int i = 0; i < elmc; i++) { | 14210 for (int i = 0; i < elmc; i++) { |
| 14182 v8::String::Utf8Value elm(props->Get(v8::Integer::New(i))); | 14211 v8::String::Utf8Value elm(props->Get(v8::Integer::New(isolate, i))); |
| 14183 CHECK_EQ(elmv[i], *elm); | 14212 CHECK_EQ(elmv[i], *elm); |
| 14184 } | 14213 } |
| 14185 } | 14214 } |
| 14186 | 14215 |
| 14187 | 14216 |
| 14188 THREADED_TEST(PropertyEnumeration) { | 14217 THREADED_TEST(PropertyEnumeration) { |
| 14189 LocalContext context; | 14218 LocalContext context; |
| 14190 v8::HandleScope scope(context->GetIsolate()); | 14219 v8::Isolate* isolate = context->GetIsolate(); |
| 14220 v8::HandleScope scope(isolate); |
| 14191 v8::Handle<v8::Value> obj = v8::Script::Compile(v8::String::NewFromUtf8( | 14221 v8::Handle<v8::Value> obj = v8::Script::Compile(v8::String::NewFromUtf8( |
| 14192 context->GetIsolate(), | 14222 context->GetIsolate(), |
| 14193 "var result = [];" | 14223 "var result = [];" |
| 14194 "result[0] = {};" | 14224 "result[0] = {};" |
| 14195 "result[1] = {a: 1, b: 2};" | 14225 "result[1] = {a: 1, b: 2};" |
| 14196 "result[2] = [1, 2, 3];" | 14226 "result[2] = [1, 2, 3];" |
| 14197 "var proto = {x: 1, y: 2, z: 3};" | 14227 "var proto = {x: 1, y: 2, z: 3};" |
| 14198 "var x = { __proto__: proto, w: 0, z: 1 };" | 14228 "var x = { __proto__: proto, w: 0, z: 1 };" |
| 14199 "result[3] = x;" | 14229 "result[3] = x;" |
| 14200 "result;"))->Run(); | 14230 "result;"))->Run(); |
| 14201 v8::Handle<v8::Array> elms = obj.As<v8::Array>(); | 14231 v8::Handle<v8::Array> elms = obj.As<v8::Array>(); |
| 14202 CHECK_EQ(4, elms->Length()); | 14232 CHECK_EQ(4, elms->Length()); |
| 14203 int elmc0 = 0; | 14233 int elmc0 = 0; |
| 14204 const char** elmv0 = NULL; | 14234 const char** elmv0 = NULL; |
| 14205 CheckProperties(elms->Get(v8::Integer::New(0)), elmc0, elmv0); | 14235 CheckProperties( |
| 14206 CheckOwnProperties(elms->Get(v8::Integer::New(0)), elmc0, elmv0); | 14236 isolate, elms->Get(v8::Integer::New(isolate, 0)), elmc0, elmv0); |
| 14237 CheckOwnProperties( |
| 14238 isolate, elms->Get(v8::Integer::New(isolate, 0)), elmc0, elmv0); |
| 14207 int elmc1 = 2; | 14239 int elmc1 = 2; |
| 14208 const char* elmv1[] = {"a", "b"}; | 14240 const char* elmv1[] = {"a", "b"}; |
| 14209 CheckProperties(elms->Get(v8::Integer::New(1)), elmc1, elmv1); | 14241 CheckProperties( |
| 14210 CheckOwnProperties(elms->Get(v8::Integer::New(1)), elmc1, elmv1); | 14242 isolate, elms->Get(v8::Integer::New(isolate, 1)), elmc1, elmv1); |
| 14243 CheckOwnProperties( |
| 14244 isolate, elms->Get(v8::Integer::New(isolate, 1)), elmc1, elmv1); |
| 14211 int elmc2 = 3; | 14245 int elmc2 = 3; |
| 14212 const char* elmv2[] = {"0", "1", "2"}; | 14246 const char* elmv2[] = {"0", "1", "2"}; |
| 14213 CheckProperties(elms->Get(v8::Integer::New(2)), elmc2, elmv2); | 14247 CheckProperties( |
| 14214 CheckOwnProperties(elms->Get(v8::Integer::New(2)), elmc2, elmv2); | 14248 isolate, elms->Get(v8::Integer::New(isolate, 2)), elmc2, elmv2); |
| 14249 CheckOwnProperties( |
| 14250 isolate, elms->Get(v8::Integer::New(isolate, 2)), elmc2, elmv2); |
| 14215 int elmc3 = 4; | 14251 int elmc3 = 4; |
| 14216 const char* elmv3[] = {"w", "z", "x", "y"}; | 14252 const char* elmv3[] = {"w", "z", "x", "y"}; |
| 14217 CheckProperties(elms->Get(v8::Integer::New(3)), elmc3, elmv3); | 14253 CheckProperties( |
| 14254 isolate, elms->Get(v8::Integer::New(isolate, 3)), elmc3, elmv3); |
| 14218 int elmc4 = 2; | 14255 int elmc4 = 2; |
| 14219 const char* elmv4[] = {"w", "z"}; | 14256 const char* elmv4[] = {"w", "z"}; |
| 14220 CheckOwnProperties(elms->Get(v8::Integer::New(3)), elmc4, elmv4); | 14257 CheckOwnProperties( |
| 14258 isolate, elms->Get(v8::Integer::New(isolate, 3)), elmc4, elmv4); |
| 14221 } | 14259 } |
| 14222 | 14260 |
| 14223 | 14261 |
| 14224 THREADED_TEST(PropertyEnumeration2) { | 14262 THREADED_TEST(PropertyEnumeration2) { |
| 14225 LocalContext context; | 14263 LocalContext context; |
| 14226 v8::HandleScope scope(context->GetIsolate()); | 14264 v8::Isolate* isolate = context->GetIsolate(); |
| 14265 v8::HandleScope scope(isolate); |
| 14227 v8::Handle<v8::Value> obj = v8::Script::Compile(v8::String::NewFromUtf8( | 14266 v8::Handle<v8::Value> obj = v8::Script::Compile(v8::String::NewFromUtf8( |
| 14228 context->GetIsolate(), | 14267 context->GetIsolate(), |
| 14229 "var result = [];" | 14268 "var result = [];" |
| 14230 "result[0] = {};" | 14269 "result[0] = {};" |
| 14231 "result[1] = {a: 1, b: 2};" | 14270 "result[1] = {a: 1, b: 2};" |
| 14232 "result[2] = [1, 2, 3];" | 14271 "result[2] = [1, 2, 3];" |
| 14233 "var proto = {x: 1, y: 2, z: 3};" | 14272 "var proto = {x: 1, y: 2, z: 3};" |
| 14234 "var x = { __proto__: proto, w: 0, z: 1 };" | 14273 "var x = { __proto__: proto, w: 0, z: 1 };" |
| 14235 "result[3] = x;" | 14274 "result[3] = x;" |
| 14236 "result;"))->Run(); | 14275 "result;"))->Run(); |
| 14237 v8::Handle<v8::Array> elms = obj.As<v8::Array>(); | 14276 v8::Handle<v8::Array> elms = obj.As<v8::Array>(); |
| 14238 CHECK_EQ(4, elms->Length()); | 14277 CHECK_EQ(4, elms->Length()); |
| 14239 int elmc0 = 0; | 14278 int elmc0 = 0; |
| 14240 const char** elmv0 = NULL; | 14279 const char** elmv0 = NULL; |
| 14241 CheckProperties(elms->Get(v8::Integer::New(0)), elmc0, elmv0); | 14280 CheckProperties(isolate, |
| 14281 elms->Get(v8::Integer::New(isolate, 0)), elmc0, elmv0); |
| 14242 | 14282 |
| 14243 v8::Handle<v8::Value> val = elms->Get(v8::Integer::New(0)); | 14283 v8::Handle<v8::Value> val = elms->Get(v8::Integer::New(isolate, 0)); |
| 14244 v8::Handle<v8::Array> props = val.As<v8::Object>()->GetPropertyNames(); | 14284 v8::Handle<v8::Array> props = val.As<v8::Object>()->GetPropertyNames(); |
| 14245 CHECK_EQ(0, props->Length()); | 14285 CHECK_EQ(0, props->Length()); |
| 14246 for (uint32_t i = 0; i < props->Length(); i++) { | 14286 for (uint32_t i = 0; i < props->Length(); i++) { |
| 14247 printf("p[%d]\n", i); | 14287 printf("p[%d]\n", i); |
| 14248 } | 14288 } |
| 14249 } | 14289 } |
| 14250 | 14290 |
| 14251 static bool NamedSetAccessBlocker(Local<v8::Object> obj, | 14291 static bool NamedSetAccessBlocker(Local<v8::Object> obj, |
| 14252 Local<Value> name, | 14292 Local<Value> name, |
| 14253 v8::AccessType type, | 14293 v8::AccessType type, |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 14307 // so that the constructor will force copying map. | 14347 // so that the constructor will force copying map. |
| 14308 // Cannot sprintf, gcc complains unsafety. | 14348 // Cannot sprintf, gcc complains unsafety. |
| 14309 char buf[4]; | 14349 char buf[4]; |
| 14310 for (char i = '0'; i <= '9' ; i++) { | 14350 for (char i = '0'; i <= '9' ; i++) { |
| 14311 buf[0] = i; | 14351 buf[0] = i; |
| 14312 for (char j = '0'; j <= '9'; j++) { | 14352 for (char j = '0'; j <= '9'; j++) { |
| 14313 buf[1] = j; | 14353 buf[1] = j; |
| 14314 for (char k = '0'; k <= '9'; k++) { | 14354 for (char k = '0'; k <= '9'; k++) { |
| 14315 buf[2] = k; | 14355 buf[2] = k; |
| 14316 buf[3] = 0; | 14356 buf[3] = 0; |
| 14317 templ->Set(v8_str(buf), v8::Number::New(k)); | 14357 templ->Set(v8_str(buf), v8::Number::New(context->GetIsolate(), k)); |
| 14318 } | 14358 } |
| 14319 } | 14359 } |
| 14320 } | 14360 } |
| 14321 | 14361 |
| 14322 Local<v8::Object> instance_1 = templ->NewInstance(); | 14362 Local<v8::Object> instance_1 = templ->NewInstance(); |
| 14323 context->Global()->Set(v8_str("obj_1"), instance_1); | 14363 context->Global()->Set(v8_str("obj_1"), instance_1); |
| 14324 | 14364 |
| 14325 Local<Value> value_1 = CompileRun("obj_1.a"); | 14365 Local<Value> value_1 = CompileRun("obj_1.a"); |
| 14326 CHECK(value_1->IsUndefined()); | 14366 CHECK(value_1->IsUndefined()); |
| 14327 | 14367 |
| (...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 14738 Local<Value> value = CompileRun("var instance = new other.C(); instance.x"); | 14778 Local<Value> value = CompileRun("var instance = new other.C(); instance.x"); |
| 14739 CHECK(value->IsInt32()); | 14779 CHECK(value->IsInt32()); |
| 14740 CHECK_EQ(42, value->Int32Value()); | 14780 CHECK_EQ(42, value->Int32Value()); |
| 14741 context1->Exit(); | 14781 context1->Exit(); |
| 14742 } | 14782 } |
| 14743 | 14783 |
| 14744 | 14784 |
| 14745 // Verify that we can clone an object | 14785 // Verify that we can clone an object |
| 14746 TEST(ObjectClone) { | 14786 TEST(ObjectClone) { |
| 14747 LocalContext env; | 14787 LocalContext env; |
| 14748 v8::HandleScope scope(env->GetIsolate()); | 14788 v8::Isolate* isolate = env->GetIsolate(); |
| 14789 v8::HandleScope scope(isolate); |
| 14749 | 14790 |
| 14750 const char* sample = | 14791 const char* sample = |
| 14751 "var rv = {};" \ | 14792 "var rv = {};" \ |
| 14752 "rv.alpha = 'hello';" \ | 14793 "rv.alpha = 'hello';" \ |
| 14753 "rv.beta = 123;" \ | 14794 "rv.beta = 123;" \ |
| 14754 "rv;"; | 14795 "rv;"; |
| 14755 | 14796 |
| 14756 // Create an object, verify basics. | 14797 // Create an object, verify basics. |
| 14757 Local<Value> val = CompileRun(sample); | 14798 Local<Value> val = CompileRun(sample); |
| 14758 CHECK(val->IsObject()); | 14799 CHECK(val->IsObject()); |
| 14759 Local<v8::Object> obj = val.As<v8::Object>(); | 14800 Local<v8::Object> obj = val.As<v8::Object>(); |
| 14760 obj->Set(v8_str("gamma"), v8_str("cloneme")); | 14801 obj->Set(v8_str("gamma"), v8_str("cloneme")); |
| 14761 | 14802 |
| 14762 CHECK_EQ(v8_str("hello"), obj->Get(v8_str("alpha"))); | 14803 CHECK_EQ(v8_str("hello"), obj->Get(v8_str("alpha"))); |
| 14763 CHECK_EQ(v8::Integer::New(123), obj->Get(v8_str("beta"))); | 14804 CHECK_EQ(v8::Integer::New(isolate, 123), obj->Get(v8_str("beta"))); |
| 14764 CHECK_EQ(v8_str("cloneme"), obj->Get(v8_str("gamma"))); | 14805 CHECK_EQ(v8_str("cloneme"), obj->Get(v8_str("gamma"))); |
| 14765 | 14806 |
| 14766 // Clone it. | 14807 // Clone it. |
| 14767 Local<v8::Object> clone = obj->Clone(); | 14808 Local<v8::Object> clone = obj->Clone(); |
| 14768 CHECK_EQ(v8_str("hello"), clone->Get(v8_str("alpha"))); | 14809 CHECK_EQ(v8_str("hello"), clone->Get(v8_str("alpha"))); |
| 14769 CHECK_EQ(v8::Integer::New(123), clone->Get(v8_str("beta"))); | 14810 CHECK_EQ(v8::Integer::New(isolate, 123), clone->Get(v8_str("beta"))); |
| 14770 CHECK_EQ(v8_str("cloneme"), clone->Get(v8_str("gamma"))); | 14811 CHECK_EQ(v8_str("cloneme"), clone->Get(v8_str("gamma"))); |
| 14771 | 14812 |
| 14772 // Set a property on the clone, verify each object. | 14813 // Set a property on the clone, verify each object. |
| 14773 clone->Set(v8_str("beta"), v8::Integer::New(456)); | 14814 clone->Set(v8_str("beta"), v8::Integer::New(isolate, 456)); |
| 14774 CHECK_EQ(v8::Integer::New(123), obj->Get(v8_str("beta"))); | 14815 CHECK_EQ(v8::Integer::New(isolate, 123), obj->Get(v8_str("beta"))); |
| 14775 CHECK_EQ(v8::Integer::New(456), clone->Get(v8_str("beta"))); | 14816 CHECK_EQ(v8::Integer::New(isolate, 456), clone->Get(v8_str("beta"))); |
| 14776 } | 14817 } |
| 14777 | 14818 |
| 14778 | 14819 |
| 14779 class AsciiVectorResource : public v8::String::ExternalAsciiStringResource { | 14820 class AsciiVectorResource : public v8::String::ExternalAsciiStringResource { |
| 14780 public: | 14821 public: |
| 14781 explicit AsciiVectorResource(i::Vector<const char> vector) | 14822 explicit AsciiVectorResource(i::Vector<const char> vector) |
| 14782 : data_(vector) {} | 14823 : data_(vector) {} |
| 14783 virtual ~AsciiVectorResource() {} | 14824 virtual ~AsciiVectorResource() {} |
| 14784 virtual size_t length() const { return data_.length(); } | 14825 virtual size_t length() const { return data_.length(); } |
| 14785 virtual const char* data() const { return data_.start(); } | 14826 virtual const char* data() const { return data_.start(); } |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 14993 regexp_interruption_data.string.Reset(); | 15034 regexp_interruption_data.string.Reset(); |
| 14994 } | 15035 } |
| 14995 | 15036 |
| 14996 #endif // V8_INTERPRETED_REGEXP | 15037 #endif // V8_INTERPRETED_REGEXP |
| 14997 | 15038 |
| 14998 | 15039 |
| 14999 // Test that we cannot set a property on the global object if there | 15040 // Test that we cannot set a property on the global object if there |
| 15000 // is a read-only property in the prototype chain. | 15041 // is a read-only property in the prototype chain. |
| 15001 TEST(ReadOnlyPropertyInGlobalProto) { | 15042 TEST(ReadOnlyPropertyInGlobalProto) { |
| 15002 i::FLAG_es5_readonly = true; | 15043 i::FLAG_es5_readonly = true; |
| 15003 v8::HandleScope scope(CcTest::isolate()); | 15044 v8::Isolate* isolate = CcTest::isolate(); |
| 15045 v8::HandleScope scope(isolate); |
| 15004 v8::Handle<v8::ObjectTemplate> templ = v8::ObjectTemplate::New(); | 15046 v8::Handle<v8::ObjectTemplate> templ = v8::ObjectTemplate::New(); |
| 15005 LocalContext context(0, templ); | 15047 LocalContext context(0, templ); |
| 15006 v8::Handle<v8::Object> global = context->Global(); | 15048 v8::Handle<v8::Object> global = context->Global(); |
| 15007 v8::Handle<v8::Object> global_proto = | 15049 v8::Handle<v8::Object> global_proto = |
| 15008 v8::Handle<v8::Object>::Cast(global->Get(v8_str("__proto__"))); | 15050 v8::Handle<v8::Object>::Cast(global->Get(v8_str("__proto__"))); |
| 15009 global_proto->Set(v8_str("x"), v8::Integer::New(0), v8::ReadOnly); | 15051 global_proto->Set(v8_str("x"), v8::Integer::New(isolate, 0), v8::ReadOnly); |
| 15010 global_proto->Set(v8_str("y"), v8::Integer::New(0), v8::ReadOnly); | 15052 global_proto->Set(v8_str("y"), v8::Integer::New(isolate, 0), v8::ReadOnly); |
| 15011 // Check without 'eval' or 'with'. | 15053 // Check without 'eval' or 'with'. |
| 15012 v8::Handle<v8::Value> res = | 15054 v8::Handle<v8::Value> res = |
| 15013 CompileRun("function f() { x = 42; return x; }; f()"); | 15055 CompileRun("function f() { x = 42; return x; }; f()"); |
| 15014 CHECK_EQ(v8::Integer::New(0), res); | 15056 CHECK_EQ(v8::Integer::New(isolate, 0), res); |
| 15015 // Check with 'eval'. | 15057 // Check with 'eval'. |
| 15016 res = CompileRun("function f() { eval('1'); y = 43; return y; }; f()"); | 15058 res = CompileRun("function f() { eval('1'); y = 43; return y; }; f()"); |
| 15017 CHECK_EQ(v8::Integer::New(0), res); | 15059 CHECK_EQ(v8::Integer::New(isolate, 0), res); |
| 15018 // Check with 'with'. | 15060 // Check with 'with'. |
| 15019 res = CompileRun("function f() { with (this) { y = 44 }; return y; }; f()"); | 15061 res = CompileRun("function f() { with (this) { y = 44 }; return y; }; f()"); |
| 15020 CHECK_EQ(v8::Integer::New(0), res); | 15062 CHECK_EQ(v8::Integer::New(isolate, 0), res); |
| 15021 } | 15063 } |
| 15022 | 15064 |
| 15023 static int force_set_set_count = 0; | 15065 static int force_set_set_count = 0; |
| 15024 static int force_set_get_count = 0; | 15066 static int force_set_get_count = 0; |
| 15025 bool pass_on_get = false; | 15067 bool pass_on_get = false; |
| 15026 | 15068 |
| 15027 static void ForceSetGetter(v8::Local<v8::String> name, | 15069 static void ForceSetGetter(v8::Local<v8::String> name, |
| 15028 const v8::PropertyCallbackInfo<v8::Value>& info) { | 15070 const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 15029 force_set_get_count++; | 15071 force_set_get_count++; |
| 15030 if (pass_on_get) { | 15072 if (pass_on_get) { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 15046 force_set_set_count++; | 15088 force_set_set_count++; |
| 15047 info.GetReturnValue().SetUndefined(); | 15089 info.GetReturnValue().SetUndefined(); |
| 15048 } | 15090 } |
| 15049 | 15091 |
| 15050 | 15092 |
| 15051 TEST(ForceSet) { | 15093 TEST(ForceSet) { |
| 15052 force_set_get_count = 0; | 15094 force_set_get_count = 0; |
| 15053 force_set_set_count = 0; | 15095 force_set_set_count = 0; |
| 15054 pass_on_get = false; | 15096 pass_on_get = false; |
| 15055 | 15097 |
| 15056 v8::HandleScope scope(CcTest::isolate()); | 15098 v8::Isolate* isolate = CcTest::isolate(); |
| 15099 v8::HandleScope scope(isolate); |
| 15057 v8::Handle<v8::ObjectTemplate> templ = v8::ObjectTemplate::New(); | 15100 v8::Handle<v8::ObjectTemplate> templ = v8::ObjectTemplate::New(); |
| 15058 v8::Handle<v8::String> access_property = | 15101 v8::Handle<v8::String> access_property = |
| 15059 v8::String::NewFromUtf8(CcTest::isolate(), "a"); | 15102 v8::String::NewFromUtf8(isolate, "a"); |
| 15060 templ->SetAccessor(access_property, ForceSetGetter, ForceSetSetter); | 15103 templ->SetAccessor(access_property, ForceSetGetter, ForceSetSetter); |
| 15061 LocalContext context(NULL, templ); | 15104 LocalContext context(NULL, templ); |
| 15062 v8::Handle<v8::Object> global = context->Global(); | 15105 v8::Handle<v8::Object> global = context->Global(); |
| 15063 | 15106 |
| 15064 // Ordinary properties | 15107 // Ordinary properties |
| 15065 v8::Handle<v8::String> simple_property = | 15108 v8::Handle<v8::String> simple_property = |
| 15066 v8::String::NewFromUtf8(CcTest::isolate(), "p"); | 15109 v8::String::NewFromUtf8(isolate, "p"); |
| 15067 global->Set(simple_property, v8::Int32::New(4), v8::ReadOnly); | 15110 global->Set(simple_property, v8::Int32::New(isolate, 4), v8::ReadOnly); |
| 15068 CHECK_EQ(4, global->Get(simple_property)->Int32Value()); | 15111 CHECK_EQ(4, global->Get(simple_property)->Int32Value()); |
| 15069 // This should fail because the property is read-only | 15112 // This should fail because the property is read-only |
| 15070 global->Set(simple_property, v8::Int32::New(5)); | 15113 global->Set(simple_property, v8::Int32::New(isolate, 5)); |
| 15071 CHECK_EQ(4, global->Get(simple_property)->Int32Value()); | 15114 CHECK_EQ(4, global->Get(simple_property)->Int32Value()); |
| 15072 // This should succeed even though the property is read-only | 15115 // This should succeed even though the property is read-only |
| 15073 global->ForceSet(simple_property, v8::Int32::New(6)); | 15116 global->ForceSet(simple_property, v8::Int32::New(isolate, 6)); |
| 15074 CHECK_EQ(6, global->Get(simple_property)->Int32Value()); | 15117 CHECK_EQ(6, global->Get(simple_property)->Int32Value()); |
| 15075 | 15118 |
| 15076 // Accessors | 15119 // Accessors |
| 15077 CHECK_EQ(0, force_set_set_count); | 15120 CHECK_EQ(0, force_set_set_count); |
| 15078 CHECK_EQ(0, force_set_get_count); | 15121 CHECK_EQ(0, force_set_get_count); |
| 15079 CHECK_EQ(3, global->Get(access_property)->Int32Value()); | 15122 CHECK_EQ(3, global->Get(access_property)->Int32Value()); |
| 15080 // CHECK_EQ the property shouldn't override it, just call the setter | 15123 // CHECK_EQ the property shouldn't override it, just call the setter |
| 15081 // which in this case does nothing. | 15124 // which in this case does nothing. |
| 15082 global->Set(access_property, v8::Int32::New(7)); | 15125 global->Set(access_property, v8::Int32::New(isolate, 7)); |
| 15083 CHECK_EQ(3, global->Get(access_property)->Int32Value()); | 15126 CHECK_EQ(3, global->Get(access_property)->Int32Value()); |
| 15084 CHECK_EQ(1, force_set_set_count); | 15127 CHECK_EQ(1, force_set_set_count); |
| 15085 CHECK_EQ(2, force_set_get_count); | 15128 CHECK_EQ(2, force_set_get_count); |
| 15086 // Forcing the property to be set should override the accessor without | 15129 // Forcing the property to be set should override the accessor without |
| 15087 // calling it | 15130 // calling it |
| 15088 global->ForceSet(access_property, v8::Int32::New(8)); | 15131 global->ForceSet(access_property, v8::Int32::New(isolate, 8)); |
| 15089 CHECK_EQ(8, global->Get(access_property)->Int32Value()); | 15132 CHECK_EQ(8, global->Get(access_property)->Int32Value()); |
| 15090 CHECK_EQ(1, force_set_set_count); | 15133 CHECK_EQ(1, force_set_set_count); |
| 15091 CHECK_EQ(2, force_set_get_count); | 15134 CHECK_EQ(2, force_set_get_count); |
| 15092 } | 15135 } |
| 15093 | 15136 |
| 15094 | 15137 |
| 15095 TEST(ForceSetWithInterceptor) { | 15138 TEST(ForceSetWithInterceptor) { |
| 15096 force_set_get_count = 0; | 15139 force_set_get_count = 0; |
| 15097 force_set_set_count = 0; | 15140 force_set_set_count = 0; |
| 15098 pass_on_get = false; | 15141 pass_on_get = false; |
| 15099 | 15142 |
| 15100 v8::HandleScope scope(CcTest::isolate()); | 15143 v8::Isolate* isolate = CcTest::isolate(); |
| 15144 v8::HandleScope scope(isolate); |
| 15101 v8::Handle<v8::ObjectTemplate> templ = v8::ObjectTemplate::New(); | 15145 v8::Handle<v8::ObjectTemplate> templ = v8::ObjectTemplate::New(); |
| 15102 templ->SetNamedPropertyHandler(ForceSetGetter, ForceSetInterceptSetter); | 15146 templ->SetNamedPropertyHandler(ForceSetGetter, ForceSetInterceptSetter); |
| 15103 LocalContext context(NULL, templ); | 15147 LocalContext context(NULL, templ); |
| 15104 v8::Handle<v8::Object> global = context->Global(); | 15148 v8::Handle<v8::Object> global = context->Global(); |
| 15105 | 15149 |
| 15106 v8::Handle<v8::String> some_property = | 15150 v8::Handle<v8::String> some_property = |
| 15107 v8::String::NewFromUtf8(CcTest::isolate(), "a"); | 15151 v8::String::NewFromUtf8(isolate, "a"); |
| 15108 CHECK_EQ(0, force_set_set_count); | 15152 CHECK_EQ(0, force_set_set_count); |
| 15109 CHECK_EQ(0, force_set_get_count); | 15153 CHECK_EQ(0, force_set_get_count); |
| 15110 CHECK_EQ(3, global->Get(some_property)->Int32Value()); | 15154 CHECK_EQ(3, global->Get(some_property)->Int32Value()); |
| 15111 // Setting the property shouldn't override it, just call the setter | 15155 // Setting the property shouldn't override it, just call the setter |
| 15112 // which in this case does nothing. | 15156 // which in this case does nothing. |
| 15113 global->Set(some_property, v8::Int32::New(7)); | 15157 global->Set(some_property, v8::Int32::New(isolate, 7)); |
| 15114 CHECK_EQ(3, global->Get(some_property)->Int32Value()); | 15158 CHECK_EQ(3, global->Get(some_property)->Int32Value()); |
| 15115 CHECK_EQ(1, force_set_set_count); | 15159 CHECK_EQ(1, force_set_set_count); |
| 15116 CHECK_EQ(2, force_set_get_count); | 15160 CHECK_EQ(2, force_set_get_count); |
| 15117 // Getting the property when the interceptor returns an empty handle | 15161 // Getting the property when the interceptor returns an empty handle |
| 15118 // should yield undefined, since the property isn't present on the | 15162 // should yield undefined, since the property isn't present on the |
| 15119 // object itself yet. | 15163 // object itself yet. |
| 15120 pass_on_get = true; | 15164 pass_on_get = true; |
| 15121 CHECK(global->Get(some_property)->IsUndefined()); | 15165 CHECK(global->Get(some_property)->IsUndefined()); |
| 15122 CHECK_EQ(1, force_set_set_count); | 15166 CHECK_EQ(1, force_set_set_count); |
| 15123 CHECK_EQ(3, force_set_get_count); | 15167 CHECK_EQ(3, force_set_get_count); |
| 15124 // Forcing the property to be set should cause the value to be | 15168 // Forcing the property to be set should cause the value to be |
| 15125 // set locally without calling the interceptor. | 15169 // set locally without calling the interceptor. |
| 15126 global->ForceSet(some_property, v8::Int32::New(8)); | 15170 global->ForceSet(some_property, v8::Int32::New(isolate, 8)); |
| 15127 CHECK_EQ(8, global->Get(some_property)->Int32Value()); | 15171 CHECK_EQ(8, global->Get(some_property)->Int32Value()); |
| 15128 CHECK_EQ(1, force_set_set_count); | 15172 CHECK_EQ(1, force_set_set_count); |
| 15129 CHECK_EQ(4, force_set_get_count); | 15173 CHECK_EQ(4, force_set_get_count); |
| 15130 // Reenabling the interceptor should cause it to take precedence over | 15174 // Reenabling the interceptor should cause it to take precedence over |
| 15131 // the property | 15175 // the property |
| 15132 pass_on_get = false; | 15176 pass_on_get = false; |
| 15133 CHECK_EQ(3, global->Get(some_property)->Int32Value()); | 15177 CHECK_EQ(3, global->Get(some_property)->Int32Value()); |
| 15134 CHECK_EQ(1, force_set_set_count); | 15178 CHECK_EQ(1, force_set_set_count); |
| 15135 CHECK_EQ(5, force_set_get_count); | 15179 CHECK_EQ(5, force_set_get_count); |
| 15136 // The interceptor should also work for other properties | 15180 // The interceptor should also work for other properties |
| 15137 CHECK_EQ(3, global->Get(v8::String::NewFromUtf8(CcTest::isolate(), "b")) | 15181 CHECK_EQ(3, global->Get(v8::String::NewFromUtf8(isolate, "b")) |
| 15138 ->Int32Value()); | 15182 ->Int32Value()); |
| 15139 CHECK_EQ(1, force_set_set_count); | 15183 CHECK_EQ(1, force_set_set_count); |
| 15140 CHECK_EQ(6, force_set_get_count); | 15184 CHECK_EQ(6, force_set_get_count); |
| 15141 } | 15185 } |
| 15142 | 15186 |
| 15143 | 15187 |
| 15144 THREADED_TEST(ForceDelete) { | 15188 THREADED_TEST(ForceDelete) { |
| 15145 v8::HandleScope scope(CcTest::isolate()); | 15189 v8::Isolate* isolate = CcTest::isolate(); |
| 15190 v8::HandleScope scope(isolate); |
| 15146 v8::Handle<v8::ObjectTemplate> templ = v8::ObjectTemplate::New(); | 15191 v8::Handle<v8::ObjectTemplate> templ = v8::ObjectTemplate::New(); |
| 15147 LocalContext context(NULL, templ); | 15192 LocalContext context(NULL, templ); |
| 15148 v8::Handle<v8::Object> global = context->Global(); | 15193 v8::Handle<v8::Object> global = context->Global(); |
| 15149 | 15194 |
| 15150 // Ordinary properties | 15195 // Ordinary properties |
| 15151 v8::Handle<v8::String> simple_property = | 15196 v8::Handle<v8::String> simple_property = |
| 15152 v8::String::NewFromUtf8(CcTest::isolate(), "p"); | 15197 v8::String::NewFromUtf8(isolate, "p"); |
| 15153 global->Set(simple_property, v8::Int32::New(4), v8::DontDelete); | 15198 global->Set(simple_property, v8::Int32::New(isolate, 4), v8::DontDelete); |
| 15154 CHECK_EQ(4, global->Get(simple_property)->Int32Value()); | 15199 CHECK_EQ(4, global->Get(simple_property)->Int32Value()); |
| 15155 // This should fail because the property is dont-delete. | 15200 // This should fail because the property is dont-delete. |
| 15156 CHECK(!global->Delete(simple_property)); | 15201 CHECK(!global->Delete(simple_property)); |
| 15157 CHECK_EQ(4, global->Get(simple_property)->Int32Value()); | 15202 CHECK_EQ(4, global->Get(simple_property)->Int32Value()); |
| 15158 // This should succeed even though the property is dont-delete. | 15203 // This should succeed even though the property is dont-delete. |
| 15159 CHECK(global->ForceDelete(simple_property)); | 15204 CHECK(global->ForceDelete(simple_property)); |
| 15160 CHECK(global->Get(simple_property)->IsUndefined()); | 15205 CHECK(global->Get(simple_property)->IsUndefined()); |
| 15161 } | 15206 } |
| 15162 | 15207 |
| 15163 | 15208 |
| 15164 static int force_delete_interceptor_count = 0; | 15209 static int force_delete_interceptor_count = 0; |
| 15165 static bool pass_on_delete = false; | 15210 static bool pass_on_delete = false; |
| 15166 | 15211 |
| 15167 | 15212 |
| 15168 static void ForceDeleteDeleter( | 15213 static void ForceDeleteDeleter( |
| 15169 v8::Local<v8::String> name, | 15214 v8::Local<v8::String> name, |
| 15170 const v8::PropertyCallbackInfo<v8::Boolean>& info) { | 15215 const v8::PropertyCallbackInfo<v8::Boolean>& info) { |
| 15171 force_delete_interceptor_count++; | 15216 force_delete_interceptor_count++; |
| 15172 if (pass_on_delete) return; | 15217 if (pass_on_delete) return; |
| 15173 info.GetReturnValue().Set(true); | 15218 info.GetReturnValue().Set(true); |
| 15174 } | 15219 } |
| 15175 | 15220 |
| 15176 | 15221 |
| 15177 THREADED_TEST(ForceDeleteWithInterceptor) { | 15222 THREADED_TEST(ForceDeleteWithInterceptor) { |
| 15178 force_delete_interceptor_count = 0; | 15223 force_delete_interceptor_count = 0; |
| 15179 pass_on_delete = false; | 15224 pass_on_delete = false; |
| 15180 | 15225 |
| 15181 v8::HandleScope scope(CcTest::isolate()); | 15226 v8::Isolate* isolate = CcTest::isolate(); |
| 15227 v8::HandleScope scope(isolate); |
| 15182 v8::Handle<v8::ObjectTemplate> templ = v8::ObjectTemplate::New(); | 15228 v8::Handle<v8::ObjectTemplate> templ = v8::ObjectTemplate::New(); |
| 15183 templ->SetNamedPropertyHandler(0, 0, 0, ForceDeleteDeleter); | 15229 templ->SetNamedPropertyHandler(0, 0, 0, ForceDeleteDeleter); |
| 15184 LocalContext context(NULL, templ); | 15230 LocalContext context(NULL, templ); |
| 15185 v8::Handle<v8::Object> global = context->Global(); | 15231 v8::Handle<v8::Object> global = context->Global(); |
| 15186 | 15232 |
| 15187 v8::Handle<v8::String> some_property = | 15233 v8::Handle<v8::String> some_property = |
| 15188 v8::String::NewFromUtf8(CcTest::isolate(), "a"); | 15234 v8::String::NewFromUtf8(isolate, "a"); |
| 15189 global->Set(some_property, v8::Integer::New(42), v8::DontDelete); | 15235 global->Set(some_property, v8::Integer::New(isolate, 42), v8::DontDelete); |
| 15190 | 15236 |
| 15191 // Deleting a property should get intercepted and nothing should | 15237 // Deleting a property should get intercepted and nothing should |
| 15192 // happen. | 15238 // happen. |
| 15193 CHECK_EQ(0, force_delete_interceptor_count); | 15239 CHECK_EQ(0, force_delete_interceptor_count); |
| 15194 CHECK(global->Delete(some_property)); | 15240 CHECK(global->Delete(some_property)); |
| 15195 CHECK_EQ(1, force_delete_interceptor_count); | 15241 CHECK_EQ(1, force_delete_interceptor_count); |
| 15196 CHECK_EQ(42, global->Get(some_property)->Int32Value()); | 15242 CHECK_EQ(42, global->Get(some_property)->Int32Value()); |
| 15197 // Deleting the property when the interceptor returns an empty | 15243 // Deleting the property when the interceptor returns an empty |
| 15198 // handle should not delete the property since it is DontDelete. | 15244 // handle should not delete the property since it is DontDelete. |
| 15199 pass_on_delete = true; | 15245 pass_on_delete = true; |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 15362 | 15408 |
| 15363 // Regression test for issue 398. | 15409 // Regression test for issue 398. |
| 15364 // If a function is added to an object, creating a constant function | 15410 // If a function is added to an object, creating a constant function |
| 15365 // field, and the result is cloned, replacing the constant function on the | 15411 // field, and the result is cloned, replacing the constant function on the |
| 15366 // original should not affect the clone. | 15412 // original should not affect the clone. |
| 15367 // See http://code.google.com/p/v8/issues/detail?id=398 | 15413 // See http://code.google.com/p/v8/issues/detail?id=398 |
| 15368 THREADED_TEST(ReplaceConstantFunction) { | 15414 THREADED_TEST(ReplaceConstantFunction) { |
| 15369 LocalContext context; | 15415 LocalContext context; |
| 15370 v8::Isolate* isolate = context->GetIsolate(); | 15416 v8::Isolate* isolate = context->GetIsolate(); |
| 15371 v8::HandleScope scope(isolate); | 15417 v8::HandleScope scope(isolate); |
| 15372 v8::Handle<v8::Object> obj = v8::Object::New(); | 15418 v8::Handle<v8::Object> obj = v8::Object::New(isolate); |
| 15373 v8::Handle<v8::FunctionTemplate> func_templ = | 15419 v8::Handle<v8::FunctionTemplate> func_templ = |
| 15374 v8::FunctionTemplate::New(isolate); | 15420 v8::FunctionTemplate::New(isolate); |
| 15375 v8::Handle<v8::String> foo_string = | 15421 v8::Handle<v8::String> foo_string = |
| 15376 v8::String::NewFromUtf8(isolate, "foo"); | 15422 v8::String::NewFromUtf8(isolate, "foo"); |
| 15377 obj->Set(foo_string, func_templ->GetFunction()); | 15423 obj->Set(foo_string, func_templ->GetFunction()); |
| 15378 v8::Handle<v8::Object> obj_clone = obj->Clone(); | 15424 v8::Handle<v8::Object> obj_clone = obj->Clone(); |
| 15379 obj_clone->Set(foo_string, | 15425 obj_clone->Set(foo_string, |
| 15380 v8::String::NewFromUtf8(isolate, "Hello")); | 15426 v8::String::NewFromUtf8(isolate, "Hello")); |
| 15381 CHECK(!obj->Get(foo_string)->IsUndefined()); | 15427 CHECK(!obj->Get(foo_string)->IsUndefined()); |
| 15382 } | 15428 } |
| (...skipping 25 matching lines...) Expand all Loading... |
| 15408 for (int i = 0; i < kElementCount; i++) { | 15454 for (int i = 0; i < kElementCount; i++) { |
| 15409 pixels->set(i, i % 256); | 15455 pixels->set(i, i % 256); |
| 15410 } | 15456 } |
| 15411 // Force GC to trigger verification. | 15457 // Force GC to trigger verification. |
| 15412 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); | 15458 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); |
| 15413 for (int i = 0; i < kElementCount; i++) { | 15459 for (int i = 0; i < kElementCount; i++) { |
| 15414 CHECK_EQ(i % 256, pixels->get_scalar(i)); | 15460 CHECK_EQ(i % 256, pixels->get_scalar(i)); |
| 15415 CHECK_EQ(i % 256, pixel_data[i]); | 15461 CHECK_EQ(i % 256, pixel_data[i]); |
| 15416 } | 15462 } |
| 15417 | 15463 |
| 15418 v8::Handle<v8::Object> obj = v8::Object::New(); | 15464 v8::Handle<v8::Object> obj = v8::Object::New(context->GetIsolate()); |
| 15419 i::Handle<i::JSObject> jsobj = v8::Utils::OpenHandle(*obj); | 15465 i::Handle<i::JSObject> jsobj = v8::Utils::OpenHandle(*obj); |
| 15420 // Set the elements to be the pixels. | 15466 // Set the elements to be the pixels. |
| 15421 // jsobj->set_elements(*pixels); | 15467 // jsobj->set_elements(*pixels); |
| 15422 obj->SetIndexedPropertiesToPixelData(pixel_data, kElementCount); | 15468 obj->SetIndexedPropertiesToPixelData(pixel_data, kElementCount); |
| 15423 CheckElementValue(isolate, 1, jsobj, 1); | 15469 CheckElementValue(isolate, 1, jsobj, 1); |
| 15424 obj->Set(v8_str("field"), v8::Int32::New(1503)); | 15470 obj->Set(v8_str("field"), v8::Int32::New(CcTest::isolate(), 1503)); |
| 15425 context->Global()->Set(v8_str("pixels"), obj); | 15471 context->Global()->Set(v8_str("pixels"), obj); |
| 15426 v8::Handle<v8::Value> result = CompileRun("pixels.field"); | 15472 v8::Handle<v8::Value> result = CompileRun("pixels.field"); |
| 15427 CHECK_EQ(1503, result->Int32Value()); | 15473 CHECK_EQ(1503, result->Int32Value()); |
| 15428 result = CompileRun("pixels[1]"); | 15474 result = CompileRun("pixels[1]"); |
| 15429 CHECK_EQ(1, result->Int32Value()); | 15475 CHECK_EQ(1, result->Int32Value()); |
| 15430 | 15476 |
| 15431 result = CompileRun("var sum = 0;" | 15477 result = CompileRun("var sum = 0;" |
| 15432 "for (var i = 0; i < 8; i++) {" | 15478 "for (var i = 0; i < 8; i++) {" |
| 15433 " sum += pixels[i] = pixels[i] = -i;" | 15479 " sum += pixels[i] = pixels[i] = -i;" |
| 15434 "}" | 15480 "}" |
| (...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 15773 | 15819 |
| 15774 free(pixel_data); | 15820 free(pixel_data); |
| 15775 } | 15821 } |
| 15776 | 15822 |
| 15777 | 15823 |
| 15778 THREADED_TEST(PixelArrayInfo) { | 15824 THREADED_TEST(PixelArrayInfo) { |
| 15779 LocalContext context; | 15825 LocalContext context; |
| 15780 v8::HandleScope scope(context->GetIsolate()); | 15826 v8::HandleScope scope(context->GetIsolate()); |
| 15781 for (int size = 0; size < 100; size += 10) { | 15827 for (int size = 0; size < 100; size += 10) { |
| 15782 uint8_t* pixel_data = reinterpret_cast<uint8_t*>(malloc(size)); | 15828 uint8_t* pixel_data = reinterpret_cast<uint8_t*>(malloc(size)); |
| 15783 v8::Handle<v8::Object> obj = v8::Object::New(); | 15829 v8::Handle<v8::Object> obj = v8::Object::New(context->GetIsolate()); |
| 15784 obj->SetIndexedPropertiesToPixelData(pixel_data, size); | 15830 obj->SetIndexedPropertiesToPixelData(pixel_data, size); |
| 15785 CHECK(obj->HasIndexedPropertiesInPixelData()); | 15831 CHECK(obj->HasIndexedPropertiesInPixelData()); |
| 15786 CHECK_EQ(pixel_data, obj->GetIndexedPropertiesPixelData()); | 15832 CHECK_EQ(pixel_data, obj->GetIndexedPropertiesPixelData()); |
| 15787 CHECK_EQ(size, obj->GetIndexedPropertiesPixelDataLength()); | 15833 CHECK_EQ(size, obj->GetIndexedPropertiesPixelDataLength()); |
| 15788 free(pixel_data); | 15834 free(pixel_data); |
| 15789 } | 15835 } |
| 15790 } | 15836 } |
| 15791 | 15837 |
| 15792 | 15838 |
| 15793 static void NotHandledIndexedPropertyGetter( | 15839 static void NotHandledIndexedPropertyGetter( |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 15869 | 15915 |
| 15870 template <class ExternalArrayClass, class ElementType> | 15916 template <class ExternalArrayClass, class ElementType> |
| 15871 static void ObjectWithExternalArrayTestHelper( | 15917 static void ObjectWithExternalArrayTestHelper( |
| 15872 Handle<Context> context, | 15918 Handle<Context> context, |
| 15873 v8::Handle<Object> obj, | 15919 v8::Handle<Object> obj, |
| 15874 int element_count, | 15920 int element_count, |
| 15875 v8::ExternalArrayType array_type, | 15921 v8::ExternalArrayType array_type, |
| 15876 int64_t low, int64_t high) { | 15922 int64_t low, int64_t high) { |
| 15877 i::Handle<i::JSObject> jsobj = v8::Utils::OpenHandle(*obj); | 15923 i::Handle<i::JSObject> jsobj = v8::Utils::OpenHandle(*obj); |
| 15878 i::Isolate* isolate = jsobj->GetIsolate(); | 15924 i::Isolate* isolate = jsobj->GetIsolate(); |
| 15879 obj->Set(v8_str("field"), v8::Int32::New(1503)); | 15925 obj->Set(v8_str("field"), |
| 15926 v8::Int32::New(reinterpret_cast<v8::Isolate*>(isolate), 1503)); |
| 15880 context->Global()->Set(v8_str("ext_array"), obj); | 15927 context->Global()->Set(v8_str("ext_array"), obj); |
| 15881 v8::Handle<v8::Value> result = CompileRun("ext_array.field"); | 15928 v8::Handle<v8::Value> result = CompileRun("ext_array.field"); |
| 15882 CHECK_EQ(1503, result->Int32Value()); | 15929 CHECK_EQ(1503, result->Int32Value()); |
| 15883 result = CompileRun("ext_array[1]"); | 15930 result = CompileRun("ext_array[1]"); |
| 15884 CHECK_EQ(1, result->Int32Value()); | 15931 CHECK_EQ(1, result->Int32Value()); |
| 15885 | 15932 |
| 15886 // Check pass through of assigned smis | 15933 // Check pass through of assigned smis |
| 15887 result = CompileRun("var sum = 0;" | 15934 result = CompileRun("var sum = 0;" |
| 15888 "for (var i = 0; i < 8; i++) {" | 15935 "for (var i = 0; i < 8; i++) {" |
| 15889 " sum += ext_array[i] = ext_array[i] = -i;" | 15936 " sum += ext_array[i] = ext_array[i] = -i;" |
| (...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 16189 array->set(i, static_cast<ElementType>(i)); | 16236 array->set(i, static_cast<ElementType>(i)); |
| 16190 } | 16237 } |
| 16191 // Force GC to trigger verification. | 16238 // Force GC to trigger verification. |
| 16192 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); | 16239 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); |
| 16193 for (int i = 0; i < kElementCount; i++) { | 16240 for (int i = 0; i < kElementCount; i++) { |
| 16194 CHECK_EQ(static_cast<int64_t>(i), | 16241 CHECK_EQ(static_cast<int64_t>(i), |
| 16195 static_cast<int64_t>(array->get_scalar(i))); | 16242 static_cast<int64_t>(array->get_scalar(i))); |
| 16196 CHECK_EQ(static_cast<int64_t>(i), static_cast<int64_t>(array_data[i])); | 16243 CHECK_EQ(static_cast<int64_t>(i), static_cast<int64_t>(array_data[i])); |
| 16197 } | 16244 } |
| 16198 | 16245 |
| 16199 v8::Handle<v8::Object> obj = v8::Object::New(); | 16246 v8::Handle<v8::Object> obj = v8::Object::New(context->GetIsolate()); |
| 16200 i::Handle<i::JSObject> jsobj = v8::Utils::OpenHandle(*obj); | 16247 i::Handle<i::JSObject> jsobj = v8::Utils::OpenHandle(*obj); |
| 16201 // Set the elements to be the external array. | 16248 // Set the elements to be the external array. |
| 16202 obj->SetIndexedPropertiesToExternalArrayData(array_data, | 16249 obj->SetIndexedPropertiesToExternalArrayData(array_data, |
| 16203 array_type, | 16250 array_type, |
| 16204 kElementCount); | 16251 kElementCount); |
| 16205 CHECK_EQ(1, | 16252 CHECK_EQ(1, |
| 16206 static_cast<int>( | 16253 static_cast<int>( |
| 16207 jsobj->GetElement(isolate, 1)->ToObjectChecked()->Number())); | 16254 jsobj->GetElement(isolate, 1)->ToObjectChecked()->Number())); |
| 16208 | 16255 |
| 16209 ObjectWithExternalArrayTestHelper<ExternalArrayClass, ElementType>( | 16256 ObjectWithExternalArrayTestHelper<ExternalArrayClass, ElementType>( |
| 16210 context.local(), obj, kElementCount, array_type, low, high); | 16257 context.local(), obj, kElementCount, array_type, low, high); |
| 16211 | 16258 |
| 16212 v8::Handle<v8::Value> result; | 16259 v8::Handle<v8::Value> result; |
| 16213 | 16260 |
| 16214 // Test more complex manipulations which cause eax to contain values | 16261 // Test more complex manipulations which cause eax to contain values |
| 16215 // that won't be completely overwritten by loads from the arrays. | 16262 // that won't be completely overwritten by loads from the arrays. |
| 16216 // This catches bugs in the instructions used for the KeyedLoadIC | 16263 // This catches bugs in the instructions used for the KeyedLoadIC |
| 16217 // for byte and word types. | 16264 // for byte and word types. |
| 16218 { | 16265 { |
| 16219 const int kXSize = 300; | 16266 const int kXSize = 300; |
| 16220 const int kYSize = 300; | 16267 const int kYSize = 300; |
| 16221 const int kLargeElementCount = kXSize * kYSize * 4; | 16268 const int kLargeElementCount = kXSize * kYSize * 4; |
| 16222 ElementType* large_array_data = | 16269 ElementType* large_array_data = |
| 16223 static_cast<ElementType*>(malloc(kLargeElementCount * element_size)); | 16270 static_cast<ElementType*>(malloc(kLargeElementCount * element_size)); |
| 16224 v8::Handle<v8::Object> large_obj = v8::Object::New(); | 16271 v8::Handle<v8::Object> large_obj = v8::Object::New(context->GetIsolate()); |
| 16225 // Set the elements to be the external array. | 16272 // Set the elements to be the external array. |
| 16226 large_obj->SetIndexedPropertiesToExternalArrayData(large_array_data, | 16273 large_obj->SetIndexedPropertiesToExternalArrayData(large_array_data, |
| 16227 array_type, | 16274 array_type, |
| 16228 kLargeElementCount); | 16275 kLargeElementCount); |
| 16229 context->Global()->Set(v8_str("large_array"), large_obj); | 16276 context->Global()->Set(v8_str("large_array"), large_obj); |
| 16230 // Initialize contents of a few rows. | 16277 // Initialize contents of a few rows. |
| 16231 for (int x = 0; x < 300; x++) { | 16278 for (int x = 0; x < 300; x++) { |
| 16232 int row = 0; | 16279 int row = 0; |
| 16233 int offset = row * 300 * 4; | 16280 int offset = row * 300 * 4; |
| 16234 large_array_data[offset + 4 * x + 0] = (ElementType) 127; | 16281 large_array_data[offset + 4 * x + 0] = (ElementType) 127; |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 16287 | 16334 |
| 16288 // The "" property descriptor is overloaded to store information about | 16335 // The "" property descriptor is overloaded to store information about |
| 16289 // the external array. Ensure that setting and accessing the "" property | 16336 // the external array. Ensure that setting and accessing the "" property |
| 16290 // works (it should overwrite the information cached about the external | 16337 // works (it should overwrite the information cached about the external |
| 16291 // array in the DescriptorArray) in various situations. | 16338 // array in the DescriptorArray) in various situations. |
| 16292 result = CompileRun("ext_array[''] = 23; ext_array['']"); | 16339 result = CompileRun("ext_array[''] = 23; ext_array['']"); |
| 16293 CHECK_EQ(23, result->Int32Value()); | 16340 CHECK_EQ(23, result->Int32Value()); |
| 16294 | 16341 |
| 16295 // Property "" set after the external array is associated with the object. | 16342 // Property "" set after the external array is associated with the object. |
| 16296 { | 16343 { |
| 16297 v8::Handle<v8::Object> obj2 = v8::Object::New(); | 16344 v8::Handle<v8::Object> obj2 = v8::Object::New(context->GetIsolate()); |
| 16298 obj2->Set(v8_str("ee_test_field"), v8::Int32::New(256)); | 16345 obj2->Set(v8_str("ee_test_field"), |
| 16299 obj2->Set(v8_str(""), v8::Int32::New(1503)); | 16346 v8::Int32::New(context->GetIsolate(), 256)); |
| 16347 obj2->Set(v8_str(""), v8::Int32::New(context->GetIsolate(), 1503)); |
| 16300 // Set the elements to be the external array. | 16348 // Set the elements to be the external array. |
| 16301 obj2->SetIndexedPropertiesToExternalArrayData(array_data, | 16349 obj2->SetIndexedPropertiesToExternalArrayData(array_data, |
| 16302 array_type, | 16350 array_type, |
| 16303 kElementCount); | 16351 kElementCount); |
| 16304 context->Global()->Set(v8_str("ext_array"), obj2); | 16352 context->Global()->Set(v8_str("ext_array"), obj2); |
| 16305 result = CompileRun("ext_array['']"); | 16353 result = CompileRun("ext_array['']"); |
| 16306 CHECK_EQ(1503, result->Int32Value()); | 16354 CHECK_EQ(1503, result->Int32Value()); |
| 16307 } | 16355 } |
| 16308 | 16356 |
| 16309 // Property "" set after the external array is associated with the object. | 16357 // Property "" set after the external array is associated with the object. |
| 16310 { | 16358 { |
| 16311 v8::Handle<v8::Object> obj2 = v8::Object::New(); | 16359 v8::Handle<v8::Object> obj2 = v8::Object::New(context->GetIsolate()); |
| 16312 obj2->Set(v8_str("ee_test_field_2"), v8::Int32::New(256)); | 16360 obj2->Set(v8_str("ee_test_field_2"), |
| 16361 v8::Int32::New(context->GetIsolate(), 256)); |
| 16313 // Set the elements to be the external array. | 16362 // Set the elements to be the external array. |
| 16314 obj2->SetIndexedPropertiesToExternalArrayData(array_data, | 16363 obj2->SetIndexedPropertiesToExternalArrayData(array_data, |
| 16315 array_type, | 16364 array_type, |
| 16316 kElementCount); | 16365 kElementCount); |
| 16317 obj2->Set(v8_str(""), v8::Int32::New(1503)); | 16366 obj2->Set(v8_str(""), v8::Int32::New(context->GetIsolate(), 1503)); |
| 16318 context->Global()->Set(v8_str("ext_array"), obj2); | 16367 context->Global()->Set(v8_str("ext_array"), obj2); |
| 16319 result = CompileRun("ext_array['']"); | 16368 result = CompileRun("ext_array['']"); |
| 16320 CHECK_EQ(1503, result->Int32Value()); | 16369 CHECK_EQ(1503, result->Int32Value()); |
| 16321 } | 16370 } |
| 16322 | 16371 |
| 16323 // Should reuse the map from previous test. | 16372 // Should reuse the map from previous test. |
| 16324 { | 16373 { |
| 16325 v8::Handle<v8::Object> obj2 = v8::Object::New(); | 16374 v8::Handle<v8::Object> obj2 = v8::Object::New(context->GetIsolate()); |
| 16326 obj2->Set(v8_str("ee_test_field_2"), v8::Int32::New(256)); | 16375 obj2->Set(v8_str("ee_test_field_2"), |
| 16376 v8::Int32::New(context->GetIsolate(), 256)); |
| 16327 // Set the elements to be the external array. Should re-use the map | 16377 // Set the elements to be the external array. Should re-use the map |
| 16328 // from previous test. | 16378 // from previous test. |
| 16329 obj2->SetIndexedPropertiesToExternalArrayData(array_data, | 16379 obj2->SetIndexedPropertiesToExternalArrayData(array_data, |
| 16330 array_type, | 16380 array_type, |
| 16331 kElementCount); | 16381 kElementCount); |
| 16332 context->Global()->Set(v8_str("ext_array"), obj2); | 16382 context->Global()->Set(v8_str("ext_array"), obj2); |
| 16333 result = CompileRun("ext_array['']"); | 16383 result = CompileRun("ext_array['']"); |
| 16334 } | 16384 } |
| 16335 | 16385 |
| 16336 // Property "" is a constant function that shouldn't not be interfered with | 16386 // Property "" is a constant function that shouldn't not be interfered with |
| 16337 // when an external array is set. | 16387 // when an external array is set. |
| 16338 { | 16388 { |
| 16339 v8::Handle<v8::Object> obj2 = v8::Object::New(); | 16389 v8::Handle<v8::Object> obj2 = v8::Object::New(context->GetIsolate()); |
| 16340 // Start | 16390 // Start |
| 16341 obj2->Set(v8_str("ee_test_field3"), v8::Int32::New(256)); | 16391 obj2->Set(v8_str("ee_test_field3"), |
| 16392 v8::Int32::New(context->GetIsolate(), 256)); |
| 16342 | 16393 |
| 16343 // Add a constant function to an object. | 16394 // Add a constant function to an object. |
| 16344 context->Global()->Set(v8_str("ext_array"), obj2); | 16395 context->Global()->Set(v8_str("ext_array"), obj2); |
| 16345 result = CompileRun("ext_array[''] = function() {return 1503;};" | 16396 result = CompileRun("ext_array[''] = function() {return 1503;};" |
| 16346 "ext_array['']();"); | 16397 "ext_array['']();"); |
| 16347 | 16398 |
| 16348 // Add an external array transition to the same map that | 16399 // Add an external array transition to the same map that |
| 16349 // has the constant transition. | 16400 // has the constant transition. |
| 16350 v8::Handle<v8::Object> obj3 = v8::Object::New(); | 16401 v8::Handle<v8::Object> obj3 = v8::Object::New(context->GetIsolate()); |
| 16351 obj3->Set(v8_str("ee_test_field3"), v8::Int32::New(256)); | 16402 obj3->Set(v8_str("ee_test_field3"), |
| 16403 v8::Int32::New(context->GetIsolate(), 256)); |
| 16352 obj3->SetIndexedPropertiesToExternalArrayData(array_data, | 16404 obj3->SetIndexedPropertiesToExternalArrayData(array_data, |
| 16353 array_type, | 16405 array_type, |
| 16354 kElementCount); | 16406 kElementCount); |
| 16355 context->Global()->Set(v8_str("ext_array"), obj3); | 16407 context->Global()->Set(v8_str("ext_array"), obj3); |
| 16356 } | 16408 } |
| 16357 | 16409 |
| 16358 // If a external array transition is in the map, it should get clobbered | 16410 // If a external array transition is in the map, it should get clobbered |
| 16359 // by a constant function. | 16411 // by a constant function. |
| 16360 { | 16412 { |
| 16361 // Add an external array transition. | 16413 // Add an external array transition. |
| 16362 v8::Handle<v8::Object> obj3 = v8::Object::New(); | 16414 v8::Handle<v8::Object> obj3 = v8::Object::New(context->GetIsolate()); |
| 16363 obj3->Set(v8_str("ee_test_field4"), v8::Int32::New(256)); | 16415 obj3->Set(v8_str("ee_test_field4"), |
| 16416 v8::Int32::New(context->GetIsolate(), 256)); |
| 16364 obj3->SetIndexedPropertiesToExternalArrayData(array_data, | 16417 obj3->SetIndexedPropertiesToExternalArrayData(array_data, |
| 16365 array_type, | 16418 array_type, |
| 16366 kElementCount); | 16419 kElementCount); |
| 16367 | 16420 |
| 16368 // Add a constant function to the same map that just got an external array | 16421 // Add a constant function to the same map that just got an external array |
| 16369 // transition. | 16422 // transition. |
| 16370 v8::Handle<v8::Object> obj2 = v8::Object::New(); | 16423 v8::Handle<v8::Object> obj2 = v8::Object::New(context->GetIsolate()); |
| 16371 obj2->Set(v8_str("ee_test_field4"), v8::Int32::New(256)); | 16424 obj2->Set(v8_str("ee_test_field4"), |
| 16425 v8::Int32::New(context->GetIsolate(), 256)); |
| 16372 context->Global()->Set(v8_str("ext_array"), obj2); | 16426 context->Global()->Set(v8_str("ext_array"), obj2); |
| 16373 result = CompileRun("ext_array[''] = function() {return 1503;};" | 16427 result = CompileRun("ext_array[''] = function() {return 1503;};" |
| 16374 "ext_array['']();"); | 16428 "ext_array['']();"); |
| 16375 } | 16429 } |
| 16376 | 16430 |
| 16377 free(array_data); | 16431 free(array_data); |
| 16378 } | 16432 } |
| 16379 | 16433 |
| 16380 | 16434 |
| 16381 THREADED_TEST(ExternalByteArray) { | 16435 THREADED_TEST(ExternalByteArray) { |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 16460 TestExternalFloatArray(); | 16514 TestExternalFloatArray(); |
| 16461 } | 16515 } |
| 16462 | 16516 |
| 16463 | 16517 |
| 16464 void ExternalArrayInfoTestHelper(v8::ExternalArrayType array_type) { | 16518 void ExternalArrayInfoTestHelper(v8::ExternalArrayType array_type) { |
| 16465 LocalContext context; | 16519 LocalContext context; |
| 16466 v8::HandleScope scope(context->GetIsolate()); | 16520 v8::HandleScope scope(context->GetIsolate()); |
| 16467 for (int size = 0; size < 100; size += 10) { | 16521 for (int size = 0; size < 100; size += 10) { |
| 16468 int element_size = ExternalArrayElementSize(array_type); | 16522 int element_size = ExternalArrayElementSize(array_type); |
| 16469 void* external_data = malloc(size * element_size); | 16523 void* external_data = malloc(size * element_size); |
| 16470 v8::Handle<v8::Object> obj = v8::Object::New(); | 16524 v8::Handle<v8::Object> obj = v8::Object::New(context->GetIsolate()); |
| 16471 obj->SetIndexedPropertiesToExternalArrayData( | 16525 obj->SetIndexedPropertiesToExternalArrayData( |
| 16472 external_data, array_type, size); | 16526 external_data, array_type, size); |
| 16473 CHECK(obj->HasIndexedPropertiesInExternalArrayData()); | 16527 CHECK(obj->HasIndexedPropertiesInExternalArrayData()); |
| 16474 CHECK_EQ(external_data, obj->GetIndexedPropertiesExternalArrayData()); | 16528 CHECK_EQ(external_data, obj->GetIndexedPropertiesExternalArrayData()); |
| 16475 CHECK_EQ(array_type, obj->GetIndexedPropertiesExternalArrayDataType()); | 16529 CHECK_EQ(array_type, obj->GetIndexedPropertiesExternalArrayDataType()); |
| 16476 CHECK_EQ(size, obj->GetIndexedPropertiesExternalArrayDataLength()); | 16530 CHECK_EQ(size, obj->GetIndexedPropertiesExternalArrayDataLength()); |
| 16477 free(external_data); | 16531 free(external_data); |
| 16478 } | 16532 } |
| 16479 } | 16533 } |
| 16480 | 16534 |
| 16481 | 16535 |
| 16482 THREADED_TEST(ExternalArrayInfo) { | 16536 THREADED_TEST(ExternalArrayInfo) { |
| 16483 ExternalArrayInfoTestHelper(v8::kExternalByteArray); | 16537 ExternalArrayInfoTestHelper(v8::kExternalByteArray); |
| 16484 ExternalArrayInfoTestHelper(v8::kExternalUnsignedByteArray); | 16538 ExternalArrayInfoTestHelper(v8::kExternalUnsignedByteArray); |
| 16485 ExternalArrayInfoTestHelper(v8::kExternalShortArray); | 16539 ExternalArrayInfoTestHelper(v8::kExternalShortArray); |
| 16486 ExternalArrayInfoTestHelper(v8::kExternalUnsignedShortArray); | 16540 ExternalArrayInfoTestHelper(v8::kExternalUnsignedShortArray); |
| 16487 ExternalArrayInfoTestHelper(v8::kExternalIntArray); | 16541 ExternalArrayInfoTestHelper(v8::kExternalIntArray); |
| 16488 ExternalArrayInfoTestHelper(v8::kExternalUnsignedIntArray); | 16542 ExternalArrayInfoTestHelper(v8::kExternalUnsignedIntArray); |
| 16489 ExternalArrayInfoTestHelper(v8::kExternalFloatArray); | 16543 ExternalArrayInfoTestHelper(v8::kExternalFloatArray); |
| 16490 ExternalArrayInfoTestHelper(v8::kExternalDoubleArray); | 16544 ExternalArrayInfoTestHelper(v8::kExternalDoubleArray); |
| 16491 ExternalArrayInfoTestHelper(v8::kExternalPixelArray); | 16545 ExternalArrayInfoTestHelper(v8::kExternalPixelArray); |
| 16492 } | 16546 } |
| 16493 | 16547 |
| 16494 | 16548 |
| 16495 void ExternalArrayLimitTestHelper(v8::ExternalArrayType array_type, int size) { | 16549 void ExtArrayLimitsHelper(v8::Isolate* isolate, |
| 16496 v8::Handle<v8::Object> obj = v8::Object::New(); | 16550 v8::ExternalArrayType array_type, |
| 16551 int size) { |
| 16552 v8::Handle<v8::Object> obj = v8::Object::New(isolate); |
| 16497 v8::V8::SetFatalErrorHandler(StoringErrorCallback); | 16553 v8::V8::SetFatalErrorHandler(StoringErrorCallback); |
| 16498 last_location = last_message = NULL; | 16554 last_location = last_message = NULL; |
| 16499 obj->SetIndexedPropertiesToExternalArrayData(NULL, array_type, size); | 16555 obj->SetIndexedPropertiesToExternalArrayData(NULL, array_type, size); |
| 16500 CHECK(!obj->HasIndexedPropertiesInExternalArrayData()); | 16556 CHECK(!obj->HasIndexedPropertiesInExternalArrayData()); |
| 16501 CHECK_NE(NULL, last_location); | 16557 CHECK_NE(NULL, last_location); |
| 16502 CHECK_NE(NULL, last_message); | 16558 CHECK_NE(NULL, last_message); |
| 16503 } | 16559 } |
| 16504 | 16560 |
| 16505 | 16561 |
| 16506 TEST(ExternalArrayLimits) { | 16562 TEST(ExternalArrayLimits) { |
| 16507 LocalContext context; | 16563 LocalContext context; |
| 16508 v8::HandleScope scope(context->GetIsolate()); | 16564 v8::Isolate* isolate = context->GetIsolate(); |
| 16509 ExternalArrayLimitTestHelper(v8::kExternalByteArray, 0x40000000); | 16565 v8::HandleScope scope(isolate); |
| 16510 ExternalArrayLimitTestHelper(v8::kExternalByteArray, 0xffffffff); | 16566 ExtArrayLimitsHelper(isolate, v8::kExternalByteArray, 0x40000000); |
| 16511 ExternalArrayLimitTestHelper(v8::kExternalUnsignedByteArray, 0x40000000); | 16567 ExtArrayLimitsHelper(isolate, v8::kExternalByteArray, 0xffffffff); |
| 16512 ExternalArrayLimitTestHelper(v8::kExternalUnsignedByteArray, 0xffffffff); | 16568 ExtArrayLimitsHelper(isolate, v8::kExternalUnsignedByteArray, 0x40000000); |
| 16513 ExternalArrayLimitTestHelper(v8::kExternalShortArray, 0x40000000); | 16569 ExtArrayLimitsHelper(isolate, v8::kExternalUnsignedByteArray, 0xffffffff); |
| 16514 ExternalArrayLimitTestHelper(v8::kExternalShortArray, 0xffffffff); | 16570 ExtArrayLimitsHelper(isolate, v8::kExternalShortArray, 0x40000000); |
| 16515 ExternalArrayLimitTestHelper(v8::kExternalUnsignedShortArray, 0x40000000); | 16571 ExtArrayLimitsHelper(isolate, v8::kExternalShortArray, 0xffffffff); |
| 16516 ExternalArrayLimitTestHelper(v8::kExternalUnsignedShortArray, 0xffffffff); | 16572 ExtArrayLimitsHelper(isolate, v8::kExternalUnsignedShortArray, 0x40000000); |
| 16517 ExternalArrayLimitTestHelper(v8::kExternalIntArray, 0x40000000); | 16573 ExtArrayLimitsHelper(isolate, v8::kExternalUnsignedShortArray, 0xffffffff); |
| 16518 ExternalArrayLimitTestHelper(v8::kExternalIntArray, 0xffffffff); | 16574 ExtArrayLimitsHelper(isolate, v8::kExternalIntArray, 0x40000000); |
| 16519 ExternalArrayLimitTestHelper(v8::kExternalUnsignedIntArray, 0x40000000); | 16575 ExtArrayLimitsHelper(isolate, v8::kExternalIntArray, 0xffffffff); |
| 16520 ExternalArrayLimitTestHelper(v8::kExternalUnsignedIntArray, 0xffffffff); | 16576 ExtArrayLimitsHelper(isolate, v8::kExternalUnsignedIntArray, 0x40000000); |
| 16521 ExternalArrayLimitTestHelper(v8::kExternalFloatArray, 0x40000000); | 16577 ExtArrayLimitsHelper(isolate, v8::kExternalUnsignedIntArray, 0xffffffff); |
| 16522 ExternalArrayLimitTestHelper(v8::kExternalFloatArray, 0xffffffff); | 16578 ExtArrayLimitsHelper(isolate, v8::kExternalFloatArray, 0x40000000); |
| 16523 ExternalArrayLimitTestHelper(v8::kExternalDoubleArray, 0x40000000); | 16579 ExtArrayLimitsHelper(isolate, v8::kExternalFloatArray, 0xffffffff); |
| 16524 ExternalArrayLimitTestHelper(v8::kExternalDoubleArray, 0xffffffff); | 16580 ExtArrayLimitsHelper(isolate, v8::kExternalDoubleArray, 0x40000000); |
| 16525 ExternalArrayLimitTestHelper(v8::kExternalPixelArray, 0x40000000); | 16581 ExtArrayLimitsHelper(isolate, v8::kExternalDoubleArray, 0xffffffff); |
| 16526 ExternalArrayLimitTestHelper(v8::kExternalPixelArray, 0xffffffff); | 16582 ExtArrayLimitsHelper(isolate, v8::kExternalPixelArray, 0x40000000); |
| 16583 ExtArrayLimitsHelper(isolate, v8::kExternalPixelArray, 0xffffffff); |
| 16527 } | 16584 } |
| 16528 | 16585 |
| 16529 | 16586 |
| 16530 template <typename ElementType, typename TypedArray, | 16587 template <typename ElementType, typename TypedArray, |
| 16531 class ExternalArrayClass> | 16588 class ExternalArrayClass> |
| 16532 void TypedArrayTestHelper(v8::ExternalArrayType array_type, | 16589 void TypedArrayTestHelper(v8::ExternalArrayType array_type, |
| 16533 int64_t low, int64_t high) { | 16590 int64_t low, int64_t high) { |
| 16534 const int kElementCount = 50; | 16591 const int kElementCount = 50; |
| 16535 | 16592 |
| 16536 i::ScopedVector<ElementType> backing_store(kElementCount+2); | 16593 i::ScopedVector<ElementType> backing_store(kElementCount+2); |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 16668 | 16725 |
| 16669 THREADED_TEST(ScriptContextDependence) { | 16726 THREADED_TEST(ScriptContextDependence) { |
| 16670 LocalContext c1; | 16727 LocalContext c1; |
| 16671 v8::HandleScope scope(c1->GetIsolate()); | 16728 v8::HandleScope scope(c1->GetIsolate()); |
| 16672 const char *source = "foo"; | 16729 const char *source = "foo"; |
| 16673 v8::Handle<v8::Script> dep = | 16730 v8::Handle<v8::Script> dep = |
| 16674 v8::Script::Compile(v8::String::NewFromUtf8(c1->GetIsolate(), source)); | 16731 v8::Script::Compile(v8::String::NewFromUtf8(c1->GetIsolate(), source)); |
| 16675 v8::Handle<v8::Script> indep = | 16732 v8::Handle<v8::Script> indep = |
| 16676 v8::Script::New(v8::String::NewFromUtf8(c1->GetIsolate(), source)); | 16733 v8::Script::New(v8::String::NewFromUtf8(c1->GetIsolate(), source)); |
| 16677 c1->Global()->Set(v8::String::NewFromUtf8(c1->GetIsolate(), "foo"), | 16734 c1->Global()->Set(v8::String::NewFromUtf8(c1->GetIsolate(), "foo"), |
| 16678 v8::Integer::New(100)); | 16735 v8::Integer::New(c1->GetIsolate(), 100)); |
| 16679 CHECK_EQ(dep->Run()->Int32Value(), 100); | 16736 CHECK_EQ(dep->Run()->Int32Value(), 100); |
| 16680 CHECK_EQ(indep->Run()->Int32Value(), 100); | 16737 CHECK_EQ(indep->Run()->Int32Value(), 100); |
| 16681 LocalContext c2; | 16738 LocalContext c2; |
| 16682 c2->Global()->Set(v8::String::NewFromUtf8(c2->GetIsolate(), "foo"), | 16739 c2->Global()->Set(v8::String::NewFromUtf8(c2->GetIsolate(), "foo"), |
| 16683 v8::Integer::New(101)); | 16740 v8::Integer::New(c2->GetIsolate(), 101)); |
| 16684 CHECK_EQ(dep->Run()->Int32Value(), 100); | 16741 CHECK_EQ(dep->Run()->Int32Value(), 100); |
| 16685 CHECK_EQ(indep->Run()->Int32Value(), 101); | 16742 CHECK_EQ(indep->Run()->Int32Value(), 101); |
| 16686 } | 16743 } |
| 16687 | 16744 |
| 16688 | 16745 |
| 16689 THREADED_TEST(StackTrace) { | 16746 THREADED_TEST(StackTrace) { |
| 16690 LocalContext context; | 16747 LocalContext context; |
| 16691 v8::HandleScope scope(context->GetIsolate()); | 16748 v8::HandleScope scope(context->GetIsolate()); |
| 16692 v8::TryCatch try_catch; | 16749 v8::TryCatch try_catch; |
| 16693 const char *source = "function foo() { FAIL.FAIL; }; foo();"; | 16750 const char *source = "function foo() { FAIL.FAIL; }; foo();"; |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 16811 "function bat() {AnalyzeStackInNativeCode(2);\n" | 16868 "function bat() {AnalyzeStackInNativeCode(2);\n" |
| 16812 "}\n" | 16869 "}\n" |
| 16813 "\n" | 16870 "\n" |
| 16814 "function baz() {\n" | 16871 "function baz() {\n" |
| 16815 " bat();\n" | 16872 " bat();\n" |
| 16816 "}\n" | 16873 "}\n" |
| 16817 "eval('new baz();');"; | 16874 "eval('new baz();');"; |
| 16818 v8::Handle<v8::String> detailed_src = | 16875 v8::Handle<v8::String> detailed_src = |
| 16819 v8::String::NewFromUtf8(isolate, detailed_source); | 16876 v8::String::NewFromUtf8(isolate, detailed_source); |
| 16820 // Make the script using a non-zero line and column offset. | 16877 // Make the script using a non-zero line and column offset. |
| 16821 v8::Handle<v8::Integer> line_offset = v8::Integer::New(3); | 16878 v8::Handle<v8::Integer> line_offset = v8::Integer::New(isolate, 3); |
| 16822 v8::Handle<v8::Integer> column_offset = v8::Integer::New(5); | 16879 v8::Handle<v8::Integer> column_offset = v8::Integer::New(isolate, 5); |
| 16823 v8::ScriptOrigin detailed_origin(origin, line_offset, column_offset); | 16880 v8::ScriptOrigin detailed_origin(origin, line_offset, column_offset); |
| 16824 v8::Handle<v8::Script> detailed_script( | 16881 v8::Handle<v8::Script> detailed_script( |
| 16825 v8::Script::New(detailed_src, &detailed_origin)); | 16882 v8::Script::New(detailed_src, &detailed_origin)); |
| 16826 v8::Handle<Value> detailed_result(detailed_script->Run()); | 16883 v8::Handle<Value> detailed_result(detailed_script->Run()); |
| 16827 CHECK(!detailed_result.IsEmpty()); | 16884 CHECK(!detailed_result.IsEmpty()); |
| 16828 CHECK(detailed_result->IsObject()); | 16885 CHECK(detailed_result->IsObject()); |
| 16829 } | 16886 } |
| 16830 | 16887 |
| 16831 | 16888 |
| 16832 static void StackTraceForUncaughtExceptionListener( | 16889 static void StackTraceForUncaughtExceptionListener( |
| (...skipping 728 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 17561 | 17618 |
| 17562 // We don't have a consistent way to write 64-bit constants syntactically, so we | 17619 // We don't have a consistent way to write 64-bit constants syntactically, so we |
| 17563 // split them into two 32-bit constants and combine them programmatically. | 17620 // split them into two 32-bit constants and combine them programmatically. |
| 17564 static double DoubleFromBits(uint32_t high_bits, uint32_t low_bits) { | 17621 static double DoubleFromBits(uint32_t high_bits, uint32_t low_bits) { |
| 17565 return DoubleFromBits((static_cast<uint64_t>(high_bits) << 32) | low_bits); | 17622 return DoubleFromBits((static_cast<uint64_t>(high_bits) << 32) | low_bits); |
| 17566 } | 17623 } |
| 17567 | 17624 |
| 17568 | 17625 |
| 17569 THREADED_TEST(QuietSignalingNaNs) { | 17626 THREADED_TEST(QuietSignalingNaNs) { |
| 17570 LocalContext context; | 17627 LocalContext context; |
| 17571 v8::HandleScope scope(context->GetIsolate()); | 17628 v8::Isolate* isolate = context->GetIsolate(); |
| 17629 v8::HandleScope scope(isolate); |
| 17572 v8::TryCatch try_catch; | 17630 v8::TryCatch try_catch; |
| 17573 | 17631 |
| 17574 // Special double values. | 17632 // Special double values. |
| 17575 double snan = DoubleFromBits(0x7ff00000, 0x00000001); | 17633 double snan = DoubleFromBits(0x7ff00000, 0x00000001); |
| 17576 double qnan = DoubleFromBits(0x7ff80000, 0x00000000); | 17634 double qnan = DoubleFromBits(0x7ff80000, 0x00000000); |
| 17577 double infinity = DoubleFromBits(0x7ff00000, 0x00000000); | 17635 double infinity = DoubleFromBits(0x7ff00000, 0x00000000); |
| 17578 double max_normal = DoubleFromBits(0x7fefffff, 0xffffffffu); | 17636 double max_normal = DoubleFromBits(0x7fefffff, 0xffffffffu); |
| 17579 double min_normal = DoubleFromBits(0x00100000, 0x00000000); | 17637 double min_normal = DoubleFromBits(0x00100000, 0x00000000); |
| 17580 double max_denormal = DoubleFromBits(0x000fffff, 0xffffffffu); | 17638 double max_denormal = DoubleFromBits(0x000fffff, 0xffffffffu); |
| 17581 double min_denormal = DoubleFromBits(0x00000000, 0x00000001); | 17639 double min_denormal = DoubleFromBits(0x00000000, 0x00000001); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 17605 -infinity, | 17663 -infinity, |
| 17606 -qnan, | 17664 -qnan, |
| 17607 -snan | 17665 -snan |
| 17608 }; | 17666 }; |
| 17609 int num_test_values = 20; | 17667 int num_test_values = 20; |
| 17610 | 17668 |
| 17611 for (int i = 0; i < num_test_values; i++) { | 17669 for (int i = 0; i < num_test_values; i++) { |
| 17612 double test_value = test_values[i]; | 17670 double test_value = test_values[i]; |
| 17613 | 17671 |
| 17614 // Check that Number::New preserves non-NaNs and quiets SNaNs. | 17672 // Check that Number::New preserves non-NaNs and quiets SNaNs. |
| 17615 v8::Handle<v8::Value> number = v8::Number::New(test_value); | 17673 v8::Handle<v8::Value> number = v8::Number::New(isolate, test_value); |
| 17616 double stored_number = number->NumberValue(); | 17674 double stored_number = number->NumberValue(); |
| 17617 if (!std::isnan(test_value)) { | 17675 if (!std::isnan(test_value)) { |
| 17618 CHECK_EQ(test_value, stored_number); | 17676 CHECK_EQ(test_value, stored_number); |
| 17619 } else { | 17677 } else { |
| 17620 uint64_t stored_bits = DoubleToBits(stored_number); | 17678 uint64_t stored_bits = DoubleToBits(stored_number); |
| 17621 // Check if quiet nan (bits 51..62 all set). | 17679 // Check if quiet nan (bits 51..62 all set). |
| 17622 #if defined(V8_TARGET_ARCH_MIPS) && !defined(USE_SIMULATOR) | 17680 #if defined(V8_TARGET_ARCH_MIPS) && !defined(USE_SIMULATOR) |
| 17623 // Most significant fraction bit for quiet nan is set to 0 | 17681 // Most significant fraction bit for quiet nan is set to 0 |
| 17624 // on MIPS architecture. Allowed by IEEE-754. | 17682 // on MIPS architecture. Allowed by IEEE-754. |
| 17625 CHECK_EQ(0xffe, static_cast<int>((stored_bits >> 51) & 0xfff)); | 17683 CHECK_EQ(0xffe, static_cast<int>((stored_bits >> 51) & 0xfff)); |
| 17626 #else | 17684 #else |
| 17627 CHECK_EQ(0xfff, static_cast<int>((stored_bits >> 51) & 0xfff)); | 17685 CHECK_EQ(0xfff, static_cast<int>((stored_bits >> 51) & 0xfff)); |
| 17628 #endif | 17686 #endif |
| 17629 } | 17687 } |
| 17630 | 17688 |
| 17631 // Check that Date::New preserves non-NaNs in the date range and | 17689 // Check that Date::New preserves non-NaNs in the date range and |
| 17632 // quiets SNaNs. | 17690 // quiets SNaNs. |
| 17633 v8::Handle<v8::Value> date = | 17691 v8::Handle<v8::Value> date = |
| 17634 v8::Date::New(context->GetIsolate(), test_value); | 17692 v8::Date::New(isolate, test_value); |
| 17635 double expected_stored_date = DoubleToDateTime(test_value); | 17693 double expected_stored_date = DoubleToDateTime(test_value); |
| 17636 double stored_date = date->NumberValue(); | 17694 double stored_date = date->NumberValue(); |
| 17637 if (!std::isnan(expected_stored_date)) { | 17695 if (!std::isnan(expected_stored_date)) { |
| 17638 CHECK_EQ(expected_stored_date, stored_date); | 17696 CHECK_EQ(expected_stored_date, stored_date); |
| 17639 } else { | 17697 } else { |
| 17640 uint64_t stored_bits = DoubleToBits(stored_date); | 17698 uint64_t stored_bits = DoubleToBits(stored_date); |
| 17641 // Check if quiet nan (bits 51..62 all set). | 17699 // Check if quiet nan (bits 51..62 all set). |
| 17642 #if defined(V8_TARGET_ARCH_MIPS) && !defined(USE_SIMULATOR) | 17700 #if defined(V8_TARGET_ARCH_MIPS) && !defined(USE_SIMULATOR) |
| 17643 // Most significant fraction bit for quiet nan is set to 0 | 17701 // Most significant fraction bit for quiet nan is set to 0 |
| 17644 // on MIPS architecture. Allowed by IEEE-754. | 17702 // on MIPS architecture. Allowed by IEEE-754. |
| (...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 17896 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "f"))); | 17954 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "f"))); |
| 17897 v8::Local<v8::Function> g = v8::Local<v8::Function>::Cast( | 17955 v8::Local<v8::Function> g = v8::Local<v8::Function>::Cast( |
| 17898 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "g"))); | 17956 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "g"))); |
| 17899 CHECK_EQ(0, f->GetScriptLineNumber()); | 17957 CHECK_EQ(0, f->GetScriptLineNumber()); |
| 17900 CHECK_EQ(2, g->GetScriptLineNumber()); | 17958 CHECK_EQ(2, g->GetScriptLineNumber()); |
| 17901 } | 17959 } |
| 17902 | 17960 |
| 17903 | 17961 |
| 17904 THREADED_TEST(ScriptColumnNumber) { | 17962 THREADED_TEST(ScriptColumnNumber) { |
| 17905 LocalContext env; | 17963 LocalContext env; |
| 17906 v8::HandleScope scope(env->GetIsolate()); | 17964 v8::Isolate* isolate = env->GetIsolate(); |
| 17965 v8::HandleScope scope(isolate); |
| 17907 v8::ScriptOrigin origin = | 17966 v8::ScriptOrigin origin = |
| 17908 v8::ScriptOrigin(v8::String::NewFromUtf8(env->GetIsolate(), "test"), | 17967 v8::ScriptOrigin(v8::String::NewFromUtf8(isolate, "test"), |
| 17909 v8::Integer::New(3), v8::Integer::New(2)); | 17968 v8::Integer::New(isolate, 3), |
| 17969 v8::Integer::New(isolate, 2)); |
| 17910 v8::Handle<v8::String> script = v8::String::NewFromUtf8( | 17970 v8::Handle<v8::String> script = v8::String::NewFromUtf8( |
| 17911 env->GetIsolate(), "function foo() {}\n\n function bar() {}"); | 17971 isolate, "function foo() {}\n\n function bar() {}"); |
| 17912 v8::Script::Compile(script, &origin)->Run(); | 17972 v8::Script::Compile(script, &origin)->Run(); |
| 17913 v8::Local<v8::Function> foo = v8::Local<v8::Function>::Cast( | 17973 v8::Local<v8::Function> foo = v8::Local<v8::Function>::Cast( |
| 17914 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "foo"))); | 17974 env->Global()->Get(v8::String::NewFromUtf8(isolate, "foo"))); |
| 17915 v8::Local<v8::Function> bar = v8::Local<v8::Function>::Cast( | 17975 v8::Local<v8::Function> bar = v8::Local<v8::Function>::Cast( |
| 17916 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "bar"))); | 17976 env->Global()->Get(v8::String::NewFromUtf8(isolate, "bar"))); |
| 17917 CHECK_EQ(14, foo->GetScriptColumnNumber()); | 17977 CHECK_EQ(14, foo->GetScriptColumnNumber()); |
| 17918 CHECK_EQ(17, bar->GetScriptColumnNumber()); | 17978 CHECK_EQ(17, bar->GetScriptColumnNumber()); |
| 17919 } | 17979 } |
| 17920 | 17980 |
| 17921 | 17981 |
| 17922 THREADED_TEST(FunctionIsBuiltin) { | 17982 THREADED_TEST(FunctionIsBuiltin) { |
| 17923 LocalContext env; | 17983 LocalContext env; |
| 17924 v8::HandleScope scope(env->GetIsolate()); | 17984 v8::Isolate* isolate = env->GetIsolate(); |
| 17985 v8::HandleScope scope(isolate); |
| 17925 v8::Local<v8::Function> f; | 17986 v8::Local<v8::Function> f; |
| 17926 f = v8::Local<v8::Function>::Cast(CompileRun("Math.floor")); | 17987 f = v8::Local<v8::Function>::Cast(CompileRun("Math.floor")); |
| 17927 CHECK(f->IsBuiltin()); | 17988 CHECK(f->IsBuiltin()); |
| 17928 f = v8::Local<v8::Function>::Cast(CompileRun("Object")); | 17989 f = v8::Local<v8::Function>::Cast(CompileRun("Object")); |
| 17929 CHECK(f->IsBuiltin()); | 17990 CHECK(f->IsBuiltin()); |
| 17930 f = v8::Local<v8::Function>::Cast(CompileRun("Object.__defineSetter__")); | 17991 f = v8::Local<v8::Function>::Cast(CompileRun("Object.__defineSetter__")); |
| 17931 CHECK(f->IsBuiltin()); | 17992 CHECK(f->IsBuiltin()); |
| 17932 f = v8::Local<v8::Function>::Cast(CompileRun("Array.prototype.toString")); | 17993 f = v8::Local<v8::Function>::Cast(CompileRun("Array.prototype.toString")); |
| 17933 CHECK(f->IsBuiltin()); | 17994 CHECK(f->IsBuiltin()); |
| 17934 f = v8::Local<v8::Function>::Cast(CompileRun("function a() {}; a;")); | 17995 f = v8::Local<v8::Function>::Cast(CompileRun("function a() {}; a;")); |
| 17935 CHECK(!f->IsBuiltin()); | 17996 CHECK(!f->IsBuiltin()); |
| 17936 } | 17997 } |
| 17937 | 17998 |
| 17938 | 17999 |
| 17939 THREADED_TEST(FunctionGetScriptId) { | 18000 THREADED_TEST(FunctionGetScriptId) { |
| 17940 LocalContext env; | 18001 LocalContext env; |
| 17941 v8::HandleScope scope(env->GetIsolate()); | 18002 v8::Isolate* isolate = env->GetIsolate(); |
| 18003 v8::HandleScope scope(isolate); |
| 17942 v8::ScriptOrigin origin = | 18004 v8::ScriptOrigin origin = |
| 17943 v8::ScriptOrigin(v8::String::NewFromUtf8(env->GetIsolate(), "test"), | 18005 v8::ScriptOrigin(v8::String::NewFromUtf8(isolate, "test"), |
| 17944 v8::Integer::New(3), v8::Integer::New(2)); | 18006 v8::Integer::New(isolate, 3), |
| 18007 v8::Integer::New(isolate, 2)); |
| 17945 v8::Handle<v8::String> scriptSource = v8::String::NewFromUtf8( | 18008 v8::Handle<v8::String> scriptSource = v8::String::NewFromUtf8( |
| 17946 env->GetIsolate(), "function foo() {}\n\n function bar() {}"); | 18009 isolate, "function foo() {}\n\n function bar() {}"); |
| 17947 v8::Local<v8::Script> script(v8::Script::Compile(scriptSource, &origin)); | 18010 v8::Local<v8::Script> script(v8::Script::Compile(scriptSource, &origin)); |
| 17948 script->Run(); | 18011 script->Run(); |
| 17949 v8::Local<v8::Function> foo = v8::Local<v8::Function>::Cast( | 18012 v8::Local<v8::Function> foo = v8::Local<v8::Function>::Cast( |
| 17950 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "foo"))); | 18013 env->Global()->Get(v8::String::NewFromUtf8(isolate, "foo"))); |
| 17951 v8::Local<v8::Function> bar = v8::Local<v8::Function>::Cast( | 18014 v8::Local<v8::Function> bar = v8::Local<v8::Function>::Cast( |
| 17952 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "bar"))); | 18015 env->Global()->Get(v8::String::NewFromUtf8(isolate, "bar"))); |
| 17953 CHECK_EQ(script->GetId(), foo->ScriptId()); | 18016 CHECK_EQ(script->GetId(), foo->ScriptId()); |
| 17954 CHECK_EQ(script->GetId(), bar->ScriptId()); | 18017 CHECK_EQ(script->GetId(), bar->ScriptId()); |
| 17955 } | 18018 } |
| 17956 | 18019 |
| 17957 | 18020 |
| 17958 static void GetterWhichReturns42( | 18021 static void GetterWhichReturns42( |
| 17959 Local<String> name, | 18022 Local<String> name, |
| 17960 const v8::PropertyCallbackInfo<v8::Value>& info) { | 18023 const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 17961 CHECK(v8::Utils::OpenHandle(*info.This())->IsJSObject()); | 18024 CHECK(v8::Utils::OpenHandle(*info.This())->IsJSObject()); |
| 17962 CHECK(v8::Utils::OpenHandle(*info.Holder())->IsJSObject()); | 18025 CHECK(v8::Utils::OpenHandle(*info.Holder())->IsJSObject()); |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 18084 const char* source = "function C1() {" | 18147 const char* source = "function C1() {" |
| 18085 " this.x = 23;" | 18148 " this.x = 23;" |
| 18086 "};" | 18149 "};" |
| 18087 "C1.prototype = P;"; | 18150 "C1.prototype = P;"; |
| 18088 | 18151 |
| 18089 LocalContext context; | 18152 LocalContext context; |
| 18090 v8::HandleScope scope(context->GetIsolate()); | 18153 v8::HandleScope scope(context->GetIsolate()); |
| 18091 v8::Local<v8::Script> script; | 18154 v8::Local<v8::Script> script; |
| 18092 | 18155 |
| 18093 // Use a simple object as prototype. | 18156 // Use a simple object as prototype. |
| 18094 v8::Local<v8::Object> prototype = v8::Object::New(); | 18157 v8::Local<v8::Object> prototype = v8::Object::New(context->GetIsolate()); |
| 18095 prototype->Set(v8_str("y"), v8_num(42)); | 18158 prototype->Set(v8_str("y"), v8_num(42)); |
| 18096 context->Global()->Set(v8_str("P"), prototype); | 18159 context->Global()->Set(v8_str("P"), prototype); |
| 18097 | 18160 |
| 18098 // This compile will add the code to the compilation cache. | 18161 // This compile will add the code to the compilation cache. |
| 18099 CompileRun(source); | 18162 CompileRun(source); |
| 18100 | 18163 |
| 18101 script = v8::Script::Compile(v8_str("new C1();")); | 18164 script = v8::Script::Compile(v8_str("new C1();")); |
| 18102 // Allow enough iterations for the inobject slack tracking logic | 18165 // Allow enough iterations for the inobject slack tracking logic |
| 18103 // to finalize instance size and install the fast construct stub. | 18166 // to finalize instance size and install the fast construct stub. |
| 18104 for (int i = 0; i < 256; i++) { | 18167 for (int i = 0; i < 256; i++) { |
| (...skipping 1043 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 19148 | 19211 |
| 19149 int counter_; | 19212 int counter_; |
| 19150 v8::Persistent<v8::Object>* object_; | 19213 v8::Persistent<v8::Object>* object_; |
| 19151 }; | 19214 }; |
| 19152 | 19215 |
| 19153 | 19216 |
| 19154 TEST(PersistentHandleVisitor) { | 19217 TEST(PersistentHandleVisitor) { |
| 19155 LocalContext context; | 19218 LocalContext context; |
| 19156 v8::Isolate* isolate = context->GetIsolate(); | 19219 v8::Isolate* isolate = context->GetIsolate(); |
| 19157 v8::HandleScope scope(isolate); | 19220 v8::HandleScope scope(isolate); |
| 19158 v8::Persistent<v8::Object> object(isolate, v8::Object::New()); | 19221 v8::Persistent<v8::Object> object(isolate, v8::Object::New(isolate)); |
| 19159 CHECK_EQ(0, object.WrapperClassId()); | 19222 CHECK_EQ(0, object.WrapperClassId()); |
| 19160 object.SetWrapperClassId(42); | 19223 object.SetWrapperClassId(42); |
| 19161 CHECK_EQ(42, object.WrapperClassId()); | 19224 CHECK_EQ(42, object.WrapperClassId()); |
| 19162 | 19225 |
| 19163 Visitor42 visitor(&object); | 19226 Visitor42 visitor(&object); |
| 19164 v8::V8::VisitHandlesWithClassIds(&visitor); | 19227 v8::V8::VisitHandlesWithClassIds(&visitor); |
| 19165 CHECK_EQ(1, visitor.counter_); | 19228 CHECK_EQ(1, visitor.counter_); |
| 19166 | 19229 |
| 19167 object.Reset(); | 19230 object.Reset(); |
| 19168 } | 19231 } |
| 19169 | 19232 |
| 19170 | 19233 |
| 19171 TEST(WrapperClassId) { | 19234 TEST(WrapperClassId) { |
| 19172 LocalContext context; | 19235 LocalContext context; |
| 19173 v8::Isolate* isolate = context->GetIsolate(); | 19236 v8::Isolate* isolate = context->GetIsolate(); |
| 19174 v8::HandleScope scope(isolate); | 19237 v8::HandleScope scope(isolate); |
| 19175 v8::Persistent<v8::Object> object(isolate, v8::Object::New()); | 19238 v8::Persistent<v8::Object> object(isolate, v8::Object::New(isolate)); |
| 19176 CHECK_EQ(0, object.WrapperClassId()); | 19239 CHECK_EQ(0, object.WrapperClassId()); |
| 19177 object.SetWrapperClassId(65535); | 19240 object.SetWrapperClassId(65535); |
| 19178 CHECK_EQ(65535, object.WrapperClassId()); | 19241 CHECK_EQ(65535, object.WrapperClassId()); |
| 19179 object.Reset(); | 19242 object.Reset(); |
| 19180 } | 19243 } |
| 19181 | 19244 |
| 19182 | 19245 |
| 19183 TEST(PersistentHandleInNewSpaceVisitor) { | 19246 TEST(PersistentHandleInNewSpaceVisitor) { |
| 19184 LocalContext context; | 19247 LocalContext context; |
| 19185 v8::Isolate* isolate = context->GetIsolate(); | 19248 v8::Isolate* isolate = context->GetIsolate(); |
| 19186 v8::HandleScope scope(isolate); | 19249 v8::HandleScope scope(isolate); |
| 19187 v8::Persistent<v8::Object> object1(isolate, v8::Object::New()); | 19250 v8::Persistent<v8::Object> object1(isolate, v8::Object::New(isolate)); |
| 19188 CHECK_EQ(0, object1.WrapperClassId()); | 19251 CHECK_EQ(0, object1.WrapperClassId()); |
| 19189 object1.SetWrapperClassId(42); | 19252 object1.SetWrapperClassId(42); |
| 19190 CHECK_EQ(42, object1.WrapperClassId()); | 19253 CHECK_EQ(42, object1.WrapperClassId()); |
| 19191 | 19254 |
| 19192 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); | 19255 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); |
| 19193 | 19256 |
| 19194 v8::Persistent<v8::Object> object2(isolate, v8::Object::New()); | 19257 v8::Persistent<v8::Object> object2(isolate, v8::Object::New(isolate)); |
| 19195 CHECK_EQ(0, object2.WrapperClassId()); | 19258 CHECK_EQ(0, object2.WrapperClassId()); |
| 19196 object2.SetWrapperClassId(42); | 19259 object2.SetWrapperClassId(42); |
| 19197 CHECK_EQ(42, object2.WrapperClassId()); | 19260 CHECK_EQ(42, object2.WrapperClassId()); |
| 19198 | 19261 |
| 19199 Visitor42 visitor(&object2); | 19262 Visitor42 visitor(&object2); |
| 19200 v8::V8::VisitHandlesForPartialDependence(isolate, &visitor); | 19263 v8::V8::VisitHandlesForPartialDependence(isolate, &visitor); |
| 19201 CHECK_EQ(1, visitor.counter_); | 19264 CHECK_EQ(1, visitor.counter_); |
| 19202 | 19265 |
| 19203 object1.Reset(); | 19266 object1.Reset(); |
| 19204 object2.Reset(); | 19267 object2.Reset(); |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 19255 v8::RegExp::kMultiline)); | 19318 v8::RegExp::kMultiline)); |
| 19256 CHECK(re->IsRegExp()); | 19319 CHECK(re->IsRegExp()); |
| 19257 CHECK(re->GetSource()->Equals(v8_str("foobarbaz"))); | 19320 CHECK(re->GetSource()->Equals(v8_str("foobarbaz"))); |
| 19258 CHECK_EQ(v8::RegExp::kIgnoreCase | v8::RegExp::kMultiline, | 19321 CHECK_EQ(v8::RegExp::kIgnoreCase | v8::RegExp::kMultiline, |
| 19259 static_cast<int>(re->GetFlags())); | 19322 static_cast<int>(re->GetFlags())); |
| 19260 | 19323 |
| 19261 context->Global()->Set(v8_str("re"), re); | 19324 context->Global()->Set(v8_str("re"), re); |
| 19262 ExpectTrue("re.test('FoobarbaZ')"); | 19325 ExpectTrue("re.test('FoobarbaZ')"); |
| 19263 | 19326 |
| 19264 // RegExps are objects on which you can set properties. | 19327 // RegExps are objects on which you can set properties. |
| 19265 re->Set(v8_str("property"), v8::Integer::New(32)); | 19328 re->Set(v8_str("property"), v8::Integer::New(context->GetIsolate(), 32)); |
| 19266 v8::Handle<v8::Value> value(CompileRun("re.property")); | 19329 v8::Handle<v8::Value> value(CompileRun("re.property")); |
| 19267 CHECK_EQ(32, value->Int32Value()); | 19330 CHECK_EQ(32, value->Int32Value()); |
| 19268 | 19331 |
| 19269 v8::TryCatch try_catch; | 19332 v8::TryCatch try_catch; |
| 19270 re = v8::RegExp::New(v8_str("foo["), v8::RegExp::kNone); | 19333 re = v8::RegExp::New(v8_str("foo["), v8::RegExp::kNone); |
| 19271 CHECK(re.IsEmpty()); | 19334 CHECK(re.IsEmpty()); |
| 19272 CHECK(try_catch.HasCaught()); | 19335 CHECK(try_catch.HasCaught()); |
| 19273 context->Global()->Set(v8_str("ex"), try_catch.Exception()); | 19336 context->Global()->Set(v8_str("ex"), try_catch.Exception()); |
| 19274 ExpectTrue("ex instanceof SyntaxError"); | 19337 ExpectTrue("ex instanceof SyntaxError"); |
| 19275 } | 19338 } |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 19334 " { configurable: true, enumerable: true, value: 3 });" | 19397 " { configurable: true, enumerable: true, value: 3 });" |
| 19335 "})").As<Function>(); | 19398 "})").As<Function>(); |
| 19336 context->DetachGlobal(); | 19399 context->DetachGlobal(); |
| 19337 define_property->Call(proxy, 0, NULL); | 19400 define_property->Call(proxy, 0, NULL); |
| 19338 } | 19401 } |
| 19339 | 19402 |
| 19340 | 19403 |
| 19341 static void InstallContextId(v8::Handle<Context> context, int id) { | 19404 static void InstallContextId(v8::Handle<Context> context, int id) { |
| 19342 Context::Scope scope(context); | 19405 Context::Scope scope(context); |
| 19343 CompileRun("Object.prototype").As<Object>()-> | 19406 CompileRun("Object.prototype").As<Object>()-> |
| 19344 Set(v8_str("context_id"), v8::Integer::New(id)); | 19407 Set(v8_str("context_id"), v8::Integer::New(context->GetIsolate(), id)); |
| 19345 } | 19408 } |
| 19346 | 19409 |
| 19347 | 19410 |
| 19348 static void CheckContextId(v8::Handle<Object> object, int expected) { | 19411 static void CheckContextId(v8::Handle<Object> object, int expected) { |
| 19349 CHECK_EQ(expected, object->Get(v8_str("context_id"))->Int32Value()); | 19412 CHECK_EQ(expected, object->Get(v8_str("context_id"))->Int32Value()); |
| 19350 } | 19413 } |
| 19351 | 19414 |
| 19352 | 19415 |
| 19353 THREADED_TEST(CreationContext) { | 19416 THREADED_TEST(CreationContext) { |
| 19354 v8::Isolate* isolate = CcTest::isolate(); | 19417 v8::Isolate* isolate = CcTest::isolate(); |
| 19355 HandleScope handle_scope(isolate); | 19418 HandleScope handle_scope(isolate); |
| 19356 Handle<Context> context1 = Context::New(isolate); | 19419 Handle<Context> context1 = Context::New(isolate); |
| 19357 InstallContextId(context1, 1); | 19420 InstallContextId(context1, 1); |
| 19358 Handle<Context> context2 = Context::New(isolate); | 19421 Handle<Context> context2 = Context::New(isolate); |
| 19359 InstallContextId(context2, 2); | 19422 InstallContextId(context2, 2); |
| 19360 Handle<Context> context3 = Context::New(isolate); | 19423 Handle<Context> context3 = Context::New(isolate); |
| 19361 InstallContextId(context3, 3); | 19424 InstallContextId(context3, 3); |
| 19362 | 19425 |
| 19363 Local<v8::FunctionTemplate> tmpl = v8::FunctionTemplate::New(isolate); | 19426 Local<v8::FunctionTemplate> tmpl = v8::FunctionTemplate::New(isolate); |
| 19364 | 19427 |
| 19365 Local<Object> object1; | 19428 Local<Object> object1; |
| 19366 Local<Function> func1; | 19429 Local<Function> func1; |
| 19367 { | 19430 { |
| 19368 Context::Scope scope(context1); | 19431 Context::Scope scope(context1); |
| 19369 object1 = Object::New(); | 19432 object1 = Object::New(isolate); |
| 19370 func1 = tmpl->GetFunction(); | 19433 func1 = tmpl->GetFunction(); |
| 19371 } | 19434 } |
| 19372 | 19435 |
| 19373 Local<Object> object2; | 19436 Local<Object> object2; |
| 19374 Local<Function> func2; | 19437 Local<Function> func2; |
| 19375 { | 19438 { |
| 19376 Context::Scope scope(context2); | 19439 Context::Scope scope(context2); |
| 19377 object2 = Object::New(); | 19440 object2 = Object::New(isolate); |
| 19378 func2 = tmpl->GetFunction(); | 19441 func2 = tmpl->GetFunction(); |
| 19379 } | 19442 } |
| 19380 | 19443 |
| 19381 Local<Object> instance1; | 19444 Local<Object> instance1; |
| 19382 Local<Object> instance2; | 19445 Local<Object> instance2; |
| 19383 | 19446 |
| 19384 { | 19447 { |
| 19385 Context::Scope scope(context3); | 19448 Context::Scope scope(context3); |
| 19386 instance1 = func1->NewInstance(); | 19449 instance1 = func1->NewInstance(); |
| 19387 instance2 = func2->NewInstance(); | 19450 instance2 = func2->NewInstance(); |
| (...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 19778 protected_hidden_proto_template->InstanceTemplate()->SetAccessCheckCallbacks( | 19841 protected_hidden_proto_template->InstanceTemplate()->SetAccessCheckCallbacks( |
| 19779 BlockProtoNamedSecurityTestCallback, | 19842 BlockProtoNamedSecurityTestCallback, |
| 19780 IndexedSecurityTestCallback); | 19843 IndexedSecurityTestCallback); |
| 19781 protected_hidden_proto_template->SetHiddenPrototype(true); | 19844 protected_hidden_proto_template->SetHiddenPrototype(true); |
| 19782 | 19845 |
| 19783 // Context for "foreign" objects used in test. | 19846 // Context for "foreign" objects used in test. |
| 19784 Local<Context> context = v8::Context::New(isolate); | 19847 Local<Context> context = v8::Context::New(isolate); |
| 19785 context->Enter(); | 19848 context->Enter(); |
| 19786 | 19849 |
| 19787 // Plain object, no security check. | 19850 // Plain object, no security check. |
| 19788 Local<Object> simple_object = Object::New(); | 19851 Local<Object> simple_object = Object::New(isolate); |
| 19789 | 19852 |
| 19790 // Object with explicit security check. | 19853 // Object with explicit security check. |
| 19791 Local<Object> protected_object = | 19854 Local<Object> protected_object = |
| 19792 no_proto_template->NewInstance(); | 19855 no_proto_template->NewInstance(); |
| 19793 | 19856 |
| 19794 // JSGlobalProxy object, always have security check. | 19857 // JSGlobalProxy object, always have security check. |
| 19795 Local<Object> proxy_object = | 19858 Local<Object> proxy_object = |
| 19796 context->Global(); | 19859 context->Global(); |
| 19797 | 19860 |
| 19798 // Global object, the prototype of proxy_object. No security checks. | 19861 // Global object, the prototype of proxy_object. No security checks. |
| 19799 Local<Object> global_object = | 19862 Local<Object> global_object = |
| 19800 proxy_object->GetPrototype()->ToObject(); | 19863 proxy_object->GetPrototype()->ToObject(); |
| 19801 | 19864 |
| 19802 // Hidden prototype without security check. | 19865 // Hidden prototype without security check. |
| 19803 Local<Object> hidden_prototype = | 19866 Local<Object> hidden_prototype = |
| 19804 hidden_proto_template->GetFunction()->NewInstance(); | 19867 hidden_proto_template->GetFunction()->NewInstance(); |
| 19805 Local<Object> object_with_hidden = | 19868 Local<Object> object_with_hidden = |
| 19806 Object::New(); | 19869 Object::New(isolate); |
| 19807 object_with_hidden->SetPrototype(hidden_prototype); | 19870 object_with_hidden->SetPrototype(hidden_prototype); |
| 19808 | 19871 |
| 19809 // Hidden prototype with security check on the hidden prototype. | 19872 // Hidden prototype with security check on the hidden prototype. |
| 19810 Local<Object> protected_hidden_prototype = | 19873 Local<Object> protected_hidden_prototype = |
| 19811 protected_hidden_proto_template->GetFunction()->NewInstance(); | 19874 protected_hidden_proto_template->GetFunction()->NewInstance(); |
| 19812 Local<Object> object_with_protected_hidden = | 19875 Local<Object> object_with_protected_hidden = |
| 19813 Object::New(); | 19876 Object::New(isolate); |
| 19814 object_with_protected_hidden->SetPrototype(protected_hidden_prototype); | 19877 object_with_protected_hidden->SetPrototype(protected_hidden_prototype); |
| 19815 | 19878 |
| 19816 context->Exit(); | 19879 context->Exit(); |
| 19817 | 19880 |
| 19818 // Template for object for second context. Values to test are put on it as | 19881 // Template for object for second context. Values to test are put on it as |
| 19819 // properties. | 19882 // properties. |
| 19820 Local<ObjectTemplate> global_template = ObjectTemplate::New(); | 19883 Local<ObjectTemplate> global_template = ObjectTemplate::New(); |
| 19821 global_template->Set(v8_str("simple"), simple_object); | 19884 global_template->Set(v8_str("simple"), simple_object); |
| 19822 global_template->Set(v8_str("protected"), protected_object); | 19885 global_template->Set(v8_str("protected"), protected_object); |
| 19823 global_template->Set(v8_str("global"), global_object); | 19886 global_template->Set(v8_str("global"), global_object); |
| (...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 20212 isolate->Dispose(); | 20275 isolate->Dispose(); |
| 20213 } | 20276 } |
| 20214 | 20277 |
| 20215 | 20278 |
| 20216 TEST(StringEmpty) { | 20279 TEST(StringEmpty) { |
| 20217 LocalContext context; | 20280 LocalContext context; |
| 20218 i::Factory* factory = CcTest::i_isolate()->factory(); | 20281 i::Factory* factory = CcTest::i_isolate()->factory(); |
| 20219 v8::Isolate* isolate = CcTest::isolate(); | 20282 v8::Isolate* isolate = CcTest::isolate(); |
| 20220 v8::HandleScope scope(isolate); | 20283 v8::HandleScope scope(isolate); |
| 20221 i::Handle<i::Object> empty_string = factory->empty_string(); | 20284 i::Handle<i::Object> empty_string = factory->empty_string(); |
| 20222 CHECK(*v8::Utils::OpenHandle(*v8::String::Empty()) == *empty_string); | |
| 20223 CHECK(*v8::Utils::OpenHandle(*v8::String::Empty(isolate)) == *empty_string); | 20285 CHECK(*v8::Utils::OpenHandle(*v8::String::Empty(isolate)) == *empty_string); |
| 20224 } | 20286 } |
| 20225 | 20287 |
| 20226 | 20288 |
| 20227 static int instance_checked_getter_count = 0; | 20289 static int instance_checked_getter_count = 0; |
| 20228 static void InstanceCheckedGetter( | 20290 static void InstanceCheckedGetter( |
| 20229 Local<String> name, | 20291 Local<String> name, |
| 20230 const v8::PropertyCallbackInfo<v8::Value>& info) { | 20292 const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 20231 CHECK_EQ(name, v8_str("foo")); | 20293 CHECK_EQ(name, v8_str("foo")); |
| 20232 instance_checked_getter_count++; | 20294 instance_checked_getter_count++; |
| (...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 20626 Local<Value> map_value = CompileRun("new Map();"); | 20688 Local<Value> map_value = CompileRun("new Map();"); |
| 20627 Local<Object> map_object(Local<Object>::Cast(map_value)); | 20689 Local<Object> map_object(Local<Object>::Cast(map_value)); |
| 20628 CHECK_EQ(0, map_object->InternalFieldCount()); | 20690 CHECK_EQ(0, map_object->InternalFieldCount()); |
| 20629 } | 20691 } |
| 20630 | 20692 |
| 20631 | 20693 |
| 20632 THREADED_TEST(Regress2746) { | 20694 THREADED_TEST(Regress2746) { |
| 20633 LocalContext context; | 20695 LocalContext context; |
| 20634 v8::Isolate* isolate = context->GetIsolate(); | 20696 v8::Isolate* isolate = context->GetIsolate(); |
| 20635 v8::HandleScope scope(isolate); | 20697 v8::HandleScope scope(isolate); |
| 20636 Local<Object> obj = Object::New(); | 20698 Local<Object> obj = Object::New(isolate); |
| 20637 Local<String> key = String::NewFromUtf8(context->GetIsolate(), "key"); | 20699 Local<String> key = String::NewFromUtf8(context->GetIsolate(), "key"); |
| 20638 obj->SetHiddenValue(key, v8::Undefined(isolate)); | 20700 obj->SetHiddenValue(key, v8::Undefined(isolate)); |
| 20639 Local<Value> value = obj->GetHiddenValue(key); | 20701 Local<Value> value = obj->GetHiddenValue(key); |
| 20640 CHECK(!value.IsEmpty()); | 20702 CHECK(!value.IsEmpty()); |
| 20641 CHECK(value->IsUndefined()); | 20703 CHECK(value->IsUndefined()); |
| 20642 } | 20704 } |
| 20643 | 20705 |
| 20644 | 20706 |
| 20645 THREADED_TEST(Regress260106) { | 20707 THREADED_TEST(Regress260106) { |
| 20646 LocalContext context; | 20708 LocalContext context; |
| (...skipping 633 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 21280 static void FunctionNewCallback(const v8::FunctionCallbackInfo<Value>& info) { | 21342 static void FunctionNewCallback(const v8::FunctionCallbackInfo<Value>& info) { |
| 21281 CHECK_EQ(function_new_expected_env, info.Data()); | 21343 CHECK_EQ(function_new_expected_env, info.Data()); |
| 21282 info.GetReturnValue().Set(17); | 21344 info.GetReturnValue().Set(17); |
| 21283 } | 21345 } |
| 21284 | 21346 |
| 21285 | 21347 |
| 21286 THREADED_TEST(FunctionNew) { | 21348 THREADED_TEST(FunctionNew) { |
| 21287 LocalContext env; | 21349 LocalContext env; |
| 21288 v8::Isolate* isolate = env->GetIsolate(); | 21350 v8::Isolate* isolate = env->GetIsolate(); |
| 21289 v8::HandleScope scope(isolate); | 21351 v8::HandleScope scope(isolate); |
| 21290 Local<Object> data = v8::Object::New(); | 21352 Local<Object> data = v8::Object::New(isolate); |
| 21291 function_new_expected_env = data; | 21353 function_new_expected_env = data; |
| 21292 Local<Function> func = Function::New(isolate, FunctionNewCallback, data); | 21354 Local<Function> func = Function::New(isolate, FunctionNewCallback, data); |
| 21293 env->Global()->Set(v8_str("func"), func); | 21355 env->Global()->Set(v8_str("func"), func); |
| 21294 Local<Value> result = CompileRun("func();"); | 21356 Local<Value> result = CompileRun("func();"); |
| 21295 CHECK_EQ(v8::Integer::New(17, isolate), result); | 21357 CHECK_EQ(v8::Integer::New(isolate, 17), result); |
| 21296 // Verify function not cached | 21358 // Verify function not cached |
| 21297 int serial_number = | 21359 int serial_number = |
| 21298 i::Smi::cast(v8::Utils::OpenHandle(*func) | 21360 i::Smi::cast(v8::Utils::OpenHandle(*func) |
| 21299 ->shared()->get_api_func_data()->serial_number())->value(); | 21361 ->shared()->get_api_func_data()->serial_number())->value(); |
| 21300 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); | 21362 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
| 21301 i::Object* elm = i_isolate->native_context()->function_cache() | 21363 i::Object* elm = i_isolate->native_context()->function_cache() |
| 21302 ->GetElementNoExceptionThrown(i_isolate, serial_number); | 21364 ->GetElementNoExceptionThrown(i_isolate, serial_number); |
| 21303 CHECK(elm->IsUndefined()); | 21365 CHECK(elm->IsUndefined()); |
| 21304 // Verify that each Function::New creates a new function instance | 21366 // Verify that each Function::New creates a new function instance |
| 21305 Local<Object> data2 = v8::Object::New(); | 21367 Local<Object> data2 = v8::Object::New(isolate); |
| 21306 function_new_expected_env = data2; | 21368 function_new_expected_env = data2; |
| 21307 Local<Function> func2 = Function::New(isolate, FunctionNewCallback, data2); | 21369 Local<Function> func2 = Function::New(isolate, FunctionNewCallback, data2); |
| 21308 CHECK(!func2->IsNull()); | 21370 CHECK(!func2->IsNull()); |
| 21309 CHECK_NE(func, func2); | 21371 CHECK_NE(func, func2); |
| 21310 env->Global()->Set(v8_str("func2"), func2); | 21372 env->Global()->Set(v8_str("func2"), func2); |
| 21311 Local<Value> result2 = CompileRun("func2();"); | 21373 Local<Value> result2 = CompileRun("func2();"); |
| 21312 CHECK_EQ(v8::Integer::New(17, isolate), result2); | 21374 CHECK_EQ(v8::Integer::New(isolate, 17), result2); |
| 21313 } | 21375 } |
| 21314 | 21376 |
| 21315 | 21377 |
| 21316 TEST(EscapeableHandleScope) { | 21378 TEST(EscapeableHandleScope) { |
| 21317 HandleScope outer_scope(CcTest::isolate()); | 21379 HandleScope outer_scope(CcTest::isolate()); |
| 21318 LocalContext context; | 21380 LocalContext context; |
| 21319 const int runs = 10; | 21381 const int runs = 10; |
| 21320 Local<String> values[runs]; | 21382 Local<String> values[runs]; |
| 21321 for (int i = 0; i < runs; i++) { | 21383 for (int i = 0; i < runs; i++) { |
| 21322 v8::EscapableHandleScope inner_scope(CcTest::isolate()); | 21384 v8::EscapableHandleScope inner_scope(CcTest::isolate()); |
| 21323 Local<String> value; | 21385 Local<String> value; |
| 21324 if (i != 0) value = v8_str("escape value"); | 21386 if (i != 0) value = v8_str("escape value"); |
| 21325 values[i] = inner_scope.Escape(value); | 21387 values[i] = inner_scope.Escape(value); |
| 21326 } | 21388 } |
| 21327 for (int i = 0; i < runs; i++) { | 21389 for (int i = 0; i < runs; i++) { |
| 21328 Local<String> expected; | 21390 Local<String> expected; |
| 21329 if (i != 0) { | 21391 if (i != 0) { |
| 21330 CHECK_EQ(v8_str("escape value"), values[i]); | 21392 CHECK_EQ(v8_str("escape value"), values[i]); |
| 21331 } else { | 21393 } else { |
| 21332 CHECK(values[i].IsEmpty()); | 21394 CHECK(values[i].IsEmpty()); |
| 21333 } | 21395 } |
| 21334 } | 21396 } |
| 21335 } | 21397 } |
| OLD | NEW |