diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-12 05:43:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-12 05:43:14 +0000 |
commit | 8dd16259287f58f9273002717ec4d27e97127719 (patch) | |
tree | 3863e62a53829a84037444beab3abd4ed9dfc7d0 /js/src/tests/test262/built-ins/TypedArray/prototype/values/make-out-of-bounds-after-exhausted.js | |
parent | Releasing progress-linux version 126.0.1-1~progress7.99u1. (diff) | |
download | firefox-8dd16259287f58f9273002717ec4d27e97127719.tar.xz firefox-8dd16259287f58f9273002717ec4d27e97127719.zip |
Merging upstream version 127.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/src/tests/test262/built-ins/TypedArray/prototype/values/make-out-of-bounds-after-exhausted.js')
-rw-r--r-- | js/src/tests/test262/built-ins/TypedArray/prototype/values/make-out-of-bounds-after-exhausted.js | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/values/make-out-of-bounds-after-exhausted.js b/js/src/tests/test262/built-ins/TypedArray/prototype/values/make-out-of-bounds-after-exhausted.js new file mode 100644 index 0000000000..8baa1c0920 --- /dev/null +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/values/make-out-of-bounds-after-exhausted.js @@ -0,0 +1,52 @@ +// |reftest| shell-option(--enable-arraybuffer-resizable) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options +// Copyright (C) 2024 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-%typedarray%.prototype.values +description: > + Calling next on an out-of-bounds typedarray throws no error when iterator exhausted. +features: [TypedArray, resizable-arraybuffer] +---*/ + +let rab = new ArrayBuffer(3, {maxByteLength: 5}); +let ta = new Int8Array(rab, 1); + +// Ensure the TypedArray is correctly initialised. +assert.sameValue(ta.length, 2); +assert.sameValue(ta.byteOffset, 1); + +ta[0] = 11; +ta[1] = 22; + +let it = ta.values(); +let r; + +// Fetch the first value. +r = it.next(); +assert.sameValue(r.done, false); +assert.sameValue(r.value, 11); + +// Fetch the second value. +r = it.next(); +assert.sameValue(r.done, false); +assert.sameValue(r.value, 22); + +// Iterator is now exhausted. +r = it.next(); +assert.sameValue(r.done, true); +assert.sameValue(r.value, undefined); + +// Resize buffer to zero. +rab.resize(0); + +// TypedArray is now out-of-bounds. +assert.sameValue(ta.length, 0); +assert.sameValue(ta.byteOffset, 0); + +// Calling next doesn't throw an error. +r = it.next(); +assert.sameValue(r.done, true); +assert.sameValue(r.value, undefined); + +reportCompare(0, 0); |