Debian Codegraph @

js/src/tests/test262/built-ins/Promise/allSettled/invoke-then-get-error-reject.js

raw
1 // |reftest| async
2 // Copyright (C) 2019 Leo Balter. All rights reserved.
3 // This code is governed by the BSD license found in the LICENSE file.
4 /*---
5 description: >
6 Error thrown when accessing the instance's `then` method (rejecting Promise)
7 esid: sec-promise.allsettled
8 info: |
9 6. Let result be PerformPromiseAllSettled(iteratorRecord, C, promiseCapability).
10 7. If result is an abrupt completion, then
11 a. If iteratorRecord.[[Done]] is false, set result to IteratorClose(iteratorRecord, result).
12 b. IfAbruptRejectPromise(result, promiseCapability).
13
14 Runtime Semantics: PerformPromiseAllSettled
15
16 z. Perform ? Invoke(nextPromise, "then", « resolveElement, rejectElement »).
17 flags: [async]
18 features: [Promise.allSettled]
19 ---*/
20
21 var promise = new Promise(function() {});
22 var error = new Test262Error();
23
24 Object.defineProperty(promise, 'then', {
25 get() {
26 throw error;
27 }
28 });
29
30 Promise.allSettled([promise]).then(function() {
31 throw new Test262Error('The promise should be rejected');
32 }, function(reason) {
33 assert.sameValue(reason, error);
34 }).then($DONE, $DONE);