Index: test/cctest/test-api.cc |
diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc |
index fe577457b0ec992d0edde5420ac7ee67c97e34f8..dccb046e800304d4609b9dedf6e6bb34278c7f2c 100644 |
--- a/test/cctest/test-api.cc |
+++ b/test/cctest/test-api.cc |
@@ -24169,6 +24169,37 @@ static void ExtrasBindingTestRuntimeFunction( |
args.GetReturnValue().Set(v8_num(7)); |
} |
+TEST(ExtrasFunctionSource) { |
+ v8::Isolate* isolate = CcTest::isolate(); |
+ v8::HandleScope handle_scope(isolate); |
+ LocalContext env; |
+ |
+ v8::Local<v8::Object> binding = env->GetExtrasBindingObject(); |
+ |
+ // Functions defined in extras do not expose source code. |
+ auto func = binding->Get(env.local(), v8_str("testFunctionToString")) |
+ .ToLocalChecked() |
+ .As<v8::Function>(); |
+ auto undefined = v8::Undefined(isolate); |
+ auto result = func->Call(env.local(), undefined, 0, {}) |
+ .ToLocalChecked() |
+ .As<v8::String>(); |
+ CHECK(result->StrictEquals(v8_str("function foo() { [native code] }"))); |
+ |
+ // Functions defined in extras do not show up in the stack trace. |
+ auto wrapper = binding->Get(env.local(), v8_str("testStackTrace")) |
+ .ToLocalChecked() |
+ .As<v8::Function>(); |
+ CHECK(env->Global()->Set(env.local(), v8_str("wrapper"), wrapper).FromJust()); |
+ ExpectString( |
+ "function f(x) { return wrapper(x) }" |
+ "function g() { return new Error().stack; }" |
+ "f(g)", |
+ "Error\n" |
+ " at g (<anonymous>:1:58)\n" |
+ " at f (<anonymous>:1:24)\n" |
+ " at <anonymous>:1:78"); |
+} |
TEST(ExtrasBindingObject) { |
v8::Isolate* isolate = CcTest::isolate(); |