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

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

Issue 655243002: Introduce v8::Exception::GetStackTrace API method. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: added test Created 6 years, 2 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
« no previous file with comments | « src/api.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/test-api.cc
diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc
index b458418f43a66147a814dbd669ec58b1043f88c4..1c67e1ff9555753d6f2aa959edcd4cb269e45bbf 100644
--- a/test/cctest/test-api.cc
+++ b/test/cctest/test-api.cc
@@ -8504,6 +8504,47 @@ THREADED_TEST(ErrorConstruction) {
}
+static void ThrowV8Exception(const v8::FunctionCallbackInfo<v8::Value>& info) {
+ ApiTestFuzzer::Fuzz();
+ v8::Handle<String> foo = v8_str("foo");
+ v8::Handle<String> message = v8_str("message");
+ v8::Handle<Value> error = v8::Exception::Error(foo);
+ CHECK(error->IsObject());
+ CHECK(error.As<v8::Object>()->Get(message)->Equals(foo));
+ info.GetIsolate()->ThrowException(error);
+ info.GetReturnValue().SetUndefined();
+}
+
+
+THREADED_TEST(ExceptionGetStackTrace) {
+ LocalContext context;
+ v8::HandleScope scope(context->GetIsolate());
+
+ v8::V8::SetCaptureStackTraceForUncaughtExceptions(true);
+
+ Local<v8::FunctionTemplate> fun =
+ v8::FunctionTemplate::New(context->GetIsolate(), ThrowV8Exception);
+ v8::Local<v8::Object> global = context->Global();
+ global->Set(v8_str("throwV8Exception"), fun->GetFunction());
+
+ TryCatch try_catch;
+ CompileRun("function f1() { throwV8Exception(); }; f1();");
+ CHECK(try_catch.HasCaught());
+
+ v8::Handle<v8::Value> error = try_catch.Exception();
+ v8::Handle<String> foo = v8_str("foo");
+ v8::Handle<String> message = v8_str("message");
+ CHECK(error->IsObject());
+ CHECK(error.As<v8::Object>()->Get(message)->Equals(foo));
+
+ v8::Handle<v8::StackTrace> stackTrace = v8::Exception::GetStackTrace(error);
+ CHECK(!stackTrace.IsEmpty());
+ CHECK_EQ(2, stackTrace->GetFrameCount());
+
+ v8::V8::SetCaptureStackTraceForUncaughtExceptions(false);
+}
+
+
static void YGetter(Local<String> name,
const v8::PropertyCallbackInfo<v8::Value>& info) {
ApiTestFuzzer::Fuzz();
« no previous file with comments | « src/api.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698