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 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4460 CompileRun( | 4473 CompileRun( |
4461 "var str = Array.prototype.join.call({length: 513}, \"A\").toUpperCase();" | 4474 "var str = Array.prototype.join.call({length: 513}, \"A\").toUpperCase();" |
4462 "for (var i = 0; i < 22; i++) { str = str + str; }"); | 4475 "for (var i = 0; i < 22; i++) { str = str + str; }"); |
4463 | 4476 |
4464 CHECK(false); // Should not return. | 4477 CHECK(false); // Should not return. |
4465 } | 4478 } |
4466 | 4479 |
4467 | 4480 |
4468 THREADED_TEST(ConstructCall) { | 4481 THREADED_TEST(ConstructCall) { |
4469 LocalContext context; | 4482 LocalContext context; |
4470 v8::HandleScope scope(context->GetIsolate()); | 4483 v8::Isolate* isolate = context->GetIsolate(); |
| 4484 v8::HandleScope scope(isolate); |
4471 CompileRun( | 4485 CompileRun( |
4472 "function Foo() {" | 4486 "function Foo() {" |
4473 " var result = [];" | 4487 " var result = [];" |
4474 " for (var i = 0; i < arguments.length; i++) {" | 4488 " for (var i = 0; i < arguments.length; i++) {" |
4475 " result.push(arguments[i]);" | 4489 " result.push(arguments[i]);" |
4476 " }" | 4490 " }" |
4477 " return result;" | 4491 " return result;" |
4478 "}"); | 4492 "}"); |
4479 Local<Function> Foo = | 4493 Local<Function> Foo = |
4480 Local<Function>::Cast(context->Global()->Get(v8_str("Foo"))); | 4494 Local<Function>::Cast(context->Global()->Get(v8_str("Foo"))); |
4481 | 4495 |
4482 v8::Handle<Value>* args0 = NULL; | 4496 v8::Handle<Value>* args0 = NULL; |
4483 Local<v8::Array> a0 = Local<v8::Array>::Cast(Foo->NewInstance(0, args0)); | 4497 Local<v8::Array> a0 = Local<v8::Array>::Cast(Foo->NewInstance(0, args0)); |
4484 CHECK_EQ(0, a0->Length()); | 4498 CHECK_EQ(0, a0->Length()); |
4485 | 4499 |
4486 v8::Handle<Value> args1[] = { v8_num(1.1) }; | 4500 v8::Handle<Value> args1[] = { v8_num(1.1) }; |
4487 Local<v8::Array> a1 = Local<v8::Array>::Cast(Foo->NewInstance(1, args1)); | 4501 Local<v8::Array> a1 = Local<v8::Array>::Cast(Foo->NewInstance(1, args1)); |
4488 CHECK_EQ(1, a1->Length()); | 4502 CHECK_EQ(1, a1->Length()); |
4489 CHECK_EQ(1.1, a1->Get(v8::Integer::New(0))->NumberValue()); | 4503 CHECK_EQ(1.1, a1->Get(v8::Integer::New(isolate, 0))->NumberValue()); |
4490 | 4504 |
4491 v8::Handle<Value> args2[] = { v8_num(2.2), | 4505 v8::Handle<Value> args2[] = { v8_num(2.2), |
4492 v8_num(3.3) }; | 4506 v8_num(3.3) }; |
4493 Local<v8::Array> a2 = Local<v8::Array>::Cast(Foo->NewInstance(2, args2)); | 4507 Local<v8::Array> a2 = Local<v8::Array>::Cast(Foo->NewInstance(2, args2)); |
4494 CHECK_EQ(2, a2->Length()); | 4508 CHECK_EQ(2, a2->Length()); |
4495 CHECK_EQ(2.2, a2->Get(v8::Integer::New(0))->NumberValue()); | 4509 CHECK_EQ(2.2, a2->Get(v8::Integer::New(isolate, 0))->NumberValue()); |
4496 CHECK_EQ(3.3, a2->Get(v8::Integer::New(1))->NumberValue()); | 4510 CHECK_EQ(3.3, a2->Get(v8::Integer::New(isolate, 1))->NumberValue()); |
4497 | 4511 |
4498 v8::Handle<Value> args3[] = { v8_num(4.4), | 4512 v8::Handle<Value> args3[] = { v8_num(4.4), |
4499 v8_num(5.5), | 4513 v8_num(5.5), |
4500 v8_num(6.6) }; | 4514 v8_num(6.6) }; |
4501 Local<v8::Array> a3 = Local<v8::Array>::Cast(Foo->NewInstance(3, args3)); | 4515 Local<v8::Array> a3 = Local<v8::Array>::Cast(Foo->NewInstance(3, args3)); |
4502 CHECK_EQ(3, a3->Length()); | 4516 CHECK_EQ(3, a3->Length()); |
4503 CHECK_EQ(4.4, a3->Get(v8::Integer::New(0))->NumberValue()); | 4517 CHECK_EQ(4.4, a3->Get(v8::Integer::New(isolate, 0))->NumberValue()); |
4504 CHECK_EQ(5.5, a3->Get(v8::Integer::New(1))->NumberValue()); | 4518 CHECK_EQ(5.5, a3->Get(v8::Integer::New(isolate, 1))->NumberValue()); |
4505 CHECK_EQ(6.6, a3->Get(v8::Integer::New(2))->NumberValue()); | 4519 CHECK_EQ(6.6, a3->Get(v8::Integer::New(isolate, 2))->NumberValue()); |
4506 | 4520 |
4507 v8::Handle<Value> args4[] = { v8_num(7.7), | 4521 v8::Handle<Value> args4[] = { v8_num(7.7), |
4508 v8_num(8.8), | 4522 v8_num(8.8), |
4509 v8_num(9.9), | 4523 v8_num(9.9), |
4510 v8_num(10.11) }; | 4524 v8_num(10.11) }; |
4511 Local<v8::Array> a4 = Local<v8::Array>::Cast(Foo->NewInstance(4, args4)); | 4525 Local<v8::Array> a4 = Local<v8::Array>::Cast(Foo->NewInstance(4, args4)); |
4512 CHECK_EQ(4, a4->Length()); | 4526 CHECK_EQ(4, a4->Length()); |
4513 CHECK_EQ(7.7, a4->Get(v8::Integer::New(0))->NumberValue()); | 4527 CHECK_EQ(7.7, a4->Get(v8::Integer::New(isolate, 0))->NumberValue()); |
4514 CHECK_EQ(8.8, a4->Get(v8::Integer::New(1))->NumberValue()); | 4528 CHECK_EQ(8.8, a4->Get(v8::Integer::New(isolate, 1))->NumberValue()); |
4515 CHECK_EQ(9.9, a4->Get(v8::Integer::New(2))->NumberValue()); | 4529 CHECK_EQ(9.9, a4->Get(v8::Integer::New(isolate, 2))->NumberValue()); |
4516 CHECK_EQ(10.11, a4->Get(v8::Integer::New(3))->NumberValue()); | 4530 CHECK_EQ(10.11, a4->Get(v8::Integer::New(isolate, 3))->NumberValue()); |
4517 } | 4531 } |
4518 | 4532 |
4519 | 4533 |
4520 static void CheckUncle(v8::TryCatch* try_catch) { | 4534 static void CheckUncle(v8::TryCatch* try_catch) { |
4521 CHECK(try_catch->HasCaught()); | 4535 CHECK(try_catch->HasCaught()); |
4522 String::Utf8Value str_value(try_catch->Exception()); | 4536 String::Utf8Value str_value(try_catch->Exception()); |
4523 CHECK_EQ(*str_value, "uncle?"); | 4537 CHECK_EQ(*str_value, "uncle?"); |
4524 try_catch->Reset(); | 4538 try_catch->Reset(); |
4525 } | 4539 } |
4526 | 4540 |
(...skipping 593 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5120 "function Run(obj) {" | 5134 "function Run(obj) {" |
5121 " try {" | 5135 " try {" |
5122 " Throw(obj);" | 5136 " Throw(obj);" |
5123 " } catch (e) {" | 5137 " } catch (e) {" |
5124 " return e;" | 5138 " return e;" |
5125 " }" | 5139 " }" |
5126 " return 'no exception';" | 5140 " return 'no exception';" |
5127 "}" | 5141 "}" |
5128 "[Run('str'), Run(1), Run(0), Run(null), Run(void 0)];")); | 5142 "[Run('str'), Run(1), Run(0), Run(null), Run(void 0)];")); |
5129 CHECK_EQ(5, result->Length()); | 5143 CHECK_EQ(5, result->Length()); |
5130 CHECK(result->Get(v8::Integer::New(0))->IsString()); | 5144 CHECK(result->Get(v8::Integer::New(isolate, 0))->IsString()); |
5131 CHECK(result->Get(v8::Integer::New(1))->IsNumber()); | 5145 CHECK(result->Get(v8::Integer::New(isolate, 1))->IsNumber()); |
5132 CHECK_EQ(1, result->Get(v8::Integer::New(1))->Int32Value()); | 5146 CHECK_EQ(1, result->Get(v8::Integer::New(isolate, 1))->Int32Value()); |
5133 CHECK(result->Get(v8::Integer::New(2))->IsNumber()); | 5147 CHECK(result->Get(v8::Integer::New(isolate, 2))->IsNumber()); |
5134 CHECK_EQ(0, result->Get(v8::Integer::New(2))->Int32Value()); | 5148 CHECK_EQ(0, result->Get(v8::Integer::New(isolate, 2))->Int32Value()); |
5135 CHECK(result->Get(v8::Integer::New(3))->IsNull()); | 5149 CHECK(result->Get(v8::Integer::New(isolate, 3))->IsNull()); |
5136 CHECK(result->Get(v8::Integer::New(4))->IsUndefined()); | 5150 CHECK(result->Get(v8::Integer::New(isolate, 4))->IsUndefined()); |
5137 } | 5151 } |
5138 | 5152 |
5139 | 5153 |
5140 THREADED_TEST(CatchZero) { | 5154 THREADED_TEST(CatchZero) { |
5141 LocalContext context; | 5155 LocalContext context; |
5142 v8::HandleScope scope(context->GetIsolate()); | 5156 v8::HandleScope scope(context->GetIsolate()); |
5143 v8::TryCatch try_catch; | 5157 v8::TryCatch try_catch; |
5144 CHECK(!try_catch.HasCaught()); | 5158 CHECK(!try_catch.HasCaught()); |
5145 Script::Compile(v8_str("throw 10"))->Run(); | 5159 Script::Compile(v8_str("throw 10"))->Run(); |
5146 CHECK(try_catch.HasCaught()); | 5160 CHECK(try_catch.HasCaught()); |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5283 CHECK(!v8_str("a")->StrictEquals(v8_str("b"))); | 5297 CHECK(!v8_str("a")->StrictEquals(v8_str("b"))); |
5284 CHECK(!v8_str("5")->StrictEquals(v8_num(5))); | 5298 CHECK(!v8_str("5")->StrictEquals(v8_num(5))); |
5285 CHECK(v8_num(1)->StrictEquals(v8_num(1))); | 5299 CHECK(v8_num(1)->StrictEquals(v8_num(1))); |
5286 CHECK(!v8_num(1)->StrictEquals(v8_num(2))); | 5300 CHECK(!v8_num(1)->StrictEquals(v8_num(2))); |
5287 CHECK(v8_num(0.0)->StrictEquals(v8_num(-0.0))); | 5301 CHECK(v8_num(0.0)->StrictEquals(v8_num(-0.0))); |
5288 Local<Value> not_a_number = v8_num(i::OS::nan_value()); | 5302 Local<Value> not_a_number = v8_num(i::OS::nan_value()); |
5289 CHECK(!not_a_number->StrictEquals(not_a_number)); | 5303 CHECK(!not_a_number->StrictEquals(not_a_number)); |
5290 CHECK(v8::False(isolate)->StrictEquals(v8::False(isolate))); | 5304 CHECK(v8::False(isolate)->StrictEquals(v8::False(isolate))); |
5291 CHECK(!v8::False(isolate)->StrictEquals(v8::Undefined(isolate))); | 5305 CHECK(!v8::False(isolate)->StrictEquals(v8::Undefined(isolate))); |
5292 | 5306 |
5293 v8::Handle<v8::Object> obj = v8::Object::New(); | 5307 v8::Handle<v8::Object> obj = v8::Object::New(isolate); |
5294 v8::Persistent<v8::Object> alias(isolate, obj); | 5308 v8::Persistent<v8::Object> alias(isolate, obj); |
5295 CHECK(v8::Local<v8::Object>::New(isolate, alias)->StrictEquals(obj)); | 5309 CHECK(v8::Local<v8::Object>::New(isolate, alias)->StrictEquals(obj)); |
5296 alias.Reset(); | 5310 alias.Reset(); |
5297 | 5311 |
5298 CHECK(v8_str("a")->SameValue(v8_str("a"))); | 5312 CHECK(v8_str("a")->SameValue(v8_str("a"))); |
5299 CHECK(!v8_str("a")->SameValue(v8_str("b"))); | 5313 CHECK(!v8_str("a")->SameValue(v8_str("b"))); |
5300 CHECK(!v8_str("5")->SameValue(v8_num(5))); | 5314 CHECK(!v8_str("5")->SameValue(v8_num(5))); |
5301 CHECK(v8_num(1)->SameValue(v8_num(1))); | 5315 CHECK(v8_num(1)->SameValue(v8_num(1))); |
5302 CHECK(!v8_num(1)->SameValue(v8_num(2))); | 5316 CHECK(!v8_num(1)->SameValue(v8_num(2))); |
5303 CHECK(!v8_num(0.0)->SameValue(v8_num(-0.0))); | 5317 CHECK(!v8_num(0.0)->SameValue(v8_num(-0.0))); |
(...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5746 CompileRun("var obj = { x : 0 }; delete obj.x;"); | 5760 CompileRun("var obj = { x : 0 }; delete obj.x;"); |
5747 context1->Exit(); | 5761 context1->Exit(); |
5748 } | 5762 } |
5749 | 5763 |
5750 | 5764 |
5751 static void SetXOnPrototypeGetter( | 5765 static void SetXOnPrototypeGetter( |
5752 Local<String> property, | 5766 Local<String> property, |
5753 const v8::PropertyCallbackInfo<v8::Value>& info) { | 5767 const v8::PropertyCallbackInfo<v8::Value>& info) { |
5754 // Set x on the prototype object and do not handle the get request. | 5768 // Set x on the prototype object and do not handle the get request. |
5755 v8::Handle<v8::Value> proto = info.Holder()->GetPrototype(); | 5769 v8::Handle<v8::Value> proto = info.Holder()->GetPrototype(); |
5756 proto.As<v8::Object>()->Set(v8_str("x"), v8::Integer::New(23)); | 5770 proto.As<v8::Object>()->Set(v8_str("x"), |
| 5771 v8::Integer::New(info.GetIsolate(), 23)); |
5757 } | 5772 } |
5758 | 5773 |
5759 | 5774 |
5760 // This is a regression test for http://crbug.com/20104. Map | 5775 // This is a regression test for http://crbug.com/20104. Map |
5761 // transitions should not interfere with post interceptor lookup. | 5776 // transitions should not interfere with post interceptor lookup. |
5762 THREADED_TEST(NamedInterceptorMapTransitionRead) { | 5777 THREADED_TEST(NamedInterceptorMapTransitionRead) { |
5763 v8::Isolate* isolate = CcTest::isolate(); | 5778 v8::Isolate* isolate = CcTest::isolate(); |
5764 v8::HandleScope scope(isolate); | 5779 v8::HandleScope scope(isolate); |
5765 Local<v8::FunctionTemplate> function_template = | 5780 Local<v8::FunctionTemplate> function_template = |
5766 v8::FunctionTemplate::New(isolate); | 5781 v8::FunctionTemplate::New(isolate); |
(...skipping 636 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6403 desc->InstanceTemplate()->MarkAsUndetectable(); // undetectable | 6418 desc->InstanceTemplate()->MarkAsUndetectable(); // undetectable |
6404 | 6419 |
6405 Local<v8::Object> obj = desc->GetFunction()->NewInstance(); | 6420 Local<v8::Object> obj = desc->GetFunction()->NewInstance(); |
6406 env->Global()->Set(v8_str("undetectable"), obj); | 6421 env->Global()->Set(v8_str("undetectable"), obj); |
6407 | 6422 |
6408 Local<String> source = v8_str("undetectable.x = 42;" | 6423 Local<String> source = v8_str("undetectable.x = 42;" |
6409 "undetectable.x"); | 6424 "undetectable.x"); |
6410 | 6425 |
6411 Local<Script> script = Script::Compile(source); | 6426 Local<Script> script = Script::Compile(source); |
6412 | 6427 |
6413 CHECK_EQ(v8::Integer::New(42), script->Run()); | 6428 CHECK_EQ(v8::Integer::New(isolate, 42), script->Run()); |
6414 | 6429 |
6415 ExpectBoolean("Object.isExtensible(undetectable)", true); | 6430 ExpectBoolean("Object.isExtensible(undetectable)", true); |
6416 | 6431 |
6417 source = v8_str("Object.preventExtensions(undetectable);"); | 6432 source = v8_str("Object.preventExtensions(undetectable);"); |
6418 script = Script::Compile(source); | 6433 script = Script::Compile(source); |
6419 script->Run(); | 6434 script->Run(); |
6420 ExpectBoolean("Object.isExtensible(undetectable)", false); | 6435 ExpectBoolean("Object.isExtensible(undetectable)", false); |
6421 | 6436 |
6422 source = v8_str("undetectable.y = 2000;"); | 6437 source = v8_str("undetectable.y = 2000;"); |
6423 script = Script::Compile(source); | 6438 script = Script::Compile(source); |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6548 | 6563 |
6549 THREADED_TEST(SimpleExtensions) { | 6564 THREADED_TEST(SimpleExtensions) { |
6550 v8::HandleScope handle_scope(CcTest::isolate()); | 6565 v8::HandleScope handle_scope(CcTest::isolate()); |
6551 v8::RegisterExtension(new Extension("simpletest", kSimpleExtensionSource)); | 6566 v8::RegisterExtension(new Extension("simpletest", kSimpleExtensionSource)); |
6552 const char* extension_names[] = { "simpletest" }; | 6567 const char* extension_names[] = { "simpletest" }; |
6553 v8::ExtensionConfiguration extensions(1, extension_names); | 6568 v8::ExtensionConfiguration extensions(1, extension_names); |
6554 v8::Handle<Context> context = | 6569 v8::Handle<Context> context = |
6555 Context::New(CcTest::isolate(), &extensions); | 6570 Context::New(CcTest::isolate(), &extensions); |
6556 Context::Scope lock(context); | 6571 Context::Scope lock(context); |
6557 v8::Handle<Value> result = Script::Compile(v8_str("Foo()"))->Run(); | 6572 v8::Handle<Value> result = Script::Compile(v8_str("Foo()"))->Run(); |
6558 CHECK_EQ(result, v8::Integer::New(4)); | 6573 CHECK_EQ(result, v8::Integer::New(CcTest::isolate(), 4)); |
6559 } | 6574 } |
6560 | 6575 |
6561 | 6576 |
6562 THREADED_TEST(NullExtensions) { | 6577 THREADED_TEST(NullExtensions) { |
6563 v8::HandleScope handle_scope(CcTest::isolate()); | 6578 v8::HandleScope handle_scope(CcTest::isolate()); |
6564 v8::RegisterExtension(new Extension("nulltest", NULL)); | 6579 v8::RegisterExtension(new Extension("nulltest", NULL)); |
6565 const char* extension_names[] = { "nulltest" }; | 6580 const char* extension_names[] = { "nulltest" }; |
6566 v8::ExtensionConfiguration extensions(1, extension_names); | 6581 v8::ExtensionConfiguration extensions(1, extension_names); |
6567 v8::Handle<Context> context = | 6582 v8::Handle<Context> context = |
6568 Context::New(CcTest::isolate(), &extensions); | 6583 Context::New(CcTest::isolate(), &extensions); |
6569 Context::Scope lock(context); | 6584 Context::Scope lock(context); |
6570 v8::Handle<Value> result = Script::Compile(v8_str("1+3"))->Run(); | 6585 v8::Handle<Value> result = Script::Compile(v8_str("1+3"))->Run(); |
6571 CHECK_EQ(result, v8::Integer::New(4)); | 6586 CHECK_EQ(result, v8::Integer::New(CcTest::isolate(), 4)); |
6572 } | 6587 } |
6573 | 6588 |
6574 | 6589 |
6575 static const char* kEmbeddedExtensionSource = | 6590 static const char* kEmbeddedExtensionSource = |
6576 "function Ret54321(){return 54321;}~~@@$" | 6591 "function Ret54321(){return 54321;}~~@@$" |
6577 "$%% THIS IS A SERIES OF NON-NULL-TERMINATED STRINGS."; | 6592 "$%% THIS IS A SERIES OF NON-NULL-TERMINATED STRINGS."; |
6578 static const int kEmbeddedExtensionSourceValidLen = 34; | 6593 static const int kEmbeddedExtensionSourceValidLen = 34; |
6579 | 6594 |
6580 | 6595 |
6581 THREADED_TEST(ExtensionMissingSourceLength) { | 6596 THREADED_TEST(ExtensionMissingSourceLength) { |
(...skipping 17 matching lines...) Expand all Loading... |
6599 v8::RegisterExtension(new Extension(extension_name.start(), | 6614 v8::RegisterExtension(new Extension(extension_name.start(), |
6600 kEmbeddedExtensionSource, 0, 0, | 6615 kEmbeddedExtensionSource, 0, 0, |
6601 source_len)); | 6616 source_len)); |
6602 const char* extension_names[1] = { extension_name.start() }; | 6617 const char* extension_names[1] = { extension_name.start() }; |
6603 v8::ExtensionConfiguration extensions(1, extension_names); | 6618 v8::ExtensionConfiguration extensions(1, extension_names); |
6604 v8::Handle<Context> context = | 6619 v8::Handle<Context> context = |
6605 Context::New(CcTest::isolate(), &extensions); | 6620 Context::New(CcTest::isolate(), &extensions); |
6606 if (source_len == kEmbeddedExtensionSourceValidLen) { | 6621 if (source_len == kEmbeddedExtensionSourceValidLen) { |
6607 Context::Scope lock(context); | 6622 Context::Scope lock(context); |
6608 v8::Handle<Value> result = Script::Compile(v8_str("Ret54321()"))->Run(); | 6623 v8::Handle<Value> result = Script::Compile(v8_str("Ret54321()"))->Run(); |
6609 CHECK_EQ(v8::Integer::New(54321), result); | 6624 CHECK_EQ(v8::Integer::New(CcTest::isolate(), 54321), result); |
6610 } else { | 6625 } else { |
6611 // Anything but exactly the right length should fail to compile. | 6626 // Anything but exactly the right length should fail to compile. |
6612 CHECK_EQ(0, *context); | 6627 CHECK_EQ(0, *context); |
6613 } | 6628 } |
6614 } | 6629 } |
6615 } | 6630 } |
6616 | 6631 |
6617 | 6632 |
6618 static const char* kEvalExtensionSource1 = | 6633 static const char* kEvalExtensionSource1 = |
6619 "function UseEval1() {" | 6634 "function UseEval1() {" |
(...skipping 15 matching lines...) Expand all Loading... |
6635 THREADED_TEST(UseEvalFromExtension) { | 6650 THREADED_TEST(UseEvalFromExtension) { |
6636 v8::HandleScope handle_scope(CcTest::isolate()); | 6651 v8::HandleScope handle_scope(CcTest::isolate()); |
6637 v8::RegisterExtension(new Extension("evaltest1", kEvalExtensionSource1)); | 6652 v8::RegisterExtension(new Extension("evaltest1", kEvalExtensionSource1)); |
6638 v8::RegisterExtension(new Extension("evaltest2", kEvalExtensionSource2)); | 6653 v8::RegisterExtension(new Extension("evaltest2", kEvalExtensionSource2)); |
6639 const char* extension_names[] = { "evaltest1", "evaltest2" }; | 6654 const char* extension_names[] = { "evaltest1", "evaltest2" }; |
6640 v8::ExtensionConfiguration extensions(2, extension_names); | 6655 v8::ExtensionConfiguration extensions(2, extension_names); |
6641 v8::Handle<Context> context = | 6656 v8::Handle<Context> context = |
6642 Context::New(CcTest::isolate(), &extensions); | 6657 Context::New(CcTest::isolate(), &extensions); |
6643 Context::Scope lock(context); | 6658 Context::Scope lock(context); |
6644 v8::Handle<Value> result = Script::Compile(v8_str("UseEval1()"))->Run(); | 6659 v8::Handle<Value> result = Script::Compile(v8_str("UseEval1()"))->Run(); |
6645 CHECK_EQ(result, v8::Integer::New(42)); | 6660 CHECK_EQ(result, v8::Integer::New(CcTest::isolate(), 42)); |
6646 result = Script::Compile(v8_str("UseEval2()"))->Run(); | 6661 result = Script::Compile(v8_str("UseEval2()"))->Run(); |
6647 CHECK_EQ(result, v8::Integer::New(42)); | 6662 CHECK_EQ(result, v8::Integer::New(CcTest::isolate(), 42)); |
6648 } | 6663 } |
6649 | 6664 |
6650 | 6665 |
6651 static const char* kWithExtensionSource1 = | 6666 static const char* kWithExtensionSource1 = |
6652 "function UseWith1() {" | 6667 "function UseWith1() {" |
6653 " var x = 42;" | 6668 " var x = 42;" |
6654 " with({x:87}) { return x; }" | 6669 " with({x:87}) { return x; }" |
6655 "}"; | 6670 "}"; |
6656 | 6671 |
6657 | 6672 |
(...skipping 11 matching lines...) Expand all Loading... |
6669 THREADED_TEST(UseWithFromExtension) { | 6684 THREADED_TEST(UseWithFromExtension) { |
6670 v8::HandleScope handle_scope(CcTest::isolate()); | 6685 v8::HandleScope handle_scope(CcTest::isolate()); |
6671 v8::RegisterExtension(new Extension("withtest1", kWithExtensionSource1)); | 6686 v8::RegisterExtension(new Extension("withtest1", kWithExtensionSource1)); |
6672 v8::RegisterExtension(new Extension("withtest2", kWithExtensionSource2)); | 6687 v8::RegisterExtension(new Extension("withtest2", kWithExtensionSource2)); |
6673 const char* extension_names[] = { "withtest1", "withtest2" }; | 6688 const char* extension_names[] = { "withtest1", "withtest2" }; |
6674 v8::ExtensionConfiguration extensions(2, extension_names); | 6689 v8::ExtensionConfiguration extensions(2, extension_names); |
6675 v8::Handle<Context> context = | 6690 v8::Handle<Context> context = |
6676 Context::New(CcTest::isolate(), &extensions); | 6691 Context::New(CcTest::isolate(), &extensions); |
6677 Context::Scope lock(context); | 6692 Context::Scope lock(context); |
6678 v8::Handle<Value> result = Script::Compile(v8_str("UseWith1()"))->Run(); | 6693 v8::Handle<Value> result = Script::Compile(v8_str("UseWith1()"))->Run(); |
6679 CHECK_EQ(result, v8::Integer::New(87)); | 6694 CHECK_EQ(result, v8::Integer::New(CcTest::isolate(), 87)); |
6680 result = Script::Compile(v8_str("UseWith2()"))->Run(); | 6695 result = Script::Compile(v8_str("UseWith2()"))->Run(); |
6681 CHECK_EQ(result, v8::Integer::New(87)); | 6696 CHECK_EQ(result, v8::Integer::New(CcTest::isolate(), 87)); |
6682 } | 6697 } |
6683 | 6698 |
6684 | 6699 |
6685 THREADED_TEST(AutoExtensions) { | 6700 THREADED_TEST(AutoExtensions) { |
6686 v8::HandleScope handle_scope(CcTest::isolate()); | 6701 v8::HandleScope handle_scope(CcTest::isolate()); |
6687 Extension* extension = new Extension("autotest", kSimpleExtensionSource); | 6702 Extension* extension = new Extension("autotest", kSimpleExtensionSource); |
6688 extension->set_auto_enable(true); | 6703 extension->set_auto_enable(true); |
6689 v8::RegisterExtension(extension); | 6704 v8::RegisterExtension(extension); |
6690 v8::Handle<Context> context = | 6705 v8::Handle<Context> context = |
6691 Context::New(CcTest::isolate()); | 6706 Context::New(CcTest::isolate()); |
6692 Context::Scope lock(context); | 6707 Context::Scope lock(context); |
6693 v8::Handle<Value> result = Script::Compile(v8_str("Foo()"))->Run(); | 6708 v8::Handle<Value> result = Script::Compile(v8_str("Foo()"))->Run(); |
6694 CHECK_EQ(result, v8::Integer::New(4)); | 6709 CHECK_EQ(result, v8::Integer::New(CcTest::isolate(), 4)); |
6695 } | 6710 } |
6696 | 6711 |
6697 | 6712 |
6698 static const char* kSyntaxErrorInExtensionSource = | 6713 static const char* kSyntaxErrorInExtensionSource = |
6699 "["; | 6714 "["; |
6700 | 6715 |
6701 | 6716 |
6702 // Test that a syntax error in an extension does not cause a fatal | 6717 // Test that a syntax error in an extension does not cause a fatal |
6703 // error but results in an empty context. | 6718 // error but results in an empty context. |
6704 THREADED_TEST(SyntaxErrorExtensions) { | 6719 THREADED_TEST(SyntaxErrorExtensions) { |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6744 THREADED_TEST(NativeCallInExtensions) { | 6759 THREADED_TEST(NativeCallInExtensions) { |
6745 v8::HandleScope handle_scope(CcTest::isolate()); | 6760 v8::HandleScope handle_scope(CcTest::isolate()); |
6746 v8::RegisterExtension(new Extension("nativecall", | 6761 v8::RegisterExtension(new Extension("nativecall", |
6747 kNativeCallInExtensionSource)); | 6762 kNativeCallInExtensionSource)); |
6748 const char* extension_names[] = { "nativecall" }; | 6763 const char* extension_names[] = { "nativecall" }; |
6749 v8::ExtensionConfiguration extensions(1, extension_names); | 6764 v8::ExtensionConfiguration extensions(1, extension_names); |
6750 v8::Handle<Context> context = | 6765 v8::Handle<Context> context = |
6751 Context::New(CcTest::isolate(), &extensions); | 6766 Context::New(CcTest::isolate(), &extensions); |
6752 Context::Scope lock(context); | 6767 Context::Scope lock(context); |
6753 v8::Handle<Value> result = Script::Compile(v8_str(kNativeCallTest))->Run(); | 6768 v8::Handle<Value> result = Script::Compile(v8_str(kNativeCallTest))->Run(); |
6754 CHECK_EQ(result, v8::Integer::New(3)); | 6769 CHECK_EQ(result, v8::Integer::New(CcTest::isolate(), 3)); |
6755 } | 6770 } |
6756 | 6771 |
6757 | 6772 |
6758 class NativeFunctionExtension : public Extension { | 6773 class NativeFunctionExtension : public Extension { |
6759 public: | 6774 public: |
6760 NativeFunctionExtension(const char* name, | 6775 NativeFunctionExtension(const char* name, |
6761 const char* source, | 6776 const char* source, |
6762 v8::FunctionCallback fun = &Echo) | 6777 v8::FunctionCallback fun = &Echo) |
6763 : Extension(name, source), | 6778 : Extension(name, source), |
6764 function_(fun) { } | 6779 function_(fun) { } |
(...skipping 16 matching lines...) Expand all Loading... |
6781 v8::HandleScope handle_scope(CcTest::isolate()); | 6796 v8::HandleScope handle_scope(CcTest::isolate()); |
6782 const char* name = "nativedecl"; | 6797 const char* name = "nativedecl"; |
6783 v8::RegisterExtension(new NativeFunctionExtension(name, | 6798 v8::RegisterExtension(new NativeFunctionExtension(name, |
6784 "native function foo();")); | 6799 "native function foo();")); |
6785 const char* extension_names[] = { name }; | 6800 const char* extension_names[] = { name }; |
6786 v8::ExtensionConfiguration extensions(1, extension_names); | 6801 v8::ExtensionConfiguration extensions(1, extension_names); |
6787 v8::Handle<Context> context = | 6802 v8::Handle<Context> context = |
6788 Context::New(CcTest::isolate(), &extensions); | 6803 Context::New(CcTest::isolate(), &extensions); |
6789 Context::Scope lock(context); | 6804 Context::Scope lock(context); |
6790 v8::Handle<Value> result = Script::Compile(v8_str("foo(42);"))->Run(); | 6805 v8::Handle<Value> result = Script::Compile(v8_str("foo(42);"))->Run(); |
6791 CHECK_EQ(result, v8::Integer::New(42)); | 6806 CHECK_EQ(result, v8::Integer::New(CcTest::isolate(), 42)); |
6792 } | 6807 } |
6793 | 6808 |
6794 | 6809 |
6795 THREADED_TEST(NativeFunctionDeclarationError) { | 6810 THREADED_TEST(NativeFunctionDeclarationError) { |
6796 v8::HandleScope handle_scope(CcTest::isolate()); | 6811 v8::HandleScope handle_scope(CcTest::isolate()); |
6797 const char* name = "nativedeclerr"; | 6812 const char* name = "nativedeclerr"; |
6798 // Syntax error in extension code. | 6813 // Syntax error in extension code. |
6799 v8::RegisterExtension(new NativeFunctionExtension(name, | 6814 v8::RegisterExtension(new NativeFunctionExtension(name, |
6800 "native\nfunction foo();")); | 6815 "native\nfunction foo();")); |
6801 const char* extension_names[] = { name }; | 6816 const char* extension_names[] = { name }; |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6889 v8::Isolate* isolate, | 6904 v8::Isolate* isolate, |
6890 v8::Handle<String> name); | 6905 v8::Handle<String> name); |
6891 }; | 6906 }; |
6892 | 6907 |
6893 | 6908 |
6894 static int lookup_count = 0; | 6909 static int lookup_count = 0; |
6895 v8::Handle<v8::FunctionTemplate> FunctionExtension::GetNativeFunctionTemplate( | 6910 v8::Handle<v8::FunctionTemplate> FunctionExtension::GetNativeFunctionTemplate( |
6896 v8::Isolate* isolate, v8::Handle<String> name) { | 6911 v8::Isolate* isolate, v8::Handle<String> name) { |
6897 lookup_count++; | 6912 lookup_count++; |
6898 if (name->Equals(v8_str("A"))) { | 6913 if (name->Equals(v8_str("A"))) { |
6899 return v8::FunctionTemplate::New(isolate, CallFun, v8::Integer::New(8)); | 6914 return v8::FunctionTemplate::New( |
| 6915 isolate, CallFun, v8::Integer::New(isolate, 8)); |
6900 } else if (name->Equals(v8_str("B"))) { | 6916 } else if (name->Equals(v8_str("B"))) { |
6901 return v8::FunctionTemplate::New(isolate, CallFun, v8::Integer::New(7)); | 6917 return v8::FunctionTemplate::New( |
| 6918 isolate, CallFun, v8::Integer::New(isolate, 7)); |
6902 } else if (name->Equals(v8_str("C"))) { | 6919 } else if (name->Equals(v8_str("C"))) { |
6903 return v8::FunctionTemplate::New(isolate, CallFun, v8::Integer::New(6)); | 6920 return v8::FunctionTemplate::New( |
| 6921 isolate, CallFun, v8::Integer::New(isolate, 6)); |
6904 } else { | 6922 } else { |
6905 return v8::Handle<v8::FunctionTemplate>(); | 6923 return v8::Handle<v8::FunctionTemplate>(); |
6906 } | 6924 } |
6907 } | 6925 } |
6908 | 6926 |
6909 | 6927 |
6910 THREADED_TEST(FunctionLookup) { | 6928 THREADED_TEST(FunctionLookup) { |
6911 v8::RegisterExtension(new FunctionExtension()); | 6929 v8::RegisterExtension(new FunctionExtension()); |
6912 v8::HandleScope handle_scope(CcTest::isolate()); | 6930 v8::HandleScope handle_scope(CcTest::isolate()); |
6913 static const char* exts[1] = { "functiontest" }; | 6931 static const char* exts[1] = { "functiontest" }; |
6914 v8::ExtensionConfiguration config(1, exts); | 6932 v8::ExtensionConfiguration config(1, exts); |
6915 LocalContext context(&config); | 6933 LocalContext context(&config); |
6916 CHECK_EQ(3, lookup_count); | 6934 CHECK_EQ(3, lookup_count); |
6917 CHECK_EQ(v8::Integer::New(8), Script::Compile(v8_str("Foo(0)"))->Run()); | 6935 CHECK_EQ(v8::Integer::New(CcTest::isolate(), 8), |
6918 CHECK_EQ(v8::Integer::New(7), Script::Compile(v8_str("Foo(1)"))->Run()); | 6936 Script::Compile(v8_str("Foo(0)"))->Run()); |
6919 CHECK_EQ(v8::Integer::New(6), Script::Compile(v8_str("Foo(2)"))->Run()); | 6937 CHECK_EQ(v8::Integer::New(CcTest::isolate(), 7), |
| 6938 Script::Compile(v8_str("Foo(1)"))->Run()); |
| 6939 CHECK_EQ(v8::Integer::New(CcTest::isolate(), 6), |
| 6940 Script::Compile(v8_str("Foo(2)"))->Run()); |
6920 } | 6941 } |
6921 | 6942 |
6922 | 6943 |
6923 THREADED_TEST(NativeFunctionConstructCall) { | 6944 THREADED_TEST(NativeFunctionConstructCall) { |
6924 v8::RegisterExtension(new FunctionExtension()); | 6945 v8::RegisterExtension(new FunctionExtension()); |
6925 v8::HandleScope handle_scope(CcTest::isolate()); | 6946 v8::HandleScope handle_scope(CcTest::isolate()); |
6926 static const char* exts[1] = { "functiontest" }; | 6947 static const char* exts[1] = { "functiontest" }; |
6927 v8::ExtensionConfiguration config(1, exts); | 6948 v8::ExtensionConfiguration config(1, exts); |
6928 LocalContext context(&config); | 6949 LocalContext context(&config); |
6929 for (int i = 0; i < 10; i++) { | 6950 for (int i = 0; i < 10; i++) { |
6930 // Run a few times to ensure that allocation of objects doesn't | 6951 // Run a few times to ensure that allocation of objects doesn't |
6931 // change behavior of a constructor function. | 6952 // change behavior of a constructor function. |
6932 CHECK_EQ(v8::Integer::New(8), | 6953 CHECK_EQ(v8::Integer::New(CcTest::isolate(), 8), |
6933 Script::Compile(v8_str("(new A()).data"))->Run()); | 6954 Script::Compile(v8_str("(new A()).data"))->Run()); |
6934 CHECK_EQ(v8::Integer::New(7), | 6955 CHECK_EQ(v8::Integer::New(CcTest::isolate(), 7), |
6935 Script::Compile(v8_str("(new B()).data"))->Run()); | 6956 Script::Compile(v8_str("(new B()).data"))->Run()); |
6936 CHECK_EQ(v8::Integer::New(6), | 6957 CHECK_EQ(v8::Integer::New(CcTest::isolate(), 6), |
6937 Script::Compile(v8_str("(new C()).data"))->Run()); | 6958 Script::Compile(v8_str("(new C()).data"))->Run()); |
6938 } | 6959 } |
6939 } | 6960 } |
6940 | 6961 |
6941 | 6962 |
6942 static const char* last_location; | 6963 static const char* last_location; |
6943 static const char* last_message; | 6964 static const char* last_message; |
6944 void StoringErrorCallback(const char* location, const char* message) { | 6965 void StoringErrorCallback(const char* location, const char* message) { |
6945 if (last_location == NULL) { | 6966 if (last_location == NULL) { |
6946 last_location = location; | 6967 last_location = location; |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7042 delete data.GetParameter(); | 7063 delete data.GetParameter(); |
7043 } | 7064 } |
7044 | 7065 |
7045 void WhammyPropertyGetter(Local<String> name, | 7066 void WhammyPropertyGetter(Local<String> name, |
7046 const v8::PropertyCallbackInfo<v8::Value>& info) { | 7067 const v8::PropertyCallbackInfo<v8::Value>& info) { |
7047 Whammy* whammy = | 7068 Whammy* whammy = |
7048 static_cast<Whammy*>(v8::Handle<v8::External>::Cast(info.Data())->Value()); | 7069 static_cast<Whammy*>(v8::Handle<v8::External>::Cast(info.Data())->Value()); |
7049 | 7070 |
7050 v8::Persistent<v8::Object>& prev = whammy->objects_[whammy->cursor_]; | 7071 v8::Persistent<v8::Object>& prev = whammy->objects_[whammy->cursor_]; |
7051 | 7072 |
7052 v8::Handle<v8::Object> obj = v8::Object::New(); | 7073 v8::Handle<v8::Object> obj = v8::Object::New(info.GetIsolate()); |
7053 if (!prev.IsEmpty()) { | 7074 if (!prev.IsEmpty()) { |
7054 v8::Local<v8::Object>::New(info.GetIsolate(), prev) | 7075 v8::Local<v8::Object>::New(info.GetIsolate(), prev) |
7055 ->Set(v8_str("next"), obj); | 7076 ->Set(v8_str("next"), obj); |
7056 prev.SetWeak<Value, Snorkel<Value> >(new Snorkel<Value>(&prev.As<Value>()), | 7077 prev.SetWeak<Value, Snorkel<Value> >(new Snorkel<Value>(&prev.As<Value>()), |
7057 &HandleWeakReference); | 7078 &HandleWeakReference); |
7058 } | 7079 } |
7059 whammy->objects_[whammy->cursor_].Reset(info.GetIsolate(), obj); | 7080 whammy->objects_[whammy->cursor_].Reset(info.GetIsolate(), obj); |
7060 whammy->cursor_ = (whammy->cursor_ + 1) % Whammy::kObjectCount; | 7081 whammy->cursor_ = (whammy->cursor_ + 1) % Whammy::kObjectCount; |
7061 info.GetReturnValue().Set(whammy->getScript()->Run()); | 7082 info.GetReturnValue().Set(whammy->getScript()->Run()); |
7062 } | 7083 } |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7108 THREADED_TEST(IndependentWeakHandle) { | 7129 THREADED_TEST(IndependentWeakHandle) { |
7109 v8::Isolate* iso = CcTest::isolate(); | 7130 v8::Isolate* iso = CcTest::isolate(); |
7110 v8::HandleScope scope(iso); | 7131 v8::HandleScope scope(iso); |
7111 v8::Handle<Context> context = Context::New(iso); | 7132 v8::Handle<Context> context = Context::New(iso); |
7112 Context::Scope context_scope(context); | 7133 Context::Scope context_scope(context); |
7113 | 7134 |
7114 FlagAndPersistent object_a, object_b; | 7135 FlagAndPersistent object_a, object_b; |
7115 | 7136 |
7116 { | 7137 { |
7117 v8::HandleScope handle_scope(iso); | 7138 v8::HandleScope handle_scope(iso); |
7118 object_a.handle.Reset(iso, v8::Object::New()); | 7139 object_a.handle.Reset(iso, v8::Object::New(iso)); |
7119 object_b.handle.Reset(iso, v8::Object::New()); | 7140 object_b.handle.Reset(iso, v8::Object::New(iso)); |
7120 } | 7141 } |
7121 | 7142 |
7122 object_a.flag = false; | 7143 object_a.flag = false; |
7123 object_b.flag = false; | 7144 object_b.flag = false; |
7124 object_a.handle.SetWeak(&object_a, &DisposeAndSetFlag); | 7145 object_a.handle.SetWeak(&object_a, &DisposeAndSetFlag); |
7125 object_b.handle.SetWeak(&object_b, &DisposeAndSetFlag); | 7146 object_b.handle.SetWeak(&object_b, &DisposeAndSetFlag); |
7126 CHECK(!object_b.handle.IsIndependent()); | 7147 CHECK(!object_b.handle.IsIndependent()); |
7127 object_a.handle.MarkIndependent(); | 7148 object_a.handle.MarkIndependent(); |
7128 object_b.handle.MarkIndependent(); | 7149 object_b.handle.MarkIndependent(); |
7129 CHECK(object_b.handle.IsIndependent()); | 7150 CHECK(object_b.handle.IsIndependent()); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7172 {&ForceScavenge, &ForceMarkSweep}; | 7193 {&ForceScavenge, &ForceMarkSweep}; |
7173 | 7194 |
7174 typedef void (*GCInvoker)(); | 7195 typedef void (*GCInvoker)(); |
7175 GCInvoker invoke_gc[kNumberOfGCTypes] = {&InvokeScavenge, &InvokeMarkSweep}; | 7196 GCInvoker invoke_gc[kNumberOfGCTypes] = {&InvokeScavenge, &InvokeMarkSweep}; |
7176 | 7197 |
7177 for (int outer_gc = 0; outer_gc < kNumberOfGCTypes; outer_gc++) { | 7198 for (int outer_gc = 0; outer_gc < kNumberOfGCTypes; outer_gc++) { |
7178 for (int inner_gc = 0; inner_gc < kNumberOfGCTypes; inner_gc++) { | 7199 for (int inner_gc = 0; inner_gc < kNumberOfGCTypes; inner_gc++) { |
7179 FlagAndPersistent object; | 7200 FlagAndPersistent object; |
7180 { | 7201 { |
7181 v8::HandleScope handle_scope(isolate); | 7202 v8::HandleScope handle_scope(isolate); |
7182 object.handle.Reset(isolate, v8::Object::New()); | 7203 object.handle.Reset(isolate, v8::Object::New(isolate)); |
7183 } | 7204 } |
7184 object.flag = false; | 7205 object.flag = false; |
7185 object.handle.SetWeak(&object, gc_forcing_callback[inner_gc]); | 7206 object.handle.SetWeak(&object, gc_forcing_callback[inner_gc]); |
7186 object.handle.MarkIndependent(); | 7207 object.handle.MarkIndependent(); |
7187 invoke_gc[outer_gc](); | 7208 invoke_gc[outer_gc](); |
7188 CHECK(object.flag); | 7209 CHECK(object.flag); |
7189 } | 7210 } |
7190 } | 7211 } |
7191 } | 7212 } |
7192 | 7213 |
7193 | 7214 |
7194 static void RevivingCallback( | 7215 static void RevivingCallback( |
7195 const v8::WeakCallbackData<v8::Object, FlagAndPersistent>& data) { | 7216 const v8::WeakCallbackData<v8::Object, FlagAndPersistent>& data) { |
7196 data.GetParameter()->handle.ClearWeak(); | 7217 data.GetParameter()->handle.ClearWeak(); |
7197 data.GetParameter()->flag = true; | 7218 data.GetParameter()->flag = true; |
7198 } | 7219 } |
7199 | 7220 |
7200 | 7221 |
7201 THREADED_TEST(IndependentHandleRevival) { | 7222 THREADED_TEST(IndependentHandleRevival) { |
7202 v8::Isolate* isolate = CcTest::isolate(); | 7223 v8::Isolate* isolate = CcTest::isolate(); |
7203 v8::HandleScope scope(isolate); | 7224 v8::HandleScope scope(isolate); |
7204 v8::Handle<Context> context = Context::New(isolate); | 7225 v8::Handle<Context> context = Context::New(isolate); |
7205 Context::Scope context_scope(context); | 7226 Context::Scope context_scope(context); |
7206 | 7227 |
7207 FlagAndPersistent object; | 7228 FlagAndPersistent object; |
7208 { | 7229 { |
7209 v8::HandleScope handle_scope(isolate); | 7230 v8::HandleScope handle_scope(isolate); |
7210 v8::Local<v8::Object> o = v8::Object::New(); | 7231 v8::Local<v8::Object> o = v8::Object::New(isolate); |
7211 object.handle.Reset(isolate, o); | 7232 object.handle.Reset(isolate, o); |
7212 o->Set(v8_str("x"), v8::Integer::New(1)); | 7233 o->Set(v8_str("x"), v8::Integer::New(isolate, 1)); |
7213 v8::Local<String> y_str = v8_str("y"); | 7234 v8::Local<String> y_str = v8_str("y"); |
7214 o->Set(y_str, y_str); | 7235 o->Set(y_str, y_str); |
7215 } | 7236 } |
7216 object.flag = false; | 7237 object.flag = false; |
7217 object.handle.SetWeak(&object, &RevivingCallback); | 7238 object.handle.SetWeak(&object, &RevivingCallback); |
7218 object.handle.MarkIndependent(); | 7239 object.handle.MarkIndependent(); |
7219 CcTest::heap()->PerformScavenge(); | 7240 CcTest::heap()->PerformScavenge(); |
7220 CHECK(object.flag); | 7241 CHECK(object.flag); |
7221 CcTest::heap()->CollectAllGarbage(i::Heap::kAbortIncrementalMarkingMask); | 7242 CcTest::heap()->CollectAllGarbage(i::Heap::kAbortIncrementalMarkingMask); |
7222 { | 7243 { |
7223 v8::HandleScope handle_scope(isolate); | 7244 v8::HandleScope handle_scope(isolate); |
7224 v8::Local<v8::Object> o = | 7245 v8::Local<v8::Object> o = |
7225 v8::Local<v8::Object>::New(isolate, object.handle); | 7246 v8::Local<v8::Object>::New(isolate, object.handle); |
7226 v8::Local<String> y_str = v8_str("y"); | 7247 v8::Local<String> y_str = v8_str("y"); |
7227 CHECK_EQ(v8::Integer::New(1), o->Get(v8_str("x"))); | 7248 CHECK_EQ(v8::Integer::New(isolate, 1), o->Get(v8_str("x"))); |
7228 CHECK(o->Get(y_str)->Equals(y_str)); | 7249 CHECK(o->Get(y_str)->Equals(y_str)); |
7229 } | 7250 } |
7230 } | 7251 } |
7231 | 7252 |
7232 | 7253 |
7233 v8::Handle<Function> args_fun; | 7254 v8::Handle<Function> args_fun; |
7234 | 7255 |
7235 | 7256 |
7236 static void ArgumentsTestCallback( | 7257 static void ArgumentsTestCallback( |
7237 const v8::FunctionCallbackInfo<v8::Value>& args) { | 7258 const v8::FunctionCallbackInfo<v8::Value>& args) { |
7238 ApiTestFuzzer::Fuzz(); | 7259 ApiTestFuzzer::Fuzz(); |
7239 v8::Isolate* isolate = args.GetIsolate(); | 7260 v8::Isolate* isolate = args.GetIsolate(); |
7240 CHECK_EQ(args_fun, args.Callee()); | 7261 CHECK_EQ(args_fun, args.Callee()); |
7241 CHECK_EQ(3, args.Length()); | 7262 CHECK_EQ(3, args.Length()); |
7242 CHECK_EQ(v8::Integer::New(1, isolate), args[0]); | 7263 CHECK_EQ(v8::Integer::New(isolate, 1), args[0]); |
7243 CHECK_EQ(v8::Integer::New(2, isolate), args[1]); | 7264 CHECK_EQ(v8::Integer::New(isolate, 2), args[1]); |
7244 CHECK_EQ(v8::Integer::New(3, isolate), args[2]); | 7265 CHECK_EQ(v8::Integer::New(isolate, 3), args[2]); |
7245 CHECK_EQ(v8::Undefined(isolate), args[3]); | 7266 CHECK_EQ(v8::Undefined(isolate), args[3]); |
7246 v8::HandleScope scope(args.GetIsolate()); | 7267 v8::HandleScope scope(args.GetIsolate()); |
7247 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); | 7268 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); |
7248 } | 7269 } |
7249 | 7270 |
7250 | 7271 |
7251 THREADED_TEST(Arguments) { | 7272 THREADED_TEST(Arguments) { |
7252 v8::Isolate* isolate = CcTest::isolate(); | 7273 v8::Isolate* isolate = CcTest::isolate(); |
7253 v8::HandleScope scope(isolate); | 7274 v8::HandleScope scope(isolate); |
7254 v8::Handle<v8::ObjectTemplate> global = ObjectTemplate::New(); | 7275 v8::Handle<v8::ObjectTemplate> global = ObjectTemplate::New(); |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7330 static void IndexedGetK(uint32_t index, | 7351 static void IndexedGetK(uint32_t index, |
7331 const v8::PropertyCallbackInfo<v8::Value>& info) { | 7352 const v8::PropertyCallbackInfo<v8::Value>& info) { |
7332 ApiTestFuzzer::Fuzz(); | 7353 ApiTestFuzzer::Fuzz(); |
7333 if (index == 0 || index == 1) info.GetReturnValue().SetUndefined(); | 7354 if (index == 0 || index == 1) info.GetReturnValue().SetUndefined(); |
7334 } | 7355 } |
7335 | 7356 |
7336 | 7357 |
7337 static void NamedEnum(const v8::PropertyCallbackInfo<v8::Array>& info) { | 7358 static void NamedEnum(const v8::PropertyCallbackInfo<v8::Array>& info) { |
7338 ApiTestFuzzer::Fuzz(); | 7359 ApiTestFuzzer::Fuzz(); |
7339 v8::Handle<v8::Array> result = v8::Array::New(info.GetIsolate(), 3); | 7360 v8::Handle<v8::Array> result = v8::Array::New(info.GetIsolate(), 3); |
7340 result->Set(v8::Integer::New(0), v8_str("foo")); | 7361 result->Set(v8::Integer::New(info.GetIsolate(), 0), v8_str("foo")); |
7341 result->Set(v8::Integer::New(1), v8_str("bar")); | 7362 result->Set(v8::Integer::New(info.GetIsolate(), 1), v8_str("bar")); |
7342 result->Set(v8::Integer::New(2), v8_str("baz")); | 7363 result->Set(v8::Integer::New(info.GetIsolate(), 2), v8_str("baz")); |
7343 info.GetReturnValue().Set(result); | 7364 info.GetReturnValue().Set(result); |
7344 } | 7365 } |
7345 | 7366 |
7346 | 7367 |
7347 static void IndexedEnum(const v8::PropertyCallbackInfo<v8::Array>& info) { | 7368 static void IndexedEnum(const v8::PropertyCallbackInfo<v8::Array>& info) { |
7348 ApiTestFuzzer::Fuzz(); | 7369 ApiTestFuzzer::Fuzz(); |
7349 v8::Handle<v8::Array> result = v8::Array::New(info.GetIsolate(), 2); | 7370 v8::Handle<v8::Array> result = v8::Array::New(info.GetIsolate(), 2); |
7350 result->Set(v8::Integer::New(0), v8_str("0")); | 7371 result->Set(v8::Integer::New(info.GetIsolate(), 0), v8_str("0")); |
7351 result->Set(v8::Integer::New(1), v8_str("1")); | 7372 result->Set(v8::Integer::New(info.GetIsolate(), 1), v8_str("1")); |
7352 info.GetReturnValue().Set(result); | 7373 info.GetReturnValue().Set(result); |
7353 } | 7374 } |
7354 | 7375 |
7355 | 7376 |
7356 THREADED_TEST(Enumerators) { | 7377 THREADED_TEST(Enumerators) { |
7357 v8::HandleScope scope(CcTest::isolate()); | 7378 v8::Isolate* isolate = CcTest::isolate(); |
| 7379 v8::HandleScope scope(isolate); |
7358 v8::Handle<v8::ObjectTemplate> obj = ObjectTemplate::New(); | 7380 v8::Handle<v8::ObjectTemplate> obj = ObjectTemplate::New(); |
7359 obj->SetNamedPropertyHandler(GetK, NULL, NULL, NULL, NamedEnum); | 7381 obj->SetNamedPropertyHandler(GetK, NULL, NULL, NULL, NamedEnum); |
7360 obj->SetIndexedPropertyHandler(IndexedGetK, NULL, NULL, NULL, IndexedEnum); | 7382 obj->SetIndexedPropertyHandler(IndexedGetK, NULL, NULL, NULL, IndexedEnum); |
7361 LocalContext context; | 7383 LocalContext context; |
7362 context->Global()->Set(v8_str("k"), obj->NewInstance()); | 7384 context->Global()->Set(v8_str("k"), obj->NewInstance()); |
7363 v8::Handle<v8::Array> result = v8::Handle<v8::Array>::Cast(CompileRun( | 7385 v8::Handle<v8::Array> result = v8::Handle<v8::Array>::Cast(CompileRun( |
7364 "k[10] = 0;" | 7386 "k[10] = 0;" |
7365 "k.a = 0;" | 7387 "k.a = 0;" |
7366 "k[5] = 0;" | 7388 "k[5] = 0;" |
7367 "k.b = 0;" | 7389 "k.b = 0;" |
(...skipping 11 matching lines...) Expand all Loading... |
7379 "}" | 7401 "}" |
7380 "result")); | 7402 "result")); |
7381 // Check that we get all the property names returned including the | 7403 // Check that we get all the property names returned including the |
7382 // ones from the enumerators in the right order: indexed properties | 7404 // ones from the enumerators in the right order: indexed properties |
7383 // in numerical order, indexed interceptor properties, named | 7405 // in numerical order, indexed interceptor properties, named |
7384 // properties in insertion order, named interceptor properties. | 7406 // properties in insertion order, named interceptor properties. |
7385 // This order is not mandated by the spec, so this test is just | 7407 // This order is not mandated by the spec, so this test is just |
7386 // documenting our behavior. | 7408 // documenting our behavior. |
7387 CHECK_EQ(17, result->Length()); | 7409 CHECK_EQ(17, result->Length()); |
7388 // Indexed properties in numerical order. | 7410 // Indexed properties in numerical order. |
7389 CHECK_EQ(v8_str("5"), result->Get(v8::Integer::New(0))); | 7411 CHECK_EQ(v8_str("5"), result->Get(v8::Integer::New(isolate, 0))); |
7390 CHECK_EQ(v8_str("10"), result->Get(v8::Integer::New(1))); | 7412 CHECK_EQ(v8_str("10"), result->Get(v8::Integer::New(isolate, 1))); |
7391 CHECK_EQ(v8_str("140000"), result->Get(v8::Integer::New(2))); | 7413 CHECK_EQ(v8_str("140000"), result->Get(v8::Integer::New(isolate, 2))); |
7392 CHECK_EQ(v8_str("4294967295"), result->Get(v8::Integer::New(3))); | 7414 CHECK_EQ(v8_str("4294967295"), result->Get(v8::Integer::New(isolate, 3))); |
7393 // Indexed interceptor properties in the order they are returned | 7415 // Indexed interceptor properties in the order they are returned |
7394 // from the enumerator interceptor. | 7416 // from the enumerator interceptor. |
7395 CHECK_EQ(v8_str("0"), result->Get(v8::Integer::New(4))); | 7417 CHECK_EQ(v8_str("0"), result->Get(v8::Integer::New(isolate, 4))); |
7396 CHECK_EQ(v8_str("1"), result->Get(v8::Integer::New(5))); | 7418 CHECK_EQ(v8_str("1"), result->Get(v8::Integer::New(isolate, 5))); |
7397 // Named properties in insertion order. | 7419 // Named properties in insertion order. |
7398 CHECK_EQ(v8_str("a"), result->Get(v8::Integer::New(6))); | 7420 CHECK_EQ(v8_str("a"), result->Get(v8::Integer::New(isolate, 6))); |
7399 CHECK_EQ(v8_str("b"), result->Get(v8::Integer::New(7))); | 7421 CHECK_EQ(v8_str("b"), result->Get(v8::Integer::New(isolate, 7))); |
7400 CHECK_EQ(v8_str("c"), result->Get(v8::Integer::New(8))); | 7422 CHECK_EQ(v8_str("c"), result->Get(v8::Integer::New(isolate, 8))); |
7401 CHECK_EQ(v8_str("4294967296"), result->Get(v8::Integer::New(9))); | 7423 CHECK_EQ(v8_str("4294967296"), result->Get(v8::Integer::New(isolate, 9))); |
7402 CHECK_EQ(v8_str("d"), result->Get(v8::Integer::New(10))); | 7424 CHECK_EQ(v8_str("d"), result->Get(v8::Integer::New(isolate, 10))); |
7403 CHECK_EQ(v8_str("e"), result->Get(v8::Integer::New(11))); | 7425 CHECK_EQ(v8_str("e"), result->Get(v8::Integer::New(isolate, 11))); |
7404 CHECK_EQ(v8_str("30000000000"), result->Get(v8::Integer::New(12))); | 7426 CHECK_EQ(v8_str("30000000000"), result->Get(v8::Integer::New(isolate, 12))); |
7405 CHECK_EQ(v8_str("f"), result->Get(v8::Integer::New(13))); | 7427 CHECK_EQ(v8_str("f"), result->Get(v8::Integer::New(isolate, 13))); |
7406 // Named interceptor properties. | 7428 // Named interceptor properties. |
7407 CHECK_EQ(v8_str("foo"), result->Get(v8::Integer::New(14))); | 7429 CHECK_EQ(v8_str("foo"), result->Get(v8::Integer::New(isolate, 14))); |
7408 CHECK_EQ(v8_str("bar"), result->Get(v8::Integer::New(15))); | 7430 CHECK_EQ(v8_str("bar"), result->Get(v8::Integer::New(isolate, 15))); |
7409 CHECK_EQ(v8_str("baz"), result->Get(v8::Integer::New(16))); | 7431 CHECK_EQ(v8_str("baz"), result->Get(v8::Integer::New(isolate, 16))); |
7410 } | 7432 } |
7411 | 7433 |
7412 | 7434 |
7413 int p_getter_count; | 7435 int p_getter_count; |
7414 int p_getter_count2; | 7436 int p_getter_count2; |
7415 | 7437 |
7416 | 7438 |
7417 static void PGetter(Local<String> name, | 7439 static void PGetter(Local<String> name, |
7418 const v8::PropertyCallbackInfo<v8::Value>& info) { | 7440 const v8::PropertyCallbackInfo<v8::Value>& info) { |
7419 ApiTestFuzzer::Fuzz(); | 7441 ApiTestFuzzer::Fuzz(); |
(...skipping 598 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8018 CHECK(SameSymbol(sym0b, Handle<String>::Cast(s0b))); | 8040 CHECK(SameSymbol(sym0b, Handle<String>::Cast(s0b))); |
8019 CHECK(SameSymbol(sym1, Handle<String>::Cast(s1))); | 8041 CHECK(SameSymbol(sym1, Handle<String>::Cast(s1))); |
8020 CHECK(SameSymbol(sym2, Handle<String>::Cast(s2))); | 8042 CHECK(SameSymbol(sym2, Handle<String>::Cast(s2))); |
8021 CHECK(SameSymbol(sym3, Handle<String>::Cast(s3))); | 8043 CHECK(SameSymbol(sym3, Handle<String>::Cast(s3))); |
8022 CHECK(SameSymbol(sym4, Handle<String>::Cast(s4))); | 8044 CHECK(SameSymbol(sym4, Handle<String>::Cast(s4))); |
8023 } | 8045 } |
8024 | 8046 |
8025 | 8047 |
8026 THREADED_TEST(ToArrayIndex) { | 8048 THREADED_TEST(ToArrayIndex) { |
8027 LocalContext context; | 8049 LocalContext context; |
8028 v8::HandleScope scope(context->GetIsolate()); | 8050 v8::Isolate* isolate = context->GetIsolate(); |
| 8051 v8::HandleScope scope(isolate); |
8029 | 8052 |
8030 v8::Handle<String> str = v8_str("42"); | 8053 v8::Handle<String> str = v8_str("42"); |
8031 v8::Handle<v8::Uint32> index = str->ToArrayIndex(); | 8054 v8::Handle<v8::Uint32> index = str->ToArrayIndex(); |
8032 CHECK(!index.IsEmpty()); | 8055 CHECK(!index.IsEmpty()); |
8033 CHECK_EQ(42.0, index->Uint32Value()); | 8056 CHECK_EQ(42.0, index->Uint32Value()); |
8034 str = v8_str("42asdf"); | 8057 str = v8_str("42asdf"); |
8035 index = str->ToArrayIndex(); | 8058 index = str->ToArrayIndex(); |
8036 CHECK(index.IsEmpty()); | 8059 CHECK(index.IsEmpty()); |
8037 str = v8_str("-42"); | 8060 str = v8_str("-42"); |
8038 index = str->ToArrayIndex(); | 8061 index = str->ToArrayIndex(); |
8039 CHECK(index.IsEmpty()); | 8062 CHECK(index.IsEmpty()); |
8040 str = v8_str("4294967295"); | 8063 str = v8_str("4294967295"); |
8041 index = str->ToArrayIndex(); | 8064 index = str->ToArrayIndex(); |
8042 CHECK(!index.IsEmpty()); | 8065 CHECK(!index.IsEmpty()); |
8043 CHECK_EQ(4294967295.0, index->Uint32Value()); | 8066 CHECK_EQ(4294967295.0, index->Uint32Value()); |
8044 v8::Handle<v8::Number> num = v8::Number::New(1); | 8067 v8::Handle<v8::Number> num = v8::Number::New(isolate, 1); |
8045 index = num->ToArrayIndex(); | 8068 index = num->ToArrayIndex(); |
8046 CHECK(!index.IsEmpty()); | 8069 CHECK(!index.IsEmpty()); |
8047 CHECK_EQ(1.0, index->Uint32Value()); | 8070 CHECK_EQ(1.0, index->Uint32Value()); |
8048 num = v8::Number::New(-1); | 8071 num = v8::Number::New(isolate, -1); |
8049 index = num->ToArrayIndex(); | 8072 index = num->ToArrayIndex(); |
8050 CHECK(index.IsEmpty()); | 8073 CHECK(index.IsEmpty()); |
8051 v8::Handle<v8::Object> obj = v8::Object::New(); | 8074 v8::Handle<v8::Object> obj = v8::Object::New(isolate); |
8052 index = obj->ToArrayIndex(); | 8075 index = obj->ToArrayIndex(); |
8053 CHECK(index.IsEmpty()); | 8076 CHECK(index.IsEmpty()); |
8054 } | 8077 } |
8055 | 8078 |
8056 | 8079 |
8057 THREADED_TEST(ErrorConstruction) { | 8080 THREADED_TEST(ErrorConstruction) { |
8058 LocalContext context; | 8081 LocalContext context; |
8059 v8::HandleScope scope(context->GetIsolate()); | 8082 v8::HandleScope scope(context->GetIsolate()); |
8060 | 8083 |
8061 v8::Handle<String> foo = v8_str("foo"); | 8084 v8::Handle<String> foo = v8_str("foo"); |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8110 | 8133 |
8111 THREADED_TEST(TypeSwitch) { | 8134 THREADED_TEST(TypeSwitch) { |
8112 v8::Isolate* isolate = CcTest::isolate(); | 8135 v8::Isolate* isolate = CcTest::isolate(); |
8113 v8::HandleScope scope(isolate); | 8136 v8::HandleScope scope(isolate); |
8114 v8::Handle<v8::FunctionTemplate> templ1 = v8::FunctionTemplate::New(isolate); | 8137 v8::Handle<v8::FunctionTemplate> templ1 = v8::FunctionTemplate::New(isolate); |
8115 v8::Handle<v8::FunctionTemplate> templ2 = v8::FunctionTemplate::New(isolate); | 8138 v8::Handle<v8::FunctionTemplate> templ2 = v8::FunctionTemplate::New(isolate); |
8116 v8::Handle<v8::FunctionTemplate> templ3 = v8::FunctionTemplate::New(isolate); | 8139 v8::Handle<v8::FunctionTemplate> templ3 = v8::FunctionTemplate::New(isolate); |
8117 v8::Handle<v8::FunctionTemplate> templs[3] = { templ1, templ2, templ3 }; | 8140 v8::Handle<v8::FunctionTemplate> templs[3] = { templ1, templ2, templ3 }; |
8118 v8::Handle<v8::TypeSwitch> type_switch = v8::TypeSwitch::New(3, templs); | 8141 v8::Handle<v8::TypeSwitch> type_switch = v8::TypeSwitch::New(3, templs); |
8119 LocalContext context; | 8142 LocalContext context; |
8120 v8::Handle<v8::Object> obj0 = v8::Object::New(); | 8143 v8::Handle<v8::Object> obj0 = v8::Object::New(isolate); |
8121 v8::Handle<v8::Object> obj1 = templ1->GetFunction()->NewInstance(); | 8144 v8::Handle<v8::Object> obj1 = templ1->GetFunction()->NewInstance(); |
8122 v8::Handle<v8::Object> obj2 = templ2->GetFunction()->NewInstance(); | 8145 v8::Handle<v8::Object> obj2 = templ2->GetFunction()->NewInstance(); |
8123 v8::Handle<v8::Object> obj3 = templ3->GetFunction()->NewInstance(); | 8146 v8::Handle<v8::Object> obj3 = templ3->GetFunction()->NewInstance(); |
8124 for (int i = 0; i < 10; i++) { | 8147 for (int i = 0; i < 10; i++) { |
8125 CHECK_EQ(0, type_switch->match(obj0)); | 8148 CHECK_EQ(0, type_switch->match(obj0)); |
8126 CHECK_EQ(1, type_switch->match(obj1)); | 8149 CHECK_EQ(1, type_switch->match(obj1)); |
8127 CHECK_EQ(2, type_switch->match(obj2)); | 8150 CHECK_EQ(2, type_switch->match(obj2)); |
8128 CHECK_EQ(3, type_switch->match(obj3)); | 8151 CHECK_EQ(3, type_switch->match(obj3)); |
8129 CHECK_EQ(3, type_switch->match(obj3)); | 8152 CHECK_EQ(3, type_switch->match(obj3)); |
8130 CHECK_EQ(2, type_switch->match(obj2)); | 8153 CHECK_EQ(2, type_switch->match(obj2)); |
(...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8563 | 8586 |
8564 // Set to the same domain. | 8587 // Set to the same domain. |
8565 env1->SetSecurityToken(foo); | 8588 env1->SetSecurityToken(foo); |
8566 env2->SetSecurityToken(foo); | 8589 env2->SetSecurityToken(foo); |
8567 | 8590 |
8568 // Enter env2 | 8591 // Enter env2 |
8569 env2->Enter(); | 8592 env2->Enter(); |
8570 | 8593 |
8571 // Create a function in env2 and add a reference to it in env1. | 8594 // Create a function in env2 and add a reference to it in env1. |
8572 Local<v8::Object> global2 = env2->Global(); | 8595 Local<v8::Object> global2 = env2->Global(); |
8573 global2->Set(v8_str("prop"), v8::Integer::New(1)); | 8596 global2->Set(v8_str("prop"), v8::Integer::New(env2->GetIsolate(), 1)); |
8574 CompileRun("function getProp() {return prop;}"); | 8597 CompileRun("function getProp() {return prop;}"); |
8575 | 8598 |
8576 env1->Global()->Set(v8_str("getProp"), | 8599 env1->Global()->Set(v8_str("getProp"), |
8577 global2->Get(v8_str("getProp"))); | 8600 global2->Get(v8_str("getProp"))); |
8578 | 8601 |
8579 // Detach env2's global, and reuse the global object of env2 | 8602 // Detach env2's global, and reuse the global object of env2 |
8580 env2->Exit(); | 8603 env2->Exit(); |
8581 env2->DetachGlobal(); | 8604 env2->DetachGlobal(); |
8582 | 8605 |
8583 v8::Handle<Context> env3 = Context::New(env1->GetIsolate(), | 8606 v8::Handle<Context> env3 = Context::New(env1->GetIsolate(), |
8584 0, | 8607 0, |
8585 v8::Handle<v8::ObjectTemplate>(), | 8608 v8::Handle<v8::ObjectTemplate>(), |
8586 global2); | 8609 global2); |
8587 env3->SetSecurityToken(v8_str("bar")); | 8610 env3->SetSecurityToken(v8_str("bar")); |
8588 env3->Enter(); | 8611 env3->Enter(); |
8589 | 8612 |
8590 Local<v8::Object> global3 = env3->Global(); | 8613 Local<v8::Object> global3 = env3->Global(); |
8591 CHECK_EQ(global2, global3); | 8614 CHECK_EQ(global2, global3); |
8592 CHECK(global3->Get(v8_str("prop"))->IsUndefined()); | 8615 CHECK(global3->Get(v8_str("prop"))->IsUndefined()); |
8593 CHECK(global3->Get(v8_str("getProp"))->IsUndefined()); | 8616 CHECK(global3->Get(v8_str("getProp"))->IsUndefined()); |
8594 global3->Set(v8_str("prop"), v8::Integer::New(-1)); | 8617 global3->Set(v8_str("prop"), v8::Integer::New(env3->GetIsolate(), -1)); |
8595 global3->Set(v8_str("prop2"), v8::Integer::New(2)); | 8618 global3->Set(v8_str("prop2"), v8::Integer::New(env3->GetIsolate(), 2)); |
8596 env3->Exit(); | 8619 env3->Exit(); |
8597 | 8620 |
8598 // Call getProp in env1, and it should return the value 1 | 8621 // Call getProp in env1, and it should return the value 1 |
8599 { | 8622 { |
8600 Local<Value> get_prop = global1->Get(v8_str("getProp")); | 8623 Local<Value> get_prop = global1->Get(v8_str("getProp")); |
8601 CHECK(get_prop->IsFunction()); | 8624 CHECK(get_prop->IsFunction()); |
8602 v8::TryCatch try_catch; | 8625 v8::TryCatch try_catch; |
8603 Local<Value> r = Function::Cast(*get_prop)->Call(global1, 0, NULL); | 8626 Local<Value> r = Function::Cast(*get_prop)->Call(global1, 0, NULL); |
8604 CHECK(!try_catch.HasCaught()); | 8627 CHECK(!try_catch.HasCaught()); |
8605 CHECK_EQ(1, r->Int32Value()); | 8628 CHECK_EQ(1, r->Int32Value()); |
(...skipping 16 matching lines...) Expand all Loading... |
8622 | 8645 |
8623 Local<Value> foo = v8_str("foo"); | 8646 Local<Value> foo = v8_str("foo"); |
8624 | 8647 |
8625 // Set same security token for env1 and env2. | 8648 // Set same security token for env1 and env2. |
8626 env1->SetSecurityToken(foo); | 8649 env1->SetSecurityToken(foo); |
8627 env2->SetSecurityToken(foo); | 8650 env2->SetSecurityToken(foo); |
8628 | 8651 |
8629 // Create a property on the global object in env2. | 8652 // Create a property on the global object in env2. |
8630 { | 8653 { |
8631 v8::Context::Scope scope(env2); | 8654 v8::Context::Scope scope(env2); |
8632 env2->Global()->Set(v8_str("p"), v8::Integer::New(42)); | 8655 env2->Global()->Set(v8_str("p"), v8::Integer::New(env2->GetIsolate(), 42)); |
8633 } | 8656 } |
8634 | 8657 |
8635 // Create a reference to env2 global from env1 global. | 8658 // Create a reference to env2 global from env1 global. |
8636 env1->Global()->Set(v8_str("other"), env2->Global()); | 8659 env1->Global()->Set(v8_str("other"), env2->Global()); |
8637 | 8660 |
8638 // Check that we have access to other.p in env2 from env1. | 8661 // Check that we have access to other.p in env2 from env1. |
8639 Local<Value> result = CompileRun("other.p"); | 8662 Local<Value> result = CompileRun("other.p"); |
8640 CHECK(result->IsInt32()); | 8663 CHECK(result->IsInt32()); |
8641 CHECK_EQ(42, result->Int32Value()); | 8664 CHECK_EQ(42, result->Int32Value()); |
8642 | 8665 |
(...skipping 12 matching lines...) Expand all Loading... |
8655 v8::Handle<v8::ObjectTemplate>(), | 8678 v8::Handle<v8::ObjectTemplate>(), |
8656 global2); | 8679 global2); |
8657 CHECK_EQ(global2, env3->Global()); | 8680 CHECK_EQ(global2, env3->Global()); |
8658 | 8681 |
8659 // Start by using the same security token for env3 as for env1 and env2. | 8682 // Start by using the same security token for env3 as for env1 and env2. |
8660 env3->SetSecurityToken(foo); | 8683 env3->SetSecurityToken(foo); |
8661 | 8684 |
8662 // Create a property on the global object in env3. | 8685 // Create a property on the global object in env3. |
8663 { | 8686 { |
8664 v8::Context::Scope scope(env3); | 8687 v8::Context::Scope scope(env3); |
8665 env3->Global()->Set(v8_str("p"), v8::Integer::New(24)); | 8688 env3->Global()->Set(v8_str("p"), v8::Integer::New(env3->GetIsolate(), 24)); |
8666 } | 8689 } |
8667 | 8690 |
8668 // Check that other.p is now the property in env3 and that we have access. | 8691 // Check that other.p is now the property in env3 and that we have access. |
8669 result = CompileRun("other.p"); | 8692 result = CompileRun("other.p"); |
8670 CHECK(result->IsInt32()); | 8693 CHECK(result->IsInt32()); |
8671 CHECK_EQ(24, result->Int32Value()); | 8694 CHECK_EQ(24, result->Int32Value()); |
8672 | 8695 |
8673 // Change security token for env3 to something different from env1 and env2. | 8696 // Change security token for env3 to something different from env1 and env2. |
8674 env3->SetSecurityToken(v8_str("bar")); | 8697 env3->SetSecurityToken(v8_str("bar")); |
8675 | 8698 |
(...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9167 Local<Value> data) { | 9190 Local<Value> data) { |
9168 return false; | 9191 return false; |
9169 } | 9192 } |
9170 | 9193 |
9171 | 9194 |
9172 THREADED_TEST(AccessControlGetOwnPropertyNames) { | 9195 THREADED_TEST(AccessControlGetOwnPropertyNames) { |
9173 v8::Isolate* isolate = CcTest::isolate(); | 9196 v8::Isolate* isolate = CcTest::isolate(); |
9174 v8::HandleScope handle_scope(isolate); | 9197 v8::HandleScope handle_scope(isolate); |
9175 v8::Handle<v8::ObjectTemplate> obj_template = v8::ObjectTemplate::New(); | 9198 v8::Handle<v8::ObjectTemplate> obj_template = v8::ObjectTemplate::New(); |
9176 | 9199 |
9177 obj_template->Set(v8_str("x"), v8::Integer::New(42)); | 9200 obj_template->Set(v8_str("x"), v8::Integer::New(isolate, 42)); |
9178 obj_template->SetAccessCheckCallbacks(GetOwnPropertyNamesNamedBlocker, | 9201 obj_template->SetAccessCheckCallbacks(GetOwnPropertyNamesNamedBlocker, |
9179 GetOwnPropertyNamesIndexedBlocker); | 9202 GetOwnPropertyNamesIndexedBlocker); |
9180 | 9203 |
9181 // Create an environment | 9204 // Create an environment |
9182 v8::Local<Context> context0 = Context::New(isolate, NULL, obj_template); | 9205 v8::Local<Context> context0 = Context::New(isolate, NULL, obj_template); |
9183 context0->Enter(); | 9206 context0->Enter(); |
9184 | 9207 |
9185 v8::Handle<v8::Object> global0 = context0->Global(); | 9208 v8::Handle<v8::Object> global0 = context0->Global(); |
9186 | 9209 |
9187 v8::HandleScope scope1(CcTest::isolate()); | 9210 v8::HandleScope scope1(CcTest::isolate()); |
(...skipping 19 matching lines...) Expand all Loading... |
9207 CHECK(value->IsTrue()); | 9230 CHECK(value->IsTrue()); |
9208 | 9231 |
9209 context1->Exit(); | 9232 context1->Exit(); |
9210 context0->Exit(); | 9233 context0->Exit(); |
9211 } | 9234 } |
9212 | 9235 |
9213 | 9236 |
9214 static void IndexedPropertyEnumerator( | 9237 static void IndexedPropertyEnumerator( |
9215 const v8::PropertyCallbackInfo<v8::Array>& info) { | 9238 const v8::PropertyCallbackInfo<v8::Array>& info) { |
9216 v8::Handle<v8::Array> result = v8::Array::New(info.GetIsolate(), 2); | 9239 v8::Handle<v8::Array> result = v8::Array::New(info.GetIsolate(), 2); |
9217 result->Set(0, v8::Integer::New(7)); | 9240 result->Set(0, v8::Integer::New(info.GetIsolate(), 7)); |
9218 result->Set(1, v8::Object::New()); | 9241 result->Set(1, v8::Object::New(info.GetIsolate())); |
9219 info.GetReturnValue().Set(result); | 9242 info.GetReturnValue().Set(result); |
9220 } | 9243 } |
9221 | 9244 |
9222 | 9245 |
9223 static void NamedPropertyEnumerator( | 9246 static void NamedPropertyEnumerator( |
9224 const v8::PropertyCallbackInfo<v8::Array>& info) { | 9247 const v8::PropertyCallbackInfo<v8::Array>& info) { |
9225 v8::Handle<v8::Array> result = v8::Array::New(info.GetIsolate(), 2); | 9248 v8::Handle<v8::Array> result = v8::Array::New(info.GetIsolate(), 2); |
9226 result->Set(0, v8_str("x")); | 9249 result->Set(0, v8_str("x")); |
9227 result->Set(1, v8::Object::New()); | 9250 result->Set(1, v8::Object::New(info.GetIsolate())); |
9228 info.GetReturnValue().Set(result); | 9251 info.GetReturnValue().Set(result); |
9229 } | 9252 } |
9230 | 9253 |
9231 | 9254 |
9232 THREADED_TEST(GetOwnPropertyNamesWithInterceptor) { | 9255 THREADED_TEST(GetOwnPropertyNamesWithInterceptor) { |
9233 v8::HandleScope handle_scope(CcTest::isolate()); | 9256 v8::HandleScope handle_scope(CcTest::isolate()); |
9234 v8::Handle<v8::ObjectTemplate> obj_template = v8::ObjectTemplate::New(); | 9257 v8::Handle<v8::ObjectTemplate> obj_template = v8::ObjectTemplate::New(); |
9235 | 9258 |
9236 obj_template->Set(v8_str("7"), v8::Integer::New(7)); | 9259 obj_template->Set(v8_str("7"), v8::Integer::New(CcTest::isolate(), 7)); |
9237 obj_template->Set(v8_str("x"), v8::Integer::New(42)); | 9260 obj_template->Set(v8_str("x"), v8::Integer::New(CcTest::isolate(), 42)); |
9238 obj_template->SetIndexedPropertyHandler(NULL, NULL, NULL, NULL, | 9261 obj_template->SetIndexedPropertyHandler(NULL, NULL, NULL, NULL, |
9239 IndexedPropertyEnumerator); | 9262 IndexedPropertyEnumerator); |
9240 obj_template->SetNamedPropertyHandler(NULL, NULL, NULL, NULL, | 9263 obj_template->SetNamedPropertyHandler(NULL, NULL, NULL, NULL, |
9241 NamedPropertyEnumerator); | 9264 NamedPropertyEnumerator); |
9242 | 9265 |
9243 LocalContext context; | 9266 LocalContext context; |
9244 v8::Handle<v8::Object> global = context->Global(); | 9267 v8::Handle<v8::Object> global = context->Global(); |
9245 global->Set(v8_str("object"), obj_template->NewInstance()); | 9268 global->Set(v8_str("object"), obj_template->NewInstance()); |
9246 | 9269 |
9247 v8::Handle<v8::Value> result = | 9270 v8::Handle<v8::Value> result = |
(...skipping 685 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9933 | 9956 |
9934 // Regression test for issue 2457. | 9957 // Regression test for issue 2457. |
9935 THREADED_TEST(HiddenPrototypeIdentityHash) { | 9958 THREADED_TEST(HiddenPrototypeIdentityHash) { |
9936 LocalContext context; | 9959 LocalContext context; |
9937 v8::HandleScope handle_scope(context->GetIsolate()); | 9960 v8::HandleScope handle_scope(context->GetIsolate()); |
9938 | 9961 |
9939 Handle<FunctionTemplate> t = FunctionTemplate::New(context->GetIsolate()); | 9962 Handle<FunctionTemplate> t = FunctionTemplate::New(context->GetIsolate()); |
9940 t->SetHiddenPrototype(true); | 9963 t->SetHiddenPrototype(true); |
9941 t->InstanceTemplate()->Set(v8_str("foo"), v8_num(75)); | 9964 t->InstanceTemplate()->Set(v8_str("foo"), v8_num(75)); |
9942 Handle<Object> p = t->GetFunction()->NewInstance(); | 9965 Handle<Object> p = t->GetFunction()->NewInstance(); |
9943 Handle<Object> o = Object::New(); | 9966 Handle<Object> o = Object::New(context->GetIsolate()); |
9944 o->SetPrototype(p); | 9967 o->SetPrototype(p); |
9945 | 9968 |
9946 int hash = o->GetIdentityHash(); | 9969 int hash = o->GetIdentityHash(); |
9947 USE(hash); | 9970 USE(hash); |
9948 o->Set(v8_str("foo"), v8_num(42)); | 9971 o->Set(v8_str("foo"), v8_num(42)); |
9949 ASSERT_EQ(hash, o->GetIdentityHash()); | 9972 ASSERT_EQ(hash, o->GetIdentityHash()); |
9950 } | 9973 } |
9951 | 9974 |
9952 | 9975 |
9953 THREADED_TEST(SetPrototype) { | 9976 THREADED_TEST(SetPrototype) { |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10016 LocalContext context; | 10039 LocalContext context; |
10017 v8::Isolate* isolate = context->GetIsolate(); | 10040 v8::Isolate* isolate = context->GetIsolate(); |
10018 v8::HandleScope handle_scope(isolate); | 10041 v8::HandleScope handle_scope(isolate); |
10019 | 10042 |
10020 Local<v8::FunctionTemplate> t1 = v8::FunctionTemplate::New(isolate); | 10043 Local<v8::FunctionTemplate> t1 = v8::FunctionTemplate::New(isolate); |
10021 t1->SetHiddenPrototype(true); | 10044 t1->SetHiddenPrototype(true); |
10022 t1->InstanceTemplate()->Set(v8_str("foo"), v8_num(1)); | 10045 t1->InstanceTemplate()->Set(v8_str("foo"), v8_num(1)); |
10023 Local<v8::FunctionTemplate> t2 = v8::FunctionTemplate::New(isolate); | 10046 Local<v8::FunctionTemplate> t2 = v8::FunctionTemplate::New(isolate); |
10024 t2->SetHiddenPrototype(true); | 10047 t2->SetHiddenPrototype(true); |
10025 t2->InstanceTemplate()->Set(v8_str("fuz1"), v8_num(2)); | 10048 t2->InstanceTemplate()->Set(v8_str("fuz1"), v8_num(2)); |
10026 t2->InstanceTemplate()->Set(v8_str("objects"), v8::Object::New()); | 10049 t2->InstanceTemplate()->Set(v8_str("objects"), v8::Object::New(isolate)); |
10027 t2->InstanceTemplate()->Set(v8_str("fuz2"), v8_num(2)); | 10050 t2->InstanceTemplate()->Set(v8_str("fuz2"), v8_num(2)); |
10028 Local<v8::FunctionTemplate> t3 = v8::FunctionTemplate::New(isolate); | 10051 Local<v8::FunctionTemplate> t3 = v8::FunctionTemplate::New(isolate); |
10029 t3->SetHiddenPrototype(true); | 10052 t3->SetHiddenPrototype(true); |
10030 t3->InstanceTemplate()->Set(v8_str("boo"), v8_num(3)); | 10053 t3->InstanceTemplate()->Set(v8_str("boo"), v8_num(3)); |
10031 Local<v8::FunctionTemplate> t4 = v8::FunctionTemplate::New(isolate); | 10054 Local<v8::FunctionTemplate> t4 = v8::FunctionTemplate::New(isolate); |
10032 t4->InstanceTemplate()->Set(v8_str("baz"), v8_num(4)); | 10055 t4->InstanceTemplate()->Set(v8_str("baz"), v8_num(4)); |
10033 | 10056 |
10034 // Force dictionary-based properties. | 10057 // Force dictionary-based properties. |
10035 i::ScopedVector<char> name_buf(1024); | 10058 i::ScopedVector<char> name_buf(1024); |
10036 for (int i = 1; i <= 1000; i++) { | 10059 for (int i = 1; i <= 1000; i++) { |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10091 | 10114 |
10092 // Inherit from t1 and mark prototype as hidden. | 10115 // Inherit from t1 and mark prototype as hidden. |
10093 t2->Inherit(t1); | 10116 t2->Inherit(t1); |
10094 t2->InstanceTemplate()->Set(v8_str("mine"), v8_num(4)); | 10117 t2->InstanceTemplate()->Set(v8_str("mine"), v8_num(4)); |
10095 | 10118 |
10096 Local<v8::Object> o2 = t2->GetFunction()->NewInstance(); | 10119 Local<v8::Object> o2 = t2->GetFunction()->NewInstance(); |
10097 CHECK(o2->SetPrototype(o1)); | 10120 CHECK(o2->SetPrototype(o1)); |
10098 | 10121 |
10099 v8::Local<v8::Symbol> sym = v8::Symbol::New(context->GetIsolate(), "s1"); | 10122 v8::Local<v8::Symbol> sym = v8::Symbol::New(context->GetIsolate(), "s1"); |
10100 o1->Set(sym, v8_num(3)); | 10123 o1->Set(sym, v8_num(3)); |
10101 o1->SetHiddenValue(v8_str("h1"), v8::Integer::New(2013)); | 10124 o1->SetHiddenValue(v8_str("h1"), |
| 10125 v8::Integer::New(context->GetIsolate(), 2013)); |
10102 | 10126 |
10103 // Call the runtime version of GetLocalPropertyNames() on | 10127 // Call the runtime version of GetLocalPropertyNames() on |
10104 // the natively created object through JavaScript. | 10128 // the natively created object through JavaScript. |
10105 context->Global()->Set(v8_str("obj"), o2); | 10129 context->Global()->Set(v8_str("obj"), o2); |
10106 context->Global()->Set(v8_str("sym"), sym); | 10130 context->Global()->Set(v8_str("sym"), sym); |
10107 CompileRun("var names = %GetLocalPropertyNames(obj, true);"); | 10131 CompileRun("var names = %GetLocalPropertyNames(obj, true);"); |
10108 | 10132 |
10109 ExpectInt32("names.length", 7); | 10133 ExpectInt32("names.length", 7); |
10110 ExpectTrue("names.indexOf(\"foo\") >= 0"); | 10134 ExpectTrue("names.indexOf(\"foo\") >= 0"); |
10111 ExpectTrue("names.indexOf(\"bar\") >= 0"); | 10135 ExpectTrue("names.indexOf(\"bar\") >= 0"); |
10112 ExpectTrue("names.indexOf(\"baz\") >= 0"); | 10136 ExpectTrue("names.indexOf(\"baz\") >= 0"); |
10113 ExpectTrue("names.indexOf(\"n1\") >= 0"); | 10137 ExpectTrue("names.indexOf(\"n1\") >= 0"); |
10114 ExpectTrue("names.indexOf(\"n2\") >= 0"); | 10138 ExpectTrue("names.indexOf(\"n2\") >= 0"); |
10115 ExpectTrue("names.indexOf(sym) >= 0"); | 10139 ExpectTrue("names.indexOf(sym) >= 0"); |
10116 ExpectTrue("names.indexOf(\"mine\") >= 0"); | 10140 ExpectTrue("names.indexOf(\"mine\") >= 0"); |
10117 } | 10141 } |
10118 | 10142 |
10119 | 10143 |
10120 THREADED_TEST(FunctionReadOnlyPrototype) { | 10144 THREADED_TEST(FunctionReadOnlyPrototype) { |
10121 LocalContext context; | 10145 LocalContext context; |
10122 v8::Isolate* isolate = context->GetIsolate(); | 10146 v8::Isolate* isolate = context->GetIsolate(); |
10123 v8::HandleScope handle_scope(isolate); | 10147 v8::HandleScope handle_scope(isolate); |
10124 | 10148 |
10125 Local<v8::FunctionTemplate> t1 = v8::FunctionTemplate::New(isolate); | 10149 Local<v8::FunctionTemplate> t1 = v8::FunctionTemplate::New(isolate); |
10126 t1->PrototypeTemplate()->Set(v8_str("x"), v8::Integer::New(42)); | 10150 t1->PrototypeTemplate()->Set(v8_str("x"), v8::Integer::New(isolate, 42)); |
10127 t1->ReadOnlyPrototype(); | 10151 t1->ReadOnlyPrototype(); |
10128 context->Global()->Set(v8_str("func1"), t1->GetFunction()); | 10152 context->Global()->Set(v8_str("func1"), t1->GetFunction()); |
10129 // Configured value of ReadOnly flag. | 10153 // Configured value of ReadOnly flag. |
10130 CHECK(CompileRun( | 10154 CHECK(CompileRun( |
10131 "(function() {" | 10155 "(function() {" |
10132 " descriptor = Object.getOwnPropertyDescriptor(func1, 'prototype');" | 10156 " descriptor = Object.getOwnPropertyDescriptor(func1, 'prototype');" |
10133 " return (descriptor['writable'] == false);" | 10157 " return (descriptor['writable'] == false);" |
10134 "})()")->BooleanValue()); | 10158 "})()")->BooleanValue()); |
10135 CHECK_EQ(42, CompileRun("func1.prototype.x")->Int32Value()); | 10159 CHECK_EQ(42, CompileRun("func1.prototype.x")->Int32Value()); |
10136 CHECK_EQ(42, | 10160 CHECK_EQ(42, |
10137 CompileRun("func1.prototype = {}; func1.prototype.x")->Int32Value()); | 10161 CompileRun("func1.prototype = {}; func1.prototype.x")->Int32Value()); |
10138 | 10162 |
10139 Local<v8::FunctionTemplate> t2 = v8::FunctionTemplate::New(isolate); | 10163 Local<v8::FunctionTemplate> t2 = v8::FunctionTemplate::New(isolate); |
10140 t2->PrototypeTemplate()->Set(v8_str("x"), v8::Integer::New(42)); | 10164 t2->PrototypeTemplate()->Set(v8_str("x"), v8::Integer::New(isolate, 42)); |
10141 context->Global()->Set(v8_str("func2"), t2->GetFunction()); | 10165 context->Global()->Set(v8_str("func2"), t2->GetFunction()); |
10142 // Default value of ReadOnly flag. | 10166 // Default value of ReadOnly flag. |
10143 CHECK(CompileRun( | 10167 CHECK(CompileRun( |
10144 "(function() {" | 10168 "(function() {" |
10145 " descriptor = Object.getOwnPropertyDescriptor(func2, 'prototype');" | 10169 " descriptor = Object.getOwnPropertyDescriptor(func2, 'prototype');" |
10146 " return (descriptor['writable'] == true);" | 10170 " return (descriptor['writable'] == true);" |
10147 "})()")->BooleanValue()); | 10171 "})()")->BooleanValue()); |
10148 CHECK_EQ(42, CompileRun("func2.prototype.x")->Int32Value()); | 10172 CHECK_EQ(42, CompileRun("func2.prototype.x")->Int32Value()); |
10149 } | 10173 } |
10150 | 10174 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10187 CHECK(try_catch.HasCaught()); | 10211 CHECK(try_catch.HasCaught()); |
10188 | 10212 |
10189 try_catch.Reset(); | 10213 try_catch.Reset(); |
10190 fun->NewInstance(); | 10214 fun->NewInstance(); |
10191 CHECK(try_catch.HasCaught()); | 10215 CHECK(try_catch.HasCaught()); |
10192 } | 10216 } |
10193 | 10217 |
10194 | 10218 |
10195 THREADED_TEST(GetterSetterExceptions) { | 10219 THREADED_TEST(GetterSetterExceptions) { |
10196 LocalContext context; | 10220 LocalContext context; |
10197 v8::HandleScope handle_scope(context->GetIsolate()); | 10221 v8::Isolate* isolate = context->GetIsolate(); |
| 10222 v8::HandleScope handle_scope(isolate); |
10198 CompileRun( | 10223 CompileRun( |
10199 "function Foo() { };" | 10224 "function Foo() { };" |
10200 "function Throw() { throw 5; };" | 10225 "function Throw() { throw 5; };" |
10201 "var x = { };" | 10226 "var x = { };" |
10202 "x.__defineSetter__('set', Throw);" | 10227 "x.__defineSetter__('set', Throw);" |
10203 "x.__defineGetter__('get', Throw);"); | 10228 "x.__defineGetter__('get', Throw);"); |
10204 Local<v8::Object> x = | 10229 Local<v8::Object> x = |
10205 Local<v8::Object>::Cast(context->Global()->Get(v8_str("x"))); | 10230 Local<v8::Object>::Cast(context->Global()->Get(v8_str("x"))); |
10206 v8::TryCatch try_catch; | 10231 v8::TryCatch try_catch; |
10207 x->Set(v8_str("set"), v8::Integer::New(8)); | 10232 x->Set(v8_str("set"), v8::Integer::New(isolate, 8)); |
10208 x->Get(v8_str("get")); | 10233 x->Get(v8_str("get")); |
10209 x->Set(v8_str("set"), v8::Integer::New(8)); | 10234 x->Set(v8_str("set"), v8::Integer::New(isolate, 8)); |
10210 x->Get(v8_str("get")); | 10235 x->Get(v8_str("get")); |
10211 x->Set(v8_str("set"), v8::Integer::New(8)); | 10236 x->Set(v8_str("set"), v8::Integer::New(isolate, 8)); |
10212 x->Get(v8_str("get")); | 10237 x->Get(v8_str("get")); |
10213 x->Set(v8_str("set"), v8::Integer::New(8)); | 10238 x->Set(v8_str("set"), v8::Integer::New(isolate, 8)); |
10214 x->Get(v8_str("get")); | 10239 x->Get(v8_str("get")); |
10215 } | 10240 } |
10216 | 10241 |
10217 | 10242 |
10218 THREADED_TEST(Constructor) { | 10243 THREADED_TEST(Constructor) { |
10219 LocalContext context; | 10244 LocalContext context; |
10220 v8::Isolate* isolate = context->GetIsolate(); | 10245 v8::Isolate* isolate = context->GetIsolate(); |
10221 v8::HandleScope handle_scope(isolate); | 10246 v8::HandleScope handle_scope(isolate); |
10222 Local<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(isolate); | 10247 Local<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(isolate); |
10223 templ->SetClassName(v8_str("Fun")); | 10248 templ->SetClassName(v8_str("Fun")); |
10224 Local<Function> cons = templ->GetFunction(); | 10249 Local<Function> cons = templ->GetFunction(); |
10225 context->Global()->Set(v8_str("Fun"), cons); | 10250 context->Global()->Set(v8_str("Fun"), cons); |
10226 Local<v8::Object> inst = cons->NewInstance(); | 10251 Local<v8::Object> inst = cons->NewInstance(); |
10227 i::Handle<i::JSObject> obj(v8::Utils::OpenHandle(*inst)); | 10252 i::Handle<i::JSObject> obj(v8::Utils::OpenHandle(*inst)); |
10228 CHECK(obj->IsJSObject()); | 10253 CHECK(obj->IsJSObject()); |
10229 Local<Value> value = CompileRun("(new Fun()).constructor === Fun"); | 10254 Local<Value> value = CompileRun("(new Fun()).constructor === Fun"); |
10230 CHECK(value->BooleanValue()); | 10255 CHECK(value->BooleanValue()); |
10231 } | 10256 } |
10232 | 10257 |
10233 | 10258 |
10234 static void ConstructorCallback( | 10259 static void ConstructorCallback( |
10235 const v8::FunctionCallbackInfo<v8::Value>& args) { | 10260 const v8::FunctionCallbackInfo<v8::Value>& args) { |
10236 ApiTestFuzzer::Fuzz(); | 10261 ApiTestFuzzer::Fuzz(); |
10237 Local<Object> This; | 10262 Local<Object> This; |
10238 | 10263 |
10239 if (args.IsConstructCall()) { | 10264 if (args.IsConstructCall()) { |
10240 Local<Object> Holder = args.Holder(); | 10265 Local<Object> Holder = args.Holder(); |
10241 This = Object::New(); | 10266 This = Object::New(args.GetIsolate()); |
10242 Local<Value> proto = Holder->GetPrototype(); | 10267 Local<Value> proto = Holder->GetPrototype(); |
10243 if (proto->IsObject()) { | 10268 if (proto->IsObject()) { |
10244 This->SetPrototype(proto); | 10269 This->SetPrototype(proto); |
10245 } | 10270 } |
10246 } else { | 10271 } else { |
10247 This = args.This(); | 10272 This = args.This(); |
10248 } | 10273 } |
10249 | 10274 |
10250 This->Set(v8_str("a"), args[0]); | 10275 This->Set(v8_str("a"), args[0]); |
10251 args.GetReturnValue().Set(This); | 10276 args.GetReturnValue().Set(This); |
(...skipping 626 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10878 | 10903 |
10879 static int CountHandles() { | 10904 static int CountHandles() { |
10880 return v8::HandleScope::NumberOfHandles(); | 10905 return v8::HandleScope::NumberOfHandles(); |
10881 } | 10906 } |
10882 | 10907 |
10883 | 10908 |
10884 static int Recurse(int depth, int iterations) { | 10909 static int Recurse(int depth, int iterations) { |
10885 v8::HandleScope scope(CcTest::isolate()); | 10910 v8::HandleScope scope(CcTest::isolate()); |
10886 if (depth == 0) return CountHandles(); | 10911 if (depth == 0) return CountHandles(); |
10887 for (int i = 0; i < iterations; i++) { | 10912 for (int i = 0; i < iterations; i++) { |
10888 Local<v8::Number> n(v8::Integer::New(42)); | 10913 Local<v8::Number> n(v8::Integer::New(CcTest::isolate(), 42)); |
10889 } | 10914 } |
10890 return Recurse(depth - 1, iterations); | 10915 return Recurse(depth - 1, iterations); |
10891 } | 10916 } |
10892 | 10917 |
10893 | 10918 |
10894 THREADED_TEST(HandleIteration) { | 10919 THREADED_TEST(HandleIteration) { |
10895 static const int kIterations = 500; | 10920 static const int kIterations = 500; |
10896 static const int kNesting = 200; | 10921 static const int kNesting = 200; |
10897 CHECK_EQ(0, CountHandles()); | 10922 CHECK_EQ(0, CountHandles()); |
10898 { | 10923 { |
10899 v8::HandleScope scope1(CcTest::isolate()); | 10924 v8::HandleScope scope1(CcTest::isolate()); |
10900 CHECK_EQ(0, CountHandles()); | 10925 CHECK_EQ(0, CountHandles()); |
10901 for (int i = 0; i < kIterations; i++) { | 10926 for (int i = 0; i < kIterations; i++) { |
10902 Local<v8::Number> n(v8::Integer::New(42)); | 10927 Local<v8::Number> n(v8::Integer::New(CcTest::isolate(), 42)); |
10903 CHECK_EQ(i + 1, CountHandles()); | 10928 CHECK_EQ(i + 1, CountHandles()); |
10904 } | 10929 } |
10905 | 10930 |
10906 CHECK_EQ(kIterations, CountHandles()); | 10931 CHECK_EQ(kIterations, CountHandles()); |
10907 { | 10932 { |
10908 v8::HandleScope scope2(CcTest::isolate()); | 10933 v8::HandleScope scope2(CcTest::isolate()); |
10909 for (int j = 0; j < kIterations; j++) { | 10934 for (int j = 0; j < kIterations; j++) { |
10910 Local<v8::Number> n(v8::Integer::New(42)); | 10935 Local<v8::Number> n(v8::Integer::New(CcTest::isolate(), 42)); |
10911 CHECK_EQ(j + 1 + kIterations, CountHandles()); | 10936 CHECK_EQ(j + 1 + kIterations, CountHandles()); |
10912 } | 10937 } |
10913 } | 10938 } |
10914 CHECK_EQ(kIterations, CountHandles()); | 10939 CHECK_EQ(kIterations, CountHandles()); |
10915 } | 10940 } |
10916 CHECK_EQ(0, CountHandles()); | 10941 CHECK_EQ(0, CountHandles()); |
10917 CHECK_EQ(kNesting * kIterations, Recurse(kNesting, kIterations)); | 10942 CHECK_EQ(kNesting * kIterations, Recurse(kNesting, kIterations)); |
10918 } | 10943 } |
10919 | 10944 |
10920 | 10945 |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11006 | 11031 |
11007 | 11032 |
11008 static void InterceptorLoadICGetter( | 11033 static void InterceptorLoadICGetter( |
11009 Local<String> name, | 11034 Local<String> name, |
11010 const v8::PropertyCallbackInfo<v8::Value>& info) { | 11035 const v8::PropertyCallbackInfo<v8::Value>& info) { |
11011 ApiTestFuzzer::Fuzz(); | 11036 ApiTestFuzzer::Fuzz(); |
11012 v8::Isolate* isolate = CcTest::isolate(); | 11037 v8::Isolate* isolate = CcTest::isolate(); |
11013 CHECK_EQ(isolate, info.GetIsolate()); | 11038 CHECK_EQ(isolate, info.GetIsolate()); |
11014 CHECK_EQ(v8_str("data"), info.Data()); | 11039 CHECK_EQ(v8_str("data"), info.Data()); |
11015 CHECK_EQ(v8_str("x"), name); | 11040 CHECK_EQ(v8_str("x"), name); |
11016 info.GetReturnValue().Set(v8::Integer::New(42)); | 11041 info.GetReturnValue().Set(v8::Integer::New(isolate, 42)); |
11017 } | 11042 } |
11018 | 11043 |
11019 | 11044 |
11020 // This test should hit the load IC for the interceptor case. | 11045 // This test should hit the load IC for the interceptor case. |
11021 THREADED_TEST(InterceptorLoadIC) { | 11046 THREADED_TEST(InterceptorLoadIC) { |
11022 CheckInterceptorLoadIC(InterceptorLoadICGetter, | 11047 CheckInterceptorLoadIC(InterceptorLoadICGetter, |
11023 "var result = 0;" | 11048 "var result = 0;" |
11024 "for (var i = 0; i < 1000; i++) {" | 11049 "for (var i = 0; i < 1000; i++) {" |
11025 " result = o.x;" | 11050 " result = o.x;" |
11026 "}", | 11051 "}", |
11027 42); | 11052 42); |
11028 } | 11053 } |
11029 | 11054 |
11030 | 11055 |
11031 // Below go several tests which verify that JITing for various | 11056 // Below go several tests which verify that JITing for various |
11032 // configurations of interceptor and explicit fields works fine | 11057 // configurations of interceptor and explicit fields works fine |
11033 // (those cases are special cased to get better performance). | 11058 // (those cases are special cased to get better performance). |
11034 | 11059 |
11035 static void InterceptorLoadXICGetter( | 11060 static void InterceptorLoadXICGetter( |
11036 Local<String> name, | 11061 Local<String> name, |
11037 const v8::PropertyCallbackInfo<v8::Value>& info) { | 11062 const v8::PropertyCallbackInfo<v8::Value>& info) { |
11038 ApiTestFuzzer::Fuzz(); | 11063 ApiTestFuzzer::Fuzz(); |
11039 info.GetReturnValue().Set( | 11064 info.GetReturnValue().Set( |
11040 v8_str("x")->Equals(name) ? | 11065 v8_str("x")->Equals(name) ? |
11041 v8::Handle<v8::Value>(v8::Integer::New(42)) : | 11066 v8::Handle<v8::Value>(v8::Integer::New(info.GetIsolate(), 42)) : |
11042 v8::Handle<v8::Value>()); | 11067 v8::Handle<v8::Value>()); |
11043 } | 11068 } |
11044 | 11069 |
11045 | 11070 |
11046 THREADED_TEST(InterceptorLoadICWithFieldOnHolder) { | 11071 THREADED_TEST(InterceptorLoadICWithFieldOnHolder) { |
11047 CheckInterceptorLoadIC(InterceptorLoadXICGetter, | 11072 CheckInterceptorLoadIC(InterceptorLoadXICGetter, |
11048 "var result = 0;" | 11073 "var result = 0;" |
11049 "o.y = 239;" | 11074 "o.y = 239;" |
11050 "for (var i = 0; i < 1000; i++) {" | 11075 "for (var i = 0; i < 1000; i++) {" |
11051 " result = o.y;" | 11076 " result = o.y;" |
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11383 "result"); | 11408 "result"); |
11384 CHECK_EQ(42 * 10, value->Int32Value()); | 11409 CHECK_EQ(42 * 10, value->Int32Value()); |
11385 } | 11410 } |
11386 | 11411 |
11387 | 11412 |
11388 static void InterceptorLoadICGetter0( | 11413 static void InterceptorLoadICGetter0( |
11389 Local<String> name, | 11414 Local<String> name, |
11390 const v8::PropertyCallbackInfo<v8::Value>& info) { | 11415 const v8::PropertyCallbackInfo<v8::Value>& info) { |
11391 ApiTestFuzzer::Fuzz(); | 11416 ApiTestFuzzer::Fuzz(); |
11392 CHECK(v8_str("x")->Equals(name)); | 11417 CHECK(v8_str("x")->Equals(name)); |
11393 info.GetReturnValue().Set(v8::Integer::New(0)); | 11418 info.GetReturnValue().Set(v8::Integer::New(info.GetIsolate(), 0)); |
11394 } | 11419 } |
11395 | 11420 |
11396 | 11421 |
11397 THREADED_TEST(InterceptorReturningZero) { | 11422 THREADED_TEST(InterceptorReturningZero) { |
11398 CheckInterceptorLoadIC(InterceptorLoadICGetter0, | 11423 CheckInterceptorLoadIC(InterceptorLoadICGetter0, |
11399 "o.x == undefined ? 1 : 0", | 11424 "o.x == undefined ? 1 : 0", |
11400 0); | 11425 0); |
11401 } | 11426 } |
11402 | 11427 |
11403 | 11428 |
(...skipping 1225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12629 ApiTestFuzzer::Fuzz(); | 12654 ApiTestFuzzer::Fuzz(); |
12630 info.GetIsolate()->ThrowException(Handle<Value>()); | 12655 info.GetIsolate()->ThrowException(Handle<Value>()); |
12631 info.GetReturnValue().SetUndefined(); | 12656 info.GetReturnValue().SetUndefined(); |
12632 } | 12657 } |
12633 | 12658 |
12634 | 12659 |
12635 THREADED_TEST(VariousGetPropertiesAndThrowingCallbacks) { | 12660 THREADED_TEST(VariousGetPropertiesAndThrowingCallbacks) { |
12636 LocalContext context; | 12661 LocalContext context; |
12637 HandleScope scope(context->GetIsolate()); | 12662 HandleScope scope(context->GetIsolate()); |
12638 | 12663 |
12639 Local<FunctionTemplate> templ = FunctionTemplate::New(CcTest::isolate()); | 12664 Local<FunctionTemplate> templ = FunctionTemplate::New(context->GetIsolate()); |
12640 Local<ObjectTemplate> instance_templ = templ->InstanceTemplate(); | 12665 Local<ObjectTemplate> instance_templ = templ->InstanceTemplate(); |
12641 instance_templ->SetAccessor(v8_str("f"), ThrowingGetter); | 12666 instance_templ->SetAccessor(v8_str("f"), ThrowingGetter); |
12642 | 12667 |
12643 Local<Object> instance = templ->GetFunction()->NewInstance(); | 12668 Local<Object> instance = templ->GetFunction()->NewInstance(); |
12644 | 12669 |
12645 Local<Object> another = Object::New(); | 12670 Local<Object> another = Object::New(context->GetIsolate()); |
12646 another->SetPrototype(instance); | 12671 another->SetPrototype(instance); |
12647 | 12672 |
12648 Local<Object> with_js_getter = CompileRun( | 12673 Local<Object> with_js_getter = CompileRun( |
12649 "o = {};\n" | 12674 "o = {};\n" |
12650 "o.__defineGetter__('f', function() { throw undefined; });\n" | 12675 "o.__defineGetter__('f', function() { throw undefined; });\n" |
12651 "o\n").As<Object>(); | 12676 "o\n").As<Object>(); |
12652 CHECK(!with_js_getter.IsEmpty()); | 12677 CHECK(!with_js_getter.IsEmpty()); |
12653 | 12678 |
12654 TryCatch try_catch; | 12679 TryCatch try_catch; |
12655 | 12680 |
(...skipping 620 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13276 v8::Isolate* isolate = context->GetIsolate(); | 13301 v8::Isolate* isolate = context->GetIsolate(); |
13277 i::GlobalHandles* globals = | 13302 i::GlobalHandles* globals = |
13278 reinterpret_cast<i::Isolate*>(isolate)->global_handles(); | 13303 reinterpret_cast<i::Isolate*>(isolate)->global_handles(); |
13279 int initial_handles = globals->global_handles_count(); | 13304 int initial_handles = globals->global_handles_count(); |
13280 typedef v8::Persistent<v8::Object, v8::CopyablePersistentTraits<v8::Object> > | 13305 typedef v8::Persistent<v8::Object, v8::CopyablePersistentTraits<v8::Object> > |
13281 CopyableObject; | 13306 CopyableObject; |
13282 { | 13307 { |
13283 CopyableObject handle1; | 13308 CopyableObject handle1; |
13284 { | 13309 { |
13285 v8::HandleScope scope(isolate); | 13310 v8::HandleScope scope(isolate); |
13286 handle1.Reset(isolate, v8::Object::New()); | 13311 handle1.Reset(isolate, v8::Object::New(isolate)); |
13287 } | 13312 } |
13288 CHECK_EQ(initial_handles + 1, globals->global_handles_count()); | 13313 CHECK_EQ(initial_handles + 1, globals->global_handles_count()); |
13289 CopyableObject handle2; | 13314 CopyableObject handle2; |
13290 handle2 = handle1; | 13315 handle2 = handle1; |
13291 CHECK(handle1 == handle2); | 13316 CHECK(handle1 == handle2); |
13292 CHECK_EQ(initial_handles + 2, globals->global_handles_count()); | 13317 CHECK_EQ(initial_handles + 2, globals->global_handles_count()); |
13293 CopyableObject handle3(handle2); | 13318 CopyableObject handle3(handle2); |
13294 CHECK(handle1 == handle3); | 13319 CHECK(handle1 == handle3); |
13295 CHECK_EQ(initial_handles + 3, globals->global_handles_count()); | 13320 CHECK_EQ(initial_handles + 3, globals->global_handles_count()); |
13296 } | 13321 } |
(...skipping 12 matching lines...) Expand all Loading... |
13309 | 13334 |
13310 | 13335 |
13311 TEST(WeakCallbackApi) { | 13336 TEST(WeakCallbackApi) { |
13312 LocalContext context; | 13337 LocalContext context; |
13313 v8::Isolate* isolate = context->GetIsolate(); | 13338 v8::Isolate* isolate = context->GetIsolate(); |
13314 i::GlobalHandles* globals = | 13339 i::GlobalHandles* globals = |
13315 reinterpret_cast<i::Isolate*>(isolate)->global_handles(); | 13340 reinterpret_cast<i::Isolate*>(isolate)->global_handles(); |
13316 int initial_handles = globals->global_handles_count(); | 13341 int initial_handles = globals->global_handles_count(); |
13317 { | 13342 { |
13318 v8::HandleScope scope(isolate); | 13343 v8::HandleScope scope(isolate); |
13319 v8::Local<v8::Object> obj = v8::Object::New(); | 13344 v8::Local<v8::Object> obj = v8::Object::New(isolate); |
13320 obj->Set(v8_str("key"), v8::Integer::New(231, isolate)); | 13345 obj->Set(v8_str("key"), v8::Integer::New(isolate, 231)); |
13321 v8::Persistent<v8::Object>* handle = | 13346 v8::Persistent<v8::Object>* handle = |
13322 new v8::Persistent<v8::Object>(isolate, obj); | 13347 new v8::Persistent<v8::Object>(isolate, obj); |
13323 handle->SetWeak<v8::Object, v8::Persistent<v8::Object> >(handle, | 13348 handle->SetWeak<v8::Object, v8::Persistent<v8::Object> >(handle, |
13324 WeakApiCallback); | 13349 WeakApiCallback); |
13325 } | 13350 } |
13326 reinterpret_cast<i::Isolate*>(isolate)->heap()-> | 13351 reinterpret_cast<i::Isolate*>(isolate)->heap()-> |
13327 CollectAllGarbage(i::Heap::kNoGCFlags); | 13352 CollectAllGarbage(i::Heap::kNoGCFlags); |
13328 // Verify disposed. | 13353 // Verify disposed. |
13329 CHECK_EQ(initial_handles, globals->global_handles_count()); | 13354 CHECK_EQ(initial_handles, globals->global_handles_count()); |
13330 } | 13355 } |
(...skipping 10 matching lines...) Expand all Loading... |
13341 } | 13366 } |
13342 | 13367 |
13343 | 13368 |
13344 THREADED_TEST(NewPersistentHandleFromWeakCallback) { | 13369 THREADED_TEST(NewPersistentHandleFromWeakCallback) { |
13345 LocalContext context; | 13370 LocalContext context; |
13346 v8::Isolate* isolate = context->GetIsolate(); | 13371 v8::Isolate* isolate = context->GetIsolate(); |
13347 | 13372 |
13348 v8::Persistent<v8::Object> handle1, handle2; | 13373 v8::Persistent<v8::Object> handle1, handle2; |
13349 { | 13374 { |
13350 v8::HandleScope scope(isolate); | 13375 v8::HandleScope scope(isolate); |
13351 some_object.Reset(isolate, v8::Object::New()); | 13376 some_object.Reset(isolate, v8::Object::New(isolate)); |
13352 handle1.Reset(isolate, v8::Object::New()); | 13377 handle1.Reset(isolate, v8::Object::New(isolate)); |
13353 handle2.Reset(isolate, v8::Object::New()); | 13378 handle2.Reset(isolate, v8::Object::New(isolate)); |
13354 } | 13379 } |
13355 // Note: order is implementation dependent alas: currently | 13380 // Note: order is implementation dependent alas: currently |
13356 // global handle nodes are processed by PostGarbageCollectionProcessing | 13381 // global handle nodes are processed by PostGarbageCollectionProcessing |
13357 // in reverse allocation order, so if second allocated handle is deleted, | 13382 // in reverse allocation order, so if second allocated handle is deleted, |
13358 // weak callback of the first handle would be able to 'reallocate' it. | 13383 // weak callback of the first handle would be able to 'reallocate' it. |
13359 handle1.SetWeak(&handle1, NewPersistentHandleCallback); | 13384 handle1.SetWeak(&handle1, NewPersistentHandleCallback); |
13360 handle2.Reset(); | 13385 handle2.Reset(); |
13361 CcTest::heap()->CollectAllGarbage(i::Heap::kAbortIncrementalMarkingMask); | 13386 CcTest::heap()->CollectAllGarbage(i::Heap::kAbortIncrementalMarkingMask); |
13362 } | 13387 } |
13363 | 13388 |
13364 | 13389 |
13365 v8::Persistent<v8::Object> to_be_disposed; | 13390 v8::Persistent<v8::Object> to_be_disposed; |
13366 | 13391 |
13367 void DisposeAndForceGcCallback( | 13392 void DisposeAndForceGcCallback( |
13368 const v8::WeakCallbackData<v8::Object, v8::Persistent<v8::Object> >& data) { | 13393 const v8::WeakCallbackData<v8::Object, v8::Persistent<v8::Object> >& data) { |
13369 to_be_disposed.Reset(); | 13394 to_be_disposed.Reset(); |
13370 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); | 13395 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); |
13371 data.GetParameter()->Reset(); | 13396 data.GetParameter()->Reset(); |
13372 } | 13397 } |
13373 | 13398 |
13374 | 13399 |
13375 THREADED_TEST(DoNotUseDeletedNodesInSecondLevelGc) { | 13400 THREADED_TEST(DoNotUseDeletedNodesInSecondLevelGc) { |
13376 LocalContext context; | 13401 LocalContext context; |
13377 v8::Isolate* isolate = context->GetIsolate(); | 13402 v8::Isolate* isolate = context->GetIsolate(); |
13378 | 13403 |
13379 v8::Persistent<v8::Object> handle1, handle2; | 13404 v8::Persistent<v8::Object> handle1, handle2; |
13380 { | 13405 { |
13381 v8::HandleScope scope(isolate); | 13406 v8::HandleScope scope(isolate); |
13382 handle1.Reset(isolate, v8::Object::New()); | 13407 handle1.Reset(isolate, v8::Object::New(isolate)); |
13383 handle2.Reset(isolate, v8::Object::New()); | 13408 handle2.Reset(isolate, v8::Object::New(isolate)); |
13384 } | 13409 } |
13385 handle1.SetWeak(&handle1, DisposeAndForceGcCallback); | 13410 handle1.SetWeak(&handle1, DisposeAndForceGcCallback); |
13386 to_be_disposed.Reset(isolate, handle2); | 13411 to_be_disposed.Reset(isolate, handle2); |
13387 CcTest::heap()->CollectAllGarbage(i::Heap::kAbortIncrementalMarkingMask); | 13412 CcTest::heap()->CollectAllGarbage(i::Heap::kAbortIncrementalMarkingMask); |
13388 } | 13413 } |
13389 | 13414 |
13390 void DisposingCallback( | 13415 void DisposingCallback( |
13391 const v8::WeakCallbackData<v8::Object, v8::Persistent<v8::Object> >& data) { | 13416 const v8::WeakCallbackData<v8::Object, v8::Persistent<v8::Object> >& data) { |
13392 data.GetParameter()->Reset(); | 13417 data.GetParameter()->Reset(); |
13393 } | 13418 } |
13394 | 13419 |
13395 void HandleCreatingCallback( | 13420 void HandleCreatingCallback( |
13396 const v8::WeakCallbackData<v8::Object, v8::Persistent<v8::Object> >& data) { | 13421 const v8::WeakCallbackData<v8::Object, v8::Persistent<v8::Object> >& data) { |
13397 v8::HandleScope scope(data.GetIsolate()); | 13422 v8::HandleScope scope(data.GetIsolate()); |
13398 v8::Persistent<v8::Object>(data.GetIsolate(), v8::Object::New()); | 13423 v8::Persistent<v8::Object>(data.GetIsolate(), |
| 13424 v8::Object::New(data.GetIsolate())); |
13399 data.GetParameter()->Reset(); | 13425 data.GetParameter()->Reset(); |
13400 } | 13426 } |
13401 | 13427 |
13402 | 13428 |
13403 THREADED_TEST(NoGlobalHandlesOrphaningDueToWeakCallback) { | 13429 THREADED_TEST(NoGlobalHandlesOrphaningDueToWeakCallback) { |
13404 LocalContext context; | 13430 LocalContext context; |
13405 v8::Isolate* isolate = context->GetIsolate(); | 13431 v8::Isolate* isolate = context->GetIsolate(); |
13406 | 13432 |
13407 v8::Persistent<v8::Object> handle1, handle2, handle3; | 13433 v8::Persistent<v8::Object> handle1, handle2, handle3; |
13408 { | 13434 { |
13409 v8::HandleScope scope(isolate); | 13435 v8::HandleScope scope(isolate); |
13410 handle3.Reset(isolate, v8::Object::New()); | 13436 handle3.Reset(isolate, v8::Object::New(isolate)); |
13411 handle2.Reset(isolate, v8::Object::New()); | 13437 handle2.Reset(isolate, v8::Object::New(isolate)); |
13412 handle1.Reset(isolate, v8::Object::New()); | 13438 handle1.Reset(isolate, v8::Object::New(isolate)); |
13413 } | 13439 } |
13414 handle2.SetWeak(&handle2, DisposingCallback); | 13440 handle2.SetWeak(&handle2, DisposingCallback); |
13415 handle3.SetWeak(&handle3, HandleCreatingCallback); | 13441 handle3.SetWeak(&handle3, HandleCreatingCallback); |
13416 CcTest::heap()->CollectAllGarbage(i::Heap::kAbortIncrementalMarkingMask); | 13442 CcTest::heap()->CollectAllGarbage(i::Heap::kAbortIncrementalMarkingMask); |
13417 } | 13443 } |
13418 | 13444 |
13419 | 13445 |
13420 THREADED_TEST(CheckForCrossContextObjectLiterals) { | 13446 THREADED_TEST(CheckForCrossContextObjectLiterals) { |
13421 v8::V8::Initialize(); | 13447 v8::V8::Initialize(); |
13422 | 13448 |
(...skipping 726 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
14149 | 14175 |
14150 resource_name = "test1.js"; | 14176 resource_name = "test1.js"; |
14151 v8::ScriptOrigin origin1( | 14177 v8::ScriptOrigin origin1( |
14152 v8::String::NewFromUtf8(context->GetIsolate(), resource_name)); | 14178 v8::String::NewFromUtf8(context->GetIsolate(), resource_name)); |
14153 script = v8::Script::Compile(source, &origin1); | 14179 script = v8::Script::Compile(source, &origin1); |
14154 CheckTryCatchSourceInfo(script, resource_name, 0); | 14180 CheckTryCatchSourceInfo(script, resource_name, 0); |
14155 | 14181 |
14156 resource_name = "test2.js"; | 14182 resource_name = "test2.js"; |
14157 v8::ScriptOrigin origin2( | 14183 v8::ScriptOrigin origin2( |
14158 v8::String::NewFromUtf8(context->GetIsolate(), resource_name), | 14184 v8::String::NewFromUtf8(context->GetIsolate(), resource_name), |
14159 v8::Integer::New(7)); | 14185 v8::Integer::New(context->GetIsolate(), 7)); |
14160 script = v8::Script::Compile(source, &origin2); | 14186 script = v8::Script::Compile(source, &origin2); |
14161 CheckTryCatchSourceInfo(script, resource_name, 7); | 14187 CheckTryCatchSourceInfo(script, resource_name, 7); |
14162 } | 14188 } |
14163 | 14189 |
14164 | 14190 |
14165 THREADED_TEST(CompilationCache) { | 14191 THREADED_TEST(CompilationCache) { |
14166 LocalContext context; | 14192 LocalContext context; |
14167 v8::HandleScope scope(context->GetIsolate()); | 14193 v8::HandleScope scope(context->GetIsolate()); |
14168 v8::Handle<v8::String> source0 = | 14194 v8::Handle<v8::String> source0 = |
14169 v8::String::NewFromUtf8(context->GetIsolate(), "1234"); | 14195 v8::String::NewFromUtf8(context->GetIsolate(), "1234"); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
14206 THREADED_TEST(DateAccess) { | 14232 THREADED_TEST(DateAccess) { |
14207 LocalContext context; | 14233 LocalContext context; |
14208 v8::HandleScope scope(context->GetIsolate()); | 14234 v8::HandleScope scope(context->GetIsolate()); |
14209 v8::Handle<v8::Value> date = | 14235 v8::Handle<v8::Value> date = |
14210 v8::Date::New(context->GetIsolate(), 1224744689038.0); | 14236 v8::Date::New(context->GetIsolate(), 1224744689038.0); |
14211 CHECK(date->IsDate()); | 14237 CHECK(date->IsDate()); |
14212 CHECK_EQ(1224744689038.0, date.As<v8::Date>()->ValueOf()); | 14238 CHECK_EQ(1224744689038.0, date.As<v8::Date>()->ValueOf()); |
14213 } | 14239 } |
14214 | 14240 |
14215 | 14241 |
14216 void CheckProperties(v8::Handle<v8::Value> val, int elmc, const char* elmv[]) { | 14242 void CheckProperties(v8::Isolate* isolate, |
| 14243 v8::Handle<v8::Value> val, |
| 14244 int elmc, |
| 14245 const char* elmv[]) { |
14217 v8::Handle<v8::Object> obj = val.As<v8::Object>(); | 14246 v8::Handle<v8::Object> obj = val.As<v8::Object>(); |
14218 v8::Handle<v8::Array> props = obj->GetPropertyNames(); | 14247 v8::Handle<v8::Array> props = obj->GetPropertyNames(); |
14219 CHECK_EQ(elmc, props->Length()); | 14248 CHECK_EQ(elmc, props->Length()); |
14220 for (int i = 0; i < elmc; i++) { | 14249 for (int i = 0; i < elmc; i++) { |
14221 v8::String::Utf8Value elm(props->Get(v8::Integer::New(i))); | 14250 v8::String::Utf8Value elm(props->Get(v8::Integer::New(isolate, i))); |
14222 CHECK_EQ(elmv[i], *elm); | 14251 CHECK_EQ(elmv[i], *elm); |
14223 } | 14252 } |
14224 } | 14253 } |
14225 | 14254 |
14226 | 14255 |
14227 void CheckOwnProperties(v8::Handle<v8::Value> val, | 14256 void CheckOwnProperties(v8::Isolate* isolate, |
| 14257 v8::Handle<v8::Value> val, |
14228 int elmc, | 14258 int elmc, |
14229 const char* elmv[]) { | 14259 const char* elmv[]) { |
14230 v8::Handle<v8::Object> obj = val.As<v8::Object>(); | 14260 v8::Handle<v8::Object> obj = val.As<v8::Object>(); |
14231 v8::Handle<v8::Array> props = obj->GetOwnPropertyNames(); | 14261 v8::Handle<v8::Array> props = obj->GetOwnPropertyNames(); |
14232 CHECK_EQ(elmc, props->Length()); | 14262 CHECK_EQ(elmc, props->Length()); |
14233 for (int i = 0; i < elmc; i++) { | 14263 for (int i = 0; i < elmc; i++) { |
14234 v8::String::Utf8Value elm(props->Get(v8::Integer::New(i))); | 14264 v8::String::Utf8Value elm(props->Get(v8::Integer::New(isolate, i))); |
14235 CHECK_EQ(elmv[i], *elm); | 14265 CHECK_EQ(elmv[i], *elm); |
14236 } | 14266 } |
14237 } | 14267 } |
14238 | 14268 |
14239 | 14269 |
14240 THREADED_TEST(PropertyEnumeration) { | 14270 THREADED_TEST(PropertyEnumeration) { |
14241 LocalContext context; | 14271 LocalContext context; |
14242 v8::HandleScope scope(context->GetIsolate()); | 14272 v8::Isolate* isolate = context->GetIsolate(); |
| 14273 v8::HandleScope scope(isolate); |
14243 v8::Handle<v8::Value> obj = v8::Script::Compile(v8::String::NewFromUtf8( | 14274 v8::Handle<v8::Value> obj = v8::Script::Compile(v8::String::NewFromUtf8( |
14244 context->GetIsolate(), | 14275 context->GetIsolate(), |
14245 "var result = [];" | 14276 "var result = [];" |
14246 "result[0] = {};" | 14277 "result[0] = {};" |
14247 "result[1] = {a: 1, b: 2};" | 14278 "result[1] = {a: 1, b: 2};" |
14248 "result[2] = [1, 2, 3];" | 14279 "result[2] = [1, 2, 3];" |
14249 "var proto = {x: 1, y: 2, z: 3};" | 14280 "var proto = {x: 1, y: 2, z: 3};" |
14250 "var x = { __proto__: proto, w: 0, z: 1 };" | 14281 "var x = { __proto__: proto, w: 0, z: 1 };" |
14251 "result[3] = x;" | 14282 "result[3] = x;" |
14252 "result;"))->Run(); | 14283 "result;"))->Run(); |
14253 v8::Handle<v8::Array> elms = obj.As<v8::Array>(); | 14284 v8::Handle<v8::Array> elms = obj.As<v8::Array>(); |
14254 CHECK_EQ(4, elms->Length()); | 14285 CHECK_EQ(4, elms->Length()); |
14255 int elmc0 = 0; | 14286 int elmc0 = 0; |
14256 const char** elmv0 = NULL; | 14287 const char** elmv0 = NULL; |
14257 CheckProperties(elms->Get(v8::Integer::New(0)), elmc0, elmv0); | 14288 CheckProperties( |
14258 CheckOwnProperties(elms->Get(v8::Integer::New(0)), elmc0, elmv0); | 14289 isolate, elms->Get(v8::Integer::New(isolate, 0)), elmc0, elmv0); |
| 14290 CheckOwnProperties( |
| 14291 isolate, elms->Get(v8::Integer::New(isolate, 0)), elmc0, elmv0); |
14259 int elmc1 = 2; | 14292 int elmc1 = 2; |
14260 const char* elmv1[] = {"a", "b"}; | 14293 const char* elmv1[] = {"a", "b"}; |
14261 CheckProperties(elms->Get(v8::Integer::New(1)), elmc1, elmv1); | 14294 CheckProperties( |
14262 CheckOwnProperties(elms->Get(v8::Integer::New(1)), elmc1, elmv1); | 14295 isolate, elms->Get(v8::Integer::New(isolate, 1)), elmc1, elmv1); |
| 14296 CheckOwnProperties( |
| 14297 isolate, elms->Get(v8::Integer::New(isolate, 1)), elmc1, elmv1); |
14263 int elmc2 = 3; | 14298 int elmc2 = 3; |
14264 const char* elmv2[] = {"0", "1", "2"}; | 14299 const char* elmv2[] = {"0", "1", "2"}; |
14265 CheckProperties(elms->Get(v8::Integer::New(2)), elmc2, elmv2); | 14300 CheckProperties( |
14266 CheckOwnProperties(elms->Get(v8::Integer::New(2)), elmc2, elmv2); | 14301 isolate, elms->Get(v8::Integer::New(isolate, 2)), elmc2, elmv2); |
| 14302 CheckOwnProperties( |
| 14303 isolate, elms->Get(v8::Integer::New(isolate, 2)), elmc2, elmv2); |
14267 int elmc3 = 4; | 14304 int elmc3 = 4; |
14268 const char* elmv3[] = {"w", "z", "x", "y"}; | 14305 const char* elmv3[] = {"w", "z", "x", "y"}; |
14269 CheckProperties(elms->Get(v8::Integer::New(3)), elmc3, elmv3); | 14306 CheckProperties( |
| 14307 isolate, elms->Get(v8::Integer::New(isolate, 3)), elmc3, elmv3); |
14270 int elmc4 = 2; | 14308 int elmc4 = 2; |
14271 const char* elmv4[] = {"w", "z"}; | 14309 const char* elmv4[] = {"w", "z"}; |
14272 CheckOwnProperties(elms->Get(v8::Integer::New(3)), elmc4, elmv4); | 14310 CheckOwnProperties( |
| 14311 isolate, elms->Get(v8::Integer::New(isolate, 3)), elmc4, elmv4); |
14273 } | 14312 } |
14274 | 14313 |
14275 | 14314 |
14276 THREADED_TEST(PropertyEnumeration2) { | 14315 THREADED_TEST(PropertyEnumeration2) { |
14277 LocalContext context; | 14316 LocalContext context; |
14278 v8::HandleScope scope(context->GetIsolate()); | 14317 v8::Isolate* isolate = context->GetIsolate(); |
| 14318 v8::HandleScope scope(isolate); |
14279 v8::Handle<v8::Value> obj = v8::Script::Compile(v8::String::NewFromUtf8( | 14319 v8::Handle<v8::Value> obj = v8::Script::Compile(v8::String::NewFromUtf8( |
14280 context->GetIsolate(), | 14320 context->GetIsolate(), |
14281 "var result = [];" | 14321 "var result = [];" |
14282 "result[0] = {};" | 14322 "result[0] = {};" |
14283 "result[1] = {a: 1, b: 2};" | 14323 "result[1] = {a: 1, b: 2};" |
14284 "result[2] = [1, 2, 3];" | 14324 "result[2] = [1, 2, 3];" |
14285 "var proto = {x: 1, y: 2, z: 3};" | 14325 "var proto = {x: 1, y: 2, z: 3};" |
14286 "var x = { __proto__: proto, w: 0, z: 1 };" | 14326 "var x = { __proto__: proto, w: 0, z: 1 };" |
14287 "result[3] = x;" | 14327 "result[3] = x;" |
14288 "result;"))->Run(); | 14328 "result;"))->Run(); |
14289 v8::Handle<v8::Array> elms = obj.As<v8::Array>(); | 14329 v8::Handle<v8::Array> elms = obj.As<v8::Array>(); |
14290 CHECK_EQ(4, elms->Length()); | 14330 CHECK_EQ(4, elms->Length()); |
14291 int elmc0 = 0; | 14331 int elmc0 = 0; |
14292 const char** elmv0 = NULL; | 14332 const char** elmv0 = NULL; |
14293 CheckProperties(elms->Get(v8::Integer::New(0)), elmc0, elmv0); | 14333 CheckProperties(isolate, |
| 14334 elms->Get(v8::Integer::New(isolate, 0)), elmc0, elmv0); |
14294 | 14335 |
14295 v8::Handle<v8::Value> val = elms->Get(v8::Integer::New(0)); | 14336 v8::Handle<v8::Value> val = elms->Get(v8::Integer::New(isolate, 0)); |
14296 v8::Handle<v8::Array> props = val.As<v8::Object>()->GetPropertyNames(); | 14337 v8::Handle<v8::Array> props = val.As<v8::Object>()->GetPropertyNames(); |
14297 CHECK_EQ(0, props->Length()); | 14338 CHECK_EQ(0, props->Length()); |
14298 for (uint32_t i = 0; i < props->Length(); i++) { | 14339 for (uint32_t i = 0; i < props->Length(); i++) { |
14299 printf("p[%d]\n", i); | 14340 printf("p[%d]\n", i); |
14300 } | 14341 } |
14301 } | 14342 } |
14302 | 14343 |
14303 static bool NamedSetAccessBlocker(Local<v8::Object> obj, | 14344 static bool NamedSetAccessBlocker(Local<v8::Object> obj, |
14304 Local<Value> name, | 14345 Local<Value> name, |
14305 v8::AccessType type, | 14346 v8::AccessType type, |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
14359 // so that the constructor will force copying map. | 14400 // so that the constructor will force copying map. |
14360 // Cannot sprintf, gcc complains unsafety. | 14401 // Cannot sprintf, gcc complains unsafety. |
14361 char buf[4]; | 14402 char buf[4]; |
14362 for (char i = '0'; i <= '9' ; i++) { | 14403 for (char i = '0'; i <= '9' ; i++) { |
14363 buf[0] = i; | 14404 buf[0] = i; |
14364 for (char j = '0'; j <= '9'; j++) { | 14405 for (char j = '0'; j <= '9'; j++) { |
14365 buf[1] = j; | 14406 buf[1] = j; |
14366 for (char k = '0'; k <= '9'; k++) { | 14407 for (char k = '0'; k <= '9'; k++) { |
14367 buf[2] = k; | 14408 buf[2] = k; |
14368 buf[3] = 0; | 14409 buf[3] = 0; |
14369 templ->Set(v8_str(buf), v8::Number::New(k)); | 14410 templ->Set(v8_str(buf), v8::Number::New(context->GetIsolate(), k)); |
14370 } | 14411 } |
14371 } | 14412 } |
14372 } | 14413 } |
14373 | 14414 |
14374 Local<v8::Object> instance_1 = templ->NewInstance(); | 14415 Local<v8::Object> instance_1 = templ->NewInstance(); |
14375 context->Global()->Set(v8_str("obj_1"), instance_1); | 14416 context->Global()->Set(v8_str("obj_1"), instance_1); |
14376 | 14417 |
14377 Local<Value> value_1 = CompileRun("obj_1.a"); | 14418 Local<Value> value_1 = CompileRun("obj_1.a"); |
14378 CHECK(value_1->IsUndefined()); | 14419 CHECK(value_1->IsUndefined()); |
14379 | 14420 |
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
14790 Local<Value> value = CompileRun("var instance = new other.C(); instance.x"); | 14831 Local<Value> value = CompileRun("var instance = new other.C(); instance.x"); |
14791 CHECK(value->IsInt32()); | 14832 CHECK(value->IsInt32()); |
14792 CHECK_EQ(42, value->Int32Value()); | 14833 CHECK_EQ(42, value->Int32Value()); |
14793 context1->Exit(); | 14834 context1->Exit(); |
14794 } | 14835 } |
14795 | 14836 |
14796 | 14837 |
14797 // Verify that we can clone an object | 14838 // Verify that we can clone an object |
14798 TEST(ObjectClone) { | 14839 TEST(ObjectClone) { |
14799 LocalContext env; | 14840 LocalContext env; |
14800 v8::HandleScope scope(env->GetIsolate()); | 14841 v8::Isolate* isolate = env->GetIsolate(); |
| 14842 v8::HandleScope scope(isolate); |
14801 | 14843 |
14802 const char* sample = | 14844 const char* sample = |
14803 "var rv = {};" \ | 14845 "var rv = {};" \ |
14804 "rv.alpha = 'hello';" \ | 14846 "rv.alpha = 'hello';" \ |
14805 "rv.beta = 123;" \ | 14847 "rv.beta = 123;" \ |
14806 "rv;"; | 14848 "rv;"; |
14807 | 14849 |
14808 // Create an object, verify basics. | 14850 // Create an object, verify basics. |
14809 Local<Value> val = CompileRun(sample); | 14851 Local<Value> val = CompileRun(sample); |
14810 CHECK(val->IsObject()); | 14852 CHECK(val->IsObject()); |
14811 Local<v8::Object> obj = val.As<v8::Object>(); | 14853 Local<v8::Object> obj = val.As<v8::Object>(); |
14812 obj->Set(v8_str("gamma"), v8_str("cloneme")); | 14854 obj->Set(v8_str("gamma"), v8_str("cloneme")); |
14813 | 14855 |
14814 CHECK_EQ(v8_str("hello"), obj->Get(v8_str("alpha"))); | 14856 CHECK_EQ(v8_str("hello"), obj->Get(v8_str("alpha"))); |
14815 CHECK_EQ(v8::Integer::New(123), obj->Get(v8_str("beta"))); | 14857 CHECK_EQ(v8::Integer::New(isolate, 123), obj->Get(v8_str("beta"))); |
14816 CHECK_EQ(v8_str("cloneme"), obj->Get(v8_str("gamma"))); | 14858 CHECK_EQ(v8_str("cloneme"), obj->Get(v8_str("gamma"))); |
14817 | 14859 |
14818 // Clone it. | 14860 // Clone it. |
14819 Local<v8::Object> clone = obj->Clone(); | 14861 Local<v8::Object> clone = obj->Clone(); |
14820 CHECK_EQ(v8_str("hello"), clone->Get(v8_str("alpha"))); | 14862 CHECK_EQ(v8_str("hello"), clone->Get(v8_str("alpha"))); |
14821 CHECK_EQ(v8::Integer::New(123), clone->Get(v8_str("beta"))); | 14863 CHECK_EQ(v8::Integer::New(isolate, 123), clone->Get(v8_str("beta"))); |
14822 CHECK_EQ(v8_str("cloneme"), clone->Get(v8_str("gamma"))); | 14864 CHECK_EQ(v8_str("cloneme"), clone->Get(v8_str("gamma"))); |
14823 | 14865 |
14824 // Set a property on the clone, verify each object. | 14866 // Set a property on the clone, verify each object. |
14825 clone->Set(v8_str("beta"), v8::Integer::New(456)); | 14867 clone->Set(v8_str("beta"), v8::Integer::New(isolate, 456)); |
14826 CHECK_EQ(v8::Integer::New(123), obj->Get(v8_str("beta"))); | 14868 CHECK_EQ(v8::Integer::New(isolate, 123), obj->Get(v8_str("beta"))); |
14827 CHECK_EQ(v8::Integer::New(456), clone->Get(v8_str("beta"))); | 14869 CHECK_EQ(v8::Integer::New(isolate, 456), clone->Get(v8_str("beta"))); |
14828 } | 14870 } |
14829 | 14871 |
14830 | 14872 |
14831 class AsciiVectorResource : public v8::String::ExternalAsciiStringResource { | 14873 class AsciiVectorResource : public v8::String::ExternalAsciiStringResource { |
14832 public: | 14874 public: |
14833 explicit AsciiVectorResource(i::Vector<const char> vector) | 14875 explicit AsciiVectorResource(i::Vector<const char> vector) |
14834 : data_(vector) {} | 14876 : data_(vector) {} |
14835 virtual ~AsciiVectorResource() {} | 14877 virtual ~AsciiVectorResource() {} |
14836 virtual size_t length() const { return data_.length(); } | 14878 virtual size_t length() const { return data_.length(); } |
14837 virtual const char* data() const { return data_.start(); } | 14879 virtual const char* data() const { return data_.start(); } |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
15045 regexp_interruption_data.string.Reset(); | 15087 regexp_interruption_data.string.Reset(); |
15046 } | 15088 } |
15047 | 15089 |
15048 #endif // V8_INTERPRETED_REGEXP | 15090 #endif // V8_INTERPRETED_REGEXP |
15049 | 15091 |
15050 | 15092 |
15051 // Test that we cannot set a property on the global object if there | 15093 // Test that we cannot set a property on the global object if there |
15052 // is a read-only property in the prototype chain. | 15094 // is a read-only property in the prototype chain. |
15053 TEST(ReadOnlyPropertyInGlobalProto) { | 15095 TEST(ReadOnlyPropertyInGlobalProto) { |
15054 i::FLAG_es5_readonly = true; | 15096 i::FLAG_es5_readonly = true; |
15055 v8::HandleScope scope(CcTest::isolate()); | 15097 v8::Isolate* isolate = CcTest::isolate(); |
| 15098 v8::HandleScope scope(isolate); |
15056 v8::Handle<v8::ObjectTemplate> templ = v8::ObjectTemplate::New(); | 15099 v8::Handle<v8::ObjectTemplate> templ = v8::ObjectTemplate::New(); |
15057 LocalContext context(0, templ); | 15100 LocalContext context(0, templ); |
15058 v8::Handle<v8::Object> global = context->Global(); | 15101 v8::Handle<v8::Object> global = context->Global(); |
15059 v8::Handle<v8::Object> global_proto = | 15102 v8::Handle<v8::Object> global_proto = |
15060 v8::Handle<v8::Object>::Cast(global->Get(v8_str("__proto__"))); | 15103 v8::Handle<v8::Object>::Cast(global->Get(v8_str("__proto__"))); |
15061 global_proto->Set(v8_str("x"), v8::Integer::New(0), v8::ReadOnly); | 15104 global_proto->Set(v8_str("x"), v8::Integer::New(isolate, 0), v8::ReadOnly); |
15062 global_proto->Set(v8_str("y"), v8::Integer::New(0), v8::ReadOnly); | 15105 global_proto->Set(v8_str("y"), v8::Integer::New(isolate, 0), v8::ReadOnly); |
15063 // Check without 'eval' or 'with'. | 15106 // Check without 'eval' or 'with'. |
15064 v8::Handle<v8::Value> res = | 15107 v8::Handle<v8::Value> res = |
15065 CompileRun("function f() { x = 42; return x; }; f()"); | 15108 CompileRun("function f() { x = 42; return x; }; f()"); |
15066 CHECK_EQ(v8::Integer::New(0), res); | 15109 CHECK_EQ(v8::Integer::New(isolate, 0), res); |
15067 // Check with 'eval'. | 15110 // Check with 'eval'. |
15068 res = CompileRun("function f() { eval('1'); y = 43; return y; }; f()"); | 15111 res = CompileRun("function f() { eval('1'); y = 43; return y; }; f()"); |
15069 CHECK_EQ(v8::Integer::New(0), res); | 15112 CHECK_EQ(v8::Integer::New(isolate, 0), res); |
15070 // Check with 'with'. | 15113 // Check with 'with'. |
15071 res = CompileRun("function f() { with (this) { y = 44 }; return y; }; f()"); | 15114 res = CompileRun("function f() { with (this) { y = 44 }; return y; }; f()"); |
15072 CHECK_EQ(v8::Integer::New(0), res); | 15115 CHECK_EQ(v8::Integer::New(isolate, 0), res); |
15073 } | 15116 } |
15074 | 15117 |
15075 static int force_set_set_count = 0; | 15118 static int force_set_set_count = 0; |
15076 static int force_set_get_count = 0; | 15119 static int force_set_get_count = 0; |
15077 bool pass_on_get = false; | 15120 bool pass_on_get = false; |
15078 | 15121 |
15079 static void ForceSetGetter(v8::Local<v8::String> name, | 15122 static void ForceSetGetter(v8::Local<v8::String> name, |
15080 const v8::PropertyCallbackInfo<v8::Value>& info) { | 15123 const v8::PropertyCallbackInfo<v8::Value>& info) { |
15081 force_set_get_count++; | 15124 force_set_get_count++; |
15082 if (pass_on_get) { | 15125 if (pass_on_get) { |
(...skipping 15 matching lines...) Expand all Loading... |
15098 force_set_set_count++; | 15141 force_set_set_count++; |
15099 info.GetReturnValue().SetUndefined(); | 15142 info.GetReturnValue().SetUndefined(); |
15100 } | 15143 } |
15101 | 15144 |
15102 | 15145 |
15103 TEST(ForceSet) { | 15146 TEST(ForceSet) { |
15104 force_set_get_count = 0; | 15147 force_set_get_count = 0; |
15105 force_set_set_count = 0; | 15148 force_set_set_count = 0; |
15106 pass_on_get = false; | 15149 pass_on_get = false; |
15107 | 15150 |
15108 v8::HandleScope scope(CcTest::isolate()); | 15151 v8::Isolate* isolate = CcTest::isolate(); |
| 15152 v8::HandleScope scope(isolate); |
15109 v8::Handle<v8::ObjectTemplate> templ = v8::ObjectTemplate::New(); | 15153 v8::Handle<v8::ObjectTemplate> templ = v8::ObjectTemplate::New(); |
15110 v8::Handle<v8::String> access_property = | 15154 v8::Handle<v8::String> access_property = |
15111 v8::String::NewFromUtf8(CcTest::isolate(), "a"); | 15155 v8::String::NewFromUtf8(isolate, "a"); |
15112 templ->SetAccessor(access_property, ForceSetGetter, ForceSetSetter); | 15156 templ->SetAccessor(access_property, ForceSetGetter, ForceSetSetter); |
15113 LocalContext context(NULL, templ); | 15157 LocalContext context(NULL, templ); |
15114 v8::Handle<v8::Object> global = context->Global(); | 15158 v8::Handle<v8::Object> global = context->Global(); |
15115 | 15159 |
15116 // Ordinary properties | 15160 // Ordinary properties |
15117 v8::Handle<v8::String> simple_property = | 15161 v8::Handle<v8::String> simple_property = |
15118 v8::String::NewFromUtf8(CcTest::isolate(), "p"); | 15162 v8::String::NewFromUtf8(isolate, "p"); |
15119 global->Set(simple_property, v8::Int32::New(4), v8::ReadOnly); | 15163 global->Set(simple_property, v8::Int32::New(isolate, 4), v8::ReadOnly); |
15120 CHECK_EQ(4, global->Get(simple_property)->Int32Value()); | 15164 CHECK_EQ(4, global->Get(simple_property)->Int32Value()); |
15121 // This should fail because the property is read-only | 15165 // This should fail because the property is read-only |
15122 global->Set(simple_property, v8::Int32::New(5)); | 15166 global->Set(simple_property, v8::Int32::New(isolate, 5)); |
15123 CHECK_EQ(4, global->Get(simple_property)->Int32Value()); | 15167 CHECK_EQ(4, global->Get(simple_property)->Int32Value()); |
15124 // This should succeed even though the property is read-only | 15168 // This should succeed even though the property is read-only |
15125 global->ForceSet(simple_property, v8::Int32::New(6)); | 15169 global->ForceSet(simple_property, v8::Int32::New(isolate, 6)); |
15126 CHECK_EQ(6, global->Get(simple_property)->Int32Value()); | 15170 CHECK_EQ(6, global->Get(simple_property)->Int32Value()); |
15127 | 15171 |
15128 // Accessors | 15172 // Accessors |
15129 CHECK_EQ(0, force_set_set_count); | 15173 CHECK_EQ(0, force_set_set_count); |
15130 CHECK_EQ(0, force_set_get_count); | 15174 CHECK_EQ(0, force_set_get_count); |
15131 CHECK_EQ(3, global->Get(access_property)->Int32Value()); | 15175 CHECK_EQ(3, global->Get(access_property)->Int32Value()); |
15132 // CHECK_EQ the property shouldn't override it, just call the setter | 15176 // CHECK_EQ the property shouldn't override it, just call the setter |
15133 // which in this case does nothing. | 15177 // which in this case does nothing. |
15134 global->Set(access_property, v8::Int32::New(7)); | 15178 global->Set(access_property, v8::Int32::New(isolate, 7)); |
15135 CHECK_EQ(3, global->Get(access_property)->Int32Value()); | 15179 CHECK_EQ(3, global->Get(access_property)->Int32Value()); |
15136 CHECK_EQ(1, force_set_set_count); | 15180 CHECK_EQ(1, force_set_set_count); |
15137 CHECK_EQ(2, force_set_get_count); | 15181 CHECK_EQ(2, force_set_get_count); |
15138 // Forcing the property to be set should override the accessor without | 15182 // Forcing the property to be set should override the accessor without |
15139 // calling it | 15183 // calling it |
15140 global->ForceSet(access_property, v8::Int32::New(8)); | 15184 global->ForceSet(access_property, v8::Int32::New(isolate, 8)); |
15141 CHECK_EQ(8, global->Get(access_property)->Int32Value()); | 15185 CHECK_EQ(8, global->Get(access_property)->Int32Value()); |
15142 CHECK_EQ(1, force_set_set_count); | 15186 CHECK_EQ(1, force_set_set_count); |
15143 CHECK_EQ(2, force_set_get_count); | 15187 CHECK_EQ(2, force_set_get_count); |
15144 } | 15188 } |
15145 | 15189 |
15146 | 15190 |
15147 TEST(ForceSetWithInterceptor) { | 15191 TEST(ForceSetWithInterceptor) { |
15148 force_set_get_count = 0; | 15192 force_set_get_count = 0; |
15149 force_set_set_count = 0; | 15193 force_set_set_count = 0; |
15150 pass_on_get = false; | 15194 pass_on_get = false; |
15151 | 15195 |
15152 v8::HandleScope scope(CcTest::isolate()); | 15196 v8::Isolate* isolate = CcTest::isolate(); |
| 15197 v8::HandleScope scope(isolate); |
15153 v8::Handle<v8::ObjectTemplate> templ = v8::ObjectTemplate::New(); | 15198 v8::Handle<v8::ObjectTemplate> templ = v8::ObjectTemplate::New(); |
15154 templ->SetNamedPropertyHandler(ForceSetGetter, ForceSetInterceptSetter); | 15199 templ->SetNamedPropertyHandler(ForceSetGetter, ForceSetInterceptSetter); |
15155 LocalContext context(NULL, templ); | 15200 LocalContext context(NULL, templ); |
15156 v8::Handle<v8::Object> global = context->Global(); | 15201 v8::Handle<v8::Object> global = context->Global(); |
15157 | 15202 |
15158 v8::Handle<v8::String> some_property = | 15203 v8::Handle<v8::String> some_property = |
15159 v8::String::NewFromUtf8(CcTest::isolate(), "a"); | 15204 v8::String::NewFromUtf8(isolate, "a"); |
15160 CHECK_EQ(0, force_set_set_count); | 15205 CHECK_EQ(0, force_set_set_count); |
15161 CHECK_EQ(0, force_set_get_count); | 15206 CHECK_EQ(0, force_set_get_count); |
15162 CHECK_EQ(3, global->Get(some_property)->Int32Value()); | 15207 CHECK_EQ(3, global->Get(some_property)->Int32Value()); |
15163 // Setting the property shouldn't override it, just call the setter | 15208 // Setting the property shouldn't override it, just call the setter |
15164 // which in this case does nothing. | 15209 // which in this case does nothing. |
15165 global->Set(some_property, v8::Int32::New(7)); | 15210 global->Set(some_property, v8::Int32::New(isolate, 7)); |
15166 CHECK_EQ(3, global->Get(some_property)->Int32Value()); | 15211 CHECK_EQ(3, global->Get(some_property)->Int32Value()); |
15167 CHECK_EQ(1, force_set_set_count); | 15212 CHECK_EQ(1, force_set_set_count); |
15168 CHECK_EQ(2, force_set_get_count); | 15213 CHECK_EQ(2, force_set_get_count); |
15169 // Getting the property when the interceptor returns an empty handle | 15214 // Getting the property when the interceptor returns an empty handle |
15170 // should yield undefined, since the property isn't present on the | 15215 // should yield undefined, since the property isn't present on the |
15171 // object itself yet. | 15216 // object itself yet. |
15172 pass_on_get = true; | 15217 pass_on_get = true; |
15173 CHECK(global->Get(some_property)->IsUndefined()); | 15218 CHECK(global->Get(some_property)->IsUndefined()); |
15174 CHECK_EQ(1, force_set_set_count); | 15219 CHECK_EQ(1, force_set_set_count); |
15175 CHECK_EQ(3, force_set_get_count); | 15220 CHECK_EQ(3, force_set_get_count); |
15176 // Forcing the property to be set should cause the value to be | 15221 // Forcing the property to be set should cause the value to be |
15177 // set locally without calling the interceptor. | 15222 // set locally without calling the interceptor. |
15178 global->ForceSet(some_property, v8::Int32::New(8)); | 15223 global->ForceSet(some_property, v8::Int32::New(isolate, 8)); |
15179 CHECK_EQ(8, global->Get(some_property)->Int32Value()); | 15224 CHECK_EQ(8, global->Get(some_property)->Int32Value()); |
15180 CHECK_EQ(1, force_set_set_count); | 15225 CHECK_EQ(1, force_set_set_count); |
15181 CHECK_EQ(4, force_set_get_count); | 15226 CHECK_EQ(4, force_set_get_count); |
15182 // Reenabling the interceptor should cause it to take precedence over | 15227 // Reenabling the interceptor should cause it to take precedence over |
15183 // the property | 15228 // the property |
15184 pass_on_get = false; | 15229 pass_on_get = false; |
15185 CHECK_EQ(3, global->Get(some_property)->Int32Value()); | 15230 CHECK_EQ(3, global->Get(some_property)->Int32Value()); |
15186 CHECK_EQ(1, force_set_set_count); | 15231 CHECK_EQ(1, force_set_set_count); |
15187 CHECK_EQ(5, force_set_get_count); | 15232 CHECK_EQ(5, force_set_get_count); |
15188 // The interceptor should also work for other properties | 15233 // The interceptor should also work for other properties |
15189 CHECK_EQ(3, global->Get(v8::String::NewFromUtf8(CcTest::isolate(), "b")) | 15234 CHECK_EQ(3, global->Get(v8::String::NewFromUtf8(isolate, "b")) |
15190 ->Int32Value()); | 15235 ->Int32Value()); |
15191 CHECK_EQ(1, force_set_set_count); | 15236 CHECK_EQ(1, force_set_set_count); |
15192 CHECK_EQ(6, force_set_get_count); | 15237 CHECK_EQ(6, force_set_get_count); |
15193 } | 15238 } |
15194 | 15239 |
15195 | 15240 |
15196 THREADED_TEST(ForceDelete) { | 15241 THREADED_TEST(ForceDelete) { |
15197 v8::HandleScope scope(CcTest::isolate()); | 15242 v8::Isolate* isolate = CcTest::isolate(); |
| 15243 v8::HandleScope scope(isolate); |
15198 v8::Handle<v8::ObjectTemplate> templ = v8::ObjectTemplate::New(); | 15244 v8::Handle<v8::ObjectTemplate> templ = v8::ObjectTemplate::New(); |
15199 LocalContext context(NULL, templ); | 15245 LocalContext context(NULL, templ); |
15200 v8::Handle<v8::Object> global = context->Global(); | 15246 v8::Handle<v8::Object> global = context->Global(); |
15201 | 15247 |
15202 // Ordinary properties | 15248 // Ordinary properties |
15203 v8::Handle<v8::String> simple_property = | 15249 v8::Handle<v8::String> simple_property = |
15204 v8::String::NewFromUtf8(CcTest::isolate(), "p"); | 15250 v8::String::NewFromUtf8(isolate, "p"); |
15205 global->Set(simple_property, v8::Int32::New(4), v8::DontDelete); | 15251 global->Set(simple_property, v8::Int32::New(isolate, 4), v8::DontDelete); |
15206 CHECK_EQ(4, global->Get(simple_property)->Int32Value()); | 15252 CHECK_EQ(4, global->Get(simple_property)->Int32Value()); |
15207 // This should fail because the property is dont-delete. | 15253 // This should fail because the property is dont-delete. |
15208 CHECK(!global->Delete(simple_property)); | 15254 CHECK(!global->Delete(simple_property)); |
15209 CHECK_EQ(4, global->Get(simple_property)->Int32Value()); | 15255 CHECK_EQ(4, global->Get(simple_property)->Int32Value()); |
15210 // This should succeed even though the property is dont-delete. | 15256 // This should succeed even though the property is dont-delete. |
15211 CHECK(global->ForceDelete(simple_property)); | 15257 CHECK(global->ForceDelete(simple_property)); |
15212 CHECK(global->Get(simple_property)->IsUndefined()); | 15258 CHECK(global->Get(simple_property)->IsUndefined()); |
15213 } | 15259 } |
15214 | 15260 |
15215 | 15261 |
15216 static int force_delete_interceptor_count = 0; | 15262 static int force_delete_interceptor_count = 0; |
15217 static bool pass_on_delete = false; | 15263 static bool pass_on_delete = false; |
15218 | 15264 |
15219 | 15265 |
15220 static void ForceDeleteDeleter( | 15266 static void ForceDeleteDeleter( |
15221 v8::Local<v8::String> name, | 15267 v8::Local<v8::String> name, |
15222 const v8::PropertyCallbackInfo<v8::Boolean>& info) { | 15268 const v8::PropertyCallbackInfo<v8::Boolean>& info) { |
15223 force_delete_interceptor_count++; | 15269 force_delete_interceptor_count++; |
15224 if (pass_on_delete) return; | 15270 if (pass_on_delete) return; |
15225 info.GetReturnValue().Set(true); | 15271 info.GetReturnValue().Set(true); |
15226 } | 15272 } |
15227 | 15273 |
15228 | 15274 |
15229 THREADED_TEST(ForceDeleteWithInterceptor) { | 15275 THREADED_TEST(ForceDeleteWithInterceptor) { |
15230 force_delete_interceptor_count = 0; | 15276 force_delete_interceptor_count = 0; |
15231 pass_on_delete = false; | 15277 pass_on_delete = false; |
15232 | 15278 |
15233 v8::HandleScope scope(CcTest::isolate()); | 15279 v8::Isolate* isolate = CcTest::isolate(); |
| 15280 v8::HandleScope scope(isolate); |
15234 v8::Handle<v8::ObjectTemplate> templ = v8::ObjectTemplate::New(); | 15281 v8::Handle<v8::ObjectTemplate> templ = v8::ObjectTemplate::New(); |
15235 templ->SetNamedPropertyHandler(0, 0, 0, ForceDeleteDeleter); | 15282 templ->SetNamedPropertyHandler(0, 0, 0, ForceDeleteDeleter); |
15236 LocalContext context(NULL, templ); | 15283 LocalContext context(NULL, templ); |
15237 v8::Handle<v8::Object> global = context->Global(); | 15284 v8::Handle<v8::Object> global = context->Global(); |
15238 | 15285 |
15239 v8::Handle<v8::String> some_property = | 15286 v8::Handle<v8::String> some_property = |
15240 v8::String::NewFromUtf8(CcTest::isolate(), "a"); | 15287 v8::String::NewFromUtf8(isolate, "a"); |
15241 global->Set(some_property, v8::Integer::New(42), v8::DontDelete); | 15288 global->Set(some_property, v8::Integer::New(isolate, 42), v8::DontDelete); |
15242 | 15289 |
15243 // Deleting a property should get intercepted and nothing should | 15290 // Deleting a property should get intercepted and nothing should |
15244 // happen. | 15291 // happen. |
15245 CHECK_EQ(0, force_delete_interceptor_count); | 15292 CHECK_EQ(0, force_delete_interceptor_count); |
15246 CHECK(global->Delete(some_property)); | 15293 CHECK(global->Delete(some_property)); |
15247 CHECK_EQ(1, force_delete_interceptor_count); | 15294 CHECK_EQ(1, force_delete_interceptor_count); |
15248 CHECK_EQ(42, global->Get(some_property)->Int32Value()); | 15295 CHECK_EQ(42, global->Get(some_property)->Int32Value()); |
15249 // Deleting the property when the interceptor returns an empty | 15296 // Deleting the property when the interceptor returns an empty |
15250 // handle should not delete the property since it is DontDelete. | 15297 // handle should not delete the property since it is DontDelete. |
15251 pass_on_delete = true; | 15298 pass_on_delete = true; |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
15414 | 15461 |
15415 // Regression test for issue 398. | 15462 // Regression test for issue 398. |
15416 // If a function is added to an object, creating a constant function | 15463 // If a function is added to an object, creating a constant function |
15417 // field, and the result is cloned, replacing the constant function on the | 15464 // field, and the result is cloned, replacing the constant function on the |
15418 // original should not affect the clone. | 15465 // original should not affect the clone. |
15419 // See http://code.google.com/p/v8/issues/detail?id=398 | 15466 // See http://code.google.com/p/v8/issues/detail?id=398 |
15420 THREADED_TEST(ReplaceConstantFunction) { | 15467 THREADED_TEST(ReplaceConstantFunction) { |
15421 LocalContext context; | 15468 LocalContext context; |
15422 v8::Isolate* isolate = context->GetIsolate(); | 15469 v8::Isolate* isolate = context->GetIsolate(); |
15423 v8::HandleScope scope(isolate); | 15470 v8::HandleScope scope(isolate); |
15424 v8::Handle<v8::Object> obj = v8::Object::New(); | 15471 v8::Handle<v8::Object> obj = v8::Object::New(isolate); |
15425 v8::Handle<v8::FunctionTemplate> func_templ = | 15472 v8::Handle<v8::FunctionTemplate> func_templ = |
15426 v8::FunctionTemplate::New(isolate); | 15473 v8::FunctionTemplate::New(isolate); |
15427 v8::Handle<v8::String> foo_string = | 15474 v8::Handle<v8::String> foo_string = |
15428 v8::String::NewFromUtf8(isolate, "foo"); | 15475 v8::String::NewFromUtf8(isolate, "foo"); |
15429 obj->Set(foo_string, func_templ->GetFunction()); | 15476 obj->Set(foo_string, func_templ->GetFunction()); |
15430 v8::Handle<v8::Object> obj_clone = obj->Clone(); | 15477 v8::Handle<v8::Object> obj_clone = obj->Clone(); |
15431 obj_clone->Set(foo_string, | 15478 obj_clone->Set(foo_string, |
15432 v8::String::NewFromUtf8(isolate, "Hello")); | 15479 v8::String::NewFromUtf8(isolate, "Hello")); |
15433 CHECK(!obj->Get(foo_string)->IsUndefined()); | 15480 CHECK(!obj->Get(foo_string)->IsUndefined()); |
15434 } | 15481 } |
(...skipping 25 matching lines...) Expand all Loading... |
15460 for (int i = 0; i < kElementCount; i++) { | 15507 for (int i = 0; i < kElementCount; i++) { |
15461 pixels->set(i, i % 256); | 15508 pixels->set(i, i % 256); |
15462 } | 15509 } |
15463 // Force GC to trigger verification. | 15510 // Force GC to trigger verification. |
15464 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); | 15511 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); |
15465 for (int i = 0; i < kElementCount; i++) { | 15512 for (int i = 0; i < kElementCount; i++) { |
15466 CHECK_EQ(i % 256, pixels->get_scalar(i)); | 15513 CHECK_EQ(i % 256, pixels->get_scalar(i)); |
15467 CHECK_EQ(i % 256, pixel_data[i]); | 15514 CHECK_EQ(i % 256, pixel_data[i]); |
15468 } | 15515 } |
15469 | 15516 |
15470 v8::Handle<v8::Object> obj = v8::Object::New(); | 15517 v8::Handle<v8::Object> obj = v8::Object::New(context->GetIsolate()); |
15471 i::Handle<i::JSObject> jsobj = v8::Utils::OpenHandle(*obj); | 15518 i::Handle<i::JSObject> jsobj = v8::Utils::OpenHandle(*obj); |
15472 // Set the elements to be the pixels. | 15519 // Set the elements to be the pixels. |
15473 // jsobj->set_elements(*pixels); | 15520 // jsobj->set_elements(*pixels); |
15474 obj->SetIndexedPropertiesToPixelData(pixel_data, kElementCount); | 15521 obj->SetIndexedPropertiesToPixelData(pixel_data, kElementCount); |
15475 CheckElementValue(isolate, 1, jsobj, 1); | 15522 CheckElementValue(isolate, 1, jsobj, 1); |
15476 obj->Set(v8_str("field"), v8::Int32::New(1503)); | 15523 obj->Set(v8_str("field"), v8::Int32::New(CcTest::isolate(), 1503)); |
15477 context->Global()->Set(v8_str("pixels"), obj); | 15524 context->Global()->Set(v8_str("pixels"), obj); |
15478 v8::Handle<v8::Value> result = CompileRun("pixels.field"); | 15525 v8::Handle<v8::Value> result = CompileRun("pixels.field"); |
15479 CHECK_EQ(1503, result->Int32Value()); | 15526 CHECK_EQ(1503, result->Int32Value()); |
15480 result = CompileRun("pixels[1]"); | 15527 result = CompileRun("pixels[1]"); |
15481 CHECK_EQ(1, result->Int32Value()); | 15528 CHECK_EQ(1, result->Int32Value()); |
15482 | 15529 |
15483 result = CompileRun("var sum = 0;" | 15530 result = CompileRun("var sum = 0;" |
15484 "for (var i = 0; i < 8; i++) {" | 15531 "for (var i = 0; i < 8; i++) {" |
15485 " sum += pixels[i] = pixels[i] = -i;" | 15532 " sum += pixels[i] = pixels[i] = -i;" |
15486 "}" | 15533 "}" |
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
15825 | 15872 |
15826 free(pixel_data); | 15873 free(pixel_data); |
15827 } | 15874 } |
15828 | 15875 |
15829 | 15876 |
15830 THREADED_TEST(PixelArrayInfo) { | 15877 THREADED_TEST(PixelArrayInfo) { |
15831 LocalContext context; | 15878 LocalContext context; |
15832 v8::HandleScope scope(context->GetIsolate()); | 15879 v8::HandleScope scope(context->GetIsolate()); |
15833 for (int size = 0; size < 100; size += 10) { | 15880 for (int size = 0; size < 100; size += 10) { |
15834 uint8_t* pixel_data = reinterpret_cast<uint8_t*>(malloc(size)); | 15881 uint8_t* pixel_data = reinterpret_cast<uint8_t*>(malloc(size)); |
15835 v8::Handle<v8::Object> obj = v8::Object::New(); | 15882 v8::Handle<v8::Object> obj = v8::Object::New(context->GetIsolate()); |
15836 obj->SetIndexedPropertiesToPixelData(pixel_data, size); | 15883 obj->SetIndexedPropertiesToPixelData(pixel_data, size); |
15837 CHECK(obj->HasIndexedPropertiesInPixelData()); | 15884 CHECK(obj->HasIndexedPropertiesInPixelData()); |
15838 CHECK_EQ(pixel_data, obj->GetIndexedPropertiesPixelData()); | 15885 CHECK_EQ(pixel_data, obj->GetIndexedPropertiesPixelData()); |
15839 CHECK_EQ(size, obj->GetIndexedPropertiesPixelDataLength()); | 15886 CHECK_EQ(size, obj->GetIndexedPropertiesPixelDataLength()); |
15840 free(pixel_data); | 15887 free(pixel_data); |
15841 } | 15888 } |
15842 } | 15889 } |
15843 | 15890 |
15844 | 15891 |
15845 static void NotHandledIndexedPropertyGetter( | 15892 static void NotHandledIndexedPropertyGetter( |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
15921 | 15968 |
15922 template <class ExternalArrayClass, class ElementType> | 15969 template <class ExternalArrayClass, class ElementType> |
15923 static void ObjectWithExternalArrayTestHelper( | 15970 static void ObjectWithExternalArrayTestHelper( |
15924 Handle<Context> context, | 15971 Handle<Context> context, |
15925 v8::Handle<Object> obj, | 15972 v8::Handle<Object> obj, |
15926 int element_count, | 15973 int element_count, |
15927 v8::ExternalArrayType array_type, | 15974 v8::ExternalArrayType array_type, |
15928 int64_t low, int64_t high) { | 15975 int64_t low, int64_t high) { |
15929 i::Handle<i::JSObject> jsobj = v8::Utils::OpenHandle(*obj); | 15976 i::Handle<i::JSObject> jsobj = v8::Utils::OpenHandle(*obj); |
15930 i::Isolate* isolate = jsobj->GetIsolate(); | 15977 i::Isolate* isolate = jsobj->GetIsolate(); |
15931 obj->Set(v8_str("field"), v8::Int32::New(1503)); | 15978 obj->Set(v8_str("field"), |
| 15979 v8::Int32::New(reinterpret_cast<v8::Isolate*>(isolate), 1503)); |
15932 context->Global()->Set(v8_str("ext_array"), obj); | 15980 context->Global()->Set(v8_str("ext_array"), obj); |
15933 v8::Handle<v8::Value> result = CompileRun("ext_array.field"); | 15981 v8::Handle<v8::Value> result = CompileRun("ext_array.field"); |
15934 CHECK_EQ(1503, result->Int32Value()); | 15982 CHECK_EQ(1503, result->Int32Value()); |
15935 result = CompileRun("ext_array[1]"); | 15983 result = CompileRun("ext_array[1]"); |
15936 CHECK_EQ(1, result->Int32Value()); | 15984 CHECK_EQ(1, result->Int32Value()); |
15937 | 15985 |
15938 // Check pass through of assigned smis | 15986 // Check pass through of assigned smis |
15939 result = CompileRun("var sum = 0;" | 15987 result = CompileRun("var sum = 0;" |
15940 "for (var i = 0; i < 8; i++) {" | 15988 "for (var i = 0; i < 8; i++) {" |
15941 " sum += ext_array[i] = ext_array[i] = -i;" | 15989 " sum += ext_array[i] = ext_array[i] = -i;" |
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
16241 array->set(i, static_cast<ElementType>(i)); | 16289 array->set(i, static_cast<ElementType>(i)); |
16242 } | 16290 } |
16243 // Force GC to trigger verification. | 16291 // Force GC to trigger verification. |
16244 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); | 16292 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); |
16245 for (int i = 0; i < kElementCount; i++) { | 16293 for (int i = 0; i < kElementCount; i++) { |
16246 CHECK_EQ(static_cast<int64_t>(i), | 16294 CHECK_EQ(static_cast<int64_t>(i), |
16247 static_cast<int64_t>(array->get_scalar(i))); | 16295 static_cast<int64_t>(array->get_scalar(i))); |
16248 CHECK_EQ(static_cast<int64_t>(i), static_cast<int64_t>(array_data[i])); | 16296 CHECK_EQ(static_cast<int64_t>(i), static_cast<int64_t>(array_data[i])); |
16249 } | 16297 } |
16250 | 16298 |
16251 v8::Handle<v8::Object> obj = v8::Object::New(); | 16299 v8::Handle<v8::Object> obj = v8::Object::New(context->GetIsolate()); |
16252 i::Handle<i::JSObject> jsobj = v8::Utils::OpenHandle(*obj); | 16300 i::Handle<i::JSObject> jsobj = v8::Utils::OpenHandle(*obj); |
16253 // Set the elements to be the external array. | 16301 // Set the elements to be the external array. |
16254 obj->SetIndexedPropertiesToExternalArrayData(array_data, | 16302 obj->SetIndexedPropertiesToExternalArrayData(array_data, |
16255 array_type, | 16303 array_type, |
16256 kElementCount); | 16304 kElementCount); |
16257 CHECK_EQ(1, | 16305 CHECK_EQ(1, |
16258 static_cast<int>( | 16306 static_cast<int>( |
16259 jsobj->GetElement(isolate, 1)->ToObjectChecked()->Number())); | 16307 jsobj->GetElement(isolate, 1)->ToObjectChecked()->Number())); |
16260 | 16308 |
16261 ObjectWithExternalArrayTestHelper<ExternalArrayClass, ElementType>( | 16309 ObjectWithExternalArrayTestHelper<ExternalArrayClass, ElementType>( |
16262 context.local(), obj, kElementCount, array_type, low, high); | 16310 context.local(), obj, kElementCount, array_type, low, high); |
16263 | 16311 |
16264 v8::Handle<v8::Value> result; | 16312 v8::Handle<v8::Value> result; |
16265 | 16313 |
16266 // Test more complex manipulations which cause eax to contain values | 16314 // Test more complex manipulations which cause eax to contain values |
16267 // that won't be completely overwritten by loads from the arrays. | 16315 // that won't be completely overwritten by loads from the arrays. |
16268 // This catches bugs in the instructions used for the KeyedLoadIC | 16316 // This catches bugs in the instructions used for the KeyedLoadIC |
16269 // for byte and word types. | 16317 // for byte and word types. |
16270 { | 16318 { |
16271 const int kXSize = 300; | 16319 const int kXSize = 300; |
16272 const int kYSize = 300; | 16320 const int kYSize = 300; |
16273 const int kLargeElementCount = kXSize * kYSize * 4; | 16321 const int kLargeElementCount = kXSize * kYSize * 4; |
16274 ElementType* large_array_data = | 16322 ElementType* large_array_data = |
16275 static_cast<ElementType*>(malloc(kLargeElementCount * element_size)); | 16323 static_cast<ElementType*>(malloc(kLargeElementCount * element_size)); |
16276 v8::Handle<v8::Object> large_obj = v8::Object::New(); | 16324 v8::Handle<v8::Object> large_obj = v8::Object::New(context->GetIsolate()); |
16277 // Set the elements to be the external array. | 16325 // Set the elements to be the external array. |
16278 large_obj->SetIndexedPropertiesToExternalArrayData(large_array_data, | 16326 large_obj->SetIndexedPropertiesToExternalArrayData(large_array_data, |
16279 array_type, | 16327 array_type, |
16280 kLargeElementCount); | 16328 kLargeElementCount); |
16281 context->Global()->Set(v8_str("large_array"), large_obj); | 16329 context->Global()->Set(v8_str("large_array"), large_obj); |
16282 // Initialize contents of a few rows. | 16330 // Initialize contents of a few rows. |
16283 for (int x = 0; x < 300; x++) { | 16331 for (int x = 0; x < 300; x++) { |
16284 int row = 0; | 16332 int row = 0; |
16285 int offset = row * 300 * 4; | 16333 int offset = row * 300 * 4; |
16286 large_array_data[offset + 4 * x + 0] = (ElementType) 127; | 16334 large_array_data[offset + 4 * x + 0] = (ElementType) 127; |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
16339 | 16387 |
16340 // The "" property descriptor is overloaded to store information about | 16388 // The "" property descriptor is overloaded to store information about |
16341 // the external array. Ensure that setting and accessing the "" property | 16389 // the external array. Ensure that setting and accessing the "" property |
16342 // works (it should overwrite the information cached about the external | 16390 // works (it should overwrite the information cached about the external |
16343 // array in the DescriptorArray) in various situations. | 16391 // array in the DescriptorArray) in various situations. |
16344 result = CompileRun("ext_array[''] = 23; ext_array['']"); | 16392 result = CompileRun("ext_array[''] = 23; ext_array['']"); |
16345 CHECK_EQ(23, result->Int32Value()); | 16393 CHECK_EQ(23, result->Int32Value()); |
16346 | 16394 |
16347 // Property "" set after the external array is associated with the object. | 16395 // Property "" set after the external array is associated with the object. |
16348 { | 16396 { |
16349 v8::Handle<v8::Object> obj2 = v8::Object::New(); | 16397 v8::Handle<v8::Object> obj2 = v8::Object::New(context->GetIsolate()); |
16350 obj2->Set(v8_str("ee_test_field"), v8::Int32::New(256)); | 16398 obj2->Set(v8_str("ee_test_field"), |
16351 obj2->Set(v8_str(""), v8::Int32::New(1503)); | 16399 v8::Int32::New(context->GetIsolate(), 256)); |
| 16400 obj2->Set(v8_str(""), v8::Int32::New(context->GetIsolate(), 1503)); |
16352 // Set the elements to be the external array. | 16401 // Set the elements to be the external array. |
16353 obj2->SetIndexedPropertiesToExternalArrayData(array_data, | 16402 obj2->SetIndexedPropertiesToExternalArrayData(array_data, |
16354 array_type, | 16403 array_type, |
16355 kElementCount); | 16404 kElementCount); |
16356 context->Global()->Set(v8_str("ext_array"), obj2); | 16405 context->Global()->Set(v8_str("ext_array"), obj2); |
16357 result = CompileRun("ext_array['']"); | 16406 result = CompileRun("ext_array['']"); |
16358 CHECK_EQ(1503, result->Int32Value()); | 16407 CHECK_EQ(1503, result->Int32Value()); |
16359 } | 16408 } |
16360 | 16409 |
16361 // Property "" set after the external array is associated with the object. | 16410 // Property "" set after the external array is associated with the object. |
16362 { | 16411 { |
16363 v8::Handle<v8::Object> obj2 = v8::Object::New(); | 16412 v8::Handle<v8::Object> obj2 = v8::Object::New(context->GetIsolate()); |
16364 obj2->Set(v8_str("ee_test_field_2"), v8::Int32::New(256)); | 16413 obj2->Set(v8_str("ee_test_field_2"), |
| 16414 v8::Int32::New(context->GetIsolate(), 256)); |
16365 // Set the elements to be the external array. | 16415 // Set the elements to be the external array. |
16366 obj2->SetIndexedPropertiesToExternalArrayData(array_data, | 16416 obj2->SetIndexedPropertiesToExternalArrayData(array_data, |
16367 array_type, | 16417 array_type, |
16368 kElementCount); | 16418 kElementCount); |
16369 obj2->Set(v8_str(""), v8::Int32::New(1503)); | 16419 obj2->Set(v8_str(""), v8::Int32::New(context->GetIsolate(), 1503)); |
16370 context->Global()->Set(v8_str("ext_array"), obj2); | 16420 context->Global()->Set(v8_str("ext_array"), obj2); |
16371 result = CompileRun("ext_array['']"); | 16421 result = CompileRun("ext_array['']"); |
16372 CHECK_EQ(1503, result->Int32Value()); | 16422 CHECK_EQ(1503, result->Int32Value()); |
16373 } | 16423 } |
16374 | 16424 |
16375 // Should reuse the map from previous test. | 16425 // Should reuse the map from previous test. |
16376 { | 16426 { |
16377 v8::Handle<v8::Object> obj2 = v8::Object::New(); | 16427 v8::Handle<v8::Object> obj2 = v8::Object::New(context->GetIsolate()); |
16378 obj2->Set(v8_str("ee_test_field_2"), v8::Int32::New(256)); | 16428 obj2->Set(v8_str("ee_test_field_2"), |
| 16429 v8::Int32::New(context->GetIsolate(), 256)); |
16379 // Set the elements to be the external array. Should re-use the map | 16430 // Set the elements to be the external array. Should re-use the map |
16380 // from previous test. | 16431 // from previous test. |
16381 obj2->SetIndexedPropertiesToExternalArrayData(array_data, | 16432 obj2->SetIndexedPropertiesToExternalArrayData(array_data, |
16382 array_type, | 16433 array_type, |
16383 kElementCount); | 16434 kElementCount); |
16384 context->Global()->Set(v8_str("ext_array"), obj2); | 16435 context->Global()->Set(v8_str("ext_array"), obj2); |
16385 result = CompileRun("ext_array['']"); | 16436 result = CompileRun("ext_array['']"); |
16386 } | 16437 } |
16387 | 16438 |
16388 // Property "" is a constant function that shouldn't not be interfered with | 16439 // Property "" is a constant function that shouldn't not be interfered with |
16389 // when an external array is set. | 16440 // when an external array is set. |
16390 { | 16441 { |
16391 v8::Handle<v8::Object> obj2 = v8::Object::New(); | 16442 v8::Handle<v8::Object> obj2 = v8::Object::New(context->GetIsolate()); |
16392 // Start | 16443 // Start |
16393 obj2->Set(v8_str("ee_test_field3"), v8::Int32::New(256)); | 16444 obj2->Set(v8_str("ee_test_field3"), |
| 16445 v8::Int32::New(context->GetIsolate(), 256)); |
16394 | 16446 |
16395 // Add a constant function to an object. | 16447 // Add a constant function to an object. |
16396 context->Global()->Set(v8_str("ext_array"), obj2); | 16448 context->Global()->Set(v8_str("ext_array"), obj2); |
16397 result = CompileRun("ext_array[''] = function() {return 1503;};" | 16449 result = CompileRun("ext_array[''] = function() {return 1503;};" |
16398 "ext_array['']();"); | 16450 "ext_array['']();"); |
16399 | 16451 |
16400 // Add an external array transition to the same map that | 16452 // Add an external array transition to the same map that |
16401 // has the constant transition. | 16453 // has the constant transition. |
16402 v8::Handle<v8::Object> obj3 = v8::Object::New(); | 16454 v8::Handle<v8::Object> obj3 = v8::Object::New(context->GetIsolate()); |
16403 obj3->Set(v8_str("ee_test_field3"), v8::Int32::New(256)); | 16455 obj3->Set(v8_str("ee_test_field3"), |
| 16456 v8::Int32::New(context->GetIsolate(), 256)); |
16404 obj3->SetIndexedPropertiesToExternalArrayData(array_data, | 16457 obj3->SetIndexedPropertiesToExternalArrayData(array_data, |
16405 array_type, | 16458 array_type, |
16406 kElementCount); | 16459 kElementCount); |
16407 context->Global()->Set(v8_str("ext_array"), obj3); | 16460 context->Global()->Set(v8_str("ext_array"), obj3); |
16408 } | 16461 } |
16409 | 16462 |
16410 // If a external array transition is in the map, it should get clobbered | 16463 // If a external array transition is in the map, it should get clobbered |
16411 // by a constant function. | 16464 // by a constant function. |
16412 { | 16465 { |
16413 // Add an external array transition. | 16466 // Add an external array transition. |
16414 v8::Handle<v8::Object> obj3 = v8::Object::New(); | 16467 v8::Handle<v8::Object> obj3 = v8::Object::New(context->GetIsolate()); |
16415 obj3->Set(v8_str("ee_test_field4"), v8::Int32::New(256)); | 16468 obj3->Set(v8_str("ee_test_field4"), |
| 16469 v8::Int32::New(context->GetIsolate(), 256)); |
16416 obj3->SetIndexedPropertiesToExternalArrayData(array_data, | 16470 obj3->SetIndexedPropertiesToExternalArrayData(array_data, |
16417 array_type, | 16471 array_type, |
16418 kElementCount); | 16472 kElementCount); |
16419 | 16473 |
16420 // Add a constant function to the same map that just got an external array | 16474 // Add a constant function to the same map that just got an external array |
16421 // transition. | 16475 // transition. |
16422 v8::Handle<v8::Object> obj2 = v8::Object::New(); | 16476 v8::Handle<v8::Object> obj2 = v8::Object::New(context->GetIsolate()); |
16423 obj2->Set(v8_str("ee_test_field4"), v8::Int32::New(256)); | 16477 obj2->Set(v8_str("ee_test_field4"), |
| 16478 v8::Int32::New(context->GetIsolate(), 256)); |
16424 context->Global()->Set(v8_str("ext_array"), obj2); | 16479 context->Global()->Set(v8_str("ext_array"), obj2); |
16425 result = CompileRun("ext_array[''] = function() {return 1503;};" | 16480 result = CompileRun("ext_array[''] = function() {return 1503;};" |
16426 "ext_array['']();"); | 16481 "ext_array['']();"); |
16427 } | 16482 } |
16428 | 16483 |
16429 free(array_data); | 16484 free(array_data); |
16430 } | 16485 } |
16431 | 16486 |
16432 | 16487 |
16433 THREADED_TEST(ExternalByteArray) { | 16488 THREADED_TEST(ExternalByteArray) { |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
16512 TestExternalFloatArray(); | 16567 TestExternalFloatArray(); |
16513 } | 16568 } |
16514 | 16569 |
16515 | 16570 |
16516 void ExternalArrayInfoTestHelper(v8::ExternalArrayType array_type) { | 16571 void ExternalArrayInfoTestHelper(v8::ExternalArrayType array_type) { |
16517 LocalContext context; | 16572 LocalContext context; |
16518 v8::HandleScope scope(context->GetIsolate()); | 16573 v8::HandleScope scope(context->GetIsolate()); |
16519 for (int size = 0; size < 100; size += 10) { | 16574 for (int size = 0; size < 100; size += 10) { |
16520 int element_size = ExternalArrayElementSize(array_type); | 16575 int element_size = ExternalArrayElementSize(array_type); |
16521 void* external_data = malloc(size * element_size); | 16576 void* external_data = malloc(size * element_size); |
16522 v8::Handle<v8::Object> obj = v8::Object::New(); | 16577 v8::Handle<v8::Object> obj = v8::Object::New(context->GetIsolate()); |
16523 obj->SetIndexedPropertiesToExternalArrayData( | 16578 obj->SetIndexedPropertiesToExternalArrayData( |
16524 external_data, array_type, size); | 16579 external_data, array_type, size); |
16525 CHECK(obj->HasIndexedPropertiesInExternalArrayData()); | 16580 CHECK(obj->HasIndexedPropertiesInExternalArrayData()); |
16526 CHECK_EQ(external_data, obj->GetIndexedPropertiesExternalArrayData()); | 16581 CHECK_EQ(external_data, obj->GetIndexedPropertiesExternalArrayData()); |
16527 CHECK_EQ(array_type, obj->GetIndexedPropertiesExternalArrayDataType()); | 16582 CHECK_EQ(array_type, obj->GetIndexedPropertiesExternalArrayDataType()); |
16528 CHECK_EQ(size, obj->GetIndexedPropertiesExternalArrayDataLength()); | 16583 CHECK_EQ(size, obj->GetIndexedPropertiesExternalArrayDataLength()); |
16529 free(external_data); | 16584 free(external_data); |
16530 } | 16585 } |
16531 } | 16586 } |
16532 | 16587 |
16533 | 16588 |
16534 THREADED_TEST(ExternalArrayInfo) { | 16589 THREADED_TEST(ExternalArrayInfo) { |
16535 ExternalArrayInfoTestHelper(v8::kExternalByteArray); | 16590 ExternalArrayInfoTestHelper(v8::kExternalByteArray); |
16536 ExternalArrayInfoTestHelper(v8::kExternalUnsignedByteArray); | 16591 ExternalArrayInfoTestHelper(v8::kExternalUnsignedByteArray); |
16537 ExternalArrayInfoTestHelper(v8::kExternalShortArray); | 16592 ExternalArrayInfoTestHelper(v8::kExternalShortArray); |
16538 ExternalArrayInfoTestHelper(v8::kExternalUnsignedShortArray); | 16593 ExternalArrayInfoTestHelper(v8::kExternalUnsignedShortArray); |
16539 ExternalArrayInfoTestHelper(v8::kExternalIntArray); | 16594 ExternalArrayInfoTestHelper(v8::kExternalIntArray); |
16540 ExternalArrayInfoTestHelper(v8::kExternalUnsignedIntArray); | 16595 ExternalArrayInfoTestHelper(v8::kExternalUnsignedIntArray); |
16541 ExternalArrayInfoTestHelper(v8::kExternalFloatArray); | 16596 ExternalArrayInfoTestHelper(v8::kExternalFloatArray); |
16542 ExternalArrayInfoTestHelper(v8::kExternalDoubleArray); | 16597 ExternalArrayInfoTestHelper(v8::kExternalDoubleArray); |
16543 ExternalArrayInfoTestHelper(v8::kExternalPixelArray); | 16598 ExternalArrayInfoTestHelper(v8::kExternalPixelArray); |
16544 } | 16599 } |
16545 | 16600 |
16546 | 16601 |
16547 void ExternalArrayLimitTestHelper(v8::ExternalArrayType array_type, int size) { | 16602 void ExtArrayLimitsHelper(v8::Isolate* isolate, |
16548 v8::Handle<v8::Object> obj = v8::Object::New(); | 16603 v8::ExternalArrayType array_type, |
| 16604 int size) { |
| 16605 v8::Handle<v8::Object> obj = v8::Object::New(isolate); |
16549 v8::V8::SetFatalErrorHandler(StoringErrorCallback); | 16606 v8::V8::SetFatalErrorHandler(StoringErrorCallback); |
16550 last_location = last_message = NULL; | 16607 last_location = last_message = NULL; |
16551 obj->SetIndexedPropertiesToExternalArrayData(NULL, array_type, size); | 16608 obj->SetIndexedPropertiesToExternalArrayData(NULL, array_type, size); |
16552 CHECK(!obj->HasIndexedPropertiesInExternalArrayData()); | 16609 CHECK(!obj->HasIndexedPropertiesInExternalArrayData()); |
16553 CHECK_NE(NULL, last_location); | 16610 CHECK_NE(NULL, last_location); |
16554 CHECK_NE(NULL, last_message); | 16611 CHECK_NE(NULL, last_message); |
16555 } | 16612 } |
16556 | 16613 |
16557 | 16614 |
16558 TEST(ExternalArrayLimits) { | 16615 TEST(ExternalArrayLimits) { |
16559 LocalContext context; | 16616 LocalContext context; |
16560 v8::HandleScope scope(context->GetIsolate()); | 16617 v8::Isolate* isolate = context->GetIsolate(); |
16561 ExternalArrayLimitTestHelper(v8::kExternalByteArray, 0x40000000); | 16618 v8::HandleScope scope(isolate); |
16562 ExternalArrayLimitTestHelper(v8::kExternalByteArray, 0xffffffff); | 16619 ExtArrayLimitsHelper(isolate, v8::kExternalByteArray, 0x40000000); |
16563 ExternalArrayLimitTestHelper(v8::kExternalUnsignedByteArray, 0x40000000); | 16620 ExtArrayLimitsHelper(isolate, v8::kExternalByteArray, 0xffffffff); |
16564 ExternalArrayLimitTestHelper(v8::kExternalUnsignedByteArray, 0xffffffff); | 16621 ExtArrayLimitsHelper(isolate, v8::kExternalUnsignedByteArray, 0x40000000); |
16565 ExternalArrayLimitTestHelper(v8::kExternalShortArray, 0x40000000); | 16622 ExtArrayLimitsHelper(isolate, v8::kExternalUnsignedByteArray, 0xffffffff); |
16566 ExternalArrayLimitTestHelper(v8::kExternalShortArray, 0xffffffff); | 16623 ExtArrayLimitsHelper(isolate, v8::kExternalShortArray, 0x40000000); |
16567 ExternalArrayLimitTestHelper(v8::kExternalUnsignedShortArray, 0x40000000); | 16624 ExtArrayLimitsHelper(isolate, v8::kExternalShortArray, 0xffffffff); |
16568 ExternalArrayLimitTestHelper(v8::kExternalUnsignedShortArray, 0xffffffff); | 16625 ExtArrayLimitsHelper(isolate, v8::kExternalUnsignedShortArray, 0x40000000); |
16569 ExternalArrayLimitTestHelper(v8::kExternalIntArray, 0x40000000); | 16626 ExtArrayLimitsHelper(isolate, v8::kExternalUnsignedShortArray, 0xffffffff); |
16570 ExternalArrayLimitTestHelper(v8::kExternalIntArray, 0xffffffff); | 16627 ExtArrayLimitsHelper(isolate, v8::kExternalIntArray, 0x40000000); |
16571 ExternalArrayLimitTestHelper(v8::kExternalUnsignedIntArray, 0x40000000); | 16628 ExtArrayLimitsHelper(isolate, v8::kExternalIntArray, 0xffffffff); |
16572 ExternalArrayLimitTestHelper(v8::kExternalUnsignedIntArray, 0xffffffff); | 16629 ExtArrayLimitsHelper(isolate, v8::kExternalUnsignedIntArray, 0x40000000); |
16573 ExternalArrayLimitTestHelper(v8::kExternalFloatArray, 0x40000000); | 16630 ExtArrayLimitsHelper(isolate, v8::kExternalUnsignedIntArray, 0xffffffff); |
16574 ExternalArrayLimitTestHelper(v8::kExternalFloatArray, 0xffffffff); | 16631 ExtArrayLimitsHelper(isolate, v8::kExternalFloatArray, 0x40000000); |
16575 ExternalArrayLimitTestHelper(v8::kExternalDoubleArray, 0x40000000); | 16632 ExtArrayLimitsHelper(isolate, v8::kExternalFloatArray, 0xffffffff); |
16576 ExternalArrayLimitTestHelper(v8::kExternalDoubleArray, 0xffffffff); | 16633 ExtArrayLimitsHelper(isolate, v8::kExternalDoubleArray, 0x40000000); |
16577 ExternalArrayLimitTestHelper(v8::kExternalPixelArray, 0x40000000); | 16634 ExtArrayLimitsHelper(isolate, v8::kExternalDoubleArray, 0xffffffff); |
16578 ExternalArrayLimitTestHelper(v8::kExternalPixelArray, 0xffffffff); | 16635 ExtArrayLimitsHelper(isolate, v8::kExternalPixelArray, 0x40000000); |
| 16636 ExtArrayLimitsHelper(isolate, v8::kExternalPixelArray, 0xffffffff); |
16579 } | 16637 } |
16580 | 16638 |
16581 | 16639 |
16582 template <typename ElementType, typename TypedArray, | 16640 template <typename ElementType, typename TypedArray, |
16583 class ExternalArrayClass> | 16641 class ExternalArrayClass> |
16584 void TypedArrayTestHelper(v8::ExternalArrayType array_type, | 16642 void TypedArrayTestHelper(v8::ExternalArrayType array_type, |
16585 int64_t low, int64_t high) { | 16643 int64_t low, int64_t high) { |
16586 const int kElementCount = 50; | 16644 const int kElementCount = 50; |
16587 | 16645 |
16588 i::ScopedVector<ElementType> backing_store(kElementCount+2); | 16646 i::ScopedVector<ElementType> backing_store(kElementCount+2); |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
16720 | 16778 |
16721 THREADED_TEST(ScriptContextDependence) { | 16779 THREADED_TEST(ScriptContextDependence) { |
16722 LocalContext c1; | 16780 LocalContext c1; |
16723 v8::HandleScope scope(c1->GetIsolate()); | 16781 v8::HandleScope scope(c1->GetIsolate()); |
16724 const char *source = "foo"; | 16782 const char *source = "foo"; |
16725 v8::Handle<v8::Script> dep = | 16783 v8::Handle<v8::Script> dep = |
16726 v8::Script::Compile(v8::String::NewFromUtf8(c1->GetIsolate(), source)); | 16784 v8::Script::Compile(v8::String::NewFromUtf8(c1->GetIsolate(), source)); |
16727 v8::Handle<v8::Script> indep = | 16785 v8::Handle<v8::Script> indep = |
16728 v8::Script::New(v8::String::NewFromUtf8(c1->GetIsolate(), source)); | 16786 v8::Script::New(v8::String::NewFromUtf8(c1->GetIsolate(), source)); |
16729 c1->Global()->Set(v8::String::NewFromUtf8(c1->GetIsolate(), "foo"), | 16787 c1->Global()->Set(v8::String::NewFromUtf8(c1->GetIsolate(), "foo"), |
16730 v8::Integer::New(100)); | 16788 v8::Integer::New(c1->GetIsolate(), 100)); |
16731 CHECK_EQ(dep->Run()->Int32Value(), 100); | 16789 CHECK_EQ(dep->Run()->Int32Value(), 100); |
16732 CHECK_EQ(indep->Run()->Int32Value(), 100); | 16790 CHECK_EQ(indep->Run()->Int32Value(), 100); |
16733 LocalContext c2; | 16791 LocalContext c2; |
16734 c2->Global()->Set(v8::String::NewFromUtf8(c2->GetIsolate(), "foo"), | 16792 c2->Global()->Set(v8::String::NewFromUtf8(c2->GetIsolate(), "foo"), |
16735 v8::Integer::New(101)); | 16793 v8::Integer::New(c2->GetIsolate(), 101)); |
16736 CHECK_EQ(dep->Run()->Int32Value(), 100); | 16794 CHECK_EQ(dep->Run()->Int32Value(), 100); |
16737 CHECK_EQ(indep->Run()->Int32Value(), 101); | 16795 CHECK_EQ(indep->Run()->Int32Value(), 101); |
16738 } | 16796 } |
16739 | 16797 |
16740 | 16798 |
16741 THREADED_TEST(StackTrace) { | 16799 THREADED_TEST(StackTrace) { |
16742 LocalContext context; | 16800 LocalContext context; |
16743 v8::HandleScope scope(context->GetIsolate()); | 16801 v8::HandleScope scope(context->GetIsolate()); |
16744 v8::TryCatch try_catch; | 16802 v8::TryCatch try_catch; |
16745 const char *source = "function foo() { FAIL.FAIL; }; foo();"; | 16803 const char *source = "function foo() { FAIL.FAIL; }; foo();"; |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
16863 "function bat() {AnalyzeStackInNativeCode(2);\n" | 16921 "function bat() {AnalyzeStackInNativeCode(2);\n" |
16864 "}\n" | 16922 "}\n" |
16865 "\n" | 16923 "\n" |
16866 "function baz() {\n" | 16924 "function baz() {\n" |
16867 " bat();\n" | 16925 " bat();\n" |
16868 "}\n" | 16926 "}\n" |
16869 "eval('new baz();');"; | 16927 "eval('new baz();');"; |
16870 v8::Handle<v8::String> detailed_src = | 16928 v8::Handle<v8::String> detailed_src = |
16871 v8::String::NewFromUtf8(isolate, detailed_source); | 16929 v8::String::NewFromUtf8(isolate, detailed_source); |
16872 // Make the script using a non-zero line and column offset. | 16930 // Make the script using a non-zero line and column offset. |
16873 v8::Handle<v8::Integer> line_offset = v8::Integer::New(3); | 16931 v8::Handle<v8::Integer> line_offset = v8::Integer::New(isolate, 3); |
16874 v8::Handle<v8::Integer> column_offset = v8::Integer::New(5); | 16932 v8::Handle<v8::Integer> column_offset = v8::Integer::New(isolate, 5); |
16875 v8::ScriptOrigin detailed_origin(origin, line_offset, column_offset); | 16933 v8::ScriptOrigin detailed_origin(origin, line_offset, column_offset); |
16876 v8::Handle<v8::Script> detailed_script( | 16934 v8::Handle<v8::Script> detailed_script( |
16877 v8::Script::New(detailed_src, &detailed_origin)); | 16935 v8::Script::New(detailed_src, &detailed_origin)); |
16878 v8::Handle<Value> detailed_result(detailed_script->Run()); | 16936 v8::Handle<Value> detailed_result(detailed_script->Run()); |
16879 CHECK(!detailed_result.IsEmpty()); | 16937 CHECK(!detailed_result.IsEmpty()); |
16880 CHECK(detailed_result->IsObject()); | 16938 CHECK(detailed_result->IsObject()); |
16881 } | 16939 } |
16882 | 16940 |
16883 | 16941 |
16884 static void StackTraceForUncaughtExceptionListener( | 16942 static void StackTraceForUncaughtExceptionListener( |
(...skipping 728 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
17613 | 17671 |
17614 // We don't have a consistent way to write 64-bit constants syntactically, so we | 17672 // We don't have a consistent way to write 64-bit constants syntactically, so we |
17615 // split them into two 32-bit constants and combine them programmatically. | 17673 // split them into two 32-bit constants and combine them programmatically. |
17616 static double DoubleFromBits(uint32_t high_bits, uint32_t low_bits) { | 17674 static double DoubleFromBits(uint32_t high_bits, uint32_t low_bits) { |
17617 return DoubleFromBits((static_cast<uint64_t>(high_bits) << 32) | low_bits); | 17675 return DoubleFromBits((static_cast<uint64_t>(high_bits) << 32) | low_bits); |
17618 } | 17676 } |
17619 | 17677 |
17620 | 17678 |
17621 THREADED_TEST(QuietSignalingNaNs) { | 17679 THREADED_TEST(QuietSignalingNaNs) { |
17622 LocalContext context; | 17680 LocalContext context; |
17623 v8::HandleScope scope(context->GetIsolate()); | 17681 v8::Isolate* isolate = context->GetIsolate(); |
| 17682 v8::HandleScope scope(isolate); |
17624 v8::TryCatch try_catch; | 17683 v8::TryCatch try_catch; |
17625 | 17684 |
17626 // Special double values. | 17685 // Special double values. |
17627 double snan = DoubleFromBits(0x7ff00000, 0x00000001); | 17686 double snan = DoubleFromBits(0x7ff00000, 0x00000001); |
17628 double qnan = DoubleFromBits(0x7ff80000, 0x00000000); | 17687 double qnan = DoubleFromBits(0x7ff80000, 0x00000000); |
17629 double infinity = DoubleFromBits(0x7ff00000, 0x00000000); | 17688 double infinity = DoubleFromBits(0x7ff00000, 0x00000000); |
17630 double max_normal = DoubleFromBits(0x7fefffff, 0xffffffffu); | 17689 double max_normal = DoubleFromBits(0x7fefffff, 0xffffffffu); |
17631 double min_normal = DoubleFromBits(0x00100000, 0x00000000); | 17690 double min_normal = DoubleFromBits(0x00100000, 0x00000000); |
17632 double max_denormal = DoubleFromBits(0x000fffff, 0xffffffffu); | 17691 double max_denormal = DoubleFromBits(0x000fffff, 0xffffffffu); |
17633 double min_denormal = DoubleFromBits(0x00000000, 0x00000001); | 17692 double min_denormal = DoubleFromBits(0x00000000, 0x00000001); |
(...skipping 23 matching lines...) Expand all Loading... |
17657 -infinity, | 17716 -infinity, |
17658 -qnan, | 17717 -qnan, |
17659 -snan | 17718 -snan |
17660 }; | 17719 }; |
17661 int num_test_values = 20; | 17720 int num_test_values = 20; |
17662 | 17721 |
17663 for (int i = 0; i < num_test_values; i++) { | 17722 for (int i = 0; i < num_test_values; i++) { |
17664 double test_value = test_values[i]; | 17723 double test_value = test_values[i]; |
17665 | 17724 |
17666 // Check that Number::New preserves non-NaNs and quiets SNaNs. | 17725 // Check that Number::New preserves non-NaNs and quiets SNaNs. |
17667 v8::Handle<v8::Value> number = v8::Number::New(test_value); | 17726 v8::Handle<v8::Value> number = v8::Number::New(isolate, test_value); |
17668 double stored_number = number->NumberValue(); | 17727 double stored_number = number->NumberValue(); |
17669 if (!std::isnan(test_value)) { | 17728 if (!std::isnan(test_value)) { |
17670 CHECK_EQ(test_value, stored_number); | 17729 CHECK_EQ(test_value, stored_number); |
17671 } else { | 17730 } else { |
17672 uint64_t stored_bits = DoubleToBits(stored_number); | 17731 uint64_t stored_bits = DoubleToBits(stored_number); |
17673 // Check if quiet nan (bits 51..62 all set). | 17732 // Check if quiet nan (bits 51..62 all set). |
17674 #if defined(V8_TARGET_ARCH_MIPS) && !defined(USE_SIMULATOR) | 17733 #if defined(V8_TARGET_ARCH_MIPS) && !defined(USE_SIMULATOR) |
17675 // Most significant fraction bit for quiet nan is set to 0 | 17734 // Most significant fraction bit for quiet nan is set to 0 |
17676 // on MIPS architecture. Allowed by IEEE-754. | 17735 // on MIPS architecture. Allowed by IEEE-754. |
17677 CHECK_EQ(0xffe, static_cast<int>((stored_bits >> 51) & 0xfff)); | 17736 CHECK_EQ(0xffe, static_cast<int>((stored_bits >> 51) & 0xfff)); |
17678 #else | 17737 #else |
17679 CHECK_EQ(0xfff, static_cast<int>((stored_bits >> 51) & 0xfff)); | 17738 CHECK_EQ(0xfff, static_cast<int>((stored_bits >> 51) & 0xfff)); |
17680 #endif | 17739 #endif |
17681 } | 17740 } |
17682 | 17741 |
17683 // Check that Date::New preserves non-NaNs in the date range and | 17742 // Check that Date::New preserves non-NaNs in the date range and |
17684 // quiets SNaNs. | 17743 // quiets SNaNs. |
17685 v8::Handle<v8::Value> date = | 17744 v8::Handle<v8::Value> date = |
17686 v8::Date::New(context->GetIsolate(), test_value); | 17745 v8::Date::New(isolate, test_value); |
17687 double expected_stored_date = DoubleToDateTime(test_value); | 17746 double expected_stored_date = DoubleToDateTime(test_value); |
17688 double stored_date = date->NumberValue(); | 17747 double stored_date = date->NumberValue(); |
17689 if (!std::isnan(expected_stored_date)) { | 17748 if (!std::isnan(expected_stored_date)) { |
17690 CHECK_EQ(expected_stored_date, stored_date); | 17749 CHECK_EQ(expected_stored_date, stored_date); |
17691 } else { | 17750 } else { |
17692 uint64_t stored_bits = DoubleToBits(stored_date); | 17751 uint64_t stored_bits = DoubleToBits(stored_date); |
17693 // Check if quiet nan (bits 51..62 all set). | 17752 // Check if quiet nan (bits 51..62 all set). |
17694 #if defined(V8_TARGET_ARCH_MIPS) && !defined(USE_SIMULATOR) | 17753 #if defined(V8_TARGET_ARCH_MIPS) && !defined(USE_SIMULATOR) |
17695 // Most significant fraction bit for quiet nan is set to 0 | 17754 // Most significant fraction bit for quiet nan is set to 0 |
17696 // on MIPS architecture. Allowed by IEEE-754. | 17755 // on MIPS architecture. Allowed by IEEE-754. |
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
17948 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "f"))); | 18007 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "f"))); |
17949 v8::Local<v8::Function> g = v8::Local<v8::Function>::Cast( | 18008 v8::Local<v8::Function> g = v8::Local<v8::Function>::Cast( |
17950 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "g"))); | 18009 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "g"))); |
17951 CHECK_EQ(0, f->GetScriptLineNumber()); | 18010 CHECK_EQ(0, f->GetScriptLineNumber()); |
17952 CHECK_EQ(2, g->GetScriptLineNumber()); | 18011 CHECK_EQ(2, g->GetScriptLineNumber()); |
17953 } | 18012 } |
17954 | 18013 |
17955 | 18014 |
17956 THREADED_TEST(ScriptColumnNumber) { | 18015 THREADED_TEST(ScriptColumnNumber) { |
17957 LocalContext env; | 18016 LocalContext env; |
17958 v8::HandleScope scope(env->GetIsolate()); | 18017 v8::Isolate* isolate = env->GetIsolate(); |
| 18018 v8::HandleScope scope(isolate); |
17959 v8::ScriptOrigin origin = | 18019 v8::ScriptOrigin origin = |
17960 v8::ScriptOrigin(v8::String::NewFromUtf8(env->GetIsolate(), "test"), | 18020 v8::ScriptOrigin(v8::String::NewFromUtf8(isolate, "test"), |
17961 v8::Integer::New(3), v8::Integer::New(2)); | 18021 v8::Integer::New(isolate, 3), |
| 18022 v8::Integer::New(isolate, 2)); |
17962 v8::Handle<v8::String> script = v8::String::NewFromUtf8( | 18023 v8::Handle<v8::String> script = v8::String::NewFromUtf8( |
17963 env->GetIsolate(), "function foo() {}\n\n function bar() {}"); | 18024 isolate, "function foo() {}\n\n function bar() {}"); |
17964 v8::Script::Compile(script, &origin)->Run(); | 18025 v8::Script::Compile(script, &origin)->Run(); |
17965 v8::Local<v8::Function> foo = v8::Local<v8::Function>::Cast( | 18026 v8::Local<v8::Function> foo = v8::Local<v8::Function>::Cast( |
17966 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "foo"))); | 18027 env->Global()->Get(v8::String::NewFromUtf8(isolate, "foo"))); |
17967 v8::Local<v8::Function> bar = v8::Local<v8::Function>::Cast( | 18028 v8::Local<v8::Function> bar = v8::Local<v8::Function>::Cast( |
17968 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "bar"))); | 18029 env->Global()->Get(v8::String::NewFromUtf8(isolate, "bar"))); |
17969 CHECK_EQ(14, foo->GetScriptColumnNumber()); | 18030 CHECK_EQ(14, foo->GetScriptColumnNumber()); |
17970 CHECK_EQ(17, bar->GetScriptColumnNumber()); | 18031 CHECK_EQ(17, bar->GetScriptColumnNumber()); |
17971 } | 18032 } |
17972 | 18033 |
17973 | 18034 |
17974 THREADED_TEST(FunctionIsBuiltin) { | 18035 THREADED_TEST(FunctionIsBuiltin) { |
17975 LocalContext env; | 18036 LocalContext env; |
17976 v8::HandleScope scope(env->GetIsolate()); | 18037 v8::Isolate* isolate = env->GetIsolate(); |
| 18038 v8::HandleScope scope(isolate); |
17977 v8::Local<v8::Function> f; | 18039 v8::Local<v8::Function> f; |
17978 f = v8::Local<v8::Function>::Cast(CompileRun("Math.floor")); | 18040 f = v8::Local<v8::Function>::Cast(CompileRun("Math.floor")); |
17979 CHECK(f->IsBuiltin()); | 18041 CHECK(f->IsBuiltin()); |
17980 f = v8::Local<v8::Function>::Cast(CompileRun("Object")); | 18042 f = v8::Local<v8::Function>::Cast(CompileRun("Object")); |
17981 CHECK(f->IsBuiltin()); | 18043 CHECK(f->IsBuiltin()); |
17982 f = v8::Local<v8::Function>::Cast(CompileRun("Object.__defineSetter__")); | 18044 f = v8::Local<v8::Function>::Cast(CompileRun("Object.__defineSetter__")); |
17983 CHECK(f->IsBuiltin()); | 18045 CHECK(f->IsBuiltin()); |
17984 f = v8::Local<v8::Function>::Cast(CompileRun("Array.prototype.toString")); | 18046 f = v8::Local<v8::Function>::Cast(CompileRun("Array.prototype.toString")); |
17985 CHECK(f->IsBuiltin()); | 18047 CHECK(f->IsBuiltin()); |
17986 f = v8::Local<v8::Function>::Cast(CompileRun("function a() {}; a;")); | 18048 f = v8::Local<v8::Function>::Cast(CompileRun("function a() {}; a;")); |
17987 CHECK(!f->IsBuiltin()); | 18049 CHECK(!f->IsBuiltin()); |
17988 } | 18050 } |
17989 | 18051 |
17990 | 18052 |
17991 THREADED_TEST(FunctionGetScriptId) { | 18053 THREADED_TEST(FunctionGetScriptId) { |
17992 LocalContext env; | 18054 LocalContext env; |
17993 v8::HandleScope scope(env->GetIsolate()); | 18055 v8::Isolate* isolate = env->GetIsolate(); |
| 18056 v8::HandleScope scope(isolate); |
17994 v8::ScriptOrigin origin = | 18057 v8::ScriptOrigin origin = |
17995 v8::ScriptOrigin(v8::String::NewFromUtf8(env->GetIsolate(), "test"), | 18058 v8::ScriptOrigin(v8::String::NewFromUtf8(isolate, "test"), |
17996 v8::Integer::New(3), v8::Integer::New(2)); | 18059 v8::Integer::New(isolate, 3), |
| 18060 v8::Integer::New(isolate, 2)); |
17997 v8::Handle<v8::String> scriptSource = v8::String::NewFromUtf8( | 18061 v8::Handle<v8::String> scriptSource = v8::String::NewFromUtf8( |
17998 env->GetIsolate(), "function foo() {}\n\n function bar() {}"); | 18062 isolate, "function foo() {}\n\n function bar() {}"); |
17999 v8::Local<v8::Script> script(v8::Script::Compile(scriptSource, &origin)); | 18063 v8::Local<v8::Script> script(v8::Script::Compile(scriptSource, &origin)); |
18000 script->Run(); | 18064 script->Run(); |
18001 v8::Local<v8::Function> foo = v8::Local<v8::Function>::Cast( | 18065 v8::Local<v8::Function> foo = v8::Local<v8::Function>::Cast( |
18002 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "foo"))); | 18066 env->Global()->Get(v8::String::NewFromUtf8(isolate, "foo"))); |
18003 v8::Local<v8::Function> bar = v8::Local<v8::Function>::Cast( | 18067 v8::Local<v8::Function> bar = v8::Local<v8::Function>::Cast( |
18004 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "bar"))); | 18068 env->Global()->Get(v8::String::NewFromUtf8(isolate, "bar"))); |
18005 CHECK_EQ(script->GetId(), foo->ScriptId()); | 18069 CHECK_EQ(script->GetId(), foo->ScriptId()); |
18006 CHECK_EQ(script->GetId(), bar->ScriptId()); | 18070 CHECK_EQ(script->GetId(), bar->ScriptId()); |
18007 } | 18071 } |
18008 | 18072 |
18009 | 18073 |
18010 THREADED_TEST(FunctionGetBoundFunction) { | 18074 THREADED_TEST(FunctionGetBoundFunction) { |
18011 LocalContext env; | 18075 LocalContext env; |
18012 v8::HandleScope scope(env->GetIsolate()); | 18076 v8::HandleScope scope(env->GetIsolate()); |
18013 v8::ScriptOrigin origin = v8::ScriptOrigin(v8::String::NewFromUtf8( | 18077 v8::ScriptOrigin origin = v8::ScriptOrigin(v8::String::NewFromUtf8( |
18014 env->GetIsolate(), "test")); | 18078 env->GetIsolate(), "test")); |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
18163 const char* source = "function C1() {" | 18227 const char* source = "function C1() {" |
18164 " this.x = 23;" | 18228 " this.x = 23;" |
18165 "};" | 18229 "};" |
18166 "C1.prototype = P;"; | 18230 "C1.prototype = P;"; |
18167 | 18231 |
18168 LocalContext context; | 18232 LocalContext context; |
18169 v8::HandleScope scope(context->GetIsolate()); | 18233 v8::HandleScope scope(context->GetIsolate()); |
18170 v8::Local<v8::Script> script; | 18234 v8::Local<v8::Script> script; |
18171 | 18235 |
18172 // Use a simple object as prototype. | 18236 // Use a simple object as prototype. |
18173 v8::Local<v8::Object> prototype = v8::Object::New(); | 18237 v8::Local<v8::Object> prototype = v8::Object::New(context->GetIsolate()); |
18174 prototype->Set(v8_str("y"), v8_num(42)); | 18238 prototype->Set(v8_str("y"), v8_num(42)); |
18175 context->Global()->Set(v8_str("P"), prototype); | 18239 context->Global()->Set(v8_str("P"), prototype); |
18176 | 18240 |
18177 // This compile will add the code to the compilation cache. | 18241 // This compile will add the code to the compilation cache. |
18178 CompileRun(source); | 18242 CompileRun(source); |
18179 | 18243 |
18180 script = v8::Script::Compile(v8_str("new C1();")); | 18244 script = v8::Script::Compile(v8_str("new C1();")); |
18181 // Allow enough iterations for the inobject slack tracking logic | 18245 // Allow enough iterations for the inobject slack tracking logic |
18182 // to finalize instance size and install the fast construct stub. | 18246 // to finalize instance size and install the fast construct stub. |
18183 for (int i = 0; i < 256; i++) { | 18247 for (int i = 0; i < 256; i++) { |
(...skipping 1043 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
19227 | 19291 |
19228 int counter_; | 19292 int counter_; |
19229 v8::Persistent<v8::Object>* object_; | 19293 v8::Persistent<v8::Object>* object_; |
19230 }; | 19294 }; |
19231 | 19295 |
19232 | 19296 |
19233 TEST(PersistentHandleVisitor) { | 19297 TEST(PersistentHandleVisitor) { |
19234 LocalContext context; | 19298 LocalContext context; |
19235 v8::Isolate* isolate = context->GetIsolate(); | 19299 v8::Isolate* isolate = context->GetIsolate(); |
19236 v8::HandleScope scope(isolate); | 19300 v8::HandleScope scope(isolate); |
19237 v8::Persistent<v8::Object> object(isolate, v8::Object::New()); | 19301 v8::Persistent<v8::Object> object(isolate, v8::Object::New(isolate)); |
19238 CHECK_EQ(0, object.WrapperClassId()); | 19302 CHECK_EQ(0, object.WrapperClassId()); |
19239 object.SetWrapperClassId(42); | 19303 object.SetWrapperClassId(42); |
19240 CHECK_EQ(42, object.WrapperClassId()); | 19304 CHECK_EQ(42, object.WrapperClassId()); |
19241 | 19305 |
19242 Visitor42 visitor(&object); | 19306 Visitor42 visitor(&object); |
19243 v8::V8::VisitHandlesWithClassIds(&visitor); | 19307 v8::V8::VisitHandlesWithClassIds(&visitor); |
19244 CHECK_EQ(1, visitor.counter_); | 19308 CHECK_EQ(1, visitor.counter_); |
19245 | 19309 |
19246 object.Reset(); | 19310 object.Reset(); |
19247 } | 19311 } |
19248 | 19312 |
19249 | 19313 |
19250 TEST(WrapperClassId) { | 19314 TEST(WrapperClassId) { |
19251 LocalContext context; | 19315 LocalContext context; |
19252 v8::Isolate* isolate = context->GetIsolate(); | 19316 v8::Isolate* isolate = context->GetIsolate(); |
19253 v8::HandleScope scope(isolate); | 19317 v8::HandleScope scope(isolate); |
19254 v8::Persistent<v8::Object> object(isolate, v8::Object::New()); | 19318 v8::Persistent<v8::Object> object(isolate, v8::Object::New(isolate)); |
19255 CHECK_EQ(0, object.WrapperClassId()); | 19319 CHECK_EQ(0, object.WrapperClassId()); |
19256 object.SetWrapperClassId(65535); | 19320 object.SetWrapperClassId(65535); |
19257 CHECK_EQ(65535, object.WrapperClassId()); | 19321 CHECK_EQ(65535, object.WrapperClassId()); |
19258 object.Reset(); | 19322 object.Reset(); |
19259 } | 19323 } |
19260 | 19324 |
19261 | 19325 |
19262 TEST(PersistentHandleInNewSpaceVisitor) { | 19326 TEST(PersistentHandleInNewSpaceVisitor) { |
19263 LocalContext context; | 19327 LocalContext context; |
19264 v8::Isolate* isolate = context->GetIsolate(); | 19328 v8::Isolate* isolate = context->GetIsolate(); |
19265 v8::HandleScope scope(isolate); | 19329 v8::HandleScope scope(isolate); |
19266 v8::Persistent<v8::Object> object1(isolate, v8::Object::New()); | 19330 v8::Persistent<v8::Object> object1(isolate, v8::Object::New(isolate)); |
19267 CHECK_EQ(0, object1.WrapperClassId()); | 19331 CHECK_EQ(0, object1.WrapperClassId()); |
19268 object1.SetWrapperClassId(42); | 19332 object1.SetWrapperClassId(42); |
19269 CHECK_EQ(42, object1.WrapperClassId()); | 19333 CHECK_EQ(42, object1.WrapperClassId()); |
19270 | 19334 |
19271 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); | 19335 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); |
19272 | 19336 |
19273 v8::Persistent<v8::Object> object2(isolate, v8::Object::New()); | 19337 v8::Persistent<v8::Object> object2(isolate, v8::Object::New(isolate)); |
19274 CHECK_EQ(0, object2.WrapperClassId()); | 19338 CHECK_EQ(0, object2.WrapperClassId()); |
19275 object2.SetWrapperClassId(42); | 19339 object2.SetWrapperClassId(42); |
19276 CHECK_EQ(42, object2.WrapperClassId()); | 19340 CHECK_EQ(42, object2.WrapperClassId()); |
19277 | 19341 |
19278 Visitor42 visitor(&object2); | 19342 Visitor42 visitor(&object2); |
19279 v8::V8::VisitHandlesForPartialDependence(isolate, &visitor); | 19343 v8::V8::VisitHandlesForPartialDependence(isolate, &visitor); |
19280 CHECK_EQ(1, visitor.counter_); | 19344 CHECK_EQ(1, visitor.counter_); |
19281 | 19345 |
19282 object1.Reset(); | 19346 object1.Reset(); |
19283 object2.Reset(); | 19347 object2.Reset(); |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
19334 v8::RegExp::kMultiline)); | 19398 v8::RegExp::kMultiline)); |
19335 CHECK(re->IsRegExp()); | 19399 CHECK(re->IsRegExp()); |
19336 CHECK(re->GetSource()->Equals(v8_str("foobarbaz"))); | 19400 CHECK(re->GetSource()->Equals(v8_str("foobarbaz"))); |
19337 CHECK_EQ(v8::RegExp::kIgnoreCase | v8::RegExp::kMultiline, | 19401 CHECK_EQ(v8::RegExp::kIgnoreCase | v8::RegExp::kMultiline, |
19338 static_cast<int>(re->GetFlags())); | 19402 static_cast<int>(re->GetFlags())); |
19339 | 19403 |
19340 context->Global()->Set(v8_str("re"), re); | 19404 context->Global()->Set(v8_str("re"), re); |
19341 ExpectTrue("re.test('FoobarbaZ')"); | 19405 ExpectTrue("re.test('FoobarbaZ')"); |
19342 | 19406 |
19343 // RegExps are objects on which you can set properties. | 19407 // RegExps are objects on which you can set properties. |
19344 re->Set(v8_str("property"), v8::Integer::New(32)); | 19408 re->Set(v8_str("property"), v8::Integer::New(context->GetIsolate(), 32)); |
19345 v8::Handle<v8::Value> value(CompileRun("re.property")); | 19409 v8::Handle<v8::Value> value(CompileRun("re.property")); |
19346 CHECK_EQ(32, value->Int32Value()); | 19410 CHECK_EQ(32, value->Int32Value()); |
19347 | 19411 |
19348 v8::TryCatch try_catch; | 19412 v8::TryCatch try_catch; |
19349 re = v8::RegExp::New(v8_str("foo["), v8::RegExp::kNone); | 19413 re = v8::RegExp::New(v8_str("foo["), v8::RegExp::kNone); |
19350 CHECK(re.IsEmpty()); | 19414 CHECK(re.IsEmpty()); |
19351 CHECK(try_catch.HasCaught()); | 19415 CHECK(try_catch.HasCaught()); |
19352 context->Global()->Set(v8_str("ex"), try_catch.Exception()); | 19416 context->Global()->Set(v8_str("ex"), try_catch.Exception()); |
19353 ExpectTrue("ex instanceof SyntaxError"); | 19417 ExpectTrue("ex instanceof SyntaxError"); |
19354 } | 19418 } |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
19413 " { configurable: true, enumerable: true, value: 3 });" | 19477 " { configurable: true, enumerable: true, value: 3 });" |
19414 "})").As<Function>(); | 19478 "})").As<Function>(); |
19415 context->DetachGlobal(); | 19479 context->DetachGlobal(); |
19416 define_property->Call(proxy, 0, NULL); | 19480 define_property->Call(proxy, 0, NULL); |
19417 } | 19481 } |
19418 | 19482 |
19419 | 19483 |
19420 static void InstallContextId(v8::Handle<Context> context, int id) { | 19484 static void InstallContextId(v8::Handle<Context> context, int id) { |
19421 Context::Scope scope(context); | 19485 Context::Scope scope(context); |
19422 CompileRun("Object.prototype").As<Object>()-> | 19486 CompileRun("Object.prototype").As<Object>()-> |
19423 Set(v8_str("context_id"), v8::Integer::New(id)); | 19487 Set(v8_str("context_id"), v8::Integer::New(context->GetIsolate(), id)); |
19424 } | 19488 } |
19425 | 19489 |
19426 | 19490 |
19427 static void CheckContextId(v8::Handle<Object> object, int expected) { | 19491 static void CheckContextId(v8::Handle<Object> object, int expected) { |
19428 CHECK_EQ(expected, object->Get(v8_str("context_id"))->Int32Value()); | 19492 CHECK_EQ(expected, object->Get(v8_str("context_id"))->Int32Value()); |
19429 } | 19493 } |
19430 | 19494 |
19431 | 19495 |
19432 THREADED_TEST(CreationContext) { | 19496 THREADED_TEST(CreationContext) { |
19433 v8::Isolate* isolate = CcTest::isolate(); | 19497 v8::Isolate* isolate = CcTest::isolate(); |
19434 HandleScope handle_scope(isolate); | 19498 HandleScope handle_scope(isolate); |
19435 Handle<Context> context1 = Context::New(isolate); | 19499 Handle<Context> context1 = Context::New(isolate); |
19436 InstallContextId(context1, 1); | 19500 InstallContextId(context1, 1); |
19437 Handle<Context> context2 = Context::New(isolate); | 19501 Handle<Context> context2 = Context::New(isolate); |
19438 InstallContextId(context2, 2); | 19502 InstallContextId(context2, 2); |
19439 Handle<Context> context3 = Context::New(isolate); | 19503 Handle<Context> context3 = Context::New(isolate); |
19440 InstallContextId(context3, 3); | 19504 InstallContextId(context3, 3); |
19441 | 19505 |
19442 Local<v8::FunctionTemplate> tmpl = v8::FunctionTemplate::New(isolate); | 19506 Local<v8::FunctionTemplate> tmpl = v8::FunctionTemplate::New(isolate); |
19443 | 19507 |
19444 Local<Object> object1; | 19508 Local<Object> object1; |
19445 Local<Function> func1; | 19509 Local<Function> func1; |
19446 { | 19510 { |
19447 Context::Scope scope(context1); | 19511 Context::Scope scope(context1); |
19448 object1 = Object::New(); | 19512 object1 = Object::New(isolate); |
19449 func1 = tmpl->GetFunction(); | 19513 func1 = tmpl->GetFunction(); |
19450 } | 19514 } |
19451 | 19515 |
19452 Local<Object> object2; | 19516 Local<Object> object2; |
19453 Local<Function> func2; | 19517 Local<Function> func2; |
19454 { | 19518 { |
19455 Context::Scope scope(context2); | 19519 Context::Scope scope(context2); |
19456 object2 = Object::New(); | 19520 object2 = Object::New(isolate); |
19457 func2 = tmpl->GetFunction(); | 19521 func2 = tmpl->GetFunction(); |
19458 } | 19522 } |
19459 | 19523 |
19460 Local<Object> instance1; | 19524 Local<Object> instance1; |
19461 Local<Object> instance2; | 19525 Local<Object> instance2; |
19462 | 19526 |
19463 { | 19527 { |
19464 Context::Scope scope(context3); | 19528 Context::Scope scope(context3); |
19465 instance1 = func1->NewInstance(); | 19529 instance1 = func1->NewInstance(); |
19466 instance2 = func2->NewInstance(); | 19530 instance2 = func2->NewInstance(); |
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
19857 protected_hidden_proto_template->InstanceTemplate()->SetAccessCheckCallbacks( | 19921 protected_hidden_proto_template->InstanceTemplate()->SetAccessCheckCallbacks( |
19858 BlockProtoNamedSecurityTestCallback, | 19922 BlockProtoNamedSecurityTestCallback, |
19859 IndexedSecurityTestCallback); | 19923 IndexedSecurityTestCallback); |
19860 protected_hidden_proto_template->SetHiddenPrototype(true); | 19924 protected_hidden_proto_template->SetHiddenPrototype(true); |
19861 | 19925 |
19862 // Context for "foreign" objects used in test. | 19926 // Context for "foreign" objects used in test. |
19863 Local<Context> context = v8::Context::New(isolate); | 19927 Local<Context> context = v8::Context::New(isolate); |
19864 context->Enter(); | 19928 context->Enter(); |
19865 | 19929 |
19866 // Plain object, no security check. | 19930 // Plain object, no security check. |
19867 Local<Object> simple_object = Object::New(); | 19931 Local<Object> simple_object = Object::New(isolate); |
19868 | 19932 |
19869 // Object with explicit security check. | 19933 // Object with explicit security check. |
19870 Local<Object> protected_object = | 19934 Local<Object> protected_object = |
19871 no_proto_template->NewInstance(); | 19935 no_proto_template->NewInstance(); |
19872 | 19936 |
19873 // JSGlobalProxy object, always have security check. | 19937 // JSGlobalProxy object, always have security check. |
19874 Local<Object> proxy_object = | 19938 Local<Object> proxy_object = |
19875 context->Global(); | 19939 context->Global(); |
19876 | 19940 |
19877 // Global object, the prototype of proxy_object. No security checks. | 19941 // Global object, the prototype of proxy_object. No security checks. |
19878 Local<Object> global_object = | 19942 Local<Object> global_object = |
19879 proxy_object->GetPrototype()->ToObject(); | 19943 proxy_object->GetPrototype()->ToObject(); |
19880 | 19944 |
19881 // Hidden prototype without security check. | 19945 // Hidden prototype without security check. |
19882 Local<Object> hidden_prototype = | 19946 Local<Object> hidden_prototype = |
19883 hidden_proto_template->GetFunction()->NewInstance(); | 19947 hidden_proto_template->GetFunction()->NewInstance(); |
19884 Local<Object> object_with_hidden = | 19948 Local<Object> object_with_hidden = |
19885 Object::New(); | 19949 Object::New(isolate); |
19886 object_with_hidden->SetPrototype(hidden_prototype); | 19950 object_with_hidden->SetPrototype(hidden_prototype); |
19887 | 19951 |
19888 // Hidden prototype with security check on the hidden prototype. | 19952 // Hidden prototype with security check on the hidden prototype. |
19889 Local<Object> protected_hidden_prototype = | 19953 Local<Object> protected_hidden_prototype = |
19890 protected_hidden_proto_template->GetFunction()->NewInstance(); | 19954 protected_hidden_proto_template->GetFunction()->NewInstance(); |
19891 Local<Object> object_with_protected_hidden = | 19955 Local<Object> object_with_protected_hidden = |
19892 Object::New(); | 19956 Object::New(isolate); |
19893 object_with_protected_hidden->SetPrototype(protected_hidden_prototype); | 19957 object_with_protected_hidden->SetPrototype(protected_hidden_prototype); |
19894 | 19958 |
19895 context->Exit(); | 19959 context->Exit(); |
19896 | 19960 |
19897 // Template for object for second context. Values to test are put on it as | 19961 // Template for object for second context. Values to test are put on it as |
19898 // properties. | 19962 // properties. |
19899 Local<ObjectTemplate> global_template = ObjectTemplate::New(); | 19963 Local<ObjectTemplate> global_template = ObjectTemplate::New(); |
19900 global_template->Set(v8_str("simple"), simple_object); | 19964 global_template->Set(v8_str("simple"), simple_object); |
19901 global_template->Set(v8_str("protected"), protected_object); | 19965 global_template->Set(v8_str("protected"), protected_object); |
19902 global_template->Set(v8_str("global"), global_object); | 19966 global_template->Set(v8_str("global"), global_object); |
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
20291 isolate->Dispose(); | 20355 isolate->Dispose(); |
20292 } | 20356 } |
20293 | 20357 |
20294 | 20358 |
20295 TEST(StringEmpty) { | 20359 TEST(StringEmpty) { |
20296 LocalContext context; | 20360 LocalContext context; |
20297 i::Factory* factory = CcTest::i_isolate()->factory(); | 20361 i::Factory* factory = CcTest::i_isolate()->factory(); |
20298 v8::Isolate* isolate = CcTest::isolate(); | 20362 v8::Isolate* isolate = CcTest::isolate(); |
20299 v8::HandleScope scope(isolate); | 20363 v8::HandleScope scope(isolate); |
20300 i::Handle<i::Object> empty_string = factory->empty_string(); | 20364 i::Handle<i::Object> empty_string = factory->empty_string(); |
20301 CHECK(*v8::Utils::OpenHandle(*v8::String::Empty()) == *empty_string); | |
20302 CHECK(*v8::Utils::OpenHandle(*v8::String::Empty(isolate)) == *empty_string); | 20365 CHECK(*v8::Utils::OpenHandle(*v8::String::Empty(isolate)) == *empty_string); |
20303 } | 20366 } |
20304 | 20367 |
20305 | 20368 |
20306 static int instance_checked_getter_count = 0; | 20369 static int instance_checked_getter_count = 0; |
20307 static void InstanceCheckedGetter( | 20370 static void InstanceCheckedGetter( |
20308 Local<String> name, | 20371 Local<String> name, |
20309 const v8::PropertyCallbackInfo<v8::Value>& info) { | 20372 const v8::PropertyCallbackInfo<v8::Value>& info) { |
20310 CHECK_EQ(name, v8_str("foo")); | 20373 CHECK_EQ(name, v8_str("foo")); |
20311 instance_checked_getter_count++; | 20374 instance_checked_getter_count++; |
(...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
20705 Local<Value> map_value = CompileRun("new Map();"); | 20768 Local<Value> map_value = CompileRun("new Map();"); |
20706 Local<Object> map_object(Local<Object>::Cast(map_value)); | 20769 Local<Object> map_object(Local<Object>::Cast(map_value)); |
20707 CHECK_EQ(0, map_object->InternalFieldCount()); | 20770 CHECK_EQ(0, map_object->InternalFieldCount()); |
20708 } | 20771 } |
20709 | 20772 |
20710 | 20773 |
20711 THREADED_TEST(Regress2746) { | 20774 THREADED_TEST(Regress2746) { |
20712 LocalContext context; | 20775 LocalContext context; |
20713 v8::Isolate* isolate = context->GetIsolate(); | 20776 v8::Isolate* isolate = context->GetIsolate(); |
20714 v8::HandleScope scope(isolate); | 20777 v8::HandleScope scope(isolate); |
20715 Local<Object> obj = Object::New(); | 20778 Local<Object> obj = Object::New(isolate); |
20716 Local<String> key = String::NewFromUtf8(context->GetIsolate(), "key"); | 20779 Local<String> key = String::NewFromUtf8(context->GetIsolate(), "key"); |
20717 obj->SetHiddenValue(key, v8::Undefined(isolate)); | 20780 obj->SetHiddenValue(key, v8::Undefined(isolate)); |
20718 Local<Value> value = obj->GetHiddenValue(key); | 20781 Local<Value> value = obj->GetHiddenValue(key); |
20719 CHECK(!value.IsEmpty()); | 20782 CHECK(!value.IsEmpty()); |
20720 CHECK(value->IsUndefined()); | 20783 CHECK(value->IsUndefined()); |
20721 } | 20784 } |
20722 | 20785 |
20723 | 20786 |
20724 THREADED_TEST(Regress260106) { | 20787 THREADED_TEST(Regress260106) { |
20725 LocalContext context; | 20788 LocalContext context; |
(...skipping 637 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
21363 static void FunctionNewCallback(const v8::FunctionCallbackInfo<Value>& info) { | 21426 static void FunctionNewCallback(const v8::FunctionCallbackInfo<Value>& info) { |
21364 CHECK_EQ(function_new_expected_env, info.Data()); | 21427 CHECK_EQ(function_new_expected_env, info.Data()); |
21365 info.GetReturnValue().Set(17); | 21428 info.GetReturnValue().Set(17); |
21366 } | 21429 } |
21367 | 21430 |
21368 | 21431 |
21369 THREADED_TEST(FunctionNew) { | 21432 THREADED_TEST(FunctionNew) { |
21370 LocalContext env; | 21433 LocalContext env; |
21371 v8::Isolate* isolate = env->GetIsolate(); | 21434 v8::Isolate* isolate = env->GetIsolate(); |
21372 v8::HandleScope scope(isolate); | 21435 v8::HandleScope scope(isolate); |
21373 Local<Object> data = v8::Object::New(); | 21436 Local<Object> data = v8::Object::New(isolate); |
21374 function_new_expected_env = data; | 21437 function_new_expected_env = data; |
21375 Local<Function> func = Function::New(isolate, FunctionNewCallback, data); | 21438 Local<Function> func = Function::New(isolate, FunctionNewCallback, data); |
21376 env->Global()->Set(v8_str("func"), func); | 21439 env->Global()->Set(v8_str("func"), func); |
21377 Local<Value> result = CompileRun("func();"); | 21440 Local<Value> result = CompileRun("func();"); |
21378 CHECK_EQ(v8::Integer::New(17, isolate), result); | 21441 CHECK_EQ(v8::Integer::New(isolate, 17), result); |
21379 // Verify function not cached | 21442 // Verify function not cached |
21380 int serial_number = | 21443 int serial_number = |
21381 i::Smi::cast(v8::Utils::OpenHandle(*func) | 21444 i::Smi::cast(v8::Utils::OpenHandle(*func) |
21382 ->shared()->get_api_func_data()->serial_number())->value(); | 21445 ->shared()->get_api_func_data()->serial_number())->value(); |
21383 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); | 21446 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
21384 i::Object* elm = i_isolate->native_context()->function_cache() | 21447 i::Object* elm = i_isolate->native_context()->function_cache() |
21385 ->GetElementNoExceptionThrown(i_isolate, serial_number); | 21448 ->GetElementNoExceptionThrown(i_isolate, serial_number); |
21386 CHECK(elm->IsUndefined()); | 21449 CHECK(elm->IsUndefined()); |
21387 // Verify that each Function::New creates a new function instance | 21450 // Verify that each Function::New creates a new function instance |
21388 Local<Object> data2 = v8::Object::New(); | 21451 Local<Object> data2 = v8::Object::New(isolate); |
21389 function_new_expected_env = data2; | 21452 function_new_expected_env = data2; |
21390 Local<Function> func2 = Function::New(isolate, FunctionNewCallback, data2); | 21453 Local<Function> func2 = Function::New(isolate, FunctionNewCallback, data2); |
21391 CHECK(!func2->IsNull()); | 21454 CHECK(!func2->IsNull()); |
21392 CHECK_NE(func, func2); | 21455 CHECK_NE(func, func2); |
21393 env->Global()->Set(v8_str("func2"), func2); | 21456 env->Global()->Set(v8_str("func2"), func2); |
21394 Local<Value> result2 = CompileRun("func2();"); | 21457 Local<Value> result2 = CompileRun("func2();"); |
21395 CHECK_EQ(v8::Integer::New(17, isolate), result2); | 21458 CHECK_EQ(v8::Integer::New(isolate, 17), result2); |
21396 } | 21459 } |
21397 | 21460 |
21398 | 21461 |
21399 TEST(EscapeableHandleScope) { | 21462 TEST(EscapeableHandleScope) { |
21400 HandleScope outer_scope(CcTest::isolate()); | 21463 HandleScope outer_scope(CcTest::isolate()); |
21401 LocalContext context; | 21464 LocalContext context; |
21402 const int runs = 10; | 21465 const int runs = 10; |
21403 Local<String> values[runs]; | 21466 Local<String> values[runs]; |
21404 for (int i = 0; i < runs; i++) { | 21467 for (int i = 0; i < runs; i++) { |
21405 v8::EscapableHandleScope inner_scope(CcTest::isolate()); | 21468 v8::EscapableHandleScope inner_scope(CcTest::isolate()); |
21406 Local<String> value; | 21469 Local<String> value; |
21407 if (i != 0) value = v8_str("escape value"); | 21470 if (i != 0) value = v8_str("escape value"); |
21408 values[i] = inner_scope.Escape(value); | 21471 values[i] = inner_scope.Escape(value); |
21409 } | 21472 } |
21410 for (int i = 0; i < runs; i++) { | 21473 for (int i = 0; i < runs; i++) { |
21411 Local<String> expected; | 21474 Local<String> expected; |
21412 if (i != 0) { | 21475 if (i != 0) { |
21413 CHECK_EQ(v8_str("escape value"), values[i]); | 21476 CHECK_EQ(v8_str("escape value"), values[i]); |
21414 } else { | 21477 } else { |
21415 CHECK(values[i].IsEmpty()); | 21478 CHECK(values[i].IsEmpty()); |
21416 } | 21479 } |
21417 } | 21480 } |
21418 } | 21481 } |
OLD | NEW |