Commit da0ca2af authored by yangguo@chromium.org's avatar yangguo@chromium.org

Expose promise value through promise mirror.

R=rossberg@chromium.org, yurys@chromium.org
BUG=v8:3093
LOG=Y

Review URL: https://codereview.chromium.org/258823012

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@21003 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 60b14ea6
......@@ -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.
......
......@@ -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');
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment