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 4113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4124 CHECK_EQ(v8_num(4), xValue); | 4124 CHECK_EQ(v8_num(4), xValue); |
4125 xValue.Dispose(context->GetIsolate()); | 4125 xValue.Dispose(context->GetIsolate()); |
4126 xValue = v8::Persistent<Value>(); | 4126 xValue = v8::Persistent<Value>(); |
4127 } | 4127 } |
4128 } | 4128 } |
4129 | 4129 |
4130 | 4130 |
4131 THREADED_TEST(NoAccessors) { | 4131 THREADED_TEST(NoAccessors) { |
4132 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 4132 v8::HandleScope scope(v8::Isolate::GetCurrent()); |
4133 Local<ObjectTemplate> templ = ObjectTemplate::New(); | 4133 Local<ObjectTemplate> templ = ObjectTemplate::New(); |
4134 templ->SetAccessor(v8_str("x"), NULL, NULL, v8_str("donut")); | 4134 templ->SetAccessor(v8_str("x"), |
| 4135 static_cast<v8::AccessorGetter>(NULL), |
| 4136 NULL, |
| 4137 v8_str("donut")); |
4135 LocalContext context; | 4138 LocalContext context; |
4136 context->Global()->Set(v8_str("obj"), templ->NewInstance()); | 4139 context->Global()->Set(v8_str("obj"), templ->NewInstance()); |
4137 Local<Script> script = Script::Compile(v8_str("obj.x = 4; obj.x")); | 4140 Local<Script> script = Script::Compile(v8_str("obj.x = 4; obj.x")); |
4138 for (int i = 0; i < 10; i++) { | 4141 for (int i = 0; i < 10; i++) { |
4139 script->Run(); | 4142 script->Run(); |
4140 } | 4143 } |
4141 } | 4144 } |
4142 | 4145 |
4143 | 4146 |
4144 static v8::Handle<Value> XPropertyGetter(Local<String> property, | 4147 static v8::Handle<Value> XPropertyGetter(Local<String> property, |
(...skipping 640 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4785 LocalContext env1; | 4788 LocalContext env1; |
4786 Local<Script> script1 = Script::Compile(source); | 4789 Local<Script> script1 = Script::Compile(source); |
4787 CHECK_EQ(8901.0, script1->Run()->NumberValue()); | 4790 CHECK_EQ(8901.0, script1->Run()->NumberValue()); |
4788 } | 4791 } |
4789 | 4792 |
4790 | 4793 |
4791 THREADED_TEST(UndetectableObject) { | 4794 THREADED_TEST(UndetectableObject) { |
4792 LocalContext env; | 4795 LocalContext env; |
4793 v8::HandleScope scope(env->GetIsolate()); | 4796 v8::HandleScope scope(env->GetIsolate()); |
4794 | 4797 |
4795 Local<v8::FunctionTemplate> desc = | 4798 Local<v8::FunctionTemplate> desc = v8::FunctionTemplate::New(); |
4796 v8::FunctionTemplate::New(0, v8::Handle<Value>()); | |
4797 desc->InstanceTemplate()->MarkAsUndetectable(); // undetectable | 4799 desc->InstanceTemplate()->MarkAsUndetectable(); // undetectable |
4798 | 4800 |
4799 Local<v8::Object> obj = desc->GetFunction()->NewInstance(); | 4801 Local<v8::Object> obj = desc->GetFunction()->NewInstance(); |
4800 env->Global()->Set(v8_str("undetectable"), obj); | 4802 env->Global()->Set(v8_str("undetectable"), obj); |
4801 | 4803 |
4802 ExpectString("undetectable.toString()", "[object Object]"); | 4804 ExpectString("undetectable.toString()", "[object Object]"); |
4803 ExpectString("typeof undetectable", "undefined"); | 4805 ExpectString("typeof undetectable", "undefined"); |
4804 ExpectString("typeof(undetectable)", "undefined"); | 4806 ExpectString("typeof(undetectable)", "undefined"); |
4805 ExpectBoolean("typeof undetectable == 'undefined'", true); | 4807 ExpectBoolean("typeof undetectable == 'undefined'", true); |
4806 ExpectBoolean("typeof undetectable == 'object'", false); | 4808 ExpectBoolean("typeof undetectable == 'object'", false); |
(...skipping 22 matching lines...) Expand all Loading... |
4829 ExpectBoolean("undetectable===undefined", false); | 4831 ExpectBoolean("undetectable===undefined", false); |
4830 ExpectBoolean("undefined===undetectable", false); | 4832 ExpectBoolean("undefined===undetectable", false); |
4831 ExpectBoolean("undetectable===undetectable", true); | 4833 ExpectBoolean("undetectable===undetectable", true); |
4832 } | 4834 } |
4833 | 4835 |
4834 | 4836 |
4835 THREADED_TEST(VoidLiteral) { | 4837 THREADED_TEST(VoidLiteral) { |
4836 LocalContext env; | 4838 LocalContext env; |
4837 v8::HandleScope scope(env->GetIsolate()); | 4839 v8::HandleScope scope(env->GetIsolate()); |
4838 | 4840 |
4839 Local<v8::FunctionTemplate> desc = | 4841 Local<v8::FunctionTemplate> desc = v8::FunctionTemplate::New(); |
4840 v8::FunctionTemplate::New(0, v8::Handle<Value>()); | |
4841 desc->InstanceTemplate()->MarkAsUndetectable(); // undetectable | 4842 desc->InstanceTemplate()->MarkAsUndetectable(); // undetectable |
4842 | 4843 |
4843 Local<v8::Object> obj = desc->GetFunction()->NewInstance(); | 4844 Local<v8::Object> obj = desc->GetFunction()->NewInstance(); |
4844 env->Global()->Set(v8_str("undetectable"), obj); | 4845 env->Global()->Set(v8_str("undetectable"), obj); |
4845 | 4846 |
4846 ExpectBoolean("undefined == void 0", true); | 4847 ExpectBoolean("undefined == void 0", true); |
4847 ExpectBoolean("undetectable == void 0", true); | 4848 ExpectBoolean("undetectable == void 0", true); |
4848 ExpectBoolean("null == void 0", true); | 4849 ExpectBoolean("null == void 0", true); |
4849 ExpectBoolean("undefined === void 0", true); | 4850 ExpectBoolean("undefined === void 0", true); |
4850 ExpectBoolean("undetectable === void 0", false); | 4851 ExpectBoolean("undetectable === void 0", false); |
(...skipping 22 matching lines...) Expand all Loading... |
4873 " }" | 4874 " }" |
4874 "})()", | 4875 "})()", |
4875 "ReferenceError: x is not defined"); | 4876 "ReferenceError: x is not defined"); |
4876 } | 4877 } |
4877 | 4878 |
4878 | 4879 |
4879 THREADED_TEST(ExtensibleOnUndetectable) { | 4880 THREADED_TEST(ExtensibleOnUndetectable) { |
4880 LocalContext env; | 4881 LocalContext env; |
4881 v8::HandleScope scope(env->GetIsolate()); | 4882 v8::HandleScope scope(env->GetIsolate()); |
4882 | 4883 |
4883 Local<v8::FunctionTemplate> desc = | 4884 Local<v8::FunctionTemplate> desc = v8::FunctionTemplate::New(); |
4884 v8::FunctionTemplate::New(0, v8::Handle<Value>()); | |
4885 desc->InstanceTemplate()->MarkAsUndetectable(); // undetectable | 4885 desc->InstanceTemplate()->MarkAsUndetectable(); // undetectable |
4886 | 4886 |
4887 Local<v8::Object> obj = desc->GetFunction()->NewInstance(); | 4887 Local<v8::Object> obj = desc->GetFunction()->NewInstance(); |
4888 env->Global()->Set(v8_str("undetectable"), obj); | 4888 env->Global()->Set(v8_str("undetectable"), obj); |
4889 | 4889 |
4890 Local<String> source = v8_str("undetectable.x = 42;" | 4890 Local<String> source = v8_str("undetectable.x = 42;" |
4891 "undetectable.x"); | 4891 "undetectable.x"); |
4892 | 4892 |
4893 Local<Script> script = Script::Compile(source); | 4893 Local<Script> script = Script::Compile(source); |
4894 | 4894 |
(...skipping 5786 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10681 "};" | 10681 "};" |
10682 "f();"); | 10682 "f();"); |
10683 CHECK_EQ(true, value->BooleanValue()); | 10683 CHECK_EQ(true, value->BooleanValue()); |
10684 } | 10684 } |
10685 | 10685 |
10686 | 10686 |
10687 // Test that we ignore null interceptors. | 10687 // Test that we ignore null interceptors. |
10688 THREADED_TEST(NullNamedInterceptor) { | 10688 THREADED_TEST(NullNamedInterceptor) { |
10689 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 10689 v8::HandleScope scope(v8::Isolate::GetCurrent()); |
10690 v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New(); | 10690 v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New(); |
10691 templ->SetNamedPropertyHandler(0); | 10691 templ->SetNamedPropertyHandler(static_cast<v8::NamedPropertyGetter>(0)); |
10692 LocalContext context; | 10692 LocalContext context; |
10693 templ->Set("x", v8_num(42)); | 10693 templ->Set("x", v8_num(42)); |
10694 v8::Handle<v8::Object> obj = templ->NewInstance(); | 10694 v8::Handle<v8::Object> obj = templ->NewInstance(); |
10695 context->Global()->Set(v8_str("obj"), obj); | 10695 context->Global()->Set(v8_str("obj"), obj); |
10696 v8::Handle<Value> value = CompileRun("obj.x"); | 10696 v8::Handle<Value> value = CompileRun("obj.x"); |
10697 CHECK(value->IsInt32()); | 10697 CHECK(value->IsInt32()); |
10698 CHECK_EQ(42, value->Int32Value()); | 10698 CHECK_EQ(42, value->Int32Value()); |
10699 } | 10699 } |
10700 | 10700 |
10701 | 10701 |
10702 // Test that we ignore null interceptors. | 10702 // Test that we ignore null interceptors. |
10703 THREADED_TEST(NullIndexedInterceptor) { | 10703 THREADED_TEST(NullIndexedInterceptor) { |
10704 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 10704 v8::HandleScope scope(v8::Isolate::GetCurrent()); |
10705 v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New(); | 10705 v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New(); |
10706 templ->SetIndexedPropertyHandler(0); | 10706 templ->SetIndexedPropertyHandler(static_cast<v8::IndexedPropertyGetter>(0)); |
10707 LocalContext context; | 10707 LocalContext context; |
10708 templ->Set("42", v8_num(42)); | 10708 templ->Set("42", v8_num(42)); |
10709 v8::Handle<v8::Object> obj = templ->NewInstance(); | 10709 v8::Handle<v8::Object> obj = templ->NewInstance(); |
10710 context->Global()->Set(v8_str("obj"), obj); | 10710 context->Global()->Set(v8_str("obj"), obj); |
10711 v8::Handle<Value> value = CompileRun("obj[42]"); | 10711 v8::Handle<Value> value = CompileRun("obj[42]"); |
10712 CHECK(value->IsInt32()); | 10712 CHECK(value->IsInt32()); |
10713 CHECK_EQ(42, value->Int32Value()); | 10713 CHECK_EQ(42, value->Int32Value()); |
10714 } | 10714 } |
10715 | 10715 |
10716 | 10716 |
(...skipping 7600 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
18317 i::Semaphore* sem_; | 18317 i::Semaphore* sem_; |
18318 volatile int sem_value_; | 18318 volatile int sem_value_; |
18319 }; | 18319 }; |
18320 | 18320 |
18321 | 18321 |
18322 THREADED_TEST(SemaphoreInterruption) { | 18322 THREADED_TEST(SemaphoreInterruption) { |
18323 ThreadInterruptTest().RunTest(); | 18323 ThreadInterruptTest().RunTest(); |
18324 } | 18324 } |
18325 | 18325 |
18326 #endif // WIN32 | 18326 #endif // WIN32 |
OLD | NEW |