diff --git a/test/built-ins/Uint8Array/prototype/setFromBase64/throws-when-target-is-backed-by-immutable-arraybuffer.js b/test/built-ins/Uint8Array/prototype/setFromBase64/throws-when-target-is-backed-by-immutable-arraybuffer.js new file mode 100644 index 00000000000..2984c2b4e38 --- /dev/null +++ b/test/built-ins/Uint8Array/prototype/setFromBase64/throws-when-target-is-backed-by-immutable-arraybuffer.js @@ -0,0 +1,19 @@ +// Copyright (C) 2026 Kevin Gibbons. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-uint8array.prototype.setfrombase64 +description: Uint8Array.prototype.setFromBase64 throws a TypeError when the target is backed by an immutable ArrayBuffer. +features: [ArrayBuffer, TypedArray, uint8array-base64, immutable-arraybuffer] +---*/ + +var iab = (new ArrayBuffer(10)).transferToImmutable(); +var target = new Uint8Array(iab); + +assert.throws(TypeError, function () { + target.setFromBase64('Zg=='); +}); + +assert.throws(TypeError, function () { + target.setFromBase64(''); +}); diff --git a/test/built-ins/Uint8Array/prototype/setFromHex/throws-when-target-is-backed-by-immutable-arraybuffer.js b/test/built-ins/Uint8Array/prototype/setFromHex/throws-when-target-is-backed-by-immutable-arraybuffer.js new file mode 100644 index 00000000000..3b50a13559d --- /dev/null +++ b/test/built-ins/Uint8Array/prototype/setFromHex/throws-when-target-is-backed-by-immutable-arraybuffer.js @@ -0,0 +1,19 @@ +// Copyright (C) 2026 Kevin Gibbons. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-uint8array.prototype.setfromhex +description: Uint8Array.prototype.setFromHex throws a TypeError when the target is backed by an immutable ArrayBuffer. +features: [ArrayBuffer, TypedArray, uint8array-base64, immutable-arraybuffer] +---*/ + +var iab = (new ArrayBuffer(10)).transferToImmutable(); +var target = new Uint8Array(iab); + +assert.throws(TypeError, function () { + target.setFromHex('aa'); +}); + +assert.throws(TypeError, function () { + target.setFromHex(''); +});