OLD | NEW |
1 // Copyright 2007-2009 the V8 project authors. All rights reserved. | 1 // Copyright 2007-2009 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 3587 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3598 v8::HandleScope handle_scope; | 3598 v8::HandleScope handle_scope; |
3599 v8::RegisterExtension(new Extension("exception", | 3599 v8::RegisterExtension(new Extension("exception", |
3600 kExceptionInExtensionSource)); | 3600 kExceptionInExtensionSource)); |
3601 const char* extension_names[] = { "exception" }; | 3601 const char* extension_names[] = { "exception" }; |
3602 v8::ExtensionConfiguration extensions(1, extension_names); | 3602 v8::ExtensionConfiguration extensions(1, extension_names); |
3603 v8::Handle<Context> context = Context::New(&extensions); | 3603 v8::Handle<Context> context = Context::New(&extensions); |
3604 CHECK(context.IsEmpty()); | 3604 CHECK(context.IsEmpty()); |
3605 } | 3605 } |
3606 | 3606 |
3607 | 3607 |
| 3608 static const char* kNativeCallInExtensionSource = |
| 3609 "function call_runtime_last_index_of(x) {" |
| 3610 " return %StringLastIndexOf(x, 'bob', 10);" |
| 3611 "}"; |
| 3612 |
| 3613 |
| 3614 static const char* kNativeCallTest = |
| 3615 "call_runtime_last_index_of('bobbobboellebobboellebobbob');"; |
| 3616 |
| 3617 // Test that a native runtime calls are supported in extensions. |
| 3618 THREADED_TEST(NativeCallInExtensions) { |
| 3619 v8::HandleScope handle_scope; |
| 3620 v8::RegisterExtension(new Extension("nativecall", |
| 3621 kNativeCallInExtensionSource)); |
| 3622 const char* extension_names[] = { "nativecall" }; |
| 3623 v8::ExtensionConfiguration extensions(1, extension_names); |
| 3624 v8::Handle<Context> context = Context::New(&extensions); |
| 3625 Context::Scope lock(context); |
| 3626 v8::Handle<Value> result = Script::Compile(v8_str(kNativeCallTest))->Run(); |
| 3627 CHECK_EQ(result, v8::Integer::New(3)); |
| 3628 } |
| 3629 |
| 3630 |
3608 static void CheckDependencies(const char* name, const char* expected) { | 3631 static void CheckDependencies(const char* name, const char* expected) { |
3609 v8::HandleScope handle_scope; | 3632 v8::HandleScope handle_scope; |
3610 v8::ExtensionConfiguration config(1, &name); | 3633 v8::ExtensionConfiguration config(1, &name); |
3611 LocalContext context(&config); | 3634 LocalContext context(&config); |
3612 CHECK_EQ(String::New(expected), context->Global()->Get(v8_str("loaded"))); | 3635 CHECK_EQ(String::New(expected), context->Global()->Get(v8_str("loaded"))); |
3613 } | 3636 } |
3614 | 3637 |
3615 | 3638 |
3616 /* | 3639 /* |
3617 * Configuration: | 3640 * Configuration: |
(...skipping 7662 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11280 ExpectFalse("Object.prototype.hasOwnProperty.call(other, \'0\')"); | 11303 ExpectFalse("Object.prototype.hasOwnProperty.call(other, \'0\')"); |
11281 | 11304 |
11282 CHECK_EQ(false, global0->HasRealIndexedProperty(0)); | 11305 CHECK_EQ(false, global0->HasRealIndexedProperty(0)); |
11283 CHECK_EQ(false, global0->HasRealNamedProperty(v8_str("x"))); | 11306 CHECK_EQ(false, global0->HasRealNamedProperty(v8_str("x"))); |
11284 CHECK_EQ(false, global0->HasRealNamedCallbackProperty(v8_str("x"))); | 11307 CHECK_EQ(false, global0->HasRealNamedCallbackProperty(v8_str("x"))); |
11285 | 11308 |
11286 // Reset the failed access check callback so it does not influence | 11309 // Reset the failed access check callback so it does not influence |
11287 // the other tests. | 11310 // the other tests. |
11288 v8::V8::SetFailedAccessCheckCallbackFunction(NULL); | 11311 v8::V8::SetFailedAccessCheckCallbackFunction(NULL); |
11289 } | 11312 } |
OLD | NEW |