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: --harmony-promises --expose-debug-as debug |
| 6 |
| 7 // Test debug events when we only listen to uncaught exceptions and |
| 8 // there is a catch handler for the exception thrown in a Promise. |
| 9 // Expectation: |
| 10 // - no debug event is triggered. |
| 11 |
| 12 Debug = debug.Debug; |
| 13 |
| 14 var p = new Promise(function(resolve, reject) { |
| 15 resolve(); |
| 16 }); |
| 17 |
| 18 var q = p.chain( |
| 19 function() { |
| 20 throw new Error("caught"); |
| 21 }); |
| 22 |
| 23 q.catch( |
| 24 function(e) { |
| 25 assertEquals("caught", e.message); |
| 26 }); |
| 27 |
| 28 function listener(event, exec_state, event_data, data) { |
| 29 try { |
| 30 assertTrue(event != Debug.DebugEvent.Exception); |
| 31 assertTrue(event != Debug.DebugEvent.PendingExceptionInPromise); |
| 32 } catch (e) { |
| 33 // Signal a failure with exit code 1. This is necessary since the |
| 34 // debugger swallows exceptions and we expect the chained function |
| 35 // and this listener to be executed after the main script is finished. |
| 36 print("Unexpected exception: " + e + "\n" + e.stack); |
| 37 quit(1); |
| 38 } |
| 39 } |
| 40 |
| 41 Debug.setBreakOnUncaughtException(); |
| 42 Debug.setListener(listener); |
OLD | NEW |