| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 // Flags: --allow-natives-syntax --expose-debug-as debug | |
| 6 | |
| 7 Debug = debug.Debug | |
| 8 var exception = null; | |
| 9 var break_count = 0; | |
| 10 const expected_breaks = 9; | |
| 11 | |
| 12 function listener(event, exec_state, event_data, data) { | |
| 13 try { | |
| 14 if (event == Debug.DebugEvent.Break) { | |
| 15 assertTrue(exec_state.frameCount() != 0, "FAIL: Empty stack trace"); | |
| 16 var source = exec_state.frame(0).sourceLineText(); | |
| 17 print("paused at: " + source); | |
| 18 assertTrue(source.indexOf("// Break " + break_count + ".") > 0, | |
| 19 "Unexpected pause at: " + source + "\n" + | |
| 20 "Expected: // Break " + break_count + "."); | |
| 21 if (source.indexOf("StepOver.") !== -1) { | |
| 22 exec_state.prepareStep(Debug.StepAction.StepNext); | |
| 23 } else { | |
| 24 exec_state.prepareStep(Debug.StepAction.StepIn); | |
| 25 } | |
| 26 ++break_count; | |
| 27 } | |
| 28 } catch (e) { | |
| 29 exception = e; | |
| 30 print(e, e.stack); | |
| 31 } | |
| 32 }; | |
| 33 | |
| 34 Debug.setListener(listener); | |
| 35 | |
| 36 Promise.resolve(42) | |
| 37 .then(promise1) | |
| 38 .then(Object) // Should skip stepping into native. | |
| 39 .then(Boolean) // Should skip stepping into native. | |
| 40 .then(promise2) | |
| 41 .catch(promise3) | |
| 42 .then(promise4) | |
| 43 .catch(function(e) { | |
| 44 %AbortJS("FAIL: uncaught exception " + e); | |
| 45 }); | |
| 46 | |
| 47 function promise1() { | |
| 48 debugger; // Break 0. | |
| 49 return exception || 1; // Break 1. | |
| 50 } // Break 2. | |
| 51 | |
| 52 function promise2() { | |
| 53 throw new Error; // Break 3. | |
| 54 } | |
| 55 | |
| 56 function promise3() { | |
| 57 return break_count; // Break 4. | |
| 58 } // Break 5. | |
| 59 | |
| 60 function promise4() { | |
| 61 finalize(); // Break 6. StepOver. | |
| 62 return 0; // Break 7. | |
| 63 } // Break 8. StepOver. | |
| 64 | |
| 65 function finalize() { | |
| 66 Promise.resolve().then(function() { | |
| 67 if (expected_breaks !== break_count) { | |
| 68 %AbortJS("FAIL: expected <" + expected_breaks + "> breaks instead of <" + | |
| 69 break_count + ">"); | |
| 70 } | |
| 71 if (exception !== null) { | |
| 72 %AbortJS("FAIL: exception: " + exception); | |
| 73 } | |
| 74 }); | |
| 75 } | |
| OLD | NEW |