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 promise, status, value; |
| 11 var newPromise = 0, updatePromise = 0, counter = 0; |
| 12 |
| 13 function listener(event, exec_state, event_data, data) { |
| 14 if (event_data instanceof debug.NewPromiseEvent) { |
| 15 newPromise = counter; |
| 16 counter++; |
| 17 return; |
| 18 } |
| 19 if (!(event_data instanceof debug.UpdatePromiseStatusEvent)) return; |
| 20 try { |
| 21 updatePromise = counter; |
| 22 assertTrue(newPromise < updatePromise); |
| 23 counter++; |
| 24 |
| 25 assertTrue(event_data.promise().isPromise()); |
| 26 promise = event_data.promise().value(); |
| 27 |
| 28 status = event_data.status(); |
| 29 |
| 30 value = event_data.value().value(); |
| 31 } catch (e) { |
| 32 print(e + e.stack); |
| 33 exception = e; |
| 34 } |
| 35 } |
| 36 |
| 37 Debug.setListener(listener); |
| 38 |
| 39 var p1 = new Promise(function(resolve, reject) { resolve(1) }); |
| 40 assertSame(promise, p1); |
| 41 assertEquals(status, 1); |
| 42 assertEquals(value, 1); |
| 43 |
| 44 var p2 = new Promise(function(resolve, reject) { reject(2) }); |
| 45 assertSame(promise, p2); |
| 46 assertEquals(status, -1); |
| 47 assertEquals(value, 2); |
| 48 |
| 49 assertNull(exception); |
| 50 Debug.setListener(null); |
OLD | NEW |