Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(114)

Side by Side Diff: test/cctest/test-debug.cc

Issue 196133017: Experimental parser: merge r19949 (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/parser
Patch Set: Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « test/cctest/test-date.cc ('k') | test/cctest/test-decls.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 debug->debug_context()->set_security_token( 107 debug->debug_context()->set_security_token(
108 v8::Utils::OpenHandle(*context_)->security_token()); 108 v8::Utils::OpenHandle(*context_)->security_token());
109 109
110 Handle<JSGlobalProxy> global(Handle<JSGlobalProxy>::cast( 110 Handle<JSGlobalProxy> global(Handle<JSGlobalProxy>::cast(
111 v8::Utils::OpenHandle(*context_->Global()))); 111 v8::Utils::OpenHandle(*context_->Global())));
112 Handle<v8::internal::String> debug_string = 112 Handle<v8::internal::String> debug_string =
113 factory->InternalizeOneByteString(STATIC_ASCII_VECTOR("debug")); 113 factory->InternalizeOneByteString(STATIC_ASCII_VECTOR("debug"));
114 v8::internal::Runtime::SetObjectProperty(isolate, global, debug_string, 114 v8::internal::Runtime::SetObjectProperty(isolate, global, debug_string,
115 Handle<Object>(debug->debug_context()->global_proxy(), isolate), 115 Handle<Object>(debug->debug_context()->global_proxy(), isolate),
116 DONT_ENUM, 116 DONT_ENUM,
117 ::v8::internal::kNonStrictMode); 117 ::v8::internal::SLOPPY);
118 } 118 }
119 119
120 private: 120 private:
121 v8::HandleScope scope_; 121 v8::HandleScope scope_;
122 v8::Local<v8::Context> context_; 122 v8::Local<v8::Context> context_;
123 }; 123 };
124 124
125 125
126 // --- H e l p e r F u n c t i o n s 126 // --- H e l p e r F u n c t i o n s
127 127
(...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after
574 574
575 // Source for the JavaScript function which picks out the script name for the 575 // Source for the JavaScript function which picks out the script name for the
576 // top frame. 576 // top frame.
577 const char* frame_script_name_source = 577 const char* frame_script_name_source =
578 "function frame_script_name(exec_state) {" 578 "function frame_script_name(exec_state) {"
579 " return exec_state.frame(0).func().script().name();" 579 " return exec_state.frame(0).func().script().name();"
580 "}"; 580 "}";
581 v8::Local<v8::Function> frame_script_name; 581 v8::Local<v8::Function> frame_script_name;
582 582
583 583
584 // Source for the JavaScript function which picks out the script data for the
585 // top frame.
586 const char* frame_script_data_source =
587 "function frame_script_data(exec_state) {"
588 " return exec_state.frame(0).func().script().data();"
589 "}";
590 v8::Local<v8::Function> frame_script_data;
591
592
593 // Source for the JavaScript function which picks out the script data from
594 // AfterCompile event
595 const char* compiled_script_data_source =
596 "function compiled_script_data(event_data) {"
597 " return event_data.script().data();"
598 "}";
599 v8::Local<v8::Function> compiled_script_data;
600
601
602 // Source for the JavaScript function which returns the number of frames. 584 // Source for the JavaScript function which returns the number of frames.
603 static const char* frame_count_source = 585 static const char* frame_count_source =
604 "function frame_count(exec_state) {" 586 "function frame_count(exec_state) {"
605 " return exec_state.frameCount();" 587 " return exec_state.frameCount();"
606 "}"; 588 "}";
607 v8::Handle<v8::Function> frame_count; 589 v8::Handle<v8::Function> frame_count;
608 590
609 591
610 // Global variable to store the last function hit - used by some tests. 592 // Global variable to store the last function hit - used by some tests.
611 char last_function_hit[80]; 593 char last_function_hit[80];
612 594
613 // Global variable to store the name and data for last script hit - used by some 595 // Global variable to store the name for last script hit - used by some tests.
614 // tests.
615 char last_script_name_hit[80]; 596 char last_script_name_hit[80];
616 char last_script_data_hit[80];
617 597
618 // Global variables to store the last source position - used by some tests. 598 // Global variables to store the last source position - used by some tests.
619 int last_source_line = -1; 599 int last_source_line = -1;
620 int last_source_column = -1; 600 int last_source_column = -1;
621 601
622 // Debug event handler which counts the break points which have been hit. 602 // Debug event handler which counts the break points which have been hit.
623 int break_point_hit_count = 0; 603 int break_point_hit_count = 0;
624 int break_point_hit_count_deoptimize = 0; 604 int break_point_hit_count_deoptimize = 0;
625 static void DebugEventBreakPointHitCount( 605 static void DebugEventBreakPointHitCount(
626 const v8::Debug::EventDetails& event_details) { 606 const v8::Debug::EventDetails& event_details) {
627 v8::DebugEvent event = event_details.GetEvent(); 607 v8::DebugEvent event = event_details.GetEvent();
628 v8::Handle<v8::Object> exec_state = event_details.GetExecutionState(); 608 v8::Handle<v8::Object> exec_state = event_details.GetExecutionState();
629 v8::Handle<v8::Object> event_data = event_details.GetEventData();
630 v8::internal::Isolate* isolate = CcTest::i_isolate(); 609 v8::internal::Isolate* isolate = CcTest::i_isolate();
631 Debug* debug = isolate->debug(); 610 Debug* debug = isolate->debug();
632 // When hitting a debug event listener there must be a break set. 611 // When hitting a debug event listener there must be a break set.
633 CHECK_NE(debug->break_id(), 0); 612 CHECK_NE(debug->break_id(), 0);
634 613
635 // Count the number of breaks. 614 // Count the number of breaks.
636 if (event == v8::Break) { 615 if (event == v8::Break) {
637 break_point_hit_count++; 616 break_point_hit_count++;
638 if (!frame_function_name.IsEmpty()) { 617 if (!frame_function_name.IsEmpty()) {
639 // Get the name of the function. 618 // Get the name of the function.
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
680 argc, argv); 659 argc, argv);
681 if (result->IsUndefined()) { 660 if (result->IsUndefined()) {
682 last_script_name_hit[0] = '\0'; 661 last_script_name_hit[0] = '\0';
683 } else { 662 } else {
684 CHECK(result->IsString()); 663 CHECK(result->IsString());
685 v8::Handle<v8::String> script_name(result->ToString()); 664 v8::Handle<v8::String> script_name(result->ToString());
686 script_name->WriteUtf8(last_script_name_hit); 665 script_name->WriteUtf8(last_script_name_hit);
687 } 666 }
688 } 667 }
689 668
690 if (!frame_script_data.IsEmpty()) {
691 // Get the script data of the function script.
692 const int argc = 1;
693 v8::Handle<v8::Value> argv[argc] = { exec_state };
694 v8::Handle<v8::Value> result = frame_script_data->Call(exec_state,
695 argc, argv);
696 if (result->IsUndefined()) {
697 last_script_data_hit[0] = '\0';
698 } else {
699 result = result->ToString();
700 CHECK(result->IsString());
701 v8::Handle<v8::String> script_data(result->ToString());
702 script_data->WriteUtf8(last_script_data_hit);
703 }
704 }
705
706 // Perform a full deoptimization when the specified number of 669 // Perform a full deoptimization when the specified number of
707 // breaks have been hit. 670 // breaks have been hit.
708 if (break_point_hit_count == break_point_hit_count_deoptimize) { 671 if (break_point_hit_count == break_point_hit_count_deoptimize) {
709 i::Deoptimizer::DeoptimizeAll(isolate); 672 i::Deoptimizer::DeoptimizeAll(isolate);
710 } 673 }
711 } else if (event == v8::AfterCompile && !compiled_script_data.IsEmpty()) {
712 const int argc = 1;
713 v8::Handle<v8::Value> argv[argc] = { event_data };
714 v8::Handle<v8::Value> result = compiled_script_data->Call(exec_state,
715 argc, argv);
716 if (result->IsUndefined()) {
717 last_script_data_hit[0] = '\0';
718 } else {
719 result = result->ToString();
720 CHECK(result->IsString());
721 v8::Handle<v8::String> script_data(result->ToString());
722 script_data->WriteUtf8(last_script_data_hit);
723 }
724 } 674 }
725 } 675 }
726 676
727 677
728 // Debug event handler which counts a number of events and collects the stack 678 // Debug event handler which counts a number of events and collects the stack
729 // height if there is a function compiled for that. 679 // height if there is a function compiled for that.
730 int exception_hit_count = 0; 680 int exception_hit_count = 0;
731 int uncaught_exception_hit_count = 0; 681 int uncaught_exception_hit_count = 0;
732 int last_js_stack_height = -1; 682 int last_js_stack_height = -1;
733 683
(...skipping 1527 matching lines...) Expand 10 before | Expand all | Expand 10 after
2261 2211
2262 v8::Local<v8::String> script = 2212 v8::Local<v8::String> script =
2263 v8::String::NewFromUtf8(env->GetIsolate(), 2213 v8::String::NewFromUtf8(env->GetIsolate(),
2264 "function f() {\n" 2214 "function f() {\n"
2265 " a = 1; // line 1\n" 2215 " a = 1; // line 1\n"
2266 "}\n" 2216 "}\n"
2267 "a = 2; // line 3\n"); 2217 "a = 2; // line 3\n");
2268 v8::Local<v8::Function> f; 2218 v8::Local<v8::Function> f;
2269 { 2219 {
2270 v8::HandleScope scope(env->GetIsolate()); 2220 v8::HandleScope scope(env->GetIsolate());
2271 v8::Script::Compile( 2221 CompileRunWithOrigin(script, "test.html");
2272 script, v8::String::NewFromUtf8(env->GetIsolate(), "test.html"))->Run();
2273 } 2222 }
2274 f = v8::Local<v8::Function>::Cast( 2223 f = v8::Local<v8::Function>::Cast(
2275 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "f"))); 2224 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "f")));
2276 2225
2277 CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags); 2226 CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags);
2278 2227
2279 SetScriptBreakPointByNameFromJS(env->GetIsolate(), "test.html", 3, -1); 2228 SetScriptBreakPointByNameFromJS(env->GetIsolate(), "test.html", 3, -1);
2280 2229
2281 // Call f and check that there was no break points. 2230 // Call f and check that there was no break points.
2282 break_point_hit_count = 0; 2231 break_point_hit_count = 0;
2283 f->Call(env->Global(), 0, NULL); 2232 f->Call(env->Global(), 0, NULL);
2284 CHECK_EQ(0, break_point_hit_count); 2233 CHECK_EQ(0, break_point_hit_count);
2285 2234
2286 // Recompile and run script and check that break point was hit. 2235 // Recompile and run script and check that break point was hit.
2287 break_point_hit_count = 0; 2236 break_point_hit_count = 0;
2288 v8::Script::Compile( 2237 CompileRunWithOrigin(script, "test.html");
2289 script, v8::String::NewFromUtf8(env->GetIsolate(), "test.html"))->Run();
2290 CHECK_EQ(1, break_point_hit_count); 2238 CHECK_EQ(1, break_point_hit_count);
2291 2239
2292 // Call f and check that there are still no break points. 2240 // Call f and check that there are still no break points.
2293 break_point_hit_count = 0; 2241 break_point_hit_count = 0;
2294 f = v8::Local<v8::Function>::Cast( 2242 f = v8::Local<v8::Function>::Cast(
2295 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "f"))); 2243 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "f")));
2296 CHECK_EQ(0, break_point_hit_count); 2244 CHECK_EQ(0, break_point_hit_count);
2297 2245
2298 v8::Debug::SetDebugEventListener2(NULL); 2246 v8::Debug::SetDebugEventListener2(NULL);
2299 CheckDebuggerUnloaded(); 2247 CheckDebuggerUnloaded();
(...skipping 14 matching lines...) Expand all
2314 "function f() {\n" 2262 "function f() {\n"
2315 " return 0;\n" 2263 " return 0;\n"
2316 "}\n" 2264 "}\n"
2317 "f()"); 2265 "f()");
2318 2266
2319 int sbp1 = 2267 int sbp1 =
2320 SetScriptBreakPointByNameFromJS(env->GetIsolate(), "test.html", 3, -1); 2268 SetScriptBreakPointByNameFromJS(env->GetIsolate(), "test.html", 3, -1);
2321 { 2269 {
2322 v8::HandleScope scope(env->GetIsolate()); 2270 v8::HandleScope scope(env->GetIsolate());
2323 break_point_hit_count = 0; 2271 break_point_hit_count = 0;
2324 v8::Script::Compile(script_source, 2272 CompileRunWithOrigin(script_source, "test.html");
2325 v8::String::NewFromUtf8(env->GetIsolate(), "test.html"))
2326 ->Run();
2327 CHECK_EQ(1, break_point_hit_count); 2273 CHECK_EQ(1, break_point_hit_count);
2328 } 2274 }
2329 2275
2330 int sbp2 = 2276 int sbp2 =
2331 SetScriptBreakPointByNameFromJS(env->GetIsolate(), "test.html", 3, -1); 2277 SetScriptBreakPointByNameFromJS(env->GetIsolate(), "test.html", 3, -1);
2332 ClearBreakPointFromJS(env->GetIsolate(), sbp1); 2278 ClearBreakPointFromJS(env->GetIsolate(), sbp1);
2333 ClearBreakPointFromJS(env->GetIsolate(), sbp2); 2279 ClearBreakPointFromJS(env->GetIsolate(), sbp2);
2334 2280
2335 v8::Debug::SetDebugEventListener2(NULL); 2281 v8::Debug::SetDebugEventListener2(NULL);
2336 CheckDebuggerUnloaded(); 2282 CheckDebuggerUnloaded();
(...skipping 3905 matching lines...) Expand 10 before | Expand all | Expand 10 after
6242 TEST(ScriptNameAndData) { 6188 TEST(ScriptNameAndData) {
6243 DebugLocalContext env; 6189 DebugLocalContext env;
6244 v8::HandleScope scope(env->GetIsolate()); 6190 v8::HandleScope scope(env->GetIsolate());
6245 env.ExposeDebug(); 6191 env.ExposeDebug();
6246 6192
6247 // Create functions for retrieving script name and data for the function on 6193 // Create functions for retrieving script name and data for the function on
6248 // the top frame when hitting a break point. 6194 // the top frame when hitting a break point.
6249 frame_script_name = CompileFunction(&env, 6195 frame_script_name = CompileFunction(&env,
6250 frame_script_name_source, 6196 frame_script_name_source,
6251 "frame_script_name"); 6197 "frame_script_name");
6252 frame_script_data = CompileFunction(&env,
6253 frame_script_data_source,
6254 "frame_script_data");
6255 compiled_script_data = CompileFunction(&env,
6256 compiled_script_data_source,
6257 "compiled_script_data");
6258 6198
6259 v8::Debug::SetDebugEventListener2(DebugEventBreakPointHitCount); 6199 v8::Debug::SetDebugEventListener2(DebugEventBreakPointHitCount);
6260 6200
6261 // Test function source. 6201 // Test function source.
6262 v8::Local<v8::String> script = v8::String::NewFromUtf8(env->GetIsolate(), 6202 v8::Local<v8::String> script = v8::String::NewFromUtf8(env->GetIsolate(),
6263 "function f() {\n" 6203 "function f() {\n"
6264 " debugger;\n" 6204 " debugger;\n"
6265 "}\n"); 6205 "}\n");
6266 6206
6267 v8::ScriptOrigin origin1 = 6207 v8::ScriptOrigin origin1 =
6268 v8::ScriptOrigin(v8::String::NewFromUtf8(env->GetIsolate(), "name")); 6208 v8::ScriptOrigin(v8::String::NewFromUtf8(env->GetIsolate(), "name"));
6269 v8::Handle<v8::Script> script1 = v8::Script::Compile(script, &origin1); 6209 v8::Handle<v8::Script> script1 = v8::Script::Compile(script, &origin1);
6270 script1->SetData(v8::String::NewFromUtf8(env->GetIsolate(), "data"));
6271 script1->Run(); 6210 script1->Run();
6272 v8::Local<v8::Function> f; 6211 v8::Local<v8::Function> f;
6273 f = v8::Local<v8::Function>::Cast( 6212 f = v8::Local<v8::Function>::Cast(
6274 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "f"))); 6213 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "f")));
6275 6214
6276 f->Call(env->Global(), 0, NULL); 6215 f->Call(env->Global(), 0, NULL);
6277 CHECK_EQ(1, break_point_hit_count); 6216 CHECK_EQ(1, break_point_hit_count);
6278 CHECK_EQ("name", last_script_name_hit); 6217 CHECK_EQ("name", last_script_name_hit);
6279 CHECK_EQ("data", last_script_data_hit);
6280 6218
6281 // Compile the same script again without setting data. As the compilation 6219 // Compile the same script again without setting data. As the compilation
6282 // cache is disabled when debugging expect the data to be missing. 6220 // cache is disabled when debugging expect the data to be missing.
6283 v8::Script::Compile(script, &origin1)->Run(); 6221 v8::Script::Compile(script, &origin1)->Run();
6284 f = v8::Local<v8::Function>::Cast( 6222 f = v8::Local<v8::Function>::Cast(
6285 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "f"))); 6223 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "f")));
6286 f->Call(env->Global(), 0, NULL); 6224 f->Call(env->Global(), 0, NULL);
6287 CHECK_EQ(2, break_point_hit_count); 6225 CHECK_EQ(2, break_point_hit_count);
6288 CHECK_EQ("name", last_script_name_hit); 6226 CHECK_EQ("name", last_script_name_hit);
6289 CHECK_EQ("", last_script_data_hit); // Undefined results in empty string.
6290 6227
6291 v8::Local<v8::String> data_obj_source = v8::String::NewFromUtf8( 6228 v8::Local<v8::String> data_obj_source = v8::String::NewFromUtf8(
6292 env->GetIsolate(), 6229 env->GetIsolate(),
6293 "({ a: 'abc',\n" 6230 "({ a: 'abc',\n"
6294 " b: 123,\n" 6231 " b: 123,\n"
6295 " toString: function() { return this.a + ' ' + this.b; }\n" 6232 " toString: function() { return this.a + ' ' + this.b; }\n"
6296 "})\n"); 6233 "})\n");
6297 v8::Local<v8::Value> data_obj = v8::Script::Compile(data_obj_source)->Run(); 6234 v8::Script::Compile(data_obj_source)->Run();
6298 v8::ScriptOrigin origin2 = 6235 v8::ScriptOrigin origin2 =
6299 v8::ScriptOrigin(v8::String::NewFromUtf8(env->GetIsolate(), "new name")); 6236 v8::ScriptOrigin(v8::String::NewFromUtf8(env->GetIsolate(), "new name"));
6300 v8::Handle<v8::Script> script2 = v8::Script::Compile(script, &origin2); 6237 v8::Handle<v8::Script> script2 = v8::Script::Compile(script, &origin2);
6301 script2->Run(); 6238 script2->Run();
6302 script2->SetData(data_obj->ToString());
6303 f = v8::Local<v8::Function>::Cast( 6239 f = v8::Local<v8::Function>::Cast(
6304 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "f"))); 6240 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "f")));
6305 f->Call(env->Global(), 0, NULL); 6241 f->Call(env->Global(), 0, NULL);
6306 CHECK_EQ(3, break_point_hit_count); 6242 CHECK_EQ(3, break_point_hit_count);
6307 CHECK_EQ("new name", last_script_name_hit); 6243 CHECK_EQ("new name", last_script_name_hit);
6308 CHECK_EQ("abc 123", last_script_data_hit);
6309 6244
6310 v8::Handle<v8::Script> script3 = v8::Script::Compile( 6245 v8::Handle<v8::Script> script3 = v8::Script::Compile(script, &origin2);
6311 script, &origin2, NULL,
6312 v8::String::NewFromUtf8(env->GetIsolate(), "in compile"));
6313 CHECK_EQ("in compile", last_script_data_hit);
6314 script3->Run(); 6246 script3->Run();
6315 f = v8::Local<v8::Function>::Cast( 6247 f = v8::Local<v8::Function>::Cast(
6316 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "f"))); 6248 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "f")));
6317 f->Call(env->Global(), 0, NULL); 6249 f->Call(env->Global(), 0, NULL);
6318 CHECK_EQ(4, break_point_hit_count); 6250 CHECK_EQ(4, break_point_hit_count);
6319 CHECK_EQ("in compile", last_script_data_hit);
6320 } 6251 }
6321 6252
6322 6253
6323 static v8::Handle<v8::Context> expected_context; 6254 static v8::Handle<v8::Context> expected_context;
6324 static v8::Handle<v8::Value> expected_context_data; 6255 static v8::Handle<v8::Value> expected_context_data;
6325 6256
6326 6257
6327 // Check that the expected context is the one generating the debug event. 6258 // Check that the expected context is the one generating the debug event.
6328 static void ContextCheckMessageHandler(const v8::Debug::Message& message) { 6259 static void ContextCheckMessageHandler(const v8::Debug::Message& message) {
6329 CHECK(message.GetEventContext() == expected_context); 6260 CHECK(message.GetEventContext() == expected_context);
(...skipping 715 matching lines...) Expand 10 before | Expand all | Expand 10 after
7045 v8::Debug::SendCommand( 6976 v8::Debug::SendCommand(
7046 isolate, 6977 isolate,
7047 buffer, 6978 buffer,
7048 AsciiToUtf16(scripts_command, buffer), 6979 AsciiToUtf16(scripts_command, buffer),
7049 NULL); 6980 NULL);
7050 v8::Debug::ProcessDebugMessages(); 6981 v8::Debug::ProcessDebugMessages();
7051 CHECK_EQ(BacktraceData::frame_counter, 0); 6982 CHECK_EQ(BacktraceData::frame_counter, 0);
7052 6983
7053 v8::Handle<v8::String> void0 = 6984 v8::Handle<v8::String> void0 =
7054 v8::String::NewFromUtf8(env->GetIsolate(), "void(0)"); 6985 v8::String::NewFromUtf8(env->GetIsolate(), "void(0)");
7055 v8::Handle<v8::Script> script = v8::Script::Compile(void0, void0); 6986 v8::Handle<v8::Script> script = CompileWithOrigin(void0, void0);
7056 6987
7057 // Check backtrace from "void(0)" script. 6988 // Check backtrace from "void(0)" script.
7058 BacktraceData::frame_counter = -10; 6989 BacktraceData::frame_counter = -10;
7059 v8::Debug::SendCommand( 6990 v8::Debug::SendCommand(
7060 isolate, 6991 isolate,
7061 buffer, 6992 buffer,
7062 AsciiToUtf16(scripts_command, buffer), 6993 AsciiToUtf16(scripts_command, buffer),
7063 NULL); 6994 NULL);
7064 script->Run(); 6995 script->Run();
7065 CHECK_EQ(BacktraceData::frame_counter, 1); 6996 CHECK_EQ(BacktraceData::frame_counter, 1);
7066 6997
7067 // Get rid of the debug message handler. 6998 // Get rid of the debug message handler.
7068 v8::Debug::SetMessageHandler2(NULL); 6999 v8::Debug::SetMessageHandler2(NULL);
7069 CheckDebuggerUnloaded(); 7000 CheckDebuggerUnloaded();
7070 } 7001 }
7071 7002
7072 7003
7073 TEST(GetMirror) { 7004 TEST(GetMirror) {
7074 DebugLocalContext env; 7005 DebugLocalContext env;
7075 v8::HandleScope scope(env->GetIsolate()); 7006 v8::Isolate* isolate = env->GetIsolate();
7007 v8::HandleScope scope(isolate);
7076 v8::Handle<v8::Value> obj = 7008 v8::Handle<v8::Value> obj =
7077 v8::Debug::GetMirror(v8::String::NewFromUtf8(env->GetIsolate(), "hodja")); 7009 v8::Debug::GetMirror(v8::String::NewFromUtf8(isolate, "hodja"));
7078 v8::Handle<v8::Function> run_test = 7010 v8::Handle<v8::Function> run_test =
7079 v8::Handle<v8::Function>::Cast(v8::Script::New( 7011 v8::Handle<v8::Function>::Cast(
7080 v8::String::NewFromUtf8( 7012 v8::ScriptCompiler::CompileUnbound(
7081 env->GetIsolate(), 7013 isolate,
7082 "function runTest(mirror) {" 7014 v8::ScriptCompiler::Source(v8_str(
7083 " return mirror.isString() && (mirror.length() == 5);" 7015 "function runTest(mirror) {"
7084 "}" 7016 " return mirror.isString() && (mirror.length() == 5);"
7085 "" 7017 "}"
7086 "runTest;"))->Run()); 7018 ""
7019 "runTest;")))->BindToCurrentContext()->Run());
7087 v8::Handle<v8::Value> result = run_test->Call(env->Global(), 1, &obj); 7020 v8::Handle<v8::Value> result = run_test->Call(env->Global(), 1, &obj);
7088 CHECK(result->IsTrue()); 7021 CHECK(result->IsTrue());
7089 } 7022 }
7090 7023
7091 7024
7092 // Test that the debug break flag works with function.apply. 7025 // Test that the debug break flag works with function.apply.
7093 TEST(DebugBreakFunctionApply) { 7026 TEST(DebugBreakFunctionApply) {
7094 DebugLocalContext env; 7027 DebugLocalContext env;
7095 v8::HandleScope scope(env->GetIsolate()); 7028 v8::HandleScope scope(env->GetIsolate());
7096 7029
(...skipping 632 matching lines...) Expand 10 before | Expand all | Expand 10 after
7729 CHECK(result->IsString()); 7662 CHECK(result->IsString());
7730 v8::String::Utf8Value utf8(result); 7663 v8::String::Utf8Value utf8(result);
7731 CHECK_EQ("bar", *utf8); 7664 CHECK_EQ("bar", *utf8);
7732 7665
7733 v8::Debug::SetDebugEventListener2(NULL); 7666 v8::Debug::SetDebugEventListener2(NULL);
7734 CheckDebuggerUnloaded(); 7667 CheckDebuggerUnloaded();
7735 } 7668 }
7736 7669
7737 7670
7738 #endif // ENABLE_DEBUGGER_SUPPORT 7671 #endif // ENABLE_DEBUGGER_SUPPORT
OLDNEW
« no previous file with comments | « test/cctest/test-date.cc ('k') | test/cctest/test-decls.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698