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 Debug = debug.Debug; | |
8 | |
9 var resolve_fun; | |
10 var log = []; | |
11 var step = 0; | |
12 var exception = undefined; | |
13 | |
14 var p = new Promise(function(resolve, reject) { | |
15 log.push("resolve"); | |
16 resolve(); | |
17 }); | |
18 | |
19 var q = p.chain( | |
20 function() { | |
21 log.push("throw"); | |
22 throw new Error("uncaught"); | |
23 }); | |
24 | |
25 function listener(event, exec_state, event_data, data) { | |
26 try { | |
27 assertEquals(["resolve", "end main", "throw"], log); | |
28 if (event == Debug.DebugEvent.Exception) { | |
29 assertEquals(0, step); | |
30 exception = event_data.exception(); | |
31 assertEquals(undefined, event_data.deferred_promise()); | |
32 } else if (event == Debug.DebugEvent.PendingExceptionInPromise) { | |
33 assertEquals(1, step); | |
34 assertEquals(exception, event_data.exception()); | |
35 assertEquals("uncaught", exception.message); | |
36 assertEquals('object', typeof event_data.deferred_promise()); | |
rossberg
2014/04/24 07:27:36
You could more specifically test 'event_data.promi
| |
37 } else { | |
38 assertUnreachable(); | |
39 } | |
40 step++; | |
41 } catch (e) { | |
42 // Signal a failure with exit code 1. This is necessary since the | |
43 // debugger swallows exceptions and we expect the chained function | |
44 // and this listener to be executed after the main script is finished. | |
45 print(e + "\n" + e.stack); | |
rossberg
2014/04/24 07:27:36
Maybe add "Unexpected exception: ".
| |
46 quit(1); | |
47 } | |
48 } | |
49 | |
50 Debug.setBreakOnException(); | |
51 Debug.setListener(listener); | |
52 | |
53 log.push("end main"); | |
OLD | NEW |