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/race/iter-next-val-err-reject.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/race/iter-next-val-err-reject.js')
-rw-r--r-- | js/src/tests/test262/built-ins/Promise/race/iter-next-val-err-reject.js | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/Promise/race/iter-next-val-err-reject.js b/js/src/tests/test262/built-ins/Promise/race/iter-next-val-err-reject.js new file mode 100644 index 0000000000..866d9af062 --- /dev/null +++ b/js/src/tests/test262/built-ins/Promise/race/iter-next-val-err-reject.js @@ -0,0 +1,53 @@ +// |reftest| async +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: > + Error when accessing an iterator result's `value` property (rejecting + promise) +esid: sec-promise.race +info: | + 11. Let result be PerformPromiseRace(iteratorRecord, C, promiseCapability). + 12. If result is an abrupt completion, + a. If iteratorRecord.[[done]] is false, let result be + IteratorClose(iterator, result). + b. IfAbruptRejectPromise(result, promiseCapability). + + [...] + + 25.4.4.3.1 Runtime Semantics: PerformPromiseRace + + 1. Repeat + [...] + e. Let nextValue be IteratorValue(next). + f. If nextValue is an abrupt completion, set iteratorRecord.[[done]] to + true. + g. ReturnIfAbrupt(nextValue). +features: [Symbol.iterator] +flags: [async] +---*/ + +var iterNextValThrows = {}; +var poisonedVal = { + done: false +}; +var error = new Test262Error(); +Object.defineProperty(poisonedVal, 'value', { + get: function() { + throw error; + } +}); +iterNextValThrows[Symbol.iterator] = function() { + return { + next: function() { + return poisonedVal; + } + }; +}; + +Promise.race(iterNextValThrows).then(function() { + $DONE('The promise should be rejected.'); +}, function(reason) { + assert.sameValue(reason, error); +}).then($DONE, $DONE); |