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

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

Issue 6086010: Update debugger test to expect new default break on exceptions settings. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 9 years, 11 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 | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2010 the V8 project authors. All rights reserved. 1 // Copyright 2010 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 3694 matching lines...) Expand 10 before | Expand all | Expand 10 after
3705 v8::Local<v8::Function> caught = 3705 v8::Local<v8::Function> caught =
3706 CompileFunction(&env, 3706 CompileFunction(&env,
3707 "function caught(){try {throws();} catch(e) {};}", 3707 "function caught(){try {throws();} catch(e) {};}",
3708 "caught"); 3708 "caught");
3709 v8::Local<v8::Function> notCaught = 3709 v8::Local<v8::Function> notCaught =
3710 CompileFunction(&env, "function notCaught(){throws();}", "notCaught"); 3710 CompileFunction(&env, "function notCaught(){throws();}", "notCaught");
3711 3711
3712 v8::V8::AddMessageListener(MessageCallbackCount); 3712 v8::V8::AddMessageListener(MessageCallbackCount);
3713 v8::Debug::SetDebugEventListener(DebugEventCounter); 3713 v8::Debug::SetDebugEventListener(DebugEventCounter);
3714 3714
3715 // Initial state should be break on uncaught exception. 3715 // Initial state should be no break on exceptions.
3716 DebugEventCounterClear(); 3716 DebugEventCounterClear();
3717 MessageCallbackCountClear(); 3717 MessageCallbackCountClear();
3718 caught->Call(env->Global(), 0, NULL); 3718 caught->Call(env->Global(), 0, NULL);
3719 CHECK_EQ(0, exception_hit_count); 3719 CHECK_EQ(0, exception_hit_count);
3720 CHECK_EQ(0, uncaught_exception_hit_count); 3720 CHECK_EQ(0, uncaught_exception_hit_count);
3721 CHECK_EQ(0, message_callback_count); 3721 CHECK_EQ(0, message_callback_count);
3722 notCaught->Call(env->Global(), 0, NULL); 3722 notCaught->Call(env->Global(), 0, NULL);
3723 CHECK_EQ(1, exception_hit_count); 3723 CHECK_EQ(0, exception_hit_count);
3724 CHECK_EQ(1, uncaught_exception_hit_count); 3724 CHECK_EQ(0, uncaught_exception_hit_count);
3725 CHECK_EQ(1, message_callback_count); 3725 CHECK_EQ(1, message_callback_count);
3726 3726
3727 // No break on exception 3727 // No break on exception
3728 DebugEventCounterClear(); 3728 DebugEventCounterClear();
3729 MessageCallbackCountClear(); 3729 MessageCallbackCountClear();
3730 ChangeBreakOnException(false, false); 3730 ChangeBreakOnException(false, false);
3731 caught->Call(env->Global(), 0, NULL); 3731 caught->Call(env->Global(), 0, NULL);
3732 CHECK_EQ(0, exception_hit_count); 3732 CHECK_EQ(0, exception_hit_count);
3733 CHECK_EQ(0, uncaught_exception_hit_count); 3733 CHECK_EQ(0, uncaught_exception_hit_count);
3734 CHECK_EQ(0, message_callback_count); 3734 CHECK_EQ(0, message_callback_count);
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
3834 } 3834 }
3835 3835
3836 3836
3837 // Test break on exception from compiler errors. When compiling using 3837 // Test break on exception from compiler errors. When compiling using
3838 // v8::Script::Compile there is no JavaScript stack whereas when compiling using 3838 // v8::Script::Compile there is no JavaScript stack whereas when compiling using
3839 // eval there are JavaScript frames. 3839 // eval there are JavaScript frames.
3840 TEST(BreakOnCompileException) { 3840 TEST(BreakOnCompileException) {
3841 v8::HandleScope scope; 3841 v8::HandleScope scope;
3842 DebugLocalContext env; 3842 DebugLocalContext env;
3843 3843
3844 // For this test, we want to break on uncaught exceptions:
3845 ChangeBreakOnException(false, true);
3846
3844 v8::internal::Top::TraceException(false); 3847 v8::internal::Top::TraceException(false);
3845 3848
3846 // Create a function for checking the function when hitting a break point. 3849 // Create a function for checking the function when hitting a break point.
3847 frame_count = CompileFunction(&env, frame_count_source, "frame_count"); 3850 frame_count = CompileFunction(&env, frame_count_source, "frame_count");
3848 3851
3849 v8::V8::AddMessageListener(MessageCallbackCount); 3852 v8::V8::AddMessageListener(MessageCallbackCount);
3850 v8::Debug::SetDebugEventListener(DebugEventCounter); 3853 v8::Debug::SetDebugEventListener(DebugEventCounter);
3851 3854
3852 DebugEventCounterClear(); 3855 DebugEventCounterClear();
3853 MessageCallbackCountClear(); 3856 MessageCallbackCountClear();
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
3885 CHECK_EQ(4, uncaught_exception_hit_count); 3888 CHECK_EQ(4, uncaught_exception_hit_count);
3886 CHECK_EQ(4, message_callback_count); 3889 CHECK_EQ(4, message_callback_count);
3887 CHECK_EQ(1, last_js_stack_height); 3890 CHECK_EQ(1, last_js_stack_height);
3888 } 3891 }
3889 3892
3890 3893
3891 TEST(StepWithException) { 3894 TEST(StepWithException) {
3892 v8::HandleScope scope; 3895 v8::HandleScope scope;
3893 DebugLocalContext env; 3896 DebugLocalContext env;
3894 3897
3898 // For this test, we want to break on uncaught exceptions:
3899 ChangeBreakOnException(false, true);
3900
3895 // Create a function for checking the function when hitting a break point. 3901 // Create a function for checking the function when hitting a break point.
3896 frame_function_name = CompileFunction(&env, 3902 frame_function_name = CompileFunction(&env,
3897 frame_function_name_source, 3903 frame_function_name_source,
3898 "frame_function_name"); 3904 "frame_function_name");
3899 3905
3900 // Register a debug event listener which steps and counts. 3906 // Register a debug event listener which steps and counts.
3901 v8::Debug::SetDebugEventListener(DebugEventStepSequence); 3907 v8::Debug::SetDebugEventListener(DebugEventStepSequence);
3902 3908
3903 // Create functions for testing stepping. 3909 // Create functions for testing stepping.
3904 const char* src = "function a() { n(); }; " 3910 const char* src = "function a() { n(); }; "
(...skipping 2611 matching lines...) Expand 10 before | Expand all | Expand 10 after
6516 exception_event_count++; 6522 exception_event_count++;
6517 SendContinueCommand(); 6523 SendContinueCommand();
6518 } 6524 }
6519 } 6525 }
6520 6526
6521 6527
6522 // Tests that exception event is sent when message handler is reset. 6528 // Tests that exception event is sent when message handler is reset.
6523 TEST(ExceptionMessageWhenMessageHandlerIsReset) { 6529 TEST(ExceptionMessageWhenMessageHandlerIsReset) {
6524 v8::HandleScope scope; 6530 v8::HandleScope scope;
6525 DebugLocalContext env; 6531 DebugLocalContext env;
6532
6533 // For this test, we want to break on uncaught exceptions:
6534 ChangeBreakOnException(false, true);
6535
6526 exception_event_count = 0; 6536 exception_event_count = 0;
6527 const char* script = "function f() {throw new Error()};"; 6537 const char* script = "function f() {throw new Error()};";
6528 6538
6529 v8::Debug::SetMessageHandler2(AfterCompileMessageHandler); 6539 v8::Debug::SetMessageHandler2(AfterCompileMessageHandler);
6530 v8::Script::Compile(v8::String::New(script))->Run(); 6540 v8::Script::Compile(v8::String::New(script))->Run();
6531 v8::Debug::SetMessageHandler2(NULL); 6541 v8::Debug::SetMessageHandler2(NULL);
6532 6542
6533 v8::Debug::SetMessageHandler2(ExceptionMessageHandler); 6543 v8::Debug::SetMessageHandler2(ExceptionMessageHandler);
6534 v8::Local<v8::Function> f = 6544 v8::Local<v8::Function> f =
6535 v8::Local<v8::Function>::Cast(env->Global()->Get(v8::String::New("f"))); 6545 v8::Local<v8::Function>::Cast(env->Global()->Get(v8::String::New("f")));
(...skipping 648 matching lines...) Expand 10 before | Expand all | Expand 10 after
7184 TestDebugBreakInLoop("for (;;) {", loop_bodies, "}"); 7194 TestDebugBreakInLoop("for (;;) {", loop_bodies, "}");
7185 TestDebugBreakInLoop("for (;a == 1;) {", loop_bodies, "}"); 7195 TestDebugBreakInLoop("for (;a == 1;) {", loop_bodies, "}");
7186 7196
7187 // Get rid of the debug event listener. 7197 // Get rid of the debug event listener.
7188 v8::Debug::SetDebugEventListener(NULL); 7198 v8::Debug::SetDebugEventListener(NULL);
7189 CheckDebuggerUnloaded(); 7199 CheckDebuggerUnloaded();
7190 } 7200 }
7191 7201
7192 7202
7193 #endif // ENABLE_DEBUGGER_SUPPORT 7203 #endif // ENABLE_DEBUGGER_SUPPORT
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698