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

Unified Diff: src/js/promise.js

Issue 1561193002: [promise] Test IsPromise() early in Promise.prototype.then() (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 11 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/test262/test262.status » ('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 ebc5802da12e7147d89908ef3bec7b0a1478d79c..91ebf898a9bf01f94b452a6fc9b8b16e3b4a8a32 100644
--- a/src/js/promise.js
+++ b/src/js/promise.js
@@ -274,16 +274,16 @@ function PromiseRejected(r) {
// Multi-unwrapped chaining with thenable coercion.
function PromiseThen(onResolve, onReject) {
+ var status = GET_PRIVATE(this, promiseStatusSymbol);
+ if (IS_UNDEFINED(status)) {
+ throw MakeTypeError(kNotAPromise, this);
+ }
+
var constructor = this.constructor;
onResolve = IS_CALLABLE(onResolve) ? onResolve : PromiseIdResolveHandler;
onReject = IS_CALLABLE(onReject) ? onReject : PromiseIdRejectHandler;
var deferred = NewPromiseCapability(constructor);
- switch (GET_PRIVATE(this, promiseStatusSymbol)) {
- case UNDEFINED:
- // TODO(littledan): The type check should be called before
- // constructing NewPromiseCapability; this is observable when
- // erroneously copying this method to other classes.
- throw MakeTypeError(kNotAPromise, this);
+ switch (status) {
case 0: // Pending
GET_PRIVATE(this, promiseOnResolveSymbol).push(onResolve, deferred);
GET_PRIVATE(this, promiseOnRejectSymbol).push(onReject, deferred);
« no previous file with comments | « no previous file | test/test262/test262.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698