Debian Codegraph @

js/src/tests/test262/built-ins/Promise/all/iter-step-err-no-close.js

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