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 var expected_breaks = 7; |
| 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); |
| 20 if (source.indexOf("StepOver.") !== -1) { |
| 21 exec_state.prepareStep(Debug.StepAction.StepNext, 1); |
| 22 } else { |
| 23 exec_state.prepareStep(Debug.StepAction.StepIn, 1); |
| 24 } |
| 25 ++break_count; |
| 26 } else if (event == Debug.DebugEvent.AsyncTaskEvent && |
| 27 event_data.type() === "willHandle" && |
| 28 event_data.name() !== "Object.observe" && |
| 29 break_count > 0) { |
| 30 exec_state.prepareStep(Debug.StepAction.StepIn, 1); |
| 31 } |
| 32 } catch (e) { |
| 33 exception = e; |
| 34 print(e, e.stack); |
| 35 } |
| 36 }; |
| 37 |
| 38 Debug.setListener(listener); |
| 39 |
| 40 Promise.resolve(42) |
| 41 .then(promise1) |
| 42 .then(Object) // Should skip stepping into native. |
| 43 .then(Boolean) // Should skip stepping into native. |
| 44 .then(promise2) |
| 45 .then(undefined, promise3) |
| 46 .catch(function(e) { |
| 47 %AbortJS("FAIL: uncaught exception " + e); |
| 48 }); |
| 49 |
| 50 function promise1() |
| 51 { |
| 52 debugger; // Break 0. |
| 53 return exception || 1; // Break 1. |
| 54 } // Break 2. |
| 55 |
| 56 function promise2() |
| 57 { |
| 58 throw new Error; // Break 3. |
| 59 } |
| 60 |
| 61 function promise3() |
| 62 { |
| 63 finalize(); // Break 4. StepOver. |
| 64 return break_count; // Break 5. |
| 65 } // Break 6. |
| 66 |
| 67 function finalize() |
| 68 { |
| 69 var dummy = {}; |
| 70 Object.observe(dummy, function() { |
| 71 if (expected_breaks !== break_count) { |
| 72 %AbortJS("FAIL: expected <" + expected_breaks + "> breaks instead of <" + |
| 73 break_count + ">"); |
| 74 } |
| 75 if (exception !== null) { |
| 76 %AbortJS("FAIL: exception: " + exception); |
| 77 } |
| 78 }); |
| 79 dummy.foo = 1; |
| 80 } |
OLD | NEW |