Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(61)

Unified Diff: test/cctest/test-api.cc

Issue 1670923003: [bootstrapper] extra natives must not use natives syntax. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: fix test Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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();
« src/globals.h ('K') | « src/runtime/runtime-test.cc ('k') | test/cctest/test-extra.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698