Index: test/mjsunit/es6/debug-promises-update-parent-event.js |
diff --git a/test/mjsunit/es6/debug-promises-update-parent-event.js b/test/mjsunit/es6/debug-promises-update-parent-event.js |
new file mode 100644 |
index 0000000000000000000000000000000000000000..f65379621ba436cc3ac45ebd9466b1063ca40944 |
--- /dev/null |
+++ b/test/mjsunit/es6/debug-promises-update-parent-event.js |
@@ -0,0 +1,41 @@ |
+// 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 result = []; |
+ |
+function listener(event, exec_state, event_data, data) { |
+ if (!(event_data instanceof debug.UpdatePromiseParentEvent)) return; |
+ try { |
+ assertTrue(event_data.promise().isPromise()); |
+ assertTrue(event_data.parentPromise().isPromise()); |
+ result.push({ promise: event_data.promise().value(), |
+ parentPromise: event_data.parentPromise().value() }); |
+ } catch (e) { |
+ print(e + e.stack); |
+ exception = e; |
+ } |
+} |
+ |
+Debug.setListener(listener); |
+ |
+var p1 = new Promise(function(resolve, reject) { resolve(1) }); |
+var p2 = p1.then().then(); |
+var p3 = p2.then(); |
+var p4 = p1.then(); |
+ |
+assertEquals(4, result.length); |
+assertSame(p1, result[0].parentPromise); |
+assertSame(p2, result[1].promise); |
+assertSame(p3, result[2].promise); |
+assertSame(p2, result[2].parentPromise); |
+assertSame(p4, result[3].promise); |
+assertSame(p1, result[3].parentPromise); |
+ |
+assertNull(exception); |
+Debug.setListener(null); |