Index: test/mjsunit/es6/debug-promises-update-status-event.js |
diff --git a/test/mjsunit/es6/debug-promises-update-status-event.js b/test/mjsunit/es6/debug-promises-update-status-event.js |
new file mode 100644 |
index 0000000000000000000000000000000000000000..7f7950ed4c987d42ee4c4cb194493b8590af318f |
--- /dev/null |
+++ b/test/mjsunit/es6/debug-promises-update-status-event.js |
@@ -0,0 +1,50 @@ |
+// Copyright 2014 the V8 project authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+// Flags: --expose-debug-as debug |
+ |
+Debug = debug.Debug; |
+ |
+var exception = null; |
+var promise, status, value; |
+var newPromise = 0, updatePromise = 0, counter = 0; |
+ |
+function listener(event, exec_state, event_data, data) { |
+ if (event_data instanceof debug.NewPromiseEvent) { |
+ newPromise = counter; |
+ counter++; |
+ return; |
+ } |
+ if (!(event_data instanceof debug.UpdatePromiseStatusEvent)) return; |
+ try { |
+ updatePromise = counter; |
+ assertTrue(newPromise < updatePromise); |
+ counter++; |
+ |
+ assertTrue(event_data.promise().isPromise()); |
+ promise = event_data.promise().value(); |
+ |
+ status = event_data.status(); |
+ |
+ value = event_data.value().value(); |
+ } catch (e) { |
+ print(e + e.stack); |
+ exception = e; |
+ } |
+} |
+ |
+Debug.setListener(listener); |
+ |
+var p1 = new Promise(function(resolve, reject) { resolve(1) }); |
+assertSame(promise, p1); |
+assertEquals(status, 1); |
+assertEquals(value, 1); |
+ |
+var p2 = new Promise(function(resolve, reject) { reject(2) }); |
+assertSame(promise, p2); |
+assertEquals(status, -1); |
+assertEquals(value, 2); |
+ |
+assertNull(exception); |
+Debug.setListener(null); |