Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1604)

Unified Diff: test/mjsunit/es6/debug-promises-update-parent-event.js

Issue 393283007: Introduce more debug events for promises. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Address comments + REBASE Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..8d972c547dee6d924b7a0df66e42e3dbaafe9b28
--- /dev/null
+++ b/test/mjsunit/es6/debug-promises-update-parent-event.js
@@ -0,0 +1,39 @@
+// 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, parentPromise;
+var counter = 0;
+
+function listener(event, exec_state, event_data, data) {
+ if (!(event_data instanceof debug.UpdatePromiseParentEvent)) return;
+ try {
+ counter++;
+
+ assertTrue(event_data.promise().isPromise());
+ promise = event_data.promise().value();
+
+ assertTrue(event_data.parentPromise().isPromise());
+ parentPromise = event_data.parentPromise().value();
Yang 2014/07/24 08:43:58 how about, instead of using a single value for par
Alexandra Mikhaylova 2014/07/24 09:18:37 Thanks, done. Added an array of promise/parent pai
+ } 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();
Yang 2014/07/24 08:43:58 Instead of a chain of promises, how about having a
Alexandra Mikhaylova 2014/07/24 09:18:37 Done.
+assertSame(parentPromise, p2);
+assertSame(promise, p3);
+assertEquals(3, counter);
+
+assertNull(exception);
+Debug.setListener(null);

Powered by Google App Engine
This is Rietveld 408576698