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

Unified Diff: src/js/promise.js

Issue 1536013002: [promise] make Promise.resolve match spec (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Re-add mjsunit/es6/promises.js fixups Created 4 years, 12 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
« no previous file with comments | « no previous file | test/mjsunit/es6/promises.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/js/promise.js
diff --git a/src/js/promise.js b/src/js/promise.js
index a165817b7160ec3798f34e01917f5f4a8467a27b..6fc8728562c03f4e5def5bc4d3dcc72088b90b75 100644
--- a/src/js/promise.js
+++ b/src/js/promise.js
@@ -317,13 +317,13 @@ function PromiseCatch(onReject) {
function PromiseCast(x) {
if (!IS_RECEIVER(this)) {
- throw MakeTypeError(kCalledOnNonObject, PromiseCast);
- }
- if (IsPromise(x) && x.constructor === this) {
- return x;
- } else {
- return new this(function(resolve, reject) { resolve(x) });
+ throw MakeTypeError(kCalledOnNonObject, "Promise.resolve");
}
+ if (IsPromise(x) && x.constructor === this) return x;
+
+ var promiseCapability = NewPromiseCapability(this);
+ var resolveResult = %_Call(promiseCapability.resolve, UNDEFINED, x);
+ return promiseCapability.promise;
}
function PromiseAll(iterable) {
« no previous file with comments | « no previous file | test/mjsunit/es6/promises.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698