| 1 |
// Copyright (C) 2015 the V8 project authors. All rights reserved. |
| 2 |
// This code is governed by the BSD license found in the LICENSE file. |
| 3 |
|
| 4 |
/*--- |
| 5 |
description: > |
| 6 |
Explicit iterator closing in response to error |
| 7 |
esid: sec-promise.all |
| 8 |
es6id: 25.4.4.1 |
| 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 |
[...] |
| 23 |
i. Let nextPromise be Invoke(constructor, "resolve", «nextValue»). |
| 24 |
j. ReturnIfAbrupt(nextPromise ). |
| 25 |
features: [Symbol.iterator] |
| 26 |
---*/ |
| 27 |
|
| 28 |
var iterDoneSpy = {}; |
| 29 |
var callCount = 0; |
| 30 |
iterDoneSpy[Symbol.iterator] = function() { |
| 31 |
return { |
| 32 |
next: function() { |
| 33 |
return { |
| 34 |
value: null, |
| 35 |
done: false |
| 36 |
}; |
| 37 |
}, |
| 38 |
return: function() { |
| 39 |
callCount += 1; |
| 40 |
} |
| 41 |
}; |
| 42 |
}; |
| 43 |
|
| 44 |
Promise.resolve = function() { |
| 45 |
throw new Error(); |
| 46 |
}; |
| 47 |
|
| 48 |
Promise.all(iterDoneSpy); |
| 49 |
|
| 50 |
assert.sameValue(callCount, 1); |