Index: test/cctest/test-debug.cc |
=================================================================== |
--- test/cctest/test-debug.cc (revision 3836) |
+++ test/cctest/test-debug.cc (working copy) |
@@ -550,6 +550,15 @@ |
v8::Local<v8::Function> frame_script_data; |
+// Source for The JavaScript function which picks out the script data from |
+// AfterCompile event |
+const char* compiled_script_data_source = |
+ "function compiled_script_data(event_data) {" |
+ " return event_data.script().data();" |
+ "}"; |
+v8::Local<v8::Function> compiled_script_data; |
+ |
+ |
// Source for The JavaScript function which returns the number of frames. |
static const char* frame_count_source = |
"function frame_count(exec_state) {" |
@@ -647,6 +656,19 @@ |
script_data->WriteAscii(last_script_data_hit); |
} |
} |
+ } else if (event == v8::AfterCompile && !compiled_script_data.IsEmpty()) { |
+ const int argc = 1; |
+ v8::Handle<v8::Value> argv[argc] = { event_data }; |
+ v8::Handle<v8::Value> result = compiled_script_data->Call(exec_state, |
+ argc, argv); |
+ if (result->IsUndefined()) { |
+ last_script_data_hit[0] = '\0'; |
+ } else { |
+ result = result->ToString(); |
+ CHECK(result->IsString()); |
+ v8::Handle<v8::String> script_data(result->ToString()); |
+ script_data->WriteAscii(last_script_data_hit); |
+ } |
} |
} |
@@ -5231,6 +5253,9 @@ |
frame_script_data = CompileFunction(&env, |
frame_script_data_source, |
"frame_script_data"); |
+ compiled_script_data = CompileFunction(&env, |
+ compiled_script_data_source, |
+ "compiled_script_data"); |
v8::Debug::SetDebugEventListener(DebugEventBreakPointHitCount, |
v8::Undefined()); |
@@ -5277,6 +5302,16 @@ |
CHECK_EQ(3, break_point_hit_count); |
CHECK_EQ("new name", last_script_name_hit); |
CHECK_EQ("abc 123", last_script_data_hit); |
+ |
+ v8::Handle<v8::Script> script3 = |
+ v8::Script::Compile(script, &origin2, NULL, |
+ v8::String::New("in compile")); |
+ CHECK_EQ("in compile", last_script_data_hit); |
+ script3->Run(); |
+ f = v8::Local<v8::Function>::Cast(env->Global()->Get(v8::String::New("f"))); |
+ f->Call(env->Global(), 0, NULL); |
+ CHECK_EQ(4, break_point_hit_count); |
+ CHECK_EQ("in compile", last_script_data_hit); |
} |