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

Unified Diff: src/promise.js

Issue 212553009: Harden internal uses of .chain (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 9 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/promise.js
diff --git a/src/promise.js b/src/promise.js
index 9937f0ced70f32d9bb6fc162be8194e9712aa996..5a834bd7afb20f569dc1a0216869df3e1519f504 100644
--- a/src/promise.js
+++ b/src/promise.js
@@ -170,7 +170,7 @@ function PromiseChain(onResolve, onReject) { // a.k.a. flatMap
}
function PromiseCatch(onReject) {
- return this.chain(UNDEFINED, onReject);
+ return this.then(UNDEFINED, onReject);
}
function PromiseEnqueue(value, tasks) {
@@ -189,7 +189,7 @@ function PromiseHandle(value, handler, deferred) {
if (result === deferred.promise)
throw MakeTypeError('promise_cyclic', [result]);
else if (IsPromise(result))
- result.chain(deferred.resolve, deferred.reject);
+ %_CallFunction(result, deferred.resolve, deferred.reject, PromiseChain);
else
deferred.resolve(result);
} catch(e) {
@@ -208,13 +208,15 @@ function PromiseThen(onResolve, onReject) {
IS_NULL_OR_UNDEFINED(onReject) ? PromiseIdRejectHandler : onReject;
var that = this;
var constructor = this.constructor;
- return this.chain(
+ return %_CallFunction(
+ this,
function(x) {
x = PromiseCoerce(constructor, x);
return x === that ? onReject(MakeTypeError('promise_cyclic', [x])) :
IsPromise(x) ? x.then(onResolve, onReject) : onResolve(x);
},
- onReject
+ onReject,
+ PromiseChain
);
}
« 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