| 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: Resolving with a non-thenable object value |
| 5 |
es6id: 25.4.4.1 |
| 6 |
info: | |
| 7 |
[...] |
| 8 |
6. Let promiseCapability be NewPromiseCapability(C). |
| 9 |
[...] |
| 10 |
11. Let result be PerformPromiseAll(iteratorRecord, C, promiseCapability). |
| 11 |
[...] |
| 12 |
|
| 13 |
25.4.4.1.1 Runtime Semantics: PerformPromiseAll |
| 14 |
[...] |
| 15 |
6. Repeat |
| 16 |
[...] |
| 17 |
d. If next is false, |
| 18 |
[...] |
| 19 |
iii. If remainingElementsCount.[[value]] is 0, |
| 20 |
1. Let valuesArray be CreateArrayFromList(values). |
| 21 |
2. Let resolveResult be Call(resultCapability.[[Resolve]], |
| 22 |
undefined, «valuesArray»). |
| 23 |
3. ReturnIfAbrupt(resolveResult) |
| 24 |
iv. Return resultCapability.[[Promise]]. |
| 25 |
|
| 26 |
25.4.1.3.2 Promise Resolve Functions |
| 27 |
[...] |
| 28 |
8. Let then be Get(resolution, "then"). |
| 29 |
9. If then is an abrupt completion, then |
| 30 |
[...] |
| 31 |
10. Let thenAction be then.[[value]]. |
| 32 |
11. If IsCallable(thenAction) is false, then |
| 33 |
a. Return FulfillPromise(promise, resolution). |
| 34 |
flags: [async] |
| 35 |
---*/ |
| 36 |
|
| 37 |
var v1 = {}; |
| 38 |
var v2 = {}; |
| 39 |
var v3 = {}; |
| 40 |
|
| 41 |
Promise.all([v1, v2, v3]) |
| 42 |
.then(function(values) { |
| 43 |
if (!values) { |
| 44 |
$DONE('The promise should be resolved with a value.'); |
| 45 |
return; |
| 46 |
} |
| 47 |
if (values.constructor !== Array) { |
| 48 |
$DONE('The promise should be resolved with an Array instance.'); |
| 49 |
return; |
| 50 |
} |
| 51 |
|
| 52 |
if (values.length !== 3) { |
| 53 |
$DONE('The promise should be resolved with an array of proper length.'); |
| 54 |
return; |
| 55 |
} |
| 56 |
|
| 57 |
if (values[0] !== v1) { |
| 58 |
$DONE('The promise should be resolved with the correct element values (#1)'); |
| 59 |
return; |
| 60 |
} |
| 61 |
|
| 62 |
if (values[1] !== v2) { |
| 63 |
$DONE('The promise should be resolved with the correct element values (#2)'); |
| 64 |
return; |
| 65 |
} |
| 66 |
|
| 67 |
if (values[2] !== v3) { |
| 68 |
$DONE('The promise should be resolved with the correct element values (#3)'); |
| 69 |
return; |
| 70 |
} |
| 71 |
|
| 72 |
$DONE(); |
| 73 |
}, function() { |
| 74 |
$DONE('The promise should not be rejected.'); |
| 75 |
}); |