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

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

Issue 687253002: Introduce v8::Exception::GetMessage to find location of an error object. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: relanding 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/isolate.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 11393f097ef71be37efbba73753ac9dc362ac6ab..da594881bf5c19284b62a96fb5b201a55060aa3e 100644
--- a/test/cctest/test-api.cc
+++ b/test/cctest/test-api.cc
@@ -8547,7 +8547,7 @@ static void ThrowV8Exception(const v8::FunctionCallbackInfo<v8::Value>& info) {
}
-THREADED_TEST(ExceptionGetStackTrace) {
+THREADED_TEST(ExceptionGetMessage) {
LocalContext context;
v8::HandleScope scope(context->GetIsolate());
@@ -8559,16 +8559,25 @@ THREADED_TEST(ExceptionGetStackTrace) {
global->Set(v8_str("throwV8Exception"), fun->GetFunction());
TryCatch try_catch;
- CompileRun("function f1() { throwV8Exception(); }; f1();");
+ CompileRun(
+ "function f1() {\n"
+ " throwV8Exception();\n"
+ "};\n"
+ "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");
+ v8::Handle<String> foo_str = v8_str("foo");
+ v8::Handle<String> message_str = v8_str("message");
CHECK(error->IsObject());
- CHECK(error.As<v8::Object>()->Get(message)->Equals(foo));
+ CHECK(error.As<v8::Object>()->Get(message_str)->Equals(foo_str));
+
+ v8::Handle<v8::Message> message = v8::Exception::GetMessage(error);
+ CHECK(!message.IsEmpty());
+ CHECK_EQ(2, message->GetLineNumber());
+ CHECK_EQ(2, message->GetStartColumn());
- v8::Handle<v8::StackTrace> stackTrace = v8::Exception::GetStackTrace(error);
+ v8::Handle<v8::StackTrace> stackTrace = message->GetStackTrace();
CHECK(!stackTrace.IsEmpty());
CHECK_EQ(2, stackTrace->GetFrameCount());
@@ -17873,7 +17882,8 @@ void PromiseRejectCallback(v8::PromiseRejectMessage message) {
promise_reject_counter++;
CcTest::global()->Set(v8_str("rejected"), message.GetPromise());
CcTest::global()->Set(v8_str("value"), message.GetValue());
- v8::Handle<v8::StackTrace> stack_trace = message.GetStackTrace();
+ v8::Handle<v8::StackTrace> stack_trace =
+ v8::Exception::GetMessage(message.GetValue())->GetStackTrace();
if (!stack_trace.IsEmpty()) {
promise_reject_frame_count = stack_trace->GetFrameCount();
if (promise_reject_frame_count > 0) {
@@ -17887,7 +17897,6 @@ void PromiseRejectCallback(v8::PromiseRejectMessage message) {
promise_revoke_counter++;
CcTest::global()->Set(v8_str("revoked"), message.GetPromise());
CHECK(message.GetValue().IsEmpty());
- CHECK(message.GetStackTrace().IsEmpty());
}
}
« no previous file with comments | « src/isolate.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698