Reviewers: rossberg,

Description:
Expose promise value through promise mirror.

[email protected]
BUG=v8:3093
LOG=Y

Please review this at https://codereview.chromium.org/258823012/

SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge

Affected files (+20, -5 lines):
  M src/mirror-debugger.js
  M test/mjsunit/es6/mirror-promises.js


Index: src/mirror-debugger.js
diff --git a/src/mirror-debugger.js b/src/mirror-debugger.js
index 9cde02b8bc75f3e97ade2e92a2843346b0114d7d..26ed909dfdedcfc3818c5a01fc44977b46cddc3c 100644
--- a/src/mirror-debugger.js
+++ b/src/mirror-debugger.js
@@ -1216,6 +1216,11 @@ PromiseMirror.prototype.status = function() {
 };


+PromiseMirror.prototype.promiseValue = function() {
+  return %GetPromiseValue(this.value_);
+};
+
+
 /**
  * Base mirror object for properties.
  * @param {ObjectMirror} mirror The mirror object having this property
@@ -2533,6 +2538,7 @@ JSONProtocolSerializer.prototype.serializeObject_ = function(mirror, content,
   if (mirror.isPromise()) {
     // Add promise specific properties.
     content.status = mirror.status();
+    content.promiseValue = mirror.promiseValue();
   }

// Add actual properties - named properties followed by indexed properties.
Index: test/mjsunit/es6/mirror-promises.js
diff --git a/test/mjsunit/es6/mirror-promises.js b/test/mjsunit/es6/mirror-promises.js index c0eb5bf9bb286f4dfd55e25b4cef8db54c86f547..5a21a6b9e621487b56745829ad03fbac1b16845f 100644
--- a/test/mjsunit/es6/mirror-promises.js
+++ b/test/mjsunit/es6/mirror-promises.js
@@ -17,7 +17,7 @@ MirrorRefCache.prototype.lookup = function(handle) {
   return this.refs_[handle];
 }

-function testPromiseMirror(promise, status) {
+function testPromiseMirror(promise, status, value) {
   // Create mirror and JSON representation.
   var mirror = debug.MakeMirror(promise);
   var serializer = debug.MakeMirrorSerializer();
@@ -39,6 +39,7 @@ function testPromiseMirror(promise, status) {
   assertEquals("Object", mirror.className());
   assertEquals("#<Promise>", mirror.toText());
   assertSame(promise, mirror.value());
+  assertEquals(value, mirror.promiseValue());

   // Parse JSON representation and check.
   var fromJSON = eval('(' + json + ')');
@@ -47,7 +48,7 @@ function testPromiseMirror(promise, status) {
assertEquals('function', refs.lookup(fromJSON.constructorFunction.ref).type); assertEquals('Promise', refs.lookup(fromJSON.constructorFunction.ref).name);
   assertEquals(status, fromJSON.status);
-
+  assertEquals(value, fromJSON.promiseValue);
 }

 // Test a number of different promises.
@@ -55,6 +56,14 @@ var resolved = new Promise(function(resolve, reject) { resolve() });
 var rejected = new Promise(function(resolve, reject) { reject() });
 var pending = new Promise(function(resolve, reject) {});

-testPromiseMirror(resolved, "resolved");
-testPromiseMirror(rejected, "rejected");
-testPromiseMirror(pending, "pending");
+testPromiseMirror(resolved, "resolved", undefined);
+testPromiseMirror(rejected, "rejected", undefined);
+testPromiseMirror(pending, "pending", undefined);
+
+var resolvedv = new Promise(function(resolve, reject) { resolve('resolve') }); +var rejectedv = new Promise(function(resolve, reject) { reject('reject') });
+var thrownv = new Promise(function(resolve, reject) { throw 'throw' });
+
+testPromiseMirror(resolvedv, "resolved", 'resolve');
+testPromiseMirror(rejectedv, "rejected", 'reject');
+testPromiseMirror(thrownv, "rejected", 'throw');


--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to