| Index: test/cctest/test-api.cc
|
| diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc
|
| index e4e8462c5d76c39a7abc81c597d969602bff0a3a..72d079d82c2f4a91be66ec0ae80a14e2d7c872ad 100644
|
| --- a/test/cctest/test-api.cc
|
| +++ b/test/cctest/test-api.cc
|
| @@ -13535,6 +13535,43 @@ TEST(CaptureStackTraceForUncaughtExceptionAndSetters) {
|
| }
|
|
|
|
|
| +static void RethrowStackTraceHandler(v8::Handle<v8::Message> message,
|
| + v8::Handle<v8::Value> data) {
|
| + // Use the frame where JavaScript is called from.
|
| + v8::Handle<v8::String> error_message = message->Get();
|
| + v8::Handle<v8::StackTrace> stack_trace = message->GetStackTrace();
|
| + CHECK(!stack_trace.IsEmpty());
|
| + int frame_count = stack_trace->GetFrameCount();
|
| + CHECK_EQ(3, frame_count);
|
| + int line_number[] = {1, 2, 5};
|
| + for (int i = 0; i < frame_count; i++) {
|
| + CHECK_EQ(line_number[i], stack_trace->GetFrame(i)->GetLineNumber());
|
| + }
|
| +}
|
| +
|
| +
|
| +// Test that we only return the stack trace at the site where the exception
|
| +// is first thrown (not where it is rethrown).
|
| +TEST(RethrowStackTrace) {
|
| + v8::HandleScope scope;
|
| + LocalContext env;
|
| + const char* source =
|
| + "function g() { error; } \n"
|
| + "function f() { g(); } \n"
|
| + "function t(e) { throw(e); } \n"
|
| + "try { \n"
|
| + " f(); \n"
|
| + "} catch (e1) { \n"
|
| + " t(e1); \n"
|
| + "} \n";
|
| + v8::V8::AddMessageListener(RethrowStackTraceHandler);
|
| + v8::V8::SetCaptureStackTraceForUncaughtExceptions(true);
|
| + CompileRun(source);
|
| + v8::V8::SetCaptureStackTraceForUncaughtExceptions(false);
|
| + v8::V8::RemoveMessageListeners(RethrowStackTraceHandler);
|
| +}
|
| +
|
| +
|
| v8::Handle<Value> AnalyzeStackOfEvalWithSourceURL(const v8::Arguments& args) {
|
| v8::HandleScope scope;
|
| v8::Handle<v8::StackTrace> stackTrace =
|
|
|