Skip to content

Commit 7f8e83b

Browse files
bmeurerCommit Bot
authored andcommitted
[builtins] Properly reject immediately throwing thenables.
Bug: chromium:830565 Change-Id: I1adab76e790a81f51f7b03165962992f5afecc99 Reviewed-on: https://chromium-review.googlesource.com/1023400 Commit-Queue: Benedikt Meurer <[email protected]> Reviewed-by: Sigurd Schneider <[email protected]> Cr-Commit-Position: refs/heads/master@{#52748}
1 parent 363996f commit 7f8e83b

3 files changed

Lines changed: 20 additions & 1 deletion

File tree

src/builtins/builtins-promise-gen.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1110,7 +1110,7 @@ TF_BUILTIN(PromiseResolveThenableJob, PromiseBuiltinsAssembler) {
11101110
// We need to reject the {thenable}.
11111111
Node* const result = CallJS(
11121112
CodeFactory::Call(isolate(), ConvertReceiverMode::kNullOrUndefined),
1113-
native_context, UndefinedConstant(), var_exception.value());
1113+
native_context, reject, UndefinedConstant(), var_exception.value());
11141114
Return(result);
11151115
}
11161116
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Copyright 2018 the V8 project authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
// Flags: --allow-natives-syntax
6+
7+
testAsync(assert => {
8+
assert.plan(1);
9+
const error = new TypeError('Throwing');
10+
Promise.resolve({ then(resolve, reject) {
11+
throw error;
12+
}}).then(v => {
13+
assert.unreachable();
14+
}, e => {
15+
assert.equals(error, e);
16+
});
17+
});

test/webkit/fast/js/Promise-resolve-with-then-exception-expected.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ Test whether Promise treats thenable correctly.
33
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
44

55
The promise is already rejected now.
6+
PASS rejected
7+
PASS result is "hello"
68
PASS successfullyParsed is true
79

810
TEST COMPLETE

0 commit comments

Comments
 (0)