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 10496 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10507 LocalContext env(NULL, instance_template, global_object); | 10507 LocalContext env(NULL, instance_template, global_object); |
10508 Local<Value> value = CompileRun("x"); | 10508 Local<Value> value = CompileRun("x"); |
10509 CHECK_EQ(42, value->Int32Value(env.local()).FromJust()); | 10509 CHECK_EQ(42, value->Int32Value(env.local()).FromJust()); |
10510 value = CompileRun("f()"); | 10510 value = CompileRun("f()"); |
10511 CHECK_EQ(12, value->Int32Value(env.local()).FromJust()); | 10511 CHECK_EQ(12, value->Int32Value(env.local()).FromJust()); |
10512 value = CompileRun(script); | 10512 value = CompileRun(script); |
10513 CHECK_EQ(1, value->Int32Value(env.local()).FromJust()); | 10513 CHECK_EQ(1, value->Int32Value(env.local()).FromJust()); |
10514 } | 10514 } |
10515 } | 10515 } |
10516 | 10516 |
| 10517 THREADED_TEST(ObjectGetOwnPropertyNames) { |
| 10518 LocalContext context; |
| 10519 v8::Isolate* isolate = context->GetIsolate(); |
| 10520 v8::HandleScope handle_scope(isolate); |
| 10521 |
| 10522 v8::Local<v8::Object> value = |
| 10523 v8::Local<v8::Object>::Cast(v8::StringObject::New(v8_str("test"))); |
| 10524 v8::Local<v8::Array> properties; |
| 10525 |
| 10526 CHECK(value |
| 10527 ->GetOwnPropertyNames(context.local(), |
| 10528 static_cast<v8::PropertyFilter>( |
| 10529 v8::PropertyFilter::ALL_PROPERTIES | |
| 10530 v8::PropertyFilter::SKIP_SYMBOLS)) |
| 10531 .ToLocal(&properties)); |
| 10532 CHECK_EQ(5, properties->Length()); |
| 10533 v8::Local<v8::Value> property; |
| 10534 CHECK(properties->Get(context.local(), 4).ToLocal(&property) && |
| 10535 property->IsString()); |
| 10536 CHECK(property.As<v8::String>() |
| 10537 ->Equals(context.local(), v8_str("length")) |
| 10538 .FromMaybe(false)); |
| 10539 for (int i = 0; i < 4; ++i) { |
| 10540 v8::Local<v8::Value> property; |
| 10541 CHECK(properties->Get(context.local(), i).ToLocal(&property) && |
| 10542 property->IsInt32()); |
| 10543 CHECK_EQ(property.As<v8::Int32>()->Value(), i); |
| 10544 } |
| 10545 |
| 10546 CHECK(value->GetOwnPropertyNames(context.local(), v8::ONLY_ENUMERABLE) |
| 10547 .ToLocal(&properties)); |
| 10548 CHECK_EQ(4, properties->Length()); |
| 10549 for (int i = 0; i < 4; ++i) { |
| 10550 v8::Local<v8::Value> property; |
| 10551 CHECK(properties->Get(context.local(), i).ToLocal(&property) && |
| 10552 property->IsInt32()); |
| 10553 CHECK_EQ(property.As<v8::Int32>()->Value(), i); |
| 10554 } |
| 10555 |
| 10556 value = value->GetPrototype().As<v8::Object>(); |
| 10557 CHECK(value |
| 10558 ->GetOwnPropertyNames(context.local(), |
| 10559 static_cast<v8::PropertyFilter>( |
| 10560 v8::PropertyFilter::ALL_PROPERTIES | |
| 10561 v8::PropertyFilter::SKIP_SYMBOLS)) |
| 10562 .ToLocal(&properties)); |
| 10563 bool concat_found = false; |
| 10564 bool starts_with_found = false; |
| 10565 for (int i = 0; i < properties->Length(); ++i) { |
| 10566 v8::Local<v8::Value> property; |
| 10567 CHECK(properties->Get(context.local(), i).ToLocal(&property)); |
| 10568 if (!property->IsString()) continue; |
| 10569 if (!concat_found) |
| 10570 concat_found = property.As<v8::String>() |
| 10571 ->Equals(context.local(), v8_str("concat")) |
| 10572 .FromMaybe(false); |
| 10573 if (!starts_with_found) |
| 10574 starts_with_found = property.As<v8::String>() |
| 10575 ->Equals(context.local(), v8_str("startsWith")) |
| 10576 .FromMaybe(false); |
| 10577 } |
| 10578 CHECK(concat_found && starts_with_found); |
| 10579 } |
10517 | 10580 |
10518 THREADED_TEST(CallKnownGlobalReceiver) { | 10581 THREADED_TEST(CallKnownGlobalReceiver) { |
10519 v8::Isolate* isolate = CcTest::isolate(); | 10582 v8::Isolate* isolate = CcTest::isolate(); |
10520 v8::HandleScope handle_scope(isolate); | 10583 v8::HandleScope handle_scope(isolate); |
10521 | 10584 |
10522 Local<Value> global_object; | 10585 Local<Value> global_object; |
10523 | 10586 |
10524 Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New(isolate); | 10587 Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New(isolate); |
10525 Local<ObjectTemplate> instance_template = t->InstanceTemplate(); | 10588 Local<ObjectTemplate> instance_template = t->InstanceTemplate(); |
10526 | 10589 |
(...skipping 14493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
25020 } | 25083 } |
25021 | 25084 |
25022 TEST(PrivateForApiIsNumber) { | 25085 TEST(PrivateForApiIsNumber) { |
25023 LocalContext context; | 25086 LocalContext context; |
25024 v8::Isolate* isolate = CcTest::isolate(); | 25087 v8::Isolate* isolate = CcTest::isolate(); |
25025 v8::HandleScope scope(isolate); | 25088 v8::HandleScope scope(isolate); |
25026 | 25089 |
25027 // Shouldn't crash. | 25090 // Shouldn't crash. |
25028 v8::Private::ForApi(isolate, v8_str("42")); | 25091 v8::Private::ForApi(isolate, v8_str("42")); |
25029 } | 25092 } |
OLD | NEW |