OLD | NEW |
1 // Copyright 2007-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2007-2008 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 2029 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2040 | 2040 |
2041 // Run function with two debugger statement | 2041 // Run function with two debugger statement |
2042 foo->Call(env->Global(), 0, NULL); | 2042 foo->Call(env->Global(), 0, NULL); |
2043 CHECK_EQ(3, break_point_hit_count); | 2043 CHECK_EQ(3, break_point_hit_count); |
2044 | 2044 |
2045 v8::Debug::SetDebugEventListener(NULL); | 2045 v8::Debug::SetDebugEventListener(NULL); |
2046 CheckDebuggerUnloaded(); | 2046 CheckDebuggerUnloaded(); |
2047 } | 2047 } |
2048 | 2048 |
2049 | 2049 |
| 2050 // Test setting a breakpoint on the debugger statement. |
| 2051 TEST(DebuggerStatementBreakpoint) { |
| 2052 break_point_hit_count = 0; |
| 2053 v8::HandleScope scope; |
| 2054 DebugLocalContext env; |
| 2055 v8::Debug::SetDebugEventListener(DebugEventBreakPointHitCount, |
| 2056 v8::Undefined()); |
| 2057 v8::Script::Compile(v8::String::New("function foo(){debugger;}"))->Run(); |
| 2058 v8::Local<v8::Function> foo = |
| 2059 v8::Local<v8::Function>::Cast(env->Global()->Get(v8::String::New("foo"))); |
| 2060 |
| 2061 // The debugger statement triggers breakpint hit |
| 2062 foo->Call(env->Global(), 0, NULL); |
| 2063 CHECK_EQ(1, break_point_hit_count); |
| 2064 |
| 2065 int bp = SetBreakPoint(foo, 0); |
| 2066 |
| 2067 // Set breakpoint does not duplicate hits |
| 2068 foo->Call(env->Global(), 0, NULL); |
| 2069 CHECK_EQ(2, break_point_hit_count); |
| 2070 |
| 2071 ClearBreakPoint(bp); |
| 2072 v8::Debug::SetDebugEventListener(NULL); |
| 2073 CheckDebuggerUnloaded(); |
| 2074 } |
| 2075 |
| 2076 |
2050 // Thest that the evaluation of expressions when a break point is hit generates | 2077 // Thest that the evaluation of expressions when a break point is hit generates |
2051 // the correct results. | 2078 // the correct results. |
2052 TEST(DebugEvaluate) { | 2079 TEST(DebugEvaluate) { |
2053 v8::HandleScope scope; | 2080 v8::HandleScope scope; |
2054 DebugLocalContext env; | 2081 DebugLocalContext env; |
2055 env.ExposeDebug(); | 2082 env.ExposeDebug(); |
2056 | 2083 |
2057 // Create a function for checking the evaluation when hitting a break point. | 2084 // Create a function for checking the evaluation when hitting a break point. |
2058 evaluate_check_function = CompileFunction(&env, | 2085 evaluate_check_function = CompileFunction(&env, |
2059 evaluate_check_source, | 2086 evaluate_check_source, |
(...skipping 4011 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6071 | 6098 |
6072 break_point_hit_count = 0; | 6099 break_point_hit_count = 0; |
6073 foo->Call(env->Global(), 0, NULL); | 6100 foo->Call(env->Global(), 0, NULL); |
6074 CHECK_EQ(1, break_point_hit_count); | 6101 CHECK_EQ(1, break_point_hit_count); |
6075 | 6102 |
6076 v8::Debug::SetDebugEventListener(NULL); | 6103 v8::Debug::SetDebugEventListener(NULL); |
6077 debugee_context = v8::Handle<v8::Context>(); | 6104 debugee_context = v8::Handle<v8::Context>(); |
6078 debugger_context = v8::Handle<v8::Context>(); | 6105 debugger_context = v8::Handle<v8::Context>(); |
6079 CheckDebuggerUnloaded(); | 6106 CheckDebuggerUnloaded(); |
6080 } | 6107 } |
OLD | NEW |