| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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: --expose-debug-as debug | 5 // Flags: --expose-debug-as debug --allow-natives-syntax --noalways-opt |
| 6 // Tests stepping into through Array.prototype.forEach callbacks. | 6 // Tests stepping into through Promises. |
| 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"); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 31 } | 31 } |
| 32 } | 32 } |
| 33 } catch(e) { | 33 } catch(e) { |
| 34 exception = e; | 34 exception = e; |
| 35 print(e, e.stack); | 35 print(e, e.stack); |
| 36 } | 36 } |
| 37 }; | 37 }; |
| 38 | 38 |
| 39 Debug.setListener(listener); | 39 Debug.setListener(listener); |
| 40 | 40 |
| 41 debugger; // Break 0. | 41 Promise.resolve(42) |
| 42 [1,2].forEach(callback); // Break 1. | 42 .then( |
| 43 function f0() { |
| 44 debugger; // Break 0. |
| 45 } // Break 1. |
| 46 ) |
| 47 .then(callback) |
| 48 .then(callback.bind(null)) |
| 49 .then(Object) |
| 50 .then(callback.bind(null).bind(null)) |
| 51 .then(finalize) |
| 52 .catch(function(err) { |
| 53 %AbortJS("FAIL: " + err); |
| 54 }); |
| 43 | 55 |
| 44 function callback(x) { | 56 function callback(x) { |
| 45 return x; // Break 2. // Break 4. | 57 return x; // Break 2. // Break 4. // Break 6. |
| 46 } // Break 3. // Break 5. | 58 } // Break 3. // Break 5. // Break 7. |
| 47 | 59 |
| 48 assertNull(exception); // Break 6. | 60 function finalize() { |
| 49 assertEquals(expected_breaks, break_count); | 61 assertNull(exception); // Break 8. |
| 62 assertEquals(expected_breaks, break_count); |
| 50 | 63 |
| 51 Debug.setListener(null); | 64 Debug.setListener(null); |
| 65 } |
| OLD | NEW |