From 8dd16259287f58f9273002717ec4d27e97127719 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 12 Jun 2024 07:43:14 +0200 Subject: Merging upstream version 127.0. Signed-off-by: Daniel Baumann --- ...fset-validated-against-initial-buffer-length.js | 46 ++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 js/src/tests/test262/built-ins/DataView/byteOffset-validated-against-initial-buffer-length.js (limited to 'js/src/tests/test262/built-ins/DataView/byteOffset-validated-against-initial-buffer-length.js') diff --git a/js/src/tests/test262/built-ins/DataView/byteOffset-validated-against-initial-buffer-length.js b/js/src/tests/test262/built-ins/DataView/byteOffset-validated-against-initial-buffer-length.js new file mode 100644 index 0000000000..51b030b66b --- /dev/null +++ b/js/src/tests/test262/built-ins/DataView/byteOffset-validated-against-initial-buffer-length.js @@ -0,0 +1,46 @@ +// Copyright (C) 2024 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-dataview-buffer-byteoffset-bytelength +description: > + The byteOffset argument is validated against the initial buffer length. +info: | + DataView ( buffer [ , byteOffset [ , byteLength ] ] ) + + ... + 3. Let offset be ? ToIndex(byteOffset). + ... + 5. Let bufferByteLength be ArrayBufferByteLength(buffer, seq-cst). + 6. If offset > bufferByteLength, throw a RangeError exception. + ... + 10. Let O be ? OrdinaryCreateFromConstructor(NewTarget, "%DataView.prototype%", + « [[DataView]], [[ViewedArrayBuffer]], [[ByteLength]], [[ByteOffset]] »). + ... + + OrdinaryCreateFromConstructor ( constructor, intrinsicDefaultProto [ , internalSlotsList ] ) + + ... + 2. Let proto be ? GetPrototypeFromConstructor(constructor, intrinsicDefaultProto). + ... + +features: [Reflect.construct] +---*/ + +let newTarget = Object.defineProperty(function(){}.bind(), "prototype", { + get() { + throw new Test262Error("GetPrototypeFromConstructor not executed"); + } +}); + +// Zero length buffer. +let ab = new ArrayBuffer(0); + +// Byte offset is larger than the buffer length, which is zero. +let byteOffset = 10; + +assert.throws(RangeError, () => { + Reflect.construct(DataView, [ab, byteOffset], newTarget); +}); + +reportCompare(0, 0); -- cgit v1.2.3