diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /js/src/tests/test262/built-ins/SharedArrayBuffer/prototype/grow/grow-smaller-size.js | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/src/tests/test262/built-ins/SharedArrayBuffer/prototype/grow/grow-smaller-size.js')
-rw-r--r-- | js/src/tests/test262/built-ins/SharedArrayBuffer/prototype/grow/grow-smaller-size.js | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/SharedArrayBuffer/prototype/grow/grow-smaller-size.js b/js/src/tests/test262/built-ins/SharedArrayBuffer/prototype/grow/grow-smaller-size.js new file mode 100644 index 0000000000..1c2b7a193d --- /dev/null +++ b/js/src/tests/test262/built-ins/SharedArrayBuffer/prototype/grow/grow-smaller-size.js @@ -0,0 +1,50 @@ +// |reftest| skip -- resizable-arraybuffer is not supported +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-sharedarraybuffer.prototype.grow +description: > + Behavior when attempting to grow a growable array buffer to a smaller size +info: | + SharedArrayBuffer.prototype.grow ( newLength ) + + 1. Let O be the this value. + 2. Perform ? RequireInternalSlot(O, [[ArrayBufferMaxByteLength]]). + 3. If IsSharedArrayBuffer(O) is false throw a TypeError exception. + 4. Let newByteLength be ? ToIntegerOrInfinity(newLength). + 5. Let hostHandled be ? HostGrowSharedArrayBuffer(O, newByteLength). + 6. If hostHandled is handled, return undefined. + [...] +features: [SharedArrayBuffer, resizable-arraybuffer] +---*/ + +var sab = new SharedArrayBuffer(4, {maxByteLength: 5}); +var result; + +// If the host chooses to throw as allowed by the specification, the observed +// behavior will be identical to the case where +// `SharedArrayBuffer.prototype.grow` has not been implemented. The following +// assertion prevents this test from passing in runtimes which have not +// implemented the method. +assert.sameValue(typeof sab.grow, 'function'); + +try { + result = ab.grow(3); +} catch (_) {} + +// One of the following three conditions must be met: +// +// - HostGrowSharedArrayBuffer returns an abrupt completion +// - HostGrowSharedArrayBuffer handles the grow operation, and the `grow` +// method returns early +// - HostGrowSharedArrayBuffer does not handle the grow operation, and the +// `grow` method executes its final steps +// +// All three conditions have the same effect on the value of `result`. +assert.sameValue(result, undefined, 'normal completion value'); + +// Neither the length nor the contents of the SharedArrayBuffer are guaranteed +// by the host-defined abstract operation, so they are not asserted in this +// test. + +reportCompare(0, 0); |