Debian Codegraph @

js/src/tests/test262/built-ins/Promise/allSettled/iter-next-val-err-no-close.js

raw
1 // Copyright (C) 2019 Leo Balter. All rights reserved.
2 // This code is governed by the BSD license found in the LICENSE file.
3
4 /*---
5 esid: sec-promise.allsettled
6 description: >
7 Error when accessing an iterator result's `value` property (not closing
8 iterator)
9 info: |
10 Promise.allSettled ( iterable )
11
12 6. Let result be PerformPromiseAllSettled(iteratorRecord, C, promiseCapability).
13 7. If result is an abrupt completion, then
14 a. If iteratorRecord.[[Done]] is false, set result to IteratorClose(iteratorRecord, result).
15 b. IfAbruptRejectPromise(result, promiseCapability).
16
17 Runtime Semantics: PerformPromiseAllSettled
18
19 ...
20 6. Repeat
21 ...
22 e. Let nextValue be IteratorValue(next).
23 f. If nextValue is an abrupt completion, set iteratorRecord.[[Done]] to true.
24 g. ReturnIfAbrupt(nextValue).
25 features: [Promise.allSettled, Symbol.iterator]
26 ---*/
27
28 var iterNextValThrows = {};
29 var returnCount = 0;
30 var nextCount = 0;
31 var poisonedVal = {
32 done: false
33 };
34 var error = new Test262Error();
35 Object.defineProperty(poisonedVal, 'value', {
36 get() {
37 throw error;
38 }
39 });
40 iterNextValThrows[Symbol.iterator] = function() {
41 return {
42 next() {
43 nextCount += 1;
44 return poisonedVal;
45 },
46 return() {
47 returnCount += 1;
48 return {};
49 }
50 };
51 };
52
53 Promise.allSettled(iterNextValThrows);
54
55 assert.sameValue(returnCount, 0);
56 assert.sameValue(nextCount, 1);
57
58 reportCompare(0, 0);