| 1 |
// Copyright (C) 2016 the V8 project authors. All rights reserved. |
| 2 |
// This code is governed by the BSD license found in the LICENSE file. |
| 3 |
/*--- |
| 4 |
description: Rejecting through immediate invocation of the provided resolving function |
| 5 |
es6id: 25.4.4.3 |
| 6 |
info: | |
| 7 |
[...] |
| 8 |
6. Let promiseCapability be NewPromiseCapability(C). |
| 9 |
[...] |
| 10 |
11. Let result be PerformPromiseRace(iteratorRecord, promiseCapability, C). |
| 11 |
[...] |
| 12 |
|
| 13 |
25.4.4.3.1 Runtime Semantics: PerformPromiseRace |
| 14 |
1. Repeat |
| 15 |
[...] |
| 16 |
j. Let result be Invoke(nextPromise, "then", |
| 17 |
«promiseCapability.[[Resolve]], promiseCapability.[[Reject]]»). |
| 18 |
|
| 19 |
25.4.1.3.1 Promise Reject Functions |
| 20 |
[...] |
| 21 |
6. Return RejectPromise(promise, reason). |
| 22 |
flags: [async] |
| 23 |
---*/ |
| 24 |
|
| 25 |
var thenable = { |
| 26 |
then: function(_, reject) { |
| 27 |
reject(); |
| 28 |
} |
| 29 |
}; |
| 30 |
|
| 31 |
Promise.race([thenable]) |
| 32 |
.then(function() { |
| 33 |
$DONE('The promise should not be fulfilled.'); |
| 34 |
}, function() { |
| 35 |
$DONE(); |
| 36 |
}); |