Debian Codegraph @

tests/auto/qml/ecmascripttests/test262/test/built-ins/Promise/all/invoke-then-get-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 accesing the instance's `then` method (closing iterator)
6 esid: sec-performpromiseall
7 es6id: 25.4.4.1
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 [...]
22 r. Let result be Invoke(nextPromise, "then", «resolveElement,
23 resultCapability.[[Reject]]»).
24 s. ReturnIfAbrupt(result).
25 features: [Symbol.iterator]
26 ---*/
27
28 var promise = new Promise(function() {});
29 var returnCount = 0;
30 var iter = {};
31 iter[Symbol.iterator] = function() {
32 return {
33 next: function() {
34 return {
35 done: false,
36 value: promise
37 };
38 },
39 return: function() {
40 returnCount += 1;
41 return {};
42 }
43 };
44 };
45
46 Object.defineProperty(promise, 'then', {
47 get: function() {
48 throw new Test262Error();
49 }
50 });
51
52 Promise.all(iter);
53
54 assert.sameValue(returnCount, 1);