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 result = []; |
| 11 |
| 12 function listener(event, exec_state, event_data, data) { |
| 13 if (!(event_data instanceof debug.UpdatePromiseParentEvent)) return; |
| 14 try { |
| 15 assertTrue(event_data.promise().isPromise()); |
| 16 assertTrue(event_data.parentPromise().isPromise()); |
| 17 result.push({ promise: event_data.promise().value(), |
| 18 parentPromise: event_data.parentPromise().value() }); |
| 19 } catch (e) { |
| 20 print(e + e.stack); |
| 21 exception = e; |
| 22 } |
| 23 } |
| 24 |
| 25 Debug.setListener(listener); |
| 26 |
| 27 var p1 = new Promise(function(resolve, reject) { resolve(1) }); |
| 28 var p2 = p1.then().then(); |
| 29 var p3 = p2.then(); |
| 30 var p4 = p1.then(); |
| 31 |
| 32 assertEquals(4, result.length); |
| 33 assertSame(p1, result[0].parentPromise); |
| 34 assertSame(p2, result[1].promise); |
| 35 assertSame(p3, result[2].promise); |
| 36 assertSame(p2, result[2].parentPromise); |
| 37 assertSame(p4, result[3].promise); |
| 38 assertSame(p1, result[3].parentPromise); |
| 39 |
| 40 assertNull(exception); |
| 41 Debug.setListener(null); |
OLD | NEW |