| OLD | NEW |
| 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 3720 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3731 v8::Local<v8::Function> caught = | 3731 v8::Local<v8::Function> caught = |
| 3732 CompileFunction(&env, | 3732 CompileFunction(&env, |
| 3733 "function caught(){try {throws();} catch(e) {};}", | 3733 "function caught(){try {throws();} catch(e) {};}", |
| 3734 "caught"); | 3734 "caught"); |
| 3735 v8::Local<v8::Function> notCaught = | 3735 v8::Local<v8::Function> notCaught = |
| 3736 CompileFunction(&env, "function notCaught(){throws();}", "notCaught"); | 3736 CompileFunction(&env, "function notCaught(){throws();}", "notCaught"); |
| 3737 | 3737 |
| 3738 v8::V8::AddMessageListener(MessageCallbackCount); | 3738 v8::V8::AddMessageListener(MessageCallbackCount); |
| 3739 v8::Debug::SetDebugEventListener(DebugEventCounter); | 3739 v8::Debug::SetDebugEventListener(DebugEventCounter); |
| 3740 | 3740 |
| 3741 // Initial state should be break on uncaught exception. | 3741 // Initial state should be no break on exceptions. |
| 3742 DebugEventCounterClear(); | 3742 DebugEventCounterClear(); |
| 3743 MessageCallbackCountClear(); | 3743 MessageCallbackCountClear(); |
| 3744 caught->Call(env->Global(), 0, NULL); | 3744 caught->Call(env->Global(), 0, NULL); |
| 3745 CHECK_EQ(0, exception_hit_count); | 3745 CHECK_EQ(0, exception_hit_count); |
| 3746 CHECK_EQ(0, uncaught_exception_hit_count); | 3746 CHECK_EQ(0, uncaught_exception_hit_count); |
| 3747 CHECK_EQ(0, message_callback_count); | 3747 CHECK_EQ(0, message_callback_count); |
| 3748 notCaught->Call(env->Global(), 0, NULL); | 3748 notCaught->Call(env->Global(), 0, NULL); |
| 3749 CHECK_EQ(1, exception_hit_count); | 3749 CHECK_EQ(0, exception_hit_count); |
| 3750 CHECK_EQ(1, uncaught_exception_hit_count); | 3750 CHECK_EQ(0, uncaught_exception_hit_count); |
| 3751 CHECK_EQ(1, message_callback_count); | 3751 CHECK_EQ(1, message_callback_count); |
| 3752 | 3752 |
| 3753 // No break on exception | 3753 // No break on exception |
| 3754 DebugEventCounterClear(); | 3754 DebugEventCounterClear(); |
| 3755 MessageCallbackCountClear(); | 3755 MessageCallbackCountClear(); |
| 3756 ChangeBreakOnException(false, false); | 3756 ChangeBreakOnException(false, false); |
| 3757 caught->Call(env->Global(), 0, NULL); | 3757 caught->Call(env->Global(), 0, NULL); |
| 3758 CHECK_EQ(0, exception_hit_count); | 3758 CHECK_EQ(0, exception_hit_count); |
| 3759 CHECK_EQ(0, uncaught_exception_hit_count); | 3759 CHECK_EQ(0, uncaught_exception_hit_count); |
| 3760 CHECK_EQ(0, message_callback_count); | 3760 CHECK_EQ(0, message_callback_count); |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3860 } | 3860 } |
| 3861 | 3861 |
| 3862 | 3862 |
| 3863 // Test break on exception from compiler errors. When compiling using | 3863 // Test break on exception from compiler errors. When compiling using |
| 3864 // v8::Script::Compile there is no JavaScript stack whereas when compiling using | 3864 // v8::Script::Compile there is no JavaScript stack whereas when compiling using |
| 3865 // eval there are JavaScript frames. | 3865 // eval there are JavaScript frames. |
| 3866 TEST(BreakOnCompileException) { | 3866 TEST(BreakOnCompileException) { |
| 3867 v8::HandleScope scope; | 3867 v8::HandleScope scope; |
| 3868 DebugLocalContext env; | 3868 DebugLocalContext env; |
| 3869 | 3869 |
| 3870 // For this test, we want to break on uncaught exceptions: |
| 3871 ChangeBreakOnException(false, true); |
| 3872 |
| 3870 v8::internal::Isolate::Current()->TraceException(false); | 3873 v8::internal::Isolate::Current()->TraceException(false); |
| 3871 | 3874 |
| 3872 // Create a function for checking the function when hitting a break point. | 3875 // Create a function for checking the function when hitting a break point. |
| 3873 frame_count = CompileFunction(&env, frame_count_source, "frame_count"); | 3876 frame_count = CompileFunction(&env, frame_count_source, "frame_count"); |
| 3874 | 3877 |
| 3875 v8::V8::AddMessageListener(MessageCallbackCount); | 3878 v8::V8::AddMessageListener(MessageCallbackCount); |
| 3876 v8::Debug::SetDebugEventListener(DebugEventCounter); | 3879 v8::Debug::SetDebugEventListener(DebugEventCounter); |
| 3877 | 3880 |
| 3878 DebugEventCounterClear(); | 3881 DebugEventCounterClear(); |
| 3879 MessageCallbackCountClear(); | 3882 MessageCallbackCountClear(); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3911 CHECK_EQ(4, uncaught_exception_hit_count); | 3914 CHECK_EQ(4, uncaught_exception_hit_count); |
| 3912 CHECK_EQ(4, message_callback_count); | 3915 CHECK_EQ(4, message_callback_count); |
| 3913 CHECK_EQ(1, last_js_stack_height); | 3916 CHECK_EQ(1, last_js_stack_height); |
| 3914 } | 3917 } |
| 3915 | 3918 |
| 3916 | 3919 |
| 3917 TEST(StepWithException) { | 3920 TEST(StepWithException) { |
| 3918 v8::HandleScope scope; | 3921 v8::HandleScope scope; |
| 3919 DebugLocalContext env; | 3922 DebugLocalContext env; |
| 3920 | 3923 |
| 3924 // For this test, we want to break on uncaught exceptions: |
| 3925 ChangeBreakOnException(false, true); |
| 3926 |
| 3921 // Create a function for checking the function when hitting a break point. | 3927 // Create a function for checking the function when hitting a break point. |
| 3922 frame_function_name = CompileFunction(&env, | 3928 frame_function_name = CompileFunction(&env, |
| 3923 frame_function_name_source, | 3929 frame_function_name_source, |
| 3924 "frame_function_name"); | 3930 "frame_function_name"); |
| 3925 | 3931 |
| 3926 // Register a debug event listener which steps and counts. | 3932 // Register a debug event listener which steps and counts. |
| 3927 v8::Debug::SetDebugEventListener(DebugEventStepSequence); | 3933 v8::Debug::SetDebugEventListener(DebugEventStepSequence); |
| 3928 | 3934 |
| 3929 // Create functions for testing stepping. | 3935 // Create functions for testing stepping. |
| 3930 const char* src = "function a() { n(); }; " | 3936 const char* src = "function a() { n(); }; " |
| (...skipping 2635 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6566 exception_event_count++; | 6572 exception_event_count++; |
| 6567 SendContinueCommand(); | 6573 SendContinueCommand(); |
| 6568 } | 6574 } |
| 6569 } | 6575 } |
| 6570 | 6576 |
| 6571 | 6577 |
| 6572 // Tests that exception event is sent when message handler is reset. | 6578 // Tests that exception event is sent when message handler is reset. |
| 6573 TEST(ExceptionMessageWhenMessageHandlerIsReset) { | 6579 TEST(ExceptionMessageWhenMessageHandlerIsReset) { |
| 6574 v8::HandleScope scope; | 6580 v8::HandleScope scope; |
| 6575 DebugLocalContext env; | 6581 DebugLocalContext env; |
| 6582 |
| 6583 // For this test, we want to break on uncaught exceptions: |
| 6584 ChangeBreakOnException(false, true); |
| 6585 |
| 6576 exception_event_count = 0; | 6586 exception_event_count = 0; |
| 6577 const char* script = "function f() {throw new Error()};"; | 6587 const char* script = "function f() {throw new Error()};"; |
| 6578 | 6588 |
| 6579 v8::Debug::SetMessageHandler2(AfterCompileMessageHandler); | 6589 v8::Debug::SetMessageHandler2(AfterCompileMessageHandler); |
| 6580 v8::Script::Compile(v8::String::New(script))->Run(); | 6590 v8::Script::Compile(v8::String::New(script))->Run(); |
| 6581 v8::Debug::SetMessageHandler2(NULL); | 6591 v8::Debug::SetMessageHandler2(NULL); |
| 6582 | 6592 |
| 6583 v8::Debug::SetMessageHandler2(ExceptionMessageHandler); | 6593 v8::Debug::SetMessageHandler2(ExceptionMessageHandler); |
| 6584 v8::Local<v8::Function> f = | 6594 v8::Local<v8::Function> f = |
| 6585 v8::Local<v8::Function>::Cast(env->Global()->Get(v8::String::New("f"))); | 6595 v8::Local<v8::Function>::Cast(env->Global()->Get(v8::String::New("f"))); |
| (...skipping 650 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7236 TestDebugBreakInLoop("for (;;) {", loop_bodies, "}"); | 7246 TestDebugBreakInLoop("for (;;) {", loop_bodies, "}"); |
| 7237 TestDebugBreakInLoop("for (;a == 1;) {", loop_bodies, "}"); | 7247 TestDebugBreakInLoop("for (;a == 1;) {", loop_bodies, "}"); |
| 7238 | 7248 |
| 7239 // Get rid of the debug event listener. | 7249 // Get rid of the debug event listener. |
| 7240 v8::Debug::SetDebugEventListener(NULL); | 7250 v8::Debug::SetDebugEventListener(NULL); |
| 7241 CheckDebuggerUnloaded(); | 7251 CheckDebuggerUnloaded(); |
| 7242 } | 7252 } |
| 7243 | 7253 |
| 7244 | 7254 |
| 7245 #endif // ENABLE_DEBUGGER_SUPPORT | 7255 #endif // ENABLE_DEBUGGER_SUPPORT |
| OLD | NEW |