| 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 |
/*--- |
| 5 |
esid: sec-promise.all |
| 6 |
es6id: 25.4.4.1 |
| 7 |
description: > |
| 8 |
Error when advancing the provided iterable (rejecting promise) |
| 9 |
info: | |
| 10 |
11. Let result be PerformPromiseAll(iteratorRecord, C, promiseCapability). |
| 11 |
12. If result is an abrupt completion, |
| 12 |
a. If iteratorRecord.[[done]] is false, let result be |
| 13 |
IteratorClose(iterator, result). |
| 14 |
b. IfAbruptRejectPromise(result, promiseCapability). |
| 15 |
|
| 16 |
[...] |
| 17 |
|
| 18 |
25.4.4.1.1 Runtime Semantics: PerformPromiseAll |
| 19 |
|
| 20 |
[...] |
| 21 |
6. Repeat |
| 22 |
a. Let next be IteratorStep(iteratorRecord.[[iterator]]). |
| 23 |
b. If next is an abrupt completion, set iteratorRecord.[[done]] to |
| 24 |
true. |
| 25 |
c. ReturnIfAbrupt(next). |
| 26 |
features: [Symbol.iterator] |
| 27 |
flags: [async] |
| 28 |
---*/ |
| 29 |
|
| 30 |
var iterStepThrows = {}; |
| 31 |
var poisonedDone = {}; |
| 32 |
var error = new Test262Error(); |
| 33 |
Object.defineProperty(poisonedDone, 'done', { |
| 34 |
get: function() { |
| 35 |
throw error; |
| 36 |
} |
| 37 |
}); |
| 38 |
Object.defineProperty(poisonedDone, 'value', { |
| 39 |
get: function() { |
| 40 |
$ERROR('The `value` property should not be accessed.'); |
| 41 |
} |
| 42 |
}); |
| 43 |
|
| 44 |
iterStepThrows[Symbol.iterator] = function() { |
| 45 |
return { |
| 46 |
next: function() { |
| 47 |
return poisonedDone; |
| 48 |
} |
| 49 |
}; |
| 50 |
}; |
| 51 |
|
| 52 |
Promise.all(iterStepThrows).then(function() { |
| 53 |
$ERROR('The promise should be rejected.'); |
| 54 |
}, function(reason) { |
| 55 |
assert.sameValue(reason, error); |
| 56 |
}).then($DONE, $DONE); |