diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 14:29:10 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 14:29:10 +0000 |
commit | 2aa4a82499d4becd2284cdb482213d541b8804dd (patch) | |
tree | b80bf8bf13c3766139fbacc530efd0dd9d54394c /js/src/tests/test262/built-ins/Promise/any/reject-from-same-thenable.js | |
parent | Initial commit. (diff) | |
download | firefox-2aa4a82499d4becd2284cdb482213d541b8804dd.tar.xz firefox-2aa4a82499d4becd2284cdb482213d541b8804dd.zip |
Adding upstream version 86.0.1.upstream/86.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/src/tests/test262/built-ins/Promise/any/reject-from-same-thenable.js')
-rw-r--r-- | js/src/tests/test262/built-ins/Promise/any/reject-from-same-thenable.js | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/Promise/any/reject-from-same-thenable.js b/js/src/tests/test262/built-ins/Promise/any/reject-from-same-thenable.js new file mode 100644 index 0000000000..9c55285599 --- /dev/null +++ b/js/src/tests/test262/built-ins/Promise/any/reject-from-same-thenable.js @@ -0,0 +1,70 @@ +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: Rejecting with a non-thenable object value +esid: sec-promise.any +info: | + PerformPromiseAny + + Set remainingElementsCount.[[Value]] to remainingElementsCount.[[Value]] + 1. + Perform ? Invoke(nextPromise, "then", « resultCapability.[[Resolve]], rejectElement »). + + Promise.any Reject Element Functions + + Let alreadyCalled be F.[[AlreadyCalled]]. + If alreadyCalled.[[Value]] is true, return undefined. + Set alreadyCalled.[[Value]] to true. + ... +features: [Promise.any] +---*/ + +let callCount = 0; +let error; + +function Constructor(executor) { + function reject(result) { + callCount += 1; + error = result; + } + executor(() => {throw new Test262Error()}, reject); +} +Constructor.resolve = function(v) { + return v; +}; + +let p1OnRejected, p2OnRejected, p3OnRejected; + +let p1 = { + then(_, onRejected) { + p1OnRejected = onRejected; + } +}; +let p2 = { + then(_, onRejected) { + p2OnRejected = onRejected; + } +}; +let p3 = { + then(_, onRejected) { + p3OnRejected = onRejected; + } +}; + +assert.sameValue(callCount, 0, 'callCount before call to any()'); + +Promise.any.call(Constructor, [p1, p2, p3]); + +assert.sameValue(callCount, 0, 'callCount after call to any()'); + +p1OnRejected('p1-rejection'); +p1OnRejected('p1-rejection-unexpected-1'); +p1OnRejected('p1-rejection-unexpected-2'); + +assert.sameValue(callCount, 0, 'callCount after resolving p1'); + +p2OnRejected('p2-rejection'); +p3OnRejected('p3-rejection'); + +assert.sameValue(callCount, 1, 'callCount after resolving all elements'); + +reportCompare(0, 0); |