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

Unified Diff: src/js/promise.js

Issue 2219623002: [promise] Spec compliance fixes for async/await (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Test for rejection Created 4 years, 4 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 | « src/js/prologue.js ('k') | test/mjsunit/harmony/async-await-no-constructor.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 20ffc8c4892327ac68f5242c7900a1006303959e..2f8d5567ceb37aa37832bd8fe4c23e7b446b0486 100644
--- a/src/js/promise.js
+++ b/src/js/promise.js
@@ -386,8 +386,20 @@ function PromiseCreateRejected(r) {
return %_Call(PromiseReject, GlobalPromise, r);
}
-function PromiseCreateResolved(x) {
- return %_Call(PromiseResolve, GlobalPromise, x);
+function PromiseCreateResolved(value) {
+ var promise = PromiseInit(new GlobalPromise(promiseRawSymbol));
+ var resolveResult = ResolvePromise(promise, value);
+ return promise;
+}
+
+function PromiseCastResolved(value) {
caitp 2016/08/06 00:55:50 nit: an alternative name for this would be very ni
+ if (IsPromise(value)) {
+ return value;
+ } else {
+ var promise = PromiseInit(new GlobalPromise(promiseRawSymbol));
+ var resolveResult = ResolvePromise(promise, value);
+ return promise;
+ }
}
function PerformPromiseThen(promise, onResolve, onReject, resultCapability) {
@@ -629,14 +641,11 @@ utils.InstallFunctions(extrasUtils, 0, [
fn => %FunctionRemovePrototype(fn));
utils.Export(function(to) {
- to.IsPromise = IsPromise;
-
to.PromiseChain = PromiseChain;
to.PromiseDefer = PromiseDefer;
to.PromiseAccept = PromiseAccept;
- to.PromiseCreateRejected = PromiseCreateRejected;
- to.PromiseCreateResolved = PromiseCreateResolved;
+ to.PromiseCastResolved = PromiseCastResolved;
to.PromiseThen = PromiseThen;
to.GlobalPromise = GlobalPromise;
« no previous file with comments | « src/js/prologue.js ('k') | test/mjsunit/harmony/async-await-no-constructor.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698