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 4653 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4664 v8::RegisterExtension(new Extension("simpletest", kSimpleExtensionSource)); | 4664 v8::RegisterExtension(new Extension("simpletest", kSimpleExtensionSource)); |
4665 const char* extension_names[] = { "simpletest" }; | 4665 const char* extension_names[] = { "simpletest" }; |
4666 v8::ExtensionConfiguration extensions(1, extension_names); | 4666 v8::ExtensionConfiguration extensions(1, extension_names); |
4667 v8::Handle<Context> context = Context::New(&extensions); | 4667 v8::Handle<Context> context = Context::New(&extensions); |
4668 Context::Scope lock(context); | 4668 Context::Scope lock(context); |
4669 v8::Handle<Value> result = Script::Compile(v8_str("Foo()"))->Run(); | 4669 v8::Handle<Value> result = Script::Compile(v8_str("Foo()"))->Run(); |
4670 CHECK_EQ(result, v8::Integer::New(4)); | 4670 CHECK_EQ(result, v8::Integer::New(4)); |
4671 } | 4671 } |
4672 | 4672 |
4673 | 4673 |
| 4674 THREADED_TEST(NullExtensions) { |
| 4675 v8::HandleScope handle_scope; |
| 4676 v8::RegisterExtension(new Extension("nulltest", NULL)); |
| 4677 const char* extension_names[] = { "nulltest" }; |
| 4678 v8::ExtensionConfiguration extensions(1, extension_names); |
| 4679 v8::Handle<Context> context = Context::New(&extensions); |
| 4680 Context::Scope lock(context); |
| 4681 v8::Handle<Value> result = Script::Compile(v8_str("1+3"))->Run(); |
| 4682 CHECK_EQ(result, v8::Integer::New(4)); |
| 4683 } |
| 4684 |
| 4685 |
4674 static const char* kEmbeddedExtensionSource = | 4686 static const char* kEmbeddedExtensionSource = |
4675 "function Ret54321(){return 54321;}~~@@$" | 4687 "function Ret54321(){return 54321;}~~@@$" |
4676 "$%% THIS IS A SERIES OF NON-NULL-TERMINATED STRINGS."; | 4688 "$%% THIS IS A SERIES OF NON-NULL-TERMINATED STRINGS."; |
4677 static const int kEmbeddedExtensionSourceValidLen = 34; | 4689 static const int kEmbeddedExtensionSourceValidLen = 34; |
4678 | 4690 |
4679 | 4691 |
4680 THREADED_TEST(ExtensionMissingSourceLength) { | 4692 THREADED_TEST(ExtensionMissingSourceLength) { |
4681 v8::HandleScope handle_scope; | 4693 v8::HandleScope handle_scope; |
4682 v8::RegisterExtension(new Extension("srclentest_fail", | 4694 v8::RegisterExtension(new Extension("srclentest_fail", |
4683 kEmbeddedExtensionSource)); | 4695 kEmbeddedExtensionSource)); |
(...skipping 9320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
14004 ExternalArrayInfoTestHelper(v8::kExternalShortArray); | 14016 ExternalArrayInfoTestHelper(v8::kExternalShortArray); |
14005 ExternalArrayInfoTestHelper(v8::kExternalUnsignedShortArray); | 14017 ExternalArrayInfoTestHelper(v8::kExternalUnsignedShortArray); |
14006 ExternalArrayInfoTestHelper(v8::kExternalIntArray); | 14018 ExternalArrayInfoTestHelper(v8::kExternalIntArray); |
14007 ExternalArrayInfoTestHelper(v8::kExternalUnsignedIntArray); | 14019 ExternalArrayInfoTestHelper(v8::kExternalUnsignedIntArray); |
14008 ExternalArrayInfoTestHelper(v8::kExternalFloatArray); | 14020 ExternalArrayInfoTestHelper(v8::kExternalFloatArray); |
14009 ExternalArrayInfoTestHelper(v8::kExternalDoubleArray); | 14021 ExternalArrayInfoTestHelper(v8::kExternalDoubleArray); |
14010 ExternalArrayInfoTestHelper(v8::kExternalPixelArray); | 14022 ExternalArrayInfoTestHelper(v8::kExternalPixelArray); |
14011 } | 14023 } |
14012 | 14024 |
14013 | 14025 |
| 14026 void ExternalArrayLimitTestHelper(v8::ExternalArrayType array_type, int size) { |
| 14027 v8::Handle<v8::Object> obj = v8::Object::New(); |
| 14028 v8::V8::SetFatalErrorHandler(StoringErrorCallback); |
| 14029 last_location = last_message = NULL; |
| 14030 obj->SetIndexedPropertiesToExternalArrayData(NULL, array_type, size); |
| 14031 CHECK(!obj->HasIndexedPropertiesInExternalArrayData()); |
| 14032 CHECK_NE(NULL, last_location); |
| 14033 CHECK_NE(NULL, last_message); |
| 14034 } |
| 14035 |
| 14036 |
| 14037 TEST(ExternalArrayLimits) { |
| 14038 v8::HandleScope scope; |
| 14039 LocalContext context; |
| 14040 ExternalArrayLimitTestHelper(v8::kExternalByteArray, 0x40000000); |
| 14041 ExternalArrayLimitTestHelper(v8::kExternalByteArray, 0xffffffff); |
| 14042 ExternalArrayLimitTestHelper(v8::kExternalUnsignedByteArray, 0x40000000); |
| 14043 ExternalArrayLimitTestHelper(v8::kExternalUnsignedByteArray, 0xffffffff); |
| 14044 ExternalArrayLimitTestHelper(v8::kExternalShortArray, 0x40000000); |
| 14045 ExternalArrayLimitTestHelper(v8::kExternalShortArray, 0xffffffff); |
| 14046 ExternalArrayLimitTestHelper(v8::kExternalUnsignedShortArray, 0x40000000); |
| 14047 ExternalArrayLimitTestHelper(v8::kExternalUnsignedShortArray, 0xffffffff); |
| 14048 ExternalArrayLimitTestHelper(v8::kExternalIntArray, 0x40000000); |
| 14049 ExternalArrayLimitTestHelper(v8::kExternalIntArray, 0xffffffff); |
| 14050 ExternalArrayLimitTestHelper(v8::kExternalUnsignedIntArray, 0x40000000); |
| 14051 ExternalArrayLimitTestHelper(v8::kExternalUnsignedIntArray, 0xffffffff); |
| 14052 ExternalArrayLimitTestHelper(v8::kExternalFloatArray, 0x40000000); |
| 14053 ExternalArrayLimitTestHelper(v8::kExternalFloatArray, 0xffffffff); |
| 14054 ExternalArrayLimitTestHelper(v8::kExternalDoubleArray, 0x40000000); |
| 14055 ExternalArrayLimitTestHelper(v8::kExternalDoubleArray, 0xffffffff); |
| 14056 ExternalArrayLimitTestHelper(v8::kExternalPixelArray, 0x40000000); |
| 14057 ExternalArrayLimitTestHelper(v8::kExternalPixelArray, 0xffffffff); |
| 14058 } |
| 14059 |
| 14060 |
14014 THREADED_TEST(ScriptContextDependence) { | 14061 THREADED_TEST(ScriptContextDependence) { |
14015 v8::HandleScope scope; | 14062 v8::HandleScope scope; |
14016 LocalContext c1; | 14063 LocalContext c1; |
14017 const char *source = "foo"; | 14064 const char *source = "foo"; |
14018 v8::Handle<v8::Script> dep = v8::Script::Compile(v8::String::New(source)); | 14065 v8::Handle<v8::Script> dep = v8::Script::Compile(v8::String::New(source)); |
14019 v8::Handle<v8::Script> indep = v8::Script::New(v8::String::New(source)); | 14066 v8::Handle<v8::Script> indep = v8::Script::New(v8::String::New(source)); |
14020 c1->Global()->Set(v8::String::New("foo"), v8::Integer::New(100)); | 14067 c1->Global()->Set(v8::String::New("foo"), v8::Integer::New(100)); |
14021 CHECK_EQ(dep->Run()->Int32Value(), 100); | 14068 CHECK_EQ(dep->Run()->Int32Value(), 100); |
14022 CHECK_EQ(indep->Run()->Int32Value(), 100); | 14069 CHECK_EQ(indep->Run()->Int32Value(), 100); |
14023 LocalContext c2; | 14070 LocalContext c2; |
(...skipping 3420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
17444 | 17491 |
17445 i::Semaphore* sem_; | 17492 i::Semaphore* sem_; |
17446 volatile int sem_value_; | 17493 volatile int sem_value_; |
17447 }; | 17494 }; |
17448 | 17495 |
17449 | 17496 |
17450 THREADED_TEST(SemaphoreInterruption) { | 17497 THREADED_TEST(SemaphoreInterruption) { |
17451 ThreadInterruptTest().RunTest(); | 17498 ThreadInterruptTest().RunTest(); |
17452 } | 17499 } |
17453 #endif // WIN32 | 17500 #endif // WIN32 |
OLD | NEW |