Debian Codegraph @

js/src/tests/test262/built-ins/Promise/all/invoke-then-error-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 description: >
5 Error thrown when invoking the instance's `then` method (closing iterator)
6 esid: sec-performpromiseall
7 info: |
8 11. Let result be PerformPromiseAll(iteratorRecord, C, promiseCapability).
9 12. If result is an abrupt completion,
10 a. If iteratorRecord.[[done]] is false, let result be
11 IteratorClose(iterator, result).
12 b. IfAbruptRejectPromise(result, promiseCapability).
13
14 [...]
15
16 25.4.4.1.1 Runtime Semantics: PerformPromiseAll
17
18 [...]
19 6. Repeat
20 [...]
21 r. Let result be Invoke(nextPromise, "then", «resolveElement,
22 resultCapability.[[Reject]]»).
23 s. ReturnIfAbrupt(result).
24 features: [Symbol.iterator]
25 ---*/
26
27 var promise = new Promise(function() {});
28 var returnCount = 0;
29 var iter = {};
30 iter[Symbol.iterator] = function() {
31 return {
32 next: function() {
33 return {
34 done: false,
35 value: promise
36 };
37 },
38 return: function() {
39 returnCount += 1;
40 return {};
41 }
42 };
43 };
44
45 Object.defineProperty(promise, "then", {
46 value: function() {
47 throw new Test262Error();
48 }
49 });
50
51 Promise.all(iter);
52
53 assert.sameValue(returnCount, 1);
54
55 reportCompare(0, 0);