OLD | NEW |
| (Empty) |
1 diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc | |
2 index 5624e3f..81936c1 100644 | |
3 --- a/test/cctest/test-api.cc | |
4 +++ b/test/cctest/test-api.cc | |
5 @@ -17049,6 +17049,43 @@ TEST(CaptureStackTraceForUncaughtExceptionAndSetters) { | |
6 } | |
7 | |
8 | |
9 +static void StackTraceFunctionNameListenerForEval(v8::Local<v8::Message> messag
e, | |
10 + v8::Local<Value>) { | |
11 + v8::Local<v8::StackTrace> stack_trace = message->GetStackTrace(); | |
12 + for (int i = 0; i < stack_trace->GetFrameCount(); i++) { | |
13 + v8::Local<v8::StackFrame> frame = stack_trace->GetFrame(i); | |
14 + v8::String::Utf8Value func_name(frame->GetFunctionName()); | |
15 + v8::String::Utf8Value script_name(frame->GetScriptName()); | |
16 + printf("%s:%s, %d,%d\n", *script_name, *func_name, frame->GetLineNumber(),
frame->GetColumn()); | |
17 + } | |
18 + | |
19 + | |
20 + CHECK_EQ(5, stack_trace->GetFrameCount()); | |
21 + checkStackFrame("origin", "foo:0", 4, 7, false, false, | |
22 + stack_trace->GetFrame(0)); | |
23 + checkStackFrame("origin", "foo:1", 5, 27, false, false, | |
24 + stack_trace->GetFrame(1)); | |
25 + checkStackFrame("origin", "foo", 5, 27, false, false, | |
26 + stack_trace->GetFrame(2)); | |
27 + checkStackFrame("origin", "foo", 5, 27, false, false, | |
28 + stack_trace->GetFrame(3)); | |
29 + checkStackFrame("origin", "", 1, 14, false, false, stack_trace->GetFrame(4)); | |
30 +} | |
31 + | |
32 + | |
33 +TEST(CaptureStackTraceForUncaughtExceptionInEval) { | |
34 + LocalContext env; | |
35 + v8::Isolate* isolate = env->GetIsolate(); | |
36 + v8::HandleScope scope(isolate); | |
37 + isolate->SetCaptureStackTraceForUncaughtExceptions(true, 1024, | |
38 + v8::StackTrace::kDetailed)
; | |
39 + isolate->AddMessageListener(StackTraceFunctionNameListenerForEval); | |
40 + | |
41 + CompileRun("eval('throw new Error()');"); | |
42 + isolate->SetCaptureStackTraceForUncaughtExceptions(false); | |
43 +} | |
44 + | |
45 + | |
46 static void StackTraceFunctionNameListener(v8::Local<v8::Message> message, | |
47 v8::Local<Value>) { | |
48 v8::Local<v8::StackTrace> stack_trace = message->GetStackTrace(); | |
OLD | NEW |