| 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 2427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2438 foo->Call(env->Global(), 0, NULL); | 2438 foo->Call(env->Global(), 0, NULL); |
| 2439 | 2439 |
| 2440 // Without stepping only the debugger statement is hit. | 2440 // Without stepping only the debugger statement is hit. |
| 2441 CHECK_EQ(1, break_point_hit_count); | 2441 CHECK_EQ(1, break_point_hit_count); |
| 2442 | 2442 |
| 2443 v8::Debug::SetDebugEventListener(NULL); | 2443 v8::Debug::SetDebugEventListener(NULL); |
| 2444 CheckDebuggerUnloaded(); | 2444 CheckDebuggerUnloaded(); |
| 2445 } | 2445 } |
| 2446 | 2446 |
| 2447 | 2447 |
| 2448 // Test that step in works with function.call. |
| 2449 TEST(DebugStepFunctionCall) { |
| 2450 v8::HandleScope scope; |
| 2451 DebugLocalContext env; |
| 2452 |
| 2453 // Create a function for testing stepping. |
| 2454 v8::Local<v8::Function> foo = CompileFunction( |
| 2455 &env, |
| 2456 "function bar(x, y, z) { if (x == 1) { a = y; b = z; } }" |
| 2457 "function foo(a){ debugger;" |
| 2458 " if (a) {" |
| 2459 " bar.call(this, 1, 2, 3);" |
| 2460 " } else {" |
| 2461 " bar.call(this, 0);" |
| 2462 " }" |
| 2463 "}", |
| 2464 "foo"); |
| 2465 |
| 2466 // Register a debug event listener which steps and counts. |
| 2467 v8::Debug::SetDebugEventListener(DebugEventStep); |
| 2468 step_action = StepIn; |
| 2469 |
| 2470 // Check stepping where the if condition in bar is false. |
| 2471 break_point_hit_count = 0; |
| 2472 foo->Call(env->Global(), 0, NULL); |
| 2473 CHECK_EQ(4, break_point_hit_count); |
| 2474 |
| 2475 // Check stepping where the if condition in bar is true. |
| 2476 break_point_hit_count = 0; |
| 2477 const int argc = 1; |
| 2478 v8::Handle<v8::Value> argv[argc] = { v8::True() }; |
| 2479 foo->Call(env->Global(), argc, argv); |
| 2480 CHECK_EQ(6, break_point_hit_count); |
| 2481 |
| 2482 v8::Debug::SetDebugEventListener(NULL); |
| 2483 CheckDebuggerUnloaded(); |
| 2484 |
| 2485 // Register a debug event listener which just counts. |
| 2486 v8::Debug::SetDebugEventListener(DebugEventBreakPointHitCount); |
| 2487 |
| 2488 break_point_hit_count = 0; |
| 2489 foo->Call(env->Global(), 0, NULL); |
| 2490 |
| 2491 // Without stepping only the debugger statement is hit. |
| 2492 CHECK_EQ(1, break_point_hit_count); |
| 2493 |
| 2494 v8::Debug::SetDebugEventListener(NULL); |
| 2495 CheckDebuggerUnloaded(); |
| 2496 } |
| 2497 |
| 2498 |
| 2448 // Test break on exceptions. For each exception break combination the number | 2499 // Test break on exceptions. For each exception break combination the number |
| 2449 // of debug event exception callbacks and message callbacks are collected. The | 2500 // of debug event exception callbacks and message callbacks are collected. The |
| 2450 // number of debug event exception callbacks are used to check that the | 2501 // number of debug event exception callbacks are used to check that the |
| 2451 // debugger is called correctly and the number of message callbacks is used to | 2502 // debugger is called correctly and the number of message callbacks is used to |
| 2452 // check that uncaught exceptions are still returned even if there is a break | 2503 // check that uncaught exceptions are still returned even if there is a break |
| 2453 // for them. | 2504 // for them. |
| 2454 TEST(BreakOnException) { | 2505 TEST(BreakOnException) { |
| 2455 v8::HandleScope scope; | 2506 v8::HandleScope scope; |
| 2456 DebugLocalContext env; | 2507 DebugLocalContext env; |
| 2457 env.ExposeDebug(); | 2508 env.ExposeDebug(); |
| (...skipping 1671 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4129 bool allow_natives_syntax = i::FLAG_allow_natives_syntax; | 4180 bool allow_natives_syntax = i::FLAG_allow_natives_syntax; |
| 4130 i::FLAG_allow_natives_syntax = true; | 4181 i::FLAG_allow_natives_syntax = true; |
| 4131 CompileRun( | 4182 CompileRun( |
| 4132 "var scripts = %DebugGetLoadedScripts();" | 4183 "var scripts = %DebugGetLoadedScripts();" |
| 4133 "for (var i = 0; i < scripts.length; ++i) {" | 4184 "for (var i = 0; i < scripts.length; ++i) {" |
| 4134 " scripts[i].line_ends;" | 4185 " scripts[i].line_ends;" |
| 4135 "}"); | 4186 "}"); |
| 4136 // Must not crash while accessing line_ends. | 4187 // Must not crash while accessing line_ends. |
| 4137 i::FLAG_allow_natives_syntax = allow_natives_syntax; | 4188 i::FLAG_allow_natives_syntax = allow_natives_syntax; |
| 4138 } | 4189 } |
| OLD | NEW |