From: whesse@chromium.org Date: Mon, 6 Sep 2010 12:54:41 +0000 (+0000) Subject: Add test for calls to native runtime functions in extensions. X-Git-Tag: upstream/4.7.83~21239 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=119f630b67215ef996d6ef1dfaef4b0ac586a2c1;p=platform%2Fupstream%2Fv8.git Add test for calls to native runtime functions in extensions. Review URL: http://codereview.chromium.org/3356007 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@5415 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc index 4b6fa9c..1406f56 100644 --- a/test/cctest/test-api.cc +++ b/test/cctest/test-api.cc @@ -3605,6 +3605,29 @@ THREADED_TEST(ExceptionExtensions) { } +static const char* kNativeCallInExtensionSource = + "function call_runtime_last_index_of(x) {" + " return %StringLastIndexOf(x, 'bob', 10);" + "}"; + + +static const char* kNativeCallTest = + "call_runtime_last_index_of('bobbobboellebobboellebobbob');"; + +// Test that a native runtime calls are supported in extensions. +THREADED_TEST(NativeCallInExtensions) { + v8::HandleScope handle_scope; + v8::RegisterExtension(new Extension("nativecall", + kNativeCallInExtensionSource)); + const char* extension_names[] = { "nativecall" }; + v8::ExtensionConfiguration extensions(1, extension_names); + v8::Handle context = Context::New(&extensions); + Context::Scope lock(context); + v8::Handle result = Script::Compile(v8_str(kNativeCallTest))->Run(); + CHECK_EQ(result, v8::Integer::New(3)); +} + + static void CheckDependencies(const char* name, const char* expected) { v8::HandleScope handle_scope; v8::ExtensionConfiguration config(1, &name);