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: --expose-debug-as debug | |
6 | |
7 Debug = debug.Debug; | |
8 | |
9 var exception = null; | |
10 var new_promise; | |
11 | |
12 function listener(event, exec_state, event_data, data) { | |
13 if (!(event_data instanceof debug.NewPromiseEvent)) return; | |
14 try { | |
15 assertTrue(event_data.resolver().isFunction()); | |
16 assertEquals(resolver, event_data.resolver().value()); | |
17 assertTrue(event_data.resolver().resolved()); | |
18 assertEquals("resolver", event_data.resolver().name()); | |
19 assertTrue(event_data.resolver().source().indexOf("Token") > 0); | |
20 | |
21 assertTrue(event_data.promise().isPromise()); | |
22 new_promise = event_data.promise().value(); | |
23 assertEquals("pending", event_data.promise().status()); | |
24 } catch (e) { | |
25 print(e + e.stack) | |
26 exception = e; | |
27 } | |
28 } | |
29 | |
30 Debug.setListener(listener); | |
31 | |
32 function resolver(resolve, reject) { | |
33 resolve(); // Token | |
34 } | |
35 | |
36 var p = new Promise(resolver); | |
37 assertEquals(new_promise, p); | |
38 | |
39 assertNull(exception); | |
40 Debug.setListener(null); | |
OLD | NEW |