[builtins] Properly reject immediately throwing thenables.

Bug: chromium:830565
Change-Id: I1adab76e790a81f51f7b03165962992f5afecc99
Reviewed-on: https://chromium-review.googlesource.com/1023400
Commit-Queue: Benedikt Meurer <bmeurer@chromium.org>
Reviewed-by: Sigurd Schneider <sigurds@chromium.org>
Cr-Commit-Position: refs/heads/master@{#52748}
This commit is contained in:
Benedikt Meurer 2018-04-24 09:18:36 +02:00 committed by Commit Bot
parent 363996f7ab
commit 7f8e83b56d
3 changed files with 20 additions and 1 deletions

View File

@ -1110,7 +1110,7 @@ TF_BUILTIN(PromiseResolveThenableJob, PromiseBuiltinsAssembler) {
// We need to reject the {thenable}. // We need to reject the {thenable}.
Node* const result = CallJS( Node* const result = CallJS(
CodeFactory::Call(isolate(), ConvertReceiverMode::kNullOrUndefined), CodeFactory::Call(isolate(), ConvertReceiverMode::kNullOrUndefined),
native_context, UndefinedConstant(), var_exception.value()); native_context, reject, UndefinedConstant(), var_exception.value());
Return(result); Return(result);
} }
} }

View File

@ -0,0 +1,17 @@
// Copyright 2018 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --allow-natives-syntax
testAsync(assert => {
assert.plan(1);
const error = new TypeError('Throwing');
Promise.resolve({ then(resolve, reject) {
throw error;
}}).then(v => {
assert.unreachable();
}, e => {
assert.equals(error, e);
});
});

View File

@ -3,6 +3,8 @@ Test whether Promise treats thenable correctly.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
The promise is already rejected now. The promise is already rejected now.
PASS rejected
PASS result is "hello"
PASS successfullyParsed is true PASS successfullyParsed is true
TEST COMPLETE TEST COMPLETE