| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Flags: --harmony-object-observe | 5 // Flags: --harmony-object-observe |
| 6 // Flags: --allow-natives-syntax --expose-debug-as debug | 6 // Flags: --allow-natives-syntax --expose-debug-as debug |
| 7 | 7 |
| 8 Debug = debug.Debug | 8 Debug = debug.Debug |
| 9 var exception = null; | 9 var exception = null; |
| 10 var break_count = 0; | 10 var break_count = 0; |
| 11 var expected_breaks = -1; | 11 var expected_breaks = -1; |
| 12 | 12 |
| 13 function listener(event, exec_state, event_data, data) { | 13 function listener(event, exec_state, event_data, data) { |
| 14 try { | 14 try { |
| 15 if (event == Debug.DebugEvent.Break) { | 15 if (event == Debug.DebugEvent.Break) { |
| 16 assertTrue(exec_state.frameCount() != 0, "FAIL: Empty stack trace"); | 16 assertTrue(exec_state.frameCount() != 0, "FAIL: Empty stack trace"); |
| 17 if (!break_count) { | 17 if (!break_count) { |
| 18 // Count number of expected breakpoints in this source file. | 18 // Count number of expected breakpoints in this source file. |
| 19 var source_text = exec_state.frame(0).func().script().source(); | 19 var source_text = exec_state.frame(0).func().script().source(); |
| 20 expected_breaks = source_text.match(/\/\/\s*Break\s+\d+\./g).length; | 20 expected_breaks = source_text.match(/\/\/\s*Break\s+\d+\./g).length; |
| 21 print("Expected breaks: " + expected_breaks); | 21 print("Expected breaks: " + expected_breaks); |
| 22 } | 22 } |
| 23 var source = exec_state.frame(0).sourceLineText(); | 23 var source = exec_state.frame(0).sourceLineText(); |
| 24 print("paused at: " + source); | 24 print("paused at: " + source); |
| 25 assertTrue(source.indexOf("// Break " + break_count + ".") > 0, | 25 assertTrue(source.indexOf("// Break " + break_count + ".") > 0, |
| 26 "Unexpected pause at: " + source + "\n" + | 26 "Unexpected pause at: " + source + "\n" + |
| 27 "Expected: // Break " + break_count + "."); | 27 "Expected: // Break " + break_count + "."); |
| 28 if (source.indexOf("StepOver.") !== -1) { | 28 if (source.indexOf("StepOver.") !== -1) { |
| 29 exec_state.prepareStep(Debug.StepAction.StepNext, 1); | 29 exec_state.prepareStep(Debug.StepAction.StepNext); |
| 30 } else { | 30 } else { |
| 31 exec_state.prepareStep(Debug.StepAction.StepIn, 1); | 31 exec_state.prepareStep(Debug.StepAction.StepIn); |
| 32 } | 32 } |
| 33 ++break_count; | 33 ++break_count; |
| 34 } | 34 } |
| 35 } catch (e) { | 35 } catch (e) { |
| 36 exception = e; | 36 exception = e; |
| 37 print(e, e.stack); | 37 print(e, e.stack); |
| 38 } | 38 } |
| 39 }; | 39 }; |
| 40 | 40 |
| 41 Debug.setListener(listener); | 41 Debug.setListener(listener); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 if (expected_breaks !== break_count) { | 93 if (expected_breaks !== break_count) { |
| 94 %AbortJS("FAIL: expected <" + expected_breaks + "> breaks instead of <" + | 94 %AbortJS("FAIL: expected <" + expected_breaks + "> breaks instead of <" + |
| 95 break_count + ">"); | 95 break_count + ">"); |
| 96 } | 96 } |
| 97 if (exception !== null) { | 97 if (exception !== null) { |
| 98 %AbortJS("FAIL: exception: " + exception); | 98 %AbortJS("FAIL: exception: " + exception); |
| 99 } | 99 } |
| 100 }); | 100 }); |
| 101 dummy.foo = 1; | 101 dummy.foo = 1; |
| 102 } | 102 } |
| OLD | NEW |