From 2aa4a82499d4becd2284cdb482213d541b8804dd Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 28 Apr 2024 16:29:10 +0200 Subject: Adding upstream version 86.0.1. Signed-off-by: Daniel Baumann --- .../capability-resolve-throws-no-close.js | 66 ++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 js/src/tests/test262/built-ins/Promise/allSettled/capability-resolve-throws-no-close.js (limited to 'js/src/tests/test262/built-ins/Promise/allSettled/capability-resolve-throws-no-close.js') diff --git a/js/src/tests/test262/built-ins/Promise/allSettled/capability-resolve-throws-no-close.js b/js/src/tests/test262/built-ins/Promise/allSettled/capability-resolve-throws-no-close.js new file mode 100644 index 0000000000..e59ca8916e --- /dev/null +++ b/js/src/tests/test262/built-ins/Promise/allSettled/capability-resolve-throws-no-close.js @@ -0,0 +1,66 @@ +// Copyright (C) 2019 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-promise.allsettled +description: > + Iterator is not closed when the "resolve" capability returns an abrupt + completion. +info: | + ... + 3. Let promiseCapability be ? NewPromiseCapability(C). + ... + 6. Let result be PerformPromiseAllSettled(iteratorRecord, C, promiseCapability). + 7. If result is an abrupt completion, then + a. If iteratorRecord.[[Done]] is false, set result to IteratorClose(iteratorRecord, result). + b. IfAbruptRejectPromise(result, promiseCapability). + 8. Return Completion(result). + + Runtime Semantics: PerformPromiseAllSettled + + ... + 6. Repeat + ... + d. If next is false, then + ... + iii. If remainingElementsCount.[[Value]] is 0, then + 1. Let valuesArray be CreateArrayFromList(values). + 2. Perform ? Call(resultCapability.[[Resolve]], undefined, « valuesArray »). + + IfAbruptRejectPromise + + 1. IfAbruptRejectPromise(value, capability). +features: [Promise.allSettled, Symbol.iterator] +---*/ + +var returnCount = 0; +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next() { + return { + done: true + }; + }, + return() { + returnCount += 1; + return {}; + } + }; +}; +var P = function(executor) { + return new Promise(function(_, reject) { + executor(function() { + throw new Test262Error(); + }, reject); + }); +}; + +P.resolve = function() { + throw new Test262Error(); +}; + +Promise.allSettled.call(P, iter); + +assert.sameValue(returnCount, 0); + +reportCompare(0, 0); -- cgit v1.2.3