| 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 an abrupt completion |
| 5 |
es6id: 25.4.3.1 |
| 6 |
info: | |
| 7 |
[...] |
| 8 |
9. Let completion be Call(executor, undefined, |
| 9 |
«resolvingFunctions.[[Resolve]], resolvingFunctions.[[Reject]]»). |
| 10 |
10. If completion is an abrupt completion, then |
| 11 |
a. Let status be Call(resolvingFunctions.[[Reject]], undefined, |
| 12 |
«completion.[[value]]»). |
| 13 |
b. ReturnIfAbrupt(status). |
| 14 |
11. Return promise. |
| 15 |
|
| 16 |
25.4.1.3.1 Promise Reject Functions |
| 17 |
[...] |
| 18 |
6. Return RejectPromise(promise, reason). |
| 19 |
flags: [async] |
| 20 |
---*/ |
| 21 |
|
| 22 |
var thenable = new Promise(function() {}); |
| 23 |
var p = new Promise(function() { |
| 24 |
throw thenable; |
| 25 |
}); |
| 26 |
|
| 27 |
p.then(function() { |
| 28 |
$DONE('The promise should not be fulfilled.'); |
| 29 |
}, function(x) { |
| 30 |
if (x !== thenable) { |
| 31 |
$DONE('The promise should be rejected with the resolution value.'); |
| 32 |
return; |
| 33 |
} |
| 34 |
|
| 35 |
$DONE(); |
| 36 |
}); |