Index: test/cctest/test-api.cc |
diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc |
index c5de6715a7baca68a7a98aeed83e7b0f0d4a7d65..19b0c47330a04e639d4bd8602bc1475486803ce9 100644 |
--- a/test/cctest/test-api.cc |
+++ b/test/cctest/test-api.cc |
@@ -16768,3 +16768,46 @@ THREADED_TEST(InstanceCheckOnPrototypeAccessor) { |
CHECK(templ->HasInstance(context->Global()->Get(v8_str("obj")))); |
CheckInstanceCheckedAccessors(true); |
} |
+ |
+ |
+TEST(TryFinallyMessage) { |
+ v8::HandleScope scope; |
+ LocalContext context; |
+ { |
+ // Test that the original error message is not lost if there is a |
+ // recursive call into Javascript is done in the finally block, e.g. to |
+ // initialize an IC. (crbug.com/129171) |
+ TryCatch try_catch; |
+ const char* trigger_ic = |
+ "try { \n" |
+ " throw new Error('test'); \n" |
+ "} finally { \n" |
+ " var x = 0; \n" |
+ " x++; \n" // Trigger an IC initialization here. |
+ "} \n"; |
+ Local<Value> result = CompileRun(trigger_ic); |
+ CHECK(try_catch.HasCaught()); |
+ Local<Message> message = try_catch.Message(); |
+ CHECK(!message.IsEmpty()); |
+ CHECK_EQ(2, message->GetLineNumber()); |
+ } |
+ |
+ { |
+ // Test that the original exception message is indeed overwritten if |
+ // a new error is thrown in the finally block. |
+ TryCatch try_catch; |
+ const char* throw_again = |
+ "try { \n" |
+ " throw new Error('test'); \n" |
+ "} finally { \n" |
+ " var x = 0; \n" |
+ " x++; \n" |
+ " throw new Error('again'); \n" // This is the new uncaught error. |
+ "} \n"; |
+ Local<Value> result = CompileRun(throw_again); |
+ CHECK(try_catch.HasCaught()); |
+ Local<Message> message = try_catch.Message(); |
+ CHECK(!message.IsEmpty()); |
+ CHECK_EQ(6, message->GetLineNumber()); |
+ } |
+} |