Index: test/cctest/test-api.cc |
diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc |
index c5de6715a7baca68a7a98aeed83e7b0f0d4a7d65..d284260a1d82758eca29185c935d3c23e2333d62 100644 |
--- a/test/cctest/test-api.cc |
+++ b/test/cctest/test-api.cc |
@@ -16768,3 +16768,47 @@ 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()); |
+ } |
+} |
+ |