[promise] Test IsPromise() early in Promise.prototype.then()
Addresses TODO by Dan --- simply by moving the check and exception earlier in the function, before calling NewPromiseCapability() or loading the constructor. BUG=v8:4633 LOG=N R=adamk@chromium.org, littledan@chromium.org, cbruni@chromium.org Fixes 'test262/built-ins/Promise/prototype/then/context-check-on-entry' Review URL: https://codereview.chromium.org/1561193002 Cr-Commit-Position: refs/heads/master@{#33137}
This commit is contained in:
parent
2c63060f11
commit
6cd8535c3b
@ -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);
|
||||
|
@ -415,7 +415,6 @@
|
||||
|
||||
# https://bugs.chromium.org/p/v8/issues/detail?id=4633
|
||||
'built-ins/Promise/prototype/then/deferred-is-resolved-value': [SKIP],
|
||||
'built-ins/Promise/prototype/then/context-check-on-entry': [FAIL],
|
||||
'built-ins/Promise/exception-after-resolve-in-executor': [FAIL],
|
||||
'built-ins/Promise/reject-function-name': [FAIL],
|
||||
'built-ins/Promise/reject-function-nonconstructor': [FAIL],
|
||||
|
Loading…
Reference in New Issue
Block a user