From bd05e23d40ef390c849d83bf24d48324f6eaaa76 Mon Sep 17 00:00:00 2001 From: Kevin Gibbons Date: Sun, 21 Jan 2024 17:09:11 -0800 Subject: [PATCH 1/8] add tests for base64 proposal --- features.txt | 4 + .../Uint8Array/fromBase64/alphabet.js | 22 +++ .../Uint8Array/fromBase64/descriptor.js | 15 ++ .../Uint8Array/fromBase64/ignores-receiver.js | 19 +++ .../fromBase64/illegal-characters.js | 23 +++ .../fromBase64/last-chunk-handling.js | 50 +++++++ .../built-ins/Uint8Array/fromBase64/length.js | 16 +++ test/built-ins/Uint8Array/fromBase64/name.js | 16 +++ .../Uint8Array/fromBase64/nonconstructor.js | 15 ++ .../Uint8Array/fromBase64/option-coercion.js | 50 +++++++ .../Uint8Array/fromBase64/results.js | 25 ++++ .../Uint8Array/fromBase64/string-coercion.js | 41 ++++++ .../Uint8Array/fromBase64/whitespace.js | 20 +++ .../Uint8Array/fromBase64Into/alphabet.js | 41 ++++++ .../Uint8Array/fromBase64Into/descriptor.js | 15 ++ .../fromBase64Into/detached-buffer.js | 29 ++++ .../fromBase64Into/ignores-receiver.js | 16 +++ .../fromBase64Into/illegal-characters.js | 24 ++++ .../fromBase64Into/last-chunk-handling.js | 131 ++++++++++++++++++ .../Uint8Array/fromBase64Into/length.js | 16 +++ .../Uint8Array/fromBase64Into/name.js | 16 +++ .../fromBase64Into/nonconstructor.js | 16 +++ .../fromBase64Into/option-coercion.js | 58 ++++++++ .../Uint8Array/fromBase64Into/results.js | 30 ++++ .../fromBase64Into/string-coercion.js | 43 ++++++ .../Uint8Array/fromBase64Into/subarray.js | 17 +++ .../Uint8Array/fromBase64Into/target-size.js | 64 +++++++++ .../Uint8Array/fromBase64Into/whitespace.js | 23 +++ .../Uint8Array/fromHex/descriptor.js | 15 ++ .../Uint8Array/fromHex/ignores-receiver.js | 19 +++ .../Uint8Array/fromHex/illegal-characters.js | 25 ++++ test/built-ins/Uint8Array/fromHex/length.js | 16 +++ test/built-ins/Uint8Array/fromHex/name.js | 16 +++ .../Uint8Array/fromHex/nonconstructor.js | 15 ++ .../Uint8Array/fromHex/odd-length-input.js | 11 ++ test/built-ins/Uint8Array/fromHex/results.js | 26 ++++ .../Uint8Array/fromHex/string-coercion.js | 20 +++ .../Uint8Array/fromHexInto/descriptor.js | 15 ++ .../Uint8Array/fromHexInto/detached-buffer.js | 14 ++ .../fromHexInto/ignores-receiver.js | 16 +++ .../fromHexInto/illegal-characters.js | 26 ++++ .../Uint8Array/fromHexInto/length.js | 16 +++ test/built-ins/Uint8Array/fromHexInto/name.js | 16 +++ .../Uint8Array/fromHexInto/nonconstructor.js | 16 +++ .../Uint8Array/fromHexInto/results.js | 31 +++++ .../Uint8Array/fromHexInto/string-coercion.js | 21 +++ .../Uint8Array/fromHexInto/subarray.js | 17 +++ .../Uint8Array/fromHexInto/target-size.js | 29 ++++ .../Uint8Array/prototype/toBase64/alphabet.js | 17 +++ .../prototype/toBase64/descriptor.js | 15 ++ .../prototype/toBase64/detached-buffer.js | 39 ++++++ .../Uint8Array/prototype/toBase64/length.js | 16 +++ .../Uint8Array/prototype/toBase64/name.js | 16 +++ .../prototype/toBase64/nonconstructor.js | 16 +++ .../prototype/toBase64/option-coercion.js | 43 ++++++ .../toBase64/receiver-not-uint8array.js | 33 +++++ .../Uint8Array/prototype/toBase64/results.js | 16 +++ .../Uint8Array/prototype/toHex/descriptor.js | 15 ++ .../prototype/toHex/detached-buffer.js | 15 ++ .../Uint8Array/prototype/toHex/length.js | 16 +++ .../Uint8Array/prototype/toHex/name.js | 16 +++ .../prototype/toHex/nonconstructor.js | 16 +++ .../toHex/receiver-not-uint8array.js | 26 ++++ .../Uint8Array/prototype/toHex/results.js | 15 ++ 64 files changed, 1565 insertions(+) create mode 100644 test/built-ins/Uint8Array/fromBase64/alphabet.js create mode 100644 test/built-ins/Uint8Array/fromBase64/descriptor.js create mode 100644 test/built-ins/Uint8Array/fromBase64/ignores-receiver.js create mode 100644 test/built-ins/Uint8Array/fromBase64/illegal-characters.js create mode 100644 test/built-ins/Uint8Array/fromBase64/last-chunk-handling.js create mode 100644 test/built-ins/Uint8Array/fromBase64/length.js create mode 100644 test/built-ins/Uint8Array/fromBase64/name.js create mode 100644 test/built-ins/Uint8Array/fromBase64/nonconstructor.js create mode 100644 test/built-ins/Uint8Array/fromBase64/option-coercion.js create mode 100644 test/built-ins/Uint8Array/fromBase64/results.js create mode 100644 test/built-ins/Uint8Array/fromBase64/string-coercion.js create mode 100644 test/built-ins/Uint8Array/fromBase64/whitespace.js create mode 100644 test/built-ins/Uint8Array/fromBase64Into/alphabet.js create mode 100644 test/built-ins/Uint8Array/fromBase64Into/descriptor.js create mode 100644 test/built-ins/Uint8Array/fromBase64Into/detached-buffer.js create mode 100644 test/built-ins/Uint8Array/fromBase64Into/ignores-receiver.js create mode 100644 test/built-ins/Uint8Array/fromBase64Into/illegal-characters.js create mode 100644 test/built-ins/Uint8Array/fromBase64Into/last-chunk-handling.js create mode 100644 test/built-ins/Uint8Array/fromBase64Into/length.js create mode 100644 test/built-ins/Uint8Array/fromBase64Into/name.js create mode 100644 test/built-ins/Uint8Array/fromBase64Into/nonconstructor.js create mode 100644 test/built-ins/Uint8Array/fromBase64Into/option-coercion.js create mode 100644 test/built-ins/Uint8Array/fromBase64Into/results.js create mode 100644 test/built-ins/Uint8Array/fromBase64Into/string-coercion.js create mode 100644 test/built-ins/Uint8Array/fromBase64Into/subarray.js create mode 100644 test/built-ins/Uint8Array/fromBase64Into/target-size.js create mode 100644 test/built-ins/Uint8Array/fromBase64Into/whitespace.js create mode 100644 test/built-ins/Uint8Array/fromHex/descriptor.js create mode 100644 test/built-ins/Uint8Array/fromHex/ignores-receiver.js create mode 100644 test/built-ins/Uint8Array/fromHex/illegal-characters.js create mode 100644 test/built-ins/Uint8Array/fromHex/length.js create mode 100644 test/built-ins/Uint8Array/fromHex/name.js create mode 100644 test/built-ins/Uint8Array/fromHex/nonconstructor.js create mode 100644 test/built-ins/Uint8Array/fromHex/odd-length-input.js create mode 100644 test/built-ins/Uint8Array/fromHex/results.js create mode 100644 test/built-ins/Uint8Array/fromHex/string-coercion.js create mode 100644 test/built-ins/Uint8Array/fromHexInto/descriptor.js create mode 100644 test/built-ins/Uint8Array/fromHexInto/detached-buffer.js create mode 100644 test/built-ins/Uint8Array/fromHexInto/ignores-receiver.js create mode 100644 test/built-ins/Uint8Array/fromHexInto/illegal-characters.js create mode 100644 test/built-ins/Uint8Array/fromHexInto/length.js create mode 100644 test/built-ins/Uint8Array/fromHexInto/name.js create mode 100644 test/built-ins/Uint8Array/fromHexInto/nonconstructor.js create mode 100644 test/built-ins/Uint8Array/fromHexInto/results.js create mode 100644 test/built-ins/Uint8Array/fromHexInto/string-coercion.js create mode 100644 test/built-ins/Uint8Array/fromHexInto/subarray.js create mode 100644 test/built-ins/Uint8Array/fromHexInto/target-size.js create mode 100644 test/built-ins/Uint8Array/prototype/toBase64/alphabet.js create mode 100644 test/built-ins/Uint8Array/prototype/toBase64/descriptor.js create mode 100644 test/built-ins/Uint8Array/prototype/toBase64/detached-buffer.js create mode 100644 test/built-ins/Uint8Array/prototype/toBase64/length.js create mode 100644 test/built-ins/Uint8Array/prototype/toBase64/name.js create mode 100644 test/built-ins/Uint8Array/prototype/toBase64/nonconstructor.js create mode 100644 test/built-ins/Uint8Array/prototype/toBase64/option-coercion.js create mode 100644 test/built-ins/Uint8Array/prototype/toBase64/receiver-not-uint8array.js create mode 100644 test/built-ins/Uint8Array/prototype/toBase64/results.js create mode 100644 test/built-ins/Uint8Array/prototype/toHex/descriptor.js create mode 100644 test/built-ins/Uint8Array/prototype/toHex/detached-buffer.js create mode 100644 test/built-ins/Uint8Array/prototype/toHex/length.js create mode 100644 test/built-ins/Uint8Array/prototype/toHex/name.js create mode 100644 test/built-ins/Uint8Array/prototype/toHex/nonconstructor.js create mode 100644 test/built-ins/Uint8Array/prototype/toHex/receiver-not-uint8array.js create mode 100644 test/built-ins/Uint8Array/prototype/toHex/results.js diff --git a/features.txt b/features.txt index 1a43df40dde..51e88dbd5b8 100644 --- a/features.txt +++ b/features.txt @@ -131,6 +131,10 @@ source-phase-imports ## test262 special specifier source-phase-imports-module-source +# Uint8Array Base64 +# https://github.com/tc39/proposal-arraybuffer-base64 +uint8array-base64 + ## Standard language features # # Language features that have been included in a published version of the diff --git a/test/built-ins/Uint8Array/fromBase64/alphabet.js b/test/built-ins/Uint8Array/fromBase64/alphabet.js new file mode 100644 index 00000000000..a5d28b7a1a4 --- /dev/null +++ b/test/built-ins/Uint8Array/fromBase64/alphabet.js @@ -0,0 +1,22 @@ +// Copyright (C) 2024 Kevin Gibbons. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-uint8array.frombase64 +description: Conversion of base64 strings to Uint8Arrays exercising the alphabet option +includes: [compareArray.js] +features: [uint8array-base64] +---*/ + +assert.compareArray(Uint8Array.fromBase64('x+/y'), [199, 239, 242]); +assert.compareArray(Uint8Array.fromBase64('x+/y', { alphabet: 'base64' }), [199, 239, 242]); +assert.throws(SyntaxError, function() { + Uint8Array.fromBase64('x+/y', { alphabet: 'base64url' }); +}); + +assert.compareArray(Uint8Array.fromBase64('x-_y', { alphabet: 'base64url' }), [199, 239, 242]); +assert.throws(SyntaxError, function() { + Uint8Array.fromBase64('x-_y'); +}); +assert.throws(SyntaxError, function() { + Uint8Array.fromBase64('x-_y', { alphabet: 'base64' }); +}); diff --git a/test/built-ins/Uint8Array/fromBase64/descriptor.js b/test/built-ins/Uint8Array/fromBase64/descriptor.js new file mode 100644 index 00000000000..dfcc913a3ca --- /dev/null +++ b/test/built-ins/Uint8Array/fromBase64/descriptor.js @@ -0,0 +1,15 @@ +// Copyright (C) 2024 Kevin Gibbons. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-uint8array.frombase64 +description: > + Uint8Array.fromBase64 has default data property attributes. +includes: [propertyHelper.js] +features: [uint8array-base64] +---*/ + +verifyProperty(Uint8Array, 'fromBase64', { + enumerable: false, + writable: true, + configurable: true +}); diff --git a/test/built-ins/Uint8Array/fromBase64/ignores-receiver.js b/test/built-ins/Uint8Array/fromBase64/ignores-receiver.js new file mode 100644 index 00000000000..811ebc517a9 --- /dev/null +++ b/test/built-ins/Uint8Array/fromBase64/ignores-receiver.js @@ -0,0 +1,19 @@ +// Copyright (C) 2024 Kevin Gibbons. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-uint8array.frombase64 +description: Uint8Array.fromBase64 ignores its receiver +features: [uint8array-base64] +---*/ + +var fromBase64 = Uint8Array.fromBase64; +var noReceiver = fromBase64("Zg=="); +assert.sameValue(Object.getPrototypeOf(noReceiver), Uint8Array.prototype); + +class Subclass extends Uint8Array { + constructor() { + throw new Test262Error("subclass constructor called"); + } +} +var fromSubclass = Subclass.fromBase64("Zg=="); +assert.sameValue(Object.getPrototypeOf(fromSubclass), Uint8Array.prototype); diff --git a/test/built-ins/Uint8Array/fromBase64/illegal-characters.js b/test/built-ins/Uint8Array/fromBase64/illegal-characters.js new file mode 100644 index 00000000000..5f2d7a8438a --- /dev/null +++ b/test/built-ins/Uint8Array/fromBase64/illegal-characters.js @@ -0,0 +1,23 @@ +// Copyright (C) 2024 Kevin Gibbons. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-uint8array.frombase64 +description: Uint8Array.fromBase64 throws a SyntaxError when input has non-base64, non-ascii-whitespace characters +features: [uint8array-base64] +---*/ + +var illegal = [ + 'Zm.9v', + 'Zm9v^', + 'Zg==&', + 'Z−==', // U+2212 'Minus Sign' + 'Z+==', // U+FF0B 'Fullwidth Plus Sign' + 'Zg\u00A0==', // nbsp + 'Zg\u2009==', // thin space + 'Zg\u2028==', // line separator +]; +illegal.forEach(function(value) { + assert.throws(SyntaxError, function() { + Uint8Array.fromBase64(value) + }); +}); diff --git a/test/built-ins/Uint8Array/fromBase64/last-chunk-handling.js b/test/built-ins/Uint8Array/fromBase64/last-chunk-handling.js new file mode 100644 index 00000000000..edade6f2ab2 --- /dev/null +++ b/test/built-ins/Uint8Array/fromBase64/last-chunk-handling.js @@ -0,0 +1,50 @@ +// Copyright (C) 2024 Kevin Gibbons. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-uint8array.frombase64 +description: Handling of final chunks in Uint8Array.fromBase64 +includes: [compareArray.js] +features: [uint8array-base64] +---*/ + +// padding +assert.compareArray(Uint8Array.fromBase64('ZXhhZg=='), [101, 120, 97, 102]); +assert.compareArray(Uint8Array.fromBase64('ZXhhZg==', { lastChunkHandling: 'loose' }), [101, 120, 97, 102]); +assert.compareArray(Uint8Array.fromBase64('ZXhhZg==', { lastChunkHandling: 'stop-before-partial' }), [101, 120, 97, 102]); +assert.compareArray(Uint8Array.fromBase64('ZXhhZg==', { lastChunkHandling: 'strict' }), [101, 120, 97, 102]); + +// no padding +assert.compareArray(Uint8Array.fromBase64('ZXhhZg'), [101, 120, 97, 102]); +assert.compareArray(Uint8Array.fromBase64('ZXhhZg', { lastChunkHandling: 'loose' }), [101, 120, 97, 102]); +assert.compareArray(Uint8Array.fromBase64('ZXhhZg', { lastChunkHandling: 'stop-before-partial' }), [101, 120, 97]); +assert.throws(SyntaxError, function() { + Uint8Array.fromBase64('ZXhhZg', { lastChunkHandling: 'strict' }); +}); + +// non-zero padding bits +assert.compareArray(Uint8Array.fromBase64('ZXhhZh=='), [101, 120, 97, 102]); +assert.compareArray(Uint8Array.fromBase64('ZXhhZh==', { lastChunkHandling: 'loose' }), [101, 120, 97, 102]); +assert.compareArray(Uint8Array.fromBase64('ZXhhZh==', { lastChunkHandling: 'stop-before-partial' }), [101, 120, 97, 102]); +assert.throws(SyntaxError, function() { + Uint8Array.fromBase64('ZXhhZh==', { lastChunkHandling: 'strict' }); +}); + +// non-zero padding bits, no padding +assert.compareArray(Uint8Array.fromBase64('ZXhhZh'), [101, 120, 97, 102]); +assert.compareArray(Uint8Array.fromBase64('ZXhhZh', { lastChunkHandling: 'loose' }), [101, 120, 97, 102]); +assert.compareArray(Uint8Array.fromBase64('ZXhhZh', { lastChunkHandling: 'stop-before-partial' }), [101, 120, 97]); +assert.throws(SyntaxError, function() { + Uint8Array.fromBase64('ZXhhZh', { lastChunkHandling: 'strict' }); +}); + +// malformed padding +assert.throws(SyntaxError, function() { + Uint8Array.fromBase64('ZXhhZg='); +}); +assert.throws(SyntaxError, function() { + Uint8Array.fromBase64('ZXhhZg=', { lastChunkHandling: 'loose' }); +}); +assert.compareArray(Uint8Array.fromBase64('ZXhhZg=', { lastChunkHandling: 'stop-before-partial' }), [101, 120, 97]); +assert.throws(SyntaxError, function() { + Uint8Array.fromBase64('ZXhhZg=', { lastChunkHandling: 'strict' }); +}); diff --git a/test/built-ins/Uint8Array/fromBase64/length.js b/test/built-ins/Uint8Array/fromBase64/length.js new file mode 100644 index 00000000000..23b70729546 --- /dev/null +++ b/test/built-ins/Uint8Array/fromBase64/length.js @@ -0,0 +1,16 @@ +// Copyright (C) 2024 Kevin Gibbons. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-uint8array.frombase64 +description: > + Uint8Array.fromBase64.length is 1. +includes: [propertyHelper.js] +features: [uint8array-base64] +---*/ + +verifyProperty(Uint8Array.fromBase64, 'length', { + value: 1, + enumerable: false, + writable: false, + configurable: true +}); diff --git a/test/built-ins/Uint8Array/fromBase64/name.js b/test/built-ins/Uint8Array/fromBase64/name.js new file mode 100644 index 00000000000..9e38d3158eb --- /dev/null +++ b/test/built-ins/Uint8Array/fromBase64/name.js @@ -0,0 +1,16 @@ +// Copyright (C) 2024 Kevin Gibbons. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-uint8array.frombase64 +description: > + Uint8Array.fromBase64.name is "fromBase64". +includes: [propertyHelper.js] +features: [uint8array-base64] +---*/ + +verifyProperty(Uint8Array.fromBase64, 'name', { + value: 'fromBase64', + enumerable: false, + writable: false, + configurable: true +}); diff --git a/test/built-ins/Uint8Array/fromBase64/nonconstructor.js b/test/built-ins/Uint8Array/fromBase64/nonconstructor.js new file mode 100644 index 00000000000..219e6399f2e --- /dev/null +++ b/test/built-ins/Uint8Array/fromBase64/nonconstructor.js @@ -0,0 +1,15 @@ +// Copyright (C) 2024 Kevin Gibbons. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-uint8array.frombase64 +description: > + Uint8Array.fromBase64 is not a constructor function. +includes: [isConstructor.js] +features: [uint8array-base64, Reflect.construct] +---*/ + +assert(!isConstructor(Uint8Array.fromBase64), "Uint8Array.fromBase64 is not a constructor"); + +assert.throws(TypeError, function() { + new Uint8Array.fromBase64(''); +}); diff --git a/test/built-ins/Uint8Array/fromBase64/option-coercion.js b/test/built-ins/Uint8Array/fromBase64/option-coercion.js new file mode 100644 index 00000000000..917aa3d1b52 --- /dev/null +++ b/test/built-ins/Uint8Array/fromBase64/option-coercion.js @@ -0,0 +1,50 @@ +// Copyright (C) 2024 Kevin Gibbons. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-uint8array.frombase64 +description: Uint8Array.fromBase64 triggers effects of the "alphabet" and "lastChunkHandling" getters, but does not perform toString on the results +includes: [compareArray.js] +features: [uint8array-base64] +---*/ + +var toStringCalls = 0; +var throwyToString = { + toString: function() { + toStringCalls += 1; + throw new Test262Error("toString called"); + } +}; +assert.throws(TypeError, function() { + Uint8Array.fromBase64("Zg==", { alphabet: throwyToString }); +}); +assert.sameValue(toStringCalls, 0); + +assert.throws(TypeError, function() { + Uint8Array.fromBase64("Zg==", { lastChunkHandling: throwyToString }); +}); +assert.sameValue(toStringCalls, 0); + + +var alphabetAccesses = 0; +var base64UrlOptions = {}; +Object.defineProperty(base64UrlOptions, "alphabet", { + get: function() { + alphabetAccesses += 1; + return "base64url"; + } +}); +var arr = Uint8Array.fromBase64("x-_y", base64UrlOptions); +assert.compareArray(arr, [199, 239, 242]); +assert.sameValue(alphabetAccesses, 1); + +var lastChunkHandlingAccesses = 0; +var strictOptions = {}; +Object.defineProperty(strictOptions, "lastChunkHandling", { + get: function() { + lastChunkHandlingAccesses += 1; + return "strict"; + } +}); +var arr = Uint8Array.fromBase64("Zg==", strictOptions); +assert.compareArray(arr, [102]); +assert.sameValue(lastChunkHandlingAccesses, 1); diff --git a/test/built-ins/Uint8Array/fromBase64/results.js b/test/built-ins/Uint8Array/fromBase64/results.js new file mode 100644 index 00000000000..48910c32cf5 --- /dev/null +++ b/test/built-ins/Uint8Array/fromBase64/results.js @@ -0,0 +1,25 @@ +// Copyright (C) 2024 Kevin Gibbons. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-uint8array.frombase64 +description: Conversion of base64 strings to Uint8Arrays +includes: [compareArray.js] +features: [uint8array-base64] +---*/ + +// standard test vectors from https://datatracker.ietf.org/doc/html/rfc4648#section-10 +var standardBase64Vectors = [ + ["", []], + ["Zg==", [102]], + ["Zm8=", [102, 111]], + ["Zm9v", [102, 111, 111]], + ["Zm9vYg==", [102, 111, 111, 98]], + ["Zm9vYmE=", [102, 111, 111, 98, 97]], + ["Zm9vYmFy", [102, 111, 111, 98, 97, 114]], +]; + +standardBase64Vectors.forEach(function (pair) { + var arr = Uint8Array.fromBase64(pair[0]); + assert.sameValue(Object.getPrototypeOf(arr), Uint8Array.prototype, "decoding " + pair[0]); + assert.compareArray(arr, pair[1], "decoding " + pair[0]); +}); diff --git a/test/built-ins/Uint8Array/fromBase64/string-coercion.js b/test/built-ins/Uint8Array/fromBase64/string-coercion.js new file mode 100644 index 00000000000..56f0648330d --- /dev/null +++ b/test/built-ins/Uint8Array/fromBase64/string-coercion.js @@ -0,0 +1,41 @@ +// Copyright (C) 2024 Kevin Gibbons. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-uint8array.frombase64 +description: Uint8Array.fromBase64 throws if its argument is not a string +features: [uint8array-base64] +---*/ + +var toStringCalls = 0; +var throwyToString = { + toString: function() { + toStringCalls += 1; + throw new Test262Error("toString called"); + } +}; + +assert.throws(TypeError, function() { + Uint8Array.fromBase64(throwyToString); +}); +assert.sameValue(toStringCalls, 0); + + +var optionAccesses = 0; +var touchyOptions = {}; +Object.defineProperty(touchyOptions, "alphabet", { + get: function() { + optionAccesses += 1; + throw new Test262Error("alphabet accessed"); + } +}); +Object.defineProperty(touchyOptions, "lastChunkHandling", { + get: function() { + optionAccesses += 1; + throw new Test262Error("lastChunkHandling accessed"); + } +}); +assert.throws(TypeError, function() { + Uint8Array.fromBase64(throwyToString, touchyOptions); +}); +assert.sameValue(toStringCalls, 0); +assert.sameValue(optionAccesses, 0); diff --git a/test/built-ins/Uint8Array/fromBase64/whitespace.js b/test/built-ins/Uint8Array/fromBase64/whitespace.js new file mode 100644 index 00000000000..ce9f7f239c8 --- /dev/null +++ b/test/built-ins/Uint8Array/fromBase64/whitespace.js @@ -0,0 +1,20 @@ +// Copyright (C) 2024 Kevin Gibbons. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-uint8array.frombase64 +description: Uint8Array.fromBase64 ignores ASCII whitespace in the input +includes: [compareArray.js] +features: [uint8array-base64] +---*/ + +var whitespaceKinds = [ + ["Z g==", "space"], + ["Z\tg==", "tab"], + ["Z\x0Ag==", "LF"], + ["Z\x0Cg==", "FF"], + ["Z\x0Dg==", "CR"], +]; +whitespaceKinds.forEach(function(pair) { + var arr = Uint8Array.fromBase64(pair[0]); + assert.compareArray(arr, [102], "ascii whitespace: " + pair[1]); +}); diff --git a/test/built-ins/Uint8Array/fromBase64Into/alphabet.js b/test/built-ins/Uint8Array/fromBase64Into/alphabet.js new file mode 100644 index 00000000000..270396581c9 --- /dev/null +++ b/test/built-ins/Uint8Array/fromBase64Into/alphabet.js @@ -0,0 +1,41 @@ +// Copyright (C) 2024 Kevin Gibbons. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-uint8array.frombase64into +description: Conversion of base64 strings to Uint8Arrays exercising the alphabet option +includes: [compareArray.js] +features: [uint8array-base64] +---*/ + +var target = new Uint8Array([255, 255, 255, 255]); +var result = Uint8Array.fromBase64Into('x+/y', target); +assert.sameValue(result.read, 4); +assert.sameValue(result.written, 3); +assert.compareArray(target, [199, 239, 242, 255]); + +var target = new Uint8Array([255, 255, 255, 255]); +var result = Uint8Array.fromBase64Into('x+/y', target, { alphabet: 'base64' }); +assert.sameValue(result.read, 4); +assert.sameValue(result.written, 3); +assert.compareArray(target, [199, 239, 242, 255]); + +assert.throws(SyntaxError, function() { + var target = new Uint8Array([255, 255, 255, 255]); + Uint8Array.fromBase64('x+/y', { alphabet: 'base64url' }); +}); + + +var target = new Uint8Array([255, 255, 255, 255]); +var result = Uint8Array.fromBase64Into('x-_y', target, { alphabet: 'base64url' }); +assert.sameValue(result.read, 4); +assert.sameValue(result.written, 3); +assert.compareArray(target, [199, 239, 242, 255]); + +assert.throws(SyntaxError, function() { + var target = new Uint8Array([255, 255, 255, 255]); + Uint8Array.fromBase64('x-_y'); +}); +assert.throws(SyntaxError, function() { + var target = new Uint8Array([255, 255, 255, 255]); + Uint8Array.fromBase64('x-_y', { alphabet: 'base64' }); +}); diff --git a/test/built-ins/Uint8Array/fromBase64Into/descriptor.js b/test/built-ins/Uint8Array/fromBase64Into/descriptor.js new file mode 100644 index 00000000000..672a29cb6ae --- /dev/null +++ b/test/built-ins/Uint8Array/fromBase64Into/descriptor.js @@ -0,0 +1,15 @@ +// Copyright (C) 2024 Kevin Gibbons. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-uint8array.frombase64into +description: > + Uint8Array.fromBase64Into has default data property attributes. +includes: [propertyHelper.js] +features: [uint8array-base64] +---*/ + +verifyProperty(Uint8Array, 'fromBase64Into', { + enumerable: false, + writable: true, + configurable: true +}); diff --git a/test/built-ins/Uint8Array/fromBase64Into/detached-buffer.js b/test/built-ins/Uint8Array/fromBase64Into/detached-buffer.js new file mode 100644 index 00000000000..80ebbcf4f41 --- /dev/null +++ b/test/built-ins/Uint8Array/fromBase64Into/detached-buffer.js @@ -0,0 +1,29 @@ +// Copyright (C) 2024 Kevin Gibbons. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-uint8array.frombase64into +description: Uint8Array.fromBase64Into does not write to or error on detatched buffers +includes: [detachArrayBuffer.js] +features: [uint8array-base64] +---*/ + +var target = new Uint8Array([255, 255, 255]); +$DETACHBUFFER(target.buffer); +var result = Uint8Array.fromBase64Into('Zg==', target); +assert.sameValue(result.read, 0); +assert.sameValue(result.written, 0); + +var getterCalls = 0; +var targetDetachingOptions = {}; +Object.defineProperty(targetDetachingOptions, 'alphabet', { + get: function() { + getterCalls += 1; + $DETACHBUFFER(target.buffer); + return "base64"; + } +}); +var target = new Uint8Array([255, 255, 255]); +var result = Uint8Array.fromBase64Into('Zg==', target, targetDetachingOptions); +assert.sameValue(getterCalls, 1); +assert.sameValue(result.read, 0); +assert.sameValue(result.written, 0); diff --git a/test/built-ins/Uint8Array/fromBase64Into/ignores-receiver.js b/test/built-ins/Uint8Array/fromBase64Into/ignores-receiver.js new file mode 100644 index 00000000000..55d3bb96cbb --- /dev/null +++ b/test/built-ins/Uint8Array/fromBase64Into/ignores-receiver.js @@ -0,0 +1,16 @@ +// Copyright (C) 2024 Kevin Gibbons. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-uint8array.frombase64into +description: Uint8Array.fromBase64Into ignores its receiver +includes: [compareArray.js] +features: [uint8array-base64] +---*/ + +var fromBase64Into = Uint8Array.fromBase64Into; +var target = new Uint8Array([255, 255, 255]); + +var result = fromBase64Into("Zg==", target); +assert.sameValue(result.read, 4); +assert.sameValue(result.written, 1); +assert.compareArray(target, [102, 255, 255]); diff --git a/test/built-ins/Uint8Array/fromBase64Into/illegal-characters.js b/test/built-ins/Uint8Array/fromBase64Into/illegal-characters.js new file mode 100644 index 00000000000..899d934c91f --- /dev/null +++ b/test/built-ins/Uint8Array/fromBase64Into/illegal-characters.js @@ -0,0 +1,24 @@ +// Copyright (C) 2024 Kevin Gibbons. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-uint8array.frombase64into +description: Uint8Array.fromBase64 throws a SyntaxError when input has non-base64, non-ascii-whitespace characters +features: [uint8array-base64] +---*/ + +var illegal = [ + 'Zm.9v', + 'Zm9v^', + 'Zg==&', + 'Z−==', // U+2212 'Minus Sign' + 'Z+==', // U+FF0B 'Fullwidth Plus Sign' + 'Zg\u00A0==', // nbsp + 'Zg\u2009==', // thin space + 'Zg\u2028==', // line separator +]; +illegal.forEach(function(value) { + assert.throws(SyntaxError, function() { + var target = new Uint8Array([255, 255, 255, 255, 255]); + Uint8Array.fromBase64Into(value, target); + }); +}); diff --git a/test/built-ins/Uint8Array/fromBase64Into/last-chunk-handling.js b/test/built-ins/Uint8Array/fromBase64Into/last-chunk-handling.js new file mode 100644 index 00000000000..1c0ab248d62 --- /dev/null +++ b/test/built-ins/Uint8Array/fromBase64Into/last-chunk-handling.js @@ -0,0 +1,131 @@ +// Copyright (C) 2024 Kevin Gibbons. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-uint8array.frombase64into +description: Handling of final chunks in Uint8Array.fromBase64Into +includes: [compareArray.js] +features: [uint8array-base64] +---*/ + +// padding +var target = new Uint8Array([255, 255, 255, 255, 255, 255]); +var result = Uint8Array.fromBase64Into('ZXhhZg==', target); +assert.sameValue(result.read, 8); +assert.sameValue(result.written, 4); +assert.compareArray(target, [101, 120, 97, 102, 255, 255]); + +var target = new Uint8Array([255, 255, 255, 255, 255, 255]); +var result = Uint8Array.fromBase64Into('ZXhhZg==', target, { lastChunkHandling: 'loose' }); +assert.sameValue(result.read, 8); +assert.sameValue(result.written, 4); +assert.compareArray(target, [101, 120, 97, 102, 255, 255]); + +var target = new Uint8Array([255, 255, 255, 255, 255, 255]); +var result = Uint8Array.fromBase64Into('ZXhhZg==', target, { lastChunkHandling: 'stop-before-partial' }); +assert.sameValue(result.read, 8); +assert.sameValue(result.written, 4); +assert.compareArray(target, [101, 120, 97, 102, 255, 255]); + +var target = new Uint8Array([255, 255, 255, 255, 255, 255]); +var result = Uint8Array.fromBase64Into('ZXhhZg==', target, { lastChunkHandling: 'strict' }); +assert.sameValue(result.read, 8); +assert.sameValue(result.written, 4); +assert.compareArray(target, [101, 120, 97, 102, 255, 255]); + + +// no padding +var target = new Uint8Array([255, 255, 255, 255, 255, 255]); +var result = Uint8Array.fromBase64Into('ZXhhZg', target); +assert.sameValue(result.read, 6); +assert.sameValue(result.written, 4); +assert.compareArray(target, [101, 120, 97, 102, 255, 255]); + +var target = new Uint8Array([255, 255, 255, 255, 255, 255]); +var result = Uint8Array.fromBase64Into('ZXhhZg', target, { lastChunkHandling: 'loose' }); +assert.sameValue(result.read, 6); +assert.sameValue(result.written, 4); +assert.compareArray(target, [101, 120, 97, 102, 255, 255]); + +var target = new Uint8Array([255, 255, 255, 255, 255, 255]); +var result = Uint8Array.fromBase64Into('ZXhhZg', target, { lastChunkHandling: 'stop-before-partial' }); +assert.sameValue(result.read, 4); +assert.sameValue(result.written, 3); +assert.compareArray(target, [101, 120, 97, 255, 255, 255]); + +assert.throws(SyntaxError, function() { + var target = new Uint8Array([255, 255, 255, 255, 255, 255]); + Uint8Array.fromBase64Into('ZXhhZg', target, { lastChunkHandling: 'strict' }); +}); + + +// non-zero padding bits +var target = new Uint8Array([255, 255, 255, 255, 255, 255]); +var result = Uint8Array.fromBase64Into('ZXhhZh==', target); +assert.sameValue(result.read, 8); +assert.sameValue(result.written, 4); +assert.compareArray(target, [101, 120, 97, 102, 255, 255]); + +var target = new Uint8Array([255, 255, 255, 255, 255, 255]); +var result = Uint8Array.fromBase64Into('ZXhhZh==', target, { lastChunkHandling: 'loose' }); +assert.sameValue(result.read, 8); +assert.sameValue(result.written, 4); +assert.compareArray(target, [101, 120, 97, 102, 255, 255]); + +var target = new Uint8Array([255, 255, 255, 255, 255, 255]); +var result = Uint8Array.fromBase64Into('ZXhhZh==', target, { lastChunkHandling: 'stop-before-partial' }); +assert.sameValue(result.read, 8); +assert.sameValue(result.written, 4); +assert.compareArray(target, [101, 120, 97, 102, 255, 255]); + +assert.throws(SyntaxError, function() { + var target = new Uint8Array([255, 255, 255, 255, 255, 255]); + Uint8Array.fromBase64Into('ZXhhZh==', target, { lastChunkHandling: 'strict' }); +}); + + +// non-zero padding bits, no padding +var target = new Uint8Array([255, 255, 255, 255, 255, 255]); +var result = Uint8Array.fromBase64Into('ZXhhZh', target); +assert.sameValue(result.read, 6); +assert.sameValue(result.written, 4); +assert.compareArray(target, [101, 120, 97, 102, 255, 255]); + +var target = new Uint8Array([255, 255, 255, 255, 255, 255]); +var result = Uint8Array.fromBase64Into('ZXhhZh', target, { lastChunkHandling: 'loose' }); +assert.sameValue(result.read, 6); +assert.sameValue(result.written, 4); +assert.compareArray(target, [101, 120, 97, 102, 255, 255]); + +var target = new Uint8Array([255, 255, 255, 255, 255, 255]); +var result = Uint8Array.fromBase64Into('ZXhhZh', target, { lastChunkHandling: 'stop-before-partial' }); +assert.sameValue(result.read, 4); +assert.sameValue(result.written, 3); +assert.compareArray(target, [101, 120, 97, 255, 255, 255]); + +assert.throws(SyntaxError, function() { + var target = new Uint8Array([255, 255, 255, 255, 255, 255]); + Uint8Array.fromBase64Into('ZXhhZh', target, { lastChunkHandling: 'strict' }); +}); + + +// malformed padding +assert.throws(SyntaxError, function() { + var target = new Uint8Array([255, 255, 255, 255, 255, 255]); + Uint8Array.fromBase64Into('ZXhhZg=', target); +}); + +assert.throws(SyntaxError, function() { + var target = new Uint8Array([255, 255, 255, 255, 255, 255]); + Uint8Array.fromBase64Into('ZXhhZg=', target, { lastChunkHandling: 'loose' }); +}); + +var target = new Uint8Array([255, 255, 255, 255, 255, 255]); +var result = Uint8Array.fromBase64Into('ZXhhZg=', target, { lastChunkHandling: 'stop-before-partial' }); +assert.sameValue(result.read, 4); +assert.sameValue(result.written, 3); +assert.compareArray(target, [101, 120, 97, 255, 255, 255]); + +assert.throws(SyntaxError, function() { + var target = new Uint8Array([255, 255, 255, 255, 255, 255]); + Uint8Array.fromBase64Into('ZXhhZg=', target, { lastChunkHandling: 'strict' }); +}); diff --git a/test/built-ins/Uint8Array/fromBase64Into/length.js b/test/built-ins/Uint8Array/fromBase64Into/length.js new file mode 100644 index 00000000000..a97be01f695 --- /dev/null +++ b/test/built-ins/Uint8Array/fromBase64Into/length.js @@ -0,0 +1,16 @@ +// Copyright (C) 2024 Kevin Gibbons. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-uint8array.frombase64into +description: > + Uint8Array.fromBase64Into.length is 2. +includes: [propertyHelper.js] +features: [uint8array-base64] +---*/ + +verifyProperty(Uint8Array.fromBase64Into, 'length', { + value: 2, + enumerable: false, + writable: false, + configurable: true +}); diff --git a/test/built-ins/Uint8Array/fromBase64Into/name.js b/test/built-ins/Uint8Array/fromBase64Into/name.js new file mode 100644 index 00000000000..dcdc49c99b2 --- /dev/null +++ b/test/built-ins/Uint8Array/fromBase64Into/name.js @@ -0,0 +1,16 @@ +// Copyright (C) 2024 Kevin Gibbons. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-uint8array.frombase64into +description: > + Uint8Array.fromBase64Into.name is "fromBase64Into". +includes: [propertyHelper.js] +features: [uint8array-base64] +---*/ + +verifyProperty(Uint8Array.fromBase64Into, 'name', { + value: 'fromBase64Into', + enumerable: false, + writable: false, + configurable: true +}); diff --git a/test/built-ins/Uint8Array/fromBase64Into/nonconstructor.js b/test/built-ins/Uint8Array/fromBase64Into/nonconstructor.js new file mode 100644 index 00000000000..a5e9f0ec7a2 --- /dev/null +++ b/test/built-ins/Uint8Array/fromBase64Into/nonconstructor.js @@ -0,0 +1,16 @@ +// Copyright (C) 2024 Kevin Gibbons. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-uint8array.frombase64into +description: > + Uint8Array.fromBase64Into is not a constructor function. +includes: [isConstructor.js] +features: [uint8array-base64, Reflect.construct] +---*/ + +assert(!isConstructor(Uint8Array.fromBase64Into), "Uint8Array.fromBase64Into is not a constructor"); + +assert.throws(TypeError, function() { + var target = new Uint8Array(10); + new Uint8Array.fromBase64Into('', target); +}); diff --git a/test/built-ins/Uint8Array/fromBase64Into/option-coercion.js b/test/built-ins/Uint8Array/fromBase64Into/option-coercion.js new file mode 100644 index 00000000000..174712f9325 --- /dev/null +++ b/test/built-ins/Uint8Array/fromBase64Into/option-coercion.js @@ -0,0 +1,58 @@ +// Copyright (C) 2024 Kevin Gibbons. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-uint8array.frombase64into +description: Uint8Array.fromBase64Into triggers effects of the "alphabet" and "lastChunkHandling" getters, but does not perform toString on the results +includes: [compareArray.js] +features: [uint8array-base64] +---*/ + +var toStringCalls = 0; +var throwyToString = { + toString: function() { + toStringCalls += 1; + throw new Test262Error("toString called"); + } +}; +assert.throws(TypeError, function() { + var target = new Uint8Array([255, 255, 255]); + Uint8Array.fromBase64Into("Zg==", target, { alphabet: throwyToString }); +}); +assert.sameValue(toStringCalls, 0); + +assert.throws(TypeError, function() { + var target = new Uint8Array([255, 255, 255]); + Uint8Array.fromBase64Into("Zg==", target, { lastChunkHandling: throwyToString }); +}); +assert.sameValue(toStringCalls, 0); + + +var alphabetAccesses = 0; +var base64UrlOptions = {}; +Object.defineProperty(base64UrlOptions, "alphabet", { + get: function() { + alphabetAccesses += 1; + return "base64url"; + } +}); +var target = new Uint8Array([255, 255, 255, 255]); +var result = Uint8Array.fromBase64Into("x-_y", target, base64UrlOptions); +assert.sameValue(result.read, 4); +assert.sameValue(result.written, 3); +assert.compareArray(target, [199, 239, 242, 255]); +assert.sameValue(alphabetAccesses, 1); + +var lastChunkHandlingAccesses = 0; +var strictOptions = {}; +Object.defineProperty(strictOptions, "lastChunkHandling", { + get: function() { + lastChunkHandlingAccesses += 1; + return "strict"; + } +}); +var target = new Uint8Array([255, 255, 255, 255]); +var result = Uint8Array.fromBase64Into("Zg==", target, strictOptions); +assert.sameValue(result.read, 4); +assert.sameValue(result.written, 1); +assert.compareArray(target, [102, 255, 255, 255]); +assert.sameValue(lastChunkHandlingAccesses, 1); diff --git a/test/built-ins/Uint8Array/fromBase64Into/results.js b/test/built-ins/Uint8Array/fromBase64Into/results.js new file mode 100644 index 00000000000..35b02b40783 --- /dev/null +++ b/test/built-ins/Uint8Array/fromBase64Into/results.js @@ -0,0 +1,30 @@ +// Copyright (C) 2024 Kevin Gibbons. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-uint8array.frombase64into +description: Conversion of base64 strings to Uint8Arrays +includes: [compareArray.js] +features: [uint8array-base64] +---*/ + +// standard test vectors from https://datatracker.ietf.org/doc/html/rfc4648#section-10 +var standardBase64Vectors = [ + ["", []], + ["Zg==", [102]], + ["Zm8=", [102, 111]], + ["Zm9v", [102, 111, 111]], + ["Zm9vYg==", [102, 111, 111, 98]], + ["Zm9vYmE=", [102, 111, 111, 98, 97]], + ["Zm9vYmFy", [102, 111, 111, 98, 97, 114]], +]; + +standardBase64Vectors.forEach(function (pair) { + var allFF = [255, 255, 255, 255, 255, 255, 255, 255]; + var target = new Uint8Array(allFF); + var result = Uint8Array.fromBase64Into(pair[0], target); + assert.sameValue(result.read, pair[0].length); + assert.sameValue(result.written, pair[1].length); + + var expected = pair[1].concat(allFF.slice(pair[1].length)) + assert.compareArray(target, expected, "decoding " + pair[0]); +}); diff --git a/test/built-ins/Uint8Array/fromBase64Into/string-coercion.js b/test/built-ins/Uint8Array/fromBase64Into/string-coercion.js new file mode 100644 index 00000000000..17ad8b48f67 --- /dev/null +++ b/test/built-ins/Uint8Array/fromBase64Into/string-coercion.js @@ -0,0 +1,43 @@ +// Copyright (C) 2024 Kevin Gibbons. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-uint8array.frombase64into +description: Uint8Array.fromBase64Into throws if its first argument is not a string +features: [uint8array-base64] +---*/ + +var toStringCalls = 0; +var throwyToString = { + toString: function() { + toStringCalls += 1; + throw new Test262Error("toString called"); + } +}; + +assert.throws(TypeError, function() { + var target = new Uint8Array(10); + Uint8Array.fromBase64Into(throwyToString, target); +}); +assert.sameValue(toStringCalls, 0); + + +var optionAccesses = 0; +var touchyOptions = {}; +Object.defineProperty(touchyOptions, "alphabet", { + get: function() { + optionAccesses += 1; + throw new Test262Error("alphabet accessed"); + } +}); +Object.defineProperty(touchyOptions, "lastChunkHandling", { + get: function() { + optionAccesses += 1; + throw new Test262Error("lastChunkHandling accessed"); + } +}); +assert.throws(TypeError, function() { + var target = new Uint8Array(10); + Uint8Array.fromBase64Into(throwyToString, target, touchyOptions); +}); +assert.sameValue(toStringCalls, 0); +assert.sameValue(optionAccesses, 0); diff --git a/test/built-ins/Uint8Array/fromBase64Into/subarray.js b/test/built-ins/Uint8Array/fromBase64Into/subarray.js new file mode 100644 index 00000000000..6c5bb95e549 --- /dev/null +++ b/test/built-ins/Uint8Array/fromBase64Into/subarray.js @@ -0,0 +1,17 @@ +// Copyright (C) 2024 Kevin Gibbons. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-uint8array.frombase64into +description: Uint8Array.fromBase64Into takes into account the offset of the target Uint8Array +includes: [compareArray.js] +features: [uint8array-base64] +---*/ + +var base = new Uint8Array([255, 255, 255, 255, 255, 255, 255]); +var subarray = base.subarray(2, 5); + +var result = Uint8Array.fromBase64Into('Zm9vYmFy', subarray); +assert.sameValue(result.read, 4); +assert.sameValue(result.written, 3); +assert.compareArray(subarray, [102, 111, 111]); +assert.compareArray(base, [255, 255, 102, 111, 111, 255, 255]); diff --git a/test/built-ins/Uint8Array/fromBase64Into/target-size.js b/test/built-ins/Uint8Array/fromBase64Into/target-size.js new file mode 100644 index 00000000000..4b44c9eaeff --- /dev/null +++ b/test/built-ins/Uint8Array/fromBase64Into/target-size.js @@ -0,0 +1,64 @@ +// Copyright (C) 2024 Kevin Gibbons. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-uint8array.frombase64 +description: Uint8Array.fromBase64Into behavior when target buffer is small +includes: [compareArray.js] +features: [uint8array-base64] +---*/ + +// buffer too small +var target = new Uint8Array([255, 255, 255, 255, 255]); +var result = Uint8Array.fromBase64Into('Zm9vYmFy', target); +assert.sameValue(result.read, 4); +assert.sameValue(result.written, 3); +assert.compareArray(target, [102, 111, 111, 255, 255]); + +// buffer too small, padded +var target = new Uint8Array([255, 255, 255, 255]); +var result = Uint8Array.fromBase64Into('Zm9vYmE=', target); +assert.sameValue(result.read, 4); +assert.sameValue(result.written, 3); +assert.compareArray(target, [102, 111, 111, 255]); + +// buffer exact +var target = new Uint8Array([255, 255, 255, 255, 255, 255]); +var result = Uint8Array.fromBase64Into('Zm9vYmFy', target); +assert.sameValue(result.read, 8); +assert.sameValue(result.written, 6); +assert.compareArray(target, [102, 111, 111, 98, 97, 114]); + +// buffer exact, padded +var target = new Uint8Array([255, 255, 255, 255, 255]); +var result = Uint8Array.fromBase64Into('Zm9vYmE=', target); +assert.sameValue(result.read, 8); +assert.sameValue(result.written, 5); +assert.compareArray(target, [102, 111, 111, 98, 97]); + +// buffer exact, not padded +var target = new Uint8Array([255, 255, 255, 255, 255]); +var result = Uint8Array.fromBase64Into('Zm9vYmE', target); +assert.sameValue(result.read, 7); +assert.sameValue(result.written, 5); +assert.compareArray(target, [102, 111, 111, 98, 97]); + +// buffer exact, padded, stop-before-partial +var target = new Uint8Array([255, 255, 255, 255, 255]); +var result = Uint8Array.fromBase64Into('Zm9vYmE=', target, { lastChunkHandling: 'stop-before-partial' }); +assert.sameValue(result.read, 8); +assert.sameValue(result.written, 5); +assert.compareArray(target, [102, 111, 111, 98, 97]); + +// buffer exact, not padded, stop-before-partial +var target = new Uint8Array([255, 255, 255, 255, 255]); +var result = Uint8Array.fromBase64Into('Zm9vYmE', target, { lastChunkHandling: 'stop-before-partial' }); +assert.sameValue(result.read, 4); +assert.sameValue(result.written, 3); +assert.compareArray(target, [102, 111, 111, 255, 255]); + +// buffer too large +var target = new Uint8Array([255, 255, 255, 255, 255, 255, 255]); +var result = Uint8Array.fromBase64Into('Zm9vYmFy', target); +assert.sameValue(result.read, 8); +assert.sameValue(result.written, 6); +assert.compareArray(target, [102, 111, 111, 98, 97, 114, 255]); diff --git a/test/built-ins/Uint8Array/fromBase64Into/whitespace.js b/test/built-ins/Uint8Array/fromBase64Into/whitespace.js new file mode 100644 index 00000000000..8ba0b01064d --- /dev/null +++ b/test/built-ins/Uint8Array/fromBase64Into/whitespace.js @@ -0,0 +1,23 @@ +// Copyright (C) 2024 Kevin Gibbons. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-uint8array.frombase64into +description: Uint8Array.fromBase64Into ignores ASCII whitespace in the input +includes: [compareArray.js] +features: [uint8array-base64] +---*/ + +var whitespaceKinds = [ + ["Z g==", "space"], + ["Z\tg==", "tab"], + ["Z\x0Ag==", "LF"], + ["Z\x0Cg==", "FF"], + ["Z\x0Dg==", "CR"], +]; +whitespaceKinds.forEach(function(pair) { + var target = new Uint8Array([255, 255, 255]); + var result = Uint8Array.fromBase64Into(pair[0], target); + assert.sameValue(result.read, 5); + assert.sameValue(result.written, 1); + assert.compareArray(target, [102, 255, 255], "ascii whitespace: " + pair[1]); +}); diff --git a/test/built-ins/Uint8Array/fromHex/descriptor.js b/test/built-ins/Uint8Array/fromHex/descriptor.js new file mode 100644 index 00000000000..1ae033cb1ee --- /dev/null +++ b/test/built-ins/Uint8Array/fromHex/descriptor.js @@ -0,0 +1,15 @@ +// Copyright (C) 2024 Kevin Gibbons. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-uint8array.fromhex +description: > + Uint8Array.fromHex has default data property attributes. +includes: [propertyHelper.js] +features: [uint8array-base64] +---*/ + +verifyProperty(Uint8Array, 'fromHex', { + enumerable: false, + writable: true, + configurable: true +}); diff --git a/test/built-ins/Uint8Array/fromHex/ignores-receiver.js b/test/built-ins/Uint8Array/fromHex/ignores-receiver.js new file mode 100644 index 00000000000..48bb0698c90 --- /dev/null +++ b/test/built-ins/Uint8Array/fromHex/ignores-receiver.js @@ -0,0 +1,19 @@ +// Copyright (C) 2024 Kevin Gibbons. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-uint8array.fromhex +description: Uint8Array.fromHex ignores its receiver +features: [uint8array-base64] +---*/ + +var fromHex = Uint8Array.fromHex; +var noReceiver = fromHex("aa"); +assert.sameValue(Object.getPrototypeOf(noReceiver), Uint8Array.prototype); + +class Subclass extends Uint8Array { + constructor() { + throw new Test262Error("subclass constructor called"); + } +} +var fromSubclass = Subclass.fromHex("aa"); +assert.sameValue(Object.getPrototypeOf(fromSubclass), Uint8Array.prototype); diff --git a/test/built-ins/Uint8Array/fromHex/illegal-characters.js b/test/built-ins/Uint8Array/fromHex/illegal-characters.js new file mode 100644 index 00000000000..dd0ae6d55b4 --- /dev/null +++ b/test/built-ins/Uint8Array/fromHex/illegal-characters.js @@ -0,0 +1,25 @@ +// Copyright (C) 2024 Kevin Gibbons. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-uint8array.fromhex +description: Uint8Array.fromHex throws a SyntaxError when input has non-hex characters +features: [uint8array-base64] +---*/ + +var illegal = [ + 'a.a', + 'aa^', + 'a a', + 'a\ta', + 'a\x0Aa', + 'a\x0Ca', + 'a\x0Da', + 'a\u00A0a', // nbsp + 'a\u2009a', // thin space + 'a\u2028a', // line separator +]; +illegal.forEach(function(value) { + assert.throws(SyntaxError, function() { + Uint8Array.fromHex(value) + }); +}); diff --git a/test/built-ins/Uint8Array/fromHex/length.js b/test/built-ins/Uint8Array/fromHex/length.js new file mode 100644 index 00000000000..ef9dca8def0 --- /dev/null +++ b/test/built-ins/Uint8Array/fromHex/length.js @@ -0,0 +1,16 @@ +// Copyright (C) 2024 Kevin Gibbons. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-uint8array.fromhex +description: > + Uint8Array.fromHex.length is 1. +includes: [propertyHelper.js] +features: [uint8array-base64] +---*/ + +verifyProperty(Uint8Array.fromHex, 'length', { + value: 1, + enumerable: false, + writable: false, + configurable: true +}); diff --git a/test/built-ins/Uint8Array/fromHex/name.js b/test/built-ins/Uint8Array/fromHex/name.js new file mode 100644 index 00000000000..083cff7b794 --- /dev/null +++ b/test/built-ins/Uint8Array/fromHex/name.js @@ -0,0 +1,16 @@ +// Copyright (C) 2024 Kevin Gibbons. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-uint8array.fromhex +description: > + Uint8Array.fromHex.name is "fromHex". +includes: [propertyHelper.js] +features: [uint8array-base64] +---*/ + +verifyProperty(Uint8Array.fromHex, 'name', { + value: 'fromHex', + enumerable: false, + writable: false, + configurable: true +}); diff --git a/test/built-ins/Uint8Array/fromHex/nonconstructor.js b/test/built-ins/Uint8Array/fromHex/nonconstructor.js new file mode 100644 index 00000000000..e06d1c54f3d --- /dev/null +++ b/test/built-ins/Uint8Array/fromHex/nonconstructor.js @@ -0,0 +1,15 @@ +// Copyright (C) 2024 Kevin Gibbons. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-uint8array.fromhex +description: > + Uint8Array.fromHex is not a constructor function. +includes: [isConstructor.js] +features: [uint8array-base64, Reflect.construct] +---*/ + +assert(!isConstructor(Uint8Array.fromHex), "Uint8Array.fromHex is not a constructor"); + +assert.throws(TypeError, function() { + new Uint8Array.fromHex(''); +}); diff --git a/test/built-ins/Uint8Array/fromHex/odd-length-input.js b/test/built-ins/Uint8Array/fromHex/odd-length-input.js new file mode 100644 index 00000000000..798be139c18 --- /dev/null +++ b/test/built-ins/Uint8Array/fromHex/odd-length-input.js @@ -0,0 +1,11 @@ +// Copyright (C) 2024 Kevin Gibbons. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-uint8array.fromhex +description: Uint8Array.fromHex throws if given an odd number of input hex characters +features: [uint8array-base64] +---*/ + +assert.throws(SyntaxError, function() { + Uint8Array.fromHex('a'); +}); diff --git a/test/built-ins/Uint8Array/fromHex/results.js b/test/built-ins/Uint8Array/fromHex/results.js new file mode 100644 index 00000000000..58cd5648c5e --- /dev/null +++ b/test/built-ins/Uint8Array/fromHex/results.js @@ -0,0 +1,26 @@ +// Copyright (C) 2024 Kevin Gibbons. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-uint8array.fromhex +description: Conversion of hex strings to Uint8Arrays +includes: [compareArray.js] +features: [uint8array-base64] +---*/ + +var cases = [ + ["", []], + ["66", [102]], + ["666f", [102, 111]], + ["666F", [102, 111]], + ["666f6f", [102, 111, 111]], + ["666F6f", [102, 111, 111]], + ["666f6f62", [102, 111, 111, 98]], + ["666f6f6261", [102, 111, 111, 98, 97]], + ["666f6f626172", [102, 111, 111, 98, 97, 114]], +]; + +cases.forEach(function (pair) { + var arr = Uint8Array.fromHex(pair[0]); + assert.sameValue(Object.getPrototypeOf(arr), Uint8Array.prototype, "decoding " + pair[0]); + assert.compareArray(arr, pair[1], "decoding " + pair[0]); +}); diff --git a/test/built-ins/Uint8Array/fromHex/string-coercion.js b/test/built-ins/Uint8Array/fromHex/string-coercion.js new file mode 100644 index 00000000000..2290f254993 --- /dev/null +++ b/test/built-ins/Uint8Array/fromHex/string-coercion.js @@ -0,0 +1,20 @@ +// Copyright (C) 2024 Kevin Gibbons. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-uint8array.fromhex +description: Uint8Array.fromHex throws if its argument is not a string +features: [uint8array-base64] +---*/ + +var toStringCalls = 0; +var throwyToString = { + toString: function() { + toStringCalls += 1; + throw new Test262Error("toString called"); + } +}; + +assert.throws(TypeError, function() { + Uint8Array.fromHex(throwyToString); +}); +assert.sameValue(toStringCalls, 0); diff --git a/test/built-ins/Uint8Array/fromHexInto/descriptor.js b/test/built-ins/Uint8Array/fromHexInto/descriptor.js new file mode 100644 index 00000000000..e26dea928b1 --- /dev/null +++ b/test/built-ins/Uint8Array/fromHexInto/descriptor.js @@ -0,0 +1,15 @@ +// Copyright (C) 2024 Kevin Gibbons. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-uint8array.fromhexinto +description: > + Uint8Array.fromHexInto has default data property attributes. +includes: [propertyHelper.js] +features: [uint8array-base64] +---*/ + +verifyProperty(Uint8Array, 'fromHexInto', { + enumerable: false, + writable: true, + configurable: true +}); diff --git a/test/built-ins/Uint8Array/fromHexInto/detached-buffer.js b/test/built-ins/Uint8Array/fromHexInto/detached-buffer.js new file mode 100644 index 00000000000..0da1767acd6 --- /dev/null +++ b/test/built-ins/Uint8Array/fromHexInto/detached-buffer.js @@ -0,0 +1,14 @@ +// Copyright (C) 2024 Kevin Gibbons. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-uint8array.fromhexinto +description: Uint8Array.fromHexInto does not write to or error on detatched buffers +includes: [detachArrayBuffer.js] +features: [uint8array-base64] +---*/ + +var target = new Uint8Array([255, 255, 255]); +$DETACHBUFFER(target.buffer); +var result = Uint8Array.fromHexInto('aa', target); +assert.sameValue(result.read, 0); +assert.sameValue(result.written, 0); diff --git a/test/built-ins/Uint8Array/fromHexInto/ignores-receiver.js b/test/built-ins/Uint8Array/fromHexInto/ignores-receiver.js new file mode 100644 index 00000000000..6c45490d198 --- /dev/null +++ b/test/built-ins/Uint8Array/fromHexInto/ignores-receiver.js @@ -0,0 +1,16 @@ +// Copyright (C) 2024 Kevin Gibbons. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-uint8array.fromhexinto +description: Uint8Array.fromHexInto ignores its receiver +includes: [compareArray.js] +features: [uint8array-base64] +---*/ + +var fromHexInto = Uint8Array.fromHexInto; +var target = new Uint8Array([255, 255, 255]); + +var result = fromHexInto("aa", target); +assert.sameValue(result.read, 2); +assert.sameValue(result.written, 1); +assert.compareArray(target, [170, 255, 255]); diff --git a/test/built-ins/Uint8Array/fromHexInto/illegal-characters.js b/test/built-ins/Uint8Array/fromHexInto/illegal-characters.js new file mode 100644 index 00000000000..3b623f2197e --- /dev/null +++ b/test/built-ins/Uint8Array/fromHexInto/illegal-characters.js @@ -0,0 +1,26 @@ +// Copyright (C) 2024 Kevin Gibbons. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-uint8array.fromhexinto +description: Uint8Array.fromHexInto throws a SyntaxError when input has non-hex characters +features: [uint8array-base64] +---*/ + +var illegal = [ + 'a.a', + 'aa^', + 'a a', + 'a\ta', + 'a\x0Aa', + 'a\x0Ca', + 'a\x0Da', + 'a\u00A0a', // nbsp + 'a\u2009a', // thin space + 'a\u2028a', // line separator +]; +illegal.forEach(function(value) { + assert.throws(SyntaxError, function() { + var target = new Uint8Array([255, 255, 255, 255, 255]); + Uint8Array.fromHexInto(value, target); + }); +}); diff --git a/test/built-ins/Uint8Array/fromHexInto/length.js b/test/built-ins/Uint8Array/fromHexInto/length.js new file mode 100644 index 00000000000..d41f5242865 --- /dev/null +++ b/test/built-ins/Uint8Array/fromHexInto/length.js @@ -0,0 +1,16 @@ +// Copyright (C) 2024 Kevin Gibbons. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-uint8array.fromhexinto +description: > + Uint8Array.fromHexInto.length is 2. +includes: [propertyHelper.js] +features: [uint8array-base64] +---*/ + +verifyProperty(Uint8Array.fromHexInto, 'length', { + value: 2, + enumerable: false, + writable: false, + configurable: true +}); diff --git a/test/built-ins/Uint8Array/fromHexInto/name.js b/test/built-ins/Uint8Array/fromHexInto/name.js new file mode 100644 index 00000000000..7bf3d9761f7 --- /dev/null +++ b/test/built-ins/Uint8Array/fromHexInto/name.js @@ -0,0 +1,16 @@ +// Copyright (C) 2024 Kevin Gibbons. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-uint8array.fromhexinto +description: > + Uint8Array.fromHexInto.name is "fromHexInto". +includes: [propertyHelper.js] +features: [uint8array-base64] +---*/ + +verifyProperty(Uint8Array.fromHexInto, 'name', { + value: 'fromHexInto', + enumerable: false, + writable: false, + configurable: true +}); diff --git a/test/built-ins/Uint8Array/fromHexInto/nonconstructor.js b/test/built-ins/Uint8Array/fromHexInto/nonconstructor.js new file mode 100644 index 00000000000..5b9ccf79665 --- /dev/null +++ b/test/built-ins/Uint8Array/fromHexInto/nonconstructor.js @@ -0,0 +1,16 @@ +// Copyright (C) 2024 Kevin Gibbons. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-uint8array.fromhexinto +description: > + Uint8Array.fromHexInto is not a constructor function. +includes: [isConstructor.js] +features: [uint8array-base64, Reflect.construct] +---*/ + +assert(!isConstructor(Uint8Array.fromHexInto), "Uint8Array.fromHexInto is not a constructor"); + +assert.throws(TypeError, function() { + var target = new Uint8Array(10); + new Uint8Array.fromHexInto('', target); +}); diff --git a/test/built-ins/Uint8Array/fromHexInto/results.js b/test/built-ins/Uint8Array/fromHexInto/results.js new file mode 100644 index 00000000000..41256e1baf2 --- /dev/null +++ b/test/built-ins/Uint8Array/fromHexInto/results.js @@ -0,0 +1,31 @@ +// Copyright (C) 2024 Kevin Gibbons. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-uint8array.fromhexinto +description: Conversion of hex strings to Uint8Arrays +includes: [compareArray.js] +features: [uint8array-base64] +---*/ + +var cases = [ + ["", []], + ["66", [102]], + ["666f", [102, 111]], + ["666F", [102, 111]], + ["666f6f", [102, 111, 111]], + ["666F6f", [102, 111, 111]], + ["666f6f62", [102, 111, 111, 98]], + ["666f6f6261", [102, 111, 111, 98, 97]], + ["666f6f626172", [102, 111, 111, 98, 97, 114]], +]; + +cases.forEach(function (pair) { + var allFF = [255, 255, 255, 255, 255, 255, 255, 255]; + var target = new Uint8Array(allFF); + var result = Uint8Array.fromHexInto(pair[0], target); + assert.sameValue(result.read, pair[0].length); + assert.sameValue(result.written, pair[1].length); + + var expected = pair[1].concat(allFF.slice(pair[1].length)) + assert.compareArray(target, expected, "decoding " + pair[0]); +}); diff --git a/test/built-ins/Uint8Array/fromHexInto/string-coercion.js b/test/built-ins/Uint8Array/fromHexInto/string-coercion.js new file mode 100644 index 00000000000..e7f08661caa --- /dev/null +++ b/test/built-ins/Uint8Array/fromHexInto/string-coercion.js @@ -0,0 +1,21 @@ +// Copyright (C) 2024 Kevin Gibbons. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-uint8array.fromhexinto +description: Uint8Array.fromHexInto throws if its first argument is not a string +features: [uint8array-base64] +---*/ + +var toStringCalls = 0; +var throwyToString = { + toString: function() { + toStringCalls += 1; + throw new Test262Error("toString called"); + } +}; + +assert.throws(TypeError, function() { + var target = new Uint8Array(10); + Uint8Array.fromHexInto(throwyToString, target); +}); +assert.sameValue(toStringCalls, 0); diff --git a/test/built-ins/Uint8Array/fromHexInto/subarray.js b/test/built-ins/Uint8Array/fromHexInto/subarray.js new file mode 100644 index 00000000000..92330afad2c --- /dev/null +++ b/test/built-ins/Uint8Array/fromHexInto/subarray.js @@ -0,0 +1,17 @@ +// Copyright (C) 2024 Kevin Gibbons. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-uint8array.fromhexinto +description: Uint8Array.fromHexInto takes into account the offset of the target Uint8Array +includes: [compareArray.js] +features: [uint8array-base64] +---*/ + +var base = new Uint8Array([255, 255, 255, 255, 255, 255, 255]); +var subarray = base.subarray(2, 5); + +var result = Uint8Array.fromHexInto('aabbcc', subarray); +assert.sameValue(result.read, 6); +assert.sameValue(result.written, 3); +assert.compareArray(subarray, [170, 187, 204]); +assert.compareArray(base, [255, 255, 170, 187, 204, 255, 255]); diff --git a/test/built-ins/Uint8Array/fromHexInto/target-size.js b/test/built-ins/Uint8Array/fromHexInto/target-size.js new file mode 100644 index 00000000000..b56a8a59059 --- /dev/null +++ b/test/built-ins/Uint8Array/fromHexInto/target-size.js @@ -0,0 +1,29 @@ +// Copyright (C) 2024 Kevin Gibbons. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-uint8array.fromhexinto +description: Uint8Array.fromHexInto behavior when target buffer is small +includes: [compareArray.js] +features: [uint8array-base64] +---*/ + +// buffer too small +var target = new Uint8Array([255, 255]); +var result = Uint8Array.fromHexInto('aabbcc', target); +assert.sameValue(result.read, 4); +assert.sameValue(result.written, 2); +assert.compareArray(target, [170, 187]); + +// buffer exact +var target = new Uint8Array([255, 255, 255]); +var result = Uint8Array.fromHexInto('aabbcc', target); +assert.sameValue(result.read, 6); +assert.sameValue(result.written, 3); +assert.compareArray(target, [170, 187, 204]); + +// buffer too large +var target = new Uint8Array([255, 255, 255, 255]); +var result = Uint8Array.fromHexInto('aabbcc', target); +assert.sameValue(result.read, 6); +assert.sameValue(result.written, 3); +assert.compareArray(target, [170, 187, 204, 255]); diff --git a/test/built-ins/Uint8Array/prototype/toBase64/alphabet.js b/test/built-ins/Uint8Array/prototype/toBase64/alphabet.js new file mode 100644 index 00000000000..64f4959a5e7 --- /dev/null +++ b/test/built-ins/Uint8Array/prototype/toBase64/alphabet.js @@ -0,0 +1,17 @@ +// Copyright (C) 2024 Kevin Gibbons. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-uint8array.prototype.tobase64 +description: Conversion of Uint8Arrays to base64 strings exercising the alphabet option +features: [uint8array-base64] +---*/ + +assert.sameValue((new Uint8Array([199, 239, 242])).toBase64(), "x+/y"); + +assert.sameValue((new Uint8Array([199, 239, 242])).toBase64({ alphabet: 'base64' }), "x+/y"); + +assert.sameValue((new Uint8Array([199, 239, 242])).toBase64({ alphabet: 'base64url' }), "x-_y"); + +assert.throws(TypeError, function() { + (new Uint8Array([199, 239, 242])).toBase64({ alphabet: 'other' }); +}); diff --git a/test/built-ins/Uint8Array/prototype/toBase64/descriptor.js b/test/built-ins/Uint8Array/prototype/toBase64/descriptor.js new file mode 100644 index 00000000000..6db2b911a73 --- /dev/null +++ b/test/built-ins/Uint8Array/prototype/toBase64/descriptor.js @@ -0,0 +1,15 @@ +// Copyright (C) 2024 Kevin Gibbons. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-uint8array.prototype.tobase64 +description: > + Uint8Array.prototype.toBase64 has default data property attributes. +includes: [propertyHelper.js] +features: [uint8array-base64] +---*/ + +verifyProperty(Uint8Array.prototype, 'toBase64', { + enumerable: false, + writable: true, + configurable: true +}); diff --git a/test/built-ins/Uint8Array/prototype/toBase64/detached-buffer.js b/test/built-ins/Uint8Array/prototype/toBase64/detached-buffer.js new file mode 100644 index 00000000000..efdf072eafe --- /dev/null +++ b/test/built-ins/Uint8Array/prototype/toBase64/detached-buffer.js @@ -0,0 +1,39 @@ +// Copyright (C) 2024 Kevin Gibbons. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-uint8array.prototype.tobase64 +description: Uint8Array.prototype.toBase64 checks for detachedness after side-effects are finished +includes: [detachArrayBuffer.js] +features: [uint8array-base64] +---*/ + +var array = new Uint8Array(2); +var getterCalls = 0; +var recevierDetachingOptions = {}; +Object.defineProperty(recevierDetachingOptions, "alphabet", { + get: function() { + getterCalls += 1; + $DETACHBUFFER(array.buffer); + return "base64"; + } +}); +assert.throws(TypeError, function() { + array.toBase64(recevierDetachingOptions); +}); +assert.sameValue(getterCalls, 1); + + +var detached = new Uint8Array(2); +$DETACHBUFFER(detached.buffer); +var getterCalls = 0; +var sideEffectingOptions = {}; +Object.defineProperty(sideEffectingOptions, "alphabet", { + get: function() { + getterCalls += 1; + return "base64"; + } +}); +assert.throws(TypeError, function() { + detached.toBase64(sideEffectingOptions); +}); +assert.sameValue(getterCalls, 1); diff --git a/test/built-ins/Uint8Array/prototype/toBase64/length.js b/test/built-ins/Uint8Array/prototype/toBase64/length.js new file mode 100644 index 00000000000..a31b79151bb --- /dev/null +++ b/test/built-ins/Uint8Array/prototype/toBase64/length.js @@ -0,0 +1,16 @@ +// Copyright (C) 2024 Kevin Gibbons. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-uint8array.prototype.tobase64 +description: > + Uint8Array.prototype.toBase64.length is 0. +includes: [propertyHelper.js] +features: [uint8array-base64] +---*/ + +verifyProperty(Uint8Array.prototype.toBase64, 'length', { + value: 0, + enumerable: false, + writable: false, + configurable: true +}); diff --git a/test/built-ins/Uint8Array/prototype/toBase64/name.js b/test/built-ins/Uint8Array/prototype/toBase64/name.js new file mode 100644 index 00000000000..f13cb969274 --- /dev/null +++ b/test/built-ins/Uint8Array/prototype/toBase64/name.js @@ -0,0 +1,16 @@ +// Copyright (C) 2024 Kevin Gibbons. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-uint8array.prototype.tobase64 +description: > + Uint8Array.prototype.toBase64.name is "toBase64". +includes: [propertyHelper.js] +features: [uint8array-base64] +---*/ + +verifyProperty(Uint8Array.prototype.toBase64, 'name', { + value: 'toBase64', + enumerable: false, + writable: false, + configurable: true +}); diff --git a/test/built-ins/Uint8Array/prototype/toBase64/nonconstructor.js b/test/built-ins/Uint8Array/prototype/toBase64/nonconstructor.js new file mode 100644 index 00000000000..6d36216a9ea --- /dev/null +++ b/test/built-ins/Uint8Array/prototype/toBase64/nonconstructor.js @@ -0,0 +1,16 @@ +// Copyright (C) 2024 Kevin Gibbons. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-uint8array.prototype.tobase64 +description: > + Uint8Array.prototype.toBase64 is not a constructor function. +includes: [isConstructor.js] +features: [uint8array-base64, Reflect.construct] +---*/ + +assert(!isConstructor(Uint8Array.prototype.toBase64), "Uint8Array.prototype.toBase64 is not a constructor"); + +var uint8Array = new Uint8Array(8); +assert.throws(TypeError, function() { + new uint8Array.toBase64(); +}); diff --git a/test/built-ins/Uint8Array/prototype/toBase64/option-coercion.js b/test/built-ins/Uint8Array/prototype/toBase64/option-coercion.js new file mode 100644 index 00000000000..c63deca5719 --- /dev/null +++ b/test/built-ins/Uint8Array/prototype/toBase64/option-coercion.js @@ -0,0 +1,43 @@ +// Copyright (C) 2024 Kevin Gibbons. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-uint8array.prototype.tobase64 +description: Uint8Array.prototype.toBase64 triggers effects of the "alphabet" getter, but does not perform toString on the result +features: [uint8array-base64] +---*/ + +var toStringCalls = 0; +var throwyToString = { + toString: function() { + toStringCalls += 1; + throw new Test262Error("toString called on alphabet value"); + } +}; +assert.throws(TypeError, function() { + (new Uint8Array(2)).toBase64({ alphabet: throwyToString }); +}); +assert.sameValue(toStringCalls, 0); + +var alphabetAccesses = 0; +var base64UrlOptions = {}; +Object.defineProperty(base64UrlOptions, "alphabet", { + get: function() { + alphabetAccesses += 1; + return "base64url"; + } +}); +assert.sameValue((new Uint8Array([199, 239, 242])).toBase64(base64UrlOptions), "x-_y"); +assert.sameValue(alphabetAccesses, 1); + +// side-effects from the getter on the receiver are reflected in the result +var array = new Uint8Array([0]); +var recevierMutatingOptions = {}; +Object.defineProperty(recevierMutatingOptions, "alphabet", { + get: function() { + array[0] = 255; + return "base64"; + } +}); +var result = array.toBase64(recevierMutatingOptions); +assert.sameValue(result, "/w=="); +assert.sameValue(array[0], 255); diff --git a/test/built-ins/Uint8Array/prototype/toBase64/receiver-not-uint8array.js b/test/built-ins/Uint8Array/prototype/toBase64/receiver-not-uint8array.js new file mode 100644 index 00000000000..e360b53da62 --- /dev/null +++ b/test/built-ins/Uint8Array/prototype/toBase64/receiver-not-uint8array.js @@ -0,0 +1,33 @@ +// Copyright (C) 2024 Kevin Gibbons. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-uint8array.prototype.tobase64 +description: Uint8Array.prototype.toBase64 throws if the receiver is not a Uint8Array +includes: [testTypedArray.js] +features: [uint8array-base64] +---*/ + +var toBase64 = Uint8Array.prototype.toBase64; + +var options = {}; +Object.defineProperty(options, "alphabet", { + get: function() { + throw new Test262Error("options.alphabet accessed despite incompatible receiver"); + } +}); + +testWithTypedArrayConstructors(function(TA) { + if (TA === Uint8Array) return; + var sample = new TA(2); + assert.throws(TypeError, function() { + Uint8Array.prototype.toBase64.call(sample, options); + }); +}); + +assert.throws(TypeError, function() { + Uint8Array.prototype.toBase64.call([], options); +}); + +assert.throws(TypeError, function() { + toBase64(options); +}); diff --git a/test/built-ins/Uint8Array/prototype/toBase64/results.js b/test/built-ins/Uint8Array/prototype/toBase64/results.js new file mode 100644 index 00000000000..d44e42d753e --- /dev/null +++ b/test/built-ins/Uint8Array/prototype/toBase64/results.js @@ -0,0 +1,16 @@ +// Copyright (C) 2024 Kevin Gibbons. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-uint8array.prototype.tobase64 +description: Conversion of Uint8Arrays to base64 strings +features: [uint8array-base64] +---*/ + +// standard test vectors from https://datatracker.ietf.org/doc/html/rfc4648#section-10 +assert.sameValue((new Uint8Array([])).toBase64(), ""); +assert.sameValue((new Uint8Array([102])).toBase64(), "Zg=="); +assert.sameValue((new Uint8Array([102, 111])).toBase64(), "Zm8="); +assert.sameValue((new Uint8Array([102, 111, 111])).toBase64(), "Zm9v"); +assert.sameValue((new Uint8Array([102, 111, 111, 98])).toBase64(), "Zm9vYg=="); +assert.sameValue((new Uint8Array([102, 111, 111, 98, 97])).toBase64(), "Zm9vYmE="); +assert.sameValue((new Uint8Array([102, 111, 111, 98, 97, 114])).toBase64(), "Zm9vYmFy"); diff --git a/test/built-ins/Uint8Array/prototype/toHex/descriptor.js b/test/built-ins/Uint8Array/prototype/toHex/descriptor.js new file mode 100644 index 00000000000..16762d452b5 --- /dev/null +++ b/test/built-ins/Uint8Array/prototype/toHex/descriptor.js @@ -0,0 +1,15 @@ +// Copyright (C) 2024 Kevin Gibbons. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-uint8array.prototype.tohex +description: > + Uint8Array.prototype.toHex has default data property attributes. +includes: [propertyHelper.js] +features: [uint8array-base64] +---*/ + +verifyProperty(Uint8Array.prototype, 'toHex', { + enumerable: false, + writable: true, + configurable: true +}); diff --git a/test/built-ins/Uint8Array/prototype/toHex/detached-buffer.js b/test/built-ins/Uint8Array/prototype/toHex/detached-buffer.js new file mode 100644 index 00000000000..d98d62aa2eb --- /dev/null +++ b/test/built-ins/Uint8Array/prototype/toHex/detached-buffer.js @@ -0,0 +1,15 @@ +// Copyright (C) 2024 Kevin Gibbons. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-uint8array.prototype.tohex +description: Uint8Array.prototype.toHex throws if called on a detached buffer +includes: [detachArrayBuffer.js] +features: [uint8array-base64] +---*/ + +var array = new Uint8Array(2); +$DETACHBUFFER(array.buffer); +assert.throws(TypeError, function() { + array.toHex(); +}); + diff --git a/test/built-ins/Uint8Array/prototype/toHex/length.js b/test/built-ins/Uint8Array/prototype/toHex/length.js new file mode 100644 index 00000000000..0cd4450c273 --- /dev/null +++ b/test/built-ins/Uint8Array/prototype/toHex/length.js @@ -0,0 +1,16 @@ +// Copyright (C) 2024 Kevin Gibbons. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-uint8array.prototype.tohex +description: > + Uint8Array.prototype.toHex.length is 0. +includes: [propertyHelper.js] +features: [uint8array-base64] +---*/ + +verifyProperty(Uint8Array.prototype.toHex, 'length', { + value: 0, + enumerable: false, + writable: false, + configurable: true +}); diff --git a/test/built-ins/Uint8Array/prototype/toHex/name.js b/test/built-ins/Uint8Array/prototype/toHex/name.js new file mode 100644 index 00000000000..beca824e229 --- /dev/null +++ b/test/built-ins/Uint8Array/prototype/toHex/name.js @@ -0,0 +1,16 @@ +// Copyright (C) 2024 Kevin Gibbons. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-uint8array.prototype.tohex +description: > + Uint8Array.prototype.toHex.name is "toHex". +includes: [propertyHelper.js] +features: [uint8array-base64] +---*/ + +verifyProperty(Uint8Array.prototype.toHex, 'name', { + value: 'toHex', + enumerable: false, + writable: false, + configurable: true +}); diff --git a/test/built-ins/Uint8Array/prototype/toHex/nonconstructor.js b/test/built-ins/Uint8Array/prototype/toHex/nonconstructor.js new file mode 100644 index 00000000000..7d4d9eac9b2 --- /dev/null +++ b/test/built-ins/Uint8Array/prototype/toHex/nonconstructor.js @@ -0,0 +1,16 @@ +// Copyright (C) 2024 Kevin Gibbons. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-uint8array.prototype.tohex +description: > + Uint8Array.prototype.toHex is not a constructor function. +includes: [isConstructor.js] +features: [uint8array-base64, Reflect.construct] +---*/ + +assert(!isConstructor(Uint8Array.prototype.toHex), "Uint8Array.prototype.toHex is not a constructor"); + +var uint8Array = new Uint8Array(8); +assert.throws(TypeError, function() { + new uint8Array.toHex(); +}); diff --git a/test/built-ins/Uint8Array/prototype/toHex/receiver-not-uint8array.js b/test/built-ins/Uint8Array/prototype/toHex/receiver-not-uint8array.js new file mode 100644 index 00000000000..c5d967a7218 --- /dev/null +++ b/test/built-ins/Uint8Array/prototype/toHex/receiver-not-uint8array.js @@ -0,0 +1,26 @@ +// Copyright (C) 2024 Kevin Gibbons. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-uint8array.prototype.tohex +description: Uint8Array.prototype.toHex throws if the receiver is not a Uint8Array +includes: [testTypedArray.js] +features: [uint8array-base64] +---*/ + +var toHex = Uint8Array.prototype.toHex; + +testWithTypedArrayConstructors(function(TA) { + if (TA === Uint8Array) return; + var sample = new TA(2); + assert.throws(TypeError, function() { + Uint8Array.prototype.toHex.call(sample); + }); +}); + +assert.throws(TypeError, function() { + Uint8Array.prototype.toHex.call([]); +}); + +assert.throws(TypeError, function() { + toHex(); +}); diff --git a/test/built-ins/Uint8Array/prototype/toHex/results.js b/test/built-ins/Uint8Array/prototype/toHex/results.js new file mode 100644 index 00000000000..108b9730458 --- /dev/null +++ b/test/built-ins/Uint8Array/prototype/toHex/results.js @@ -0,0 +1,15 @@ +// Copyright (C) 2024 Kevin Gibbons. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-uint8array.prototype.tohex +description: Conversion of Uint8Arrays to hex strings +features: [uint8array-base64] +---*/ + +assert.sameValue((new Uint8Array([])).toHex(), ""); +assert.sameValue((new Uint8Array([102])).toHex(), "66"); +assert.sameValue((new Uint8Array([102, 111])).toHex(), "666f"); +assert.sameValue((new Uint8Array([102, 111, 111])).toHex(), "666f6f"); +assert.sameValue((new Uint8Array([102, 111, 111, 98])).toHex(), "666f6f62"); +assert.sameValue((new Uint8Array([102, 111, 111, 98, 97])).toHex(), "666f6f6261"); +assert.sameValue((new Uint8Array([102, 111, 111, 98, 97, 114])).toHex(), "666f6f626172"); From 07807bd544366bf1b2dc1c0e57992b91ec708413 Mon Sep 17 00:00:00 2001 From: Kevin Gibbons Date: Wed, 7 Feb 2024 16:41:32 -0800 Subject: [PATCH 2/8] fromBase64Into -> setFromBase64 --- .../fromBase64Into/ignores-receiver.js | 16 ------- .../fromHexInto/ignores-receiver.js | 16 ------- .../setFromBase64}/alphabet.js | 14 +++--- .../setFromBase64}/descriptor.js | 6 +-- .../setFromBase64}/detached-buffer.js | 8 ++-- .../setFromBase64}/illegal-characters.js | 6 +-- .../setFromBase64}/last-chunk-handling.js | 44 +++++++++---------- .../setFromBase64}/length.js | 8 ++-- .../setFromBase64}/name.js | 8 ++-- .../setFromBase64}/nonconstructor.js | 8 ++-- .../setFromBase64}/option-coercion.js | 12 ++--- .../setFromBase64}/results.js | 4 +- .../setFromBase64}/string-coercion.js | 8 ++-- .../setFromBase64}/subarray.js | 6 +-- .../setFromBase64}/target-size.js | 20 ++++----- .../setFromBase64}/whitespace.js | 6 +-- .../setFromHex}/descriptor.js | 6 +-- .../setFromHex}/detached-buffer.js | 6 +-- .../setFromHex}/illegal-characters.js | 6 +-- .../setFromHex}/length.js | 8 ++-- .../setFromHex}/name.js | 8 ++-- .../setFromHex}/nonconstructor.js | 8 ++-- .../setFromHex}/results.js | 4 +- .../setFromHex}/string-coercion.js | 6 +-- .../setFromHex}/subarray.js | 6 +-- .../setFromHex}/target-size.js | 10 ++--- 26 files changed, 113 insertions(+), 145 deletions(-) delete mode 100644 test/built-ins/Uint8Array/fromBase64Into/ignores-receiver.js delete mode 100644 test/built-ins/Uint8Array/fromHexInto/ignores-receiver.js rename test/built-ins/Uint8Array/{fromBase64Into => prototype/setFromBase64}/alphabet.js (73%) rename test/built-ins/Uint8Array/{fromHexInto => prototype/setFromBase64}/descriptor.js (61%) rename test/built-ins/Uint8Array/{fromBase64Into => prototype/setFromBase64}/detached-buffer.js (73%) rename test/built-ins/Uint8Array/{fromBase64Into => prototype/setFromBase64}/illegal-characters.js (72%) rename test/built-ins/Uint8Array/{fromBase64Into => prototype/setFromBase64}/last-chunk-handling.js (67%) rename test/built-ins/Uint8Array/{fromBase64Into => prototype/setFromBase64}/length.js (62%) rename test/built-ins/Uint8Array/{fromHexInto => prototype/setFromBase64}/name.js (59%) rename test/built-ins/Uint8Array/{fromBase64Into => prototype/setFromBase64}/nonconstructor.js (54%) rename test/built-ins/Uint8Array/{fromBase64Into => prototype/setFromBase64}/option-coercion.js (74%) rename test/built-ins/Uint8Array/{fromBase64Into => prototype/setFromBase64}/results.js (90%) rename test/built-ins/Uint8Array/{fromBase64Into => prototype/setFromBase64}/string-coercion.js (79%) rename test/built-ins/Uint8Array/{fromBase64Into => prototype/setFromBase64}/subarray.js (71%) rename test/built-ins/Uint8Array/{fromBase64Into => prototype/setFromBase64}/target-size.js (73%) rename test/built-ins/Uint8Array/{fromBase64Into => prototype/setFromBase64}/whitespace.js (76%) rename test/built-ins/Uint8Array/{fromBase64Into => prototype/setFromHex}/descriptor.js (62%) rename test/built-ins/Uint8Array/{fromHexInto => prototype/setFromHex}/detached-buffer.js (67%) rename test/built-ins/Uint8Array/{fromHexInto => prototype/setFromHex}/illegal-characters.js (74%) rename test/built-ins/Uint8Array/{fromHexInto => prototype/setFromHex}/length.js (63%) rename test/built-ins/Uint8Array/{fromBase64Into => prototype/setFromHex}/name.js (61%) rename test/built-ins/Uint8Array/{fromHexInto => prototype/setFromHex}/nonconstructor.js (57%) rename test/built-ins/Uint8Array/{fromHexInto => prototype/setFromHex}/results.js (90%) rename test/built-ins/Uint8Array/{fromHexInto => prototype/setFromHex}/string-coercion.js (72%) rename test/built-ins/Uint8Array/{fromHexInto => prototype/setFromHex}/subarray.js (72%) rename test/built-ins/Uint8Array/{fromHexInto => prototype/setFromHex}/target-size.js (73%) diff --git a/test/built-ins/Uint8Array/fromBase64Into/ignores-receiver.js b/test/built-ins/Uint8Array/fromBase64Into/ignores-receiver.js deleted file mode 100644 index 55d3bb96cbb..00000000000 --- a/test/built-ins/Uint8Array/fromBase64Into/ignores-receiver.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2024 Kevin Gibbons. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-uint8array.frombase64into -description: Uint8Array.fromBase64Into ignores its receiver -includes: [compareArray.js] -features: [uint8array-base64] ----*/ - -var fromBase64Into = Uint8Array.fromBase64Into; -var target = new Uint8Array([255, 255, 255]); - -var result = fromBase64Into("Zg==", target); -assert.sameValue(result.read, 4); -assert.sameValue(result.written, 1); -assert.compareArray(target, [102, 255, 255]); diff --git a/test/built-ins/Uint8Array/fromHexInto/ignores-receiver.js b/test/built-ins/Uint8Array/fromHexInto/ignores-receiver.js deleted file mode 100644 index 6c45490d198..00000000000 --- a/test/built-ins/Uint8Array/fromHexInto/ignores-receiver.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2024 Kevin Gibbons. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-uint8array.fromhexinto -description: Uint8Array.fromHexInto ignores its receiver -includes: [compareArray.js] -features: [uint8array-base64] ----*/ - -var fromHexInto = Uint8Array.fromHexInto; -var target = new Uint8Array([255, 255, 255]); - -var result = fromHexInto("aa", target); -assert.sameValue(result.read, 2); -assert.sameValue(result.written, 1); -assert.compareArray(target, [170, 255, 255]); diff --git a/test/built-ins/Uint8Array/fromBase64Into/alphabet.js b/test/built-ins/Uint8Array/prototype/setFromBase64/alphabet.js similarity index 73% rename from test/built-ins/Uint8Array/fromBase64Into/alphabet.js rename to test/built-ins/Uint8Array/prototype/setFromBase64/alphabet.js index 270396581c9..d931f7ca05e 100644 --- a/test/built-ins/Uint8Array/fromBase64Into/alphabet.js +++ b/test/built-ins/Uint8Array/prototype/setFromBase64/alphabet.js @@ -1,41 +1,41 @@ // Copyright (C) 2024 Kevin Gibbons. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- -esid: sec-uint8array.frombase64into +esid: sec-uint8array.prototype.setfrombase64 description: Conversion of base64 strings to Uint8Arrays exercising the alphabet option includes: [compareArray.js] features: [uint8array-base64] ---*/ var target = new Uint8Array([255, 255, 255, 255]); -var result = Uint8Array.fromBase64Into('x+/y', target); +var result = target.setFromBase64('x+/y'); assert.sameValue(result.read, 4); assert.sameValue(result.written, 3); assert.compareArray(target, [199, 239, 242, 255]); var target = new Uint8Array([255, 255, 255, 255]); -var result = Uint8Array.fromBase64Into('x+/y', target, { alphabet: 'base64' }); +var result = target.setFromBase64('x+/y', { alphabet: 'base64' }); assert.sameValue(result.read, 4); assert.sameValue(result.written, 3); assert.compareArray(target, [199, 239, 242, 255]); assert.throws(SyntaxError, function() { var target = new Uint8Array([255, 255, 255, 255]); - Uint8Array.fromBase64('x+/y', { alphabet: 'base64url' }); + target.setFromBase64('x+/y', { alphabet: 'base64url' }); }); var target = new Uint8Array([255, 255, 255, 255]); -var result = Uint8Array.fromBase64Into('x-_y', target, { alphabet: 'base64url' }); +var result = target.setFromBase64('x-_y', { alphabet: 'base64url' }); assert.sameValue(result.read, 4); assert.sameValue(result.written, 3); assert.compareArray(target, [199, 239, 242, 255]); assert.throws(SyntaxError, function() { var target = new Uint8Array([255, 255, 255, 255]); - Uint8Array.fromBase64('x-_y'); + target.setFromBase64('x-_y'); }); assert.throws(SyntaxError, function() { var target = new Uint8Array([255, 255, 255, 255]); - Uint8Array.fromBase64('x-_y', { alphabet: 'base64' }); + target.setFromBase64('x-_y', { alphabet: 'base64' }); }); diff --git a/test/built-ins/Uint8Array/fromHexInto/descriptor.js b/test/built-ins/Uint8Array/prototype/setFromBase64/descriptor.js similarity index 61% rename from test/built-ins/Uint8Array/fromHexInto/descriptor.js rename to test/built-ins/Uint8Array/prototype/setFromBase64/descriptor.js index e26dea928b1..f6765bb60c9 100644 --- a/test/built-ins/Uint8Array/fromHexInto/descriptor.js +++ b/test/built-ins/Uint8Array/prototype/setFromBase64/descriptor.js @@ -1,14 +1,14 @@ // Copyright (C) 2024 Kevin Gibbons. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- -esid: sec-uint8array.fromhexinto +esid: sec-uint8array.prototype.setfrombase64 description: > - Uint8Array.fromHexInto has default data property attributes. + Uint8Array.prototype.setFromBase64 has default data property attributes. includes: [propertyHelper.js] features: [uint8array-base64] ---*/ -verifyProperty(Uint8Array, 'fromHexInto', { +verifyProperty(Uint8Array.prototype, 'setFromBase64', { enumerable: false, writable: true, configurable: true diff --git a/test/built-ins/Uint8Array/fromBase64Into/detached-buffer.js b/test/built-ins/Uint8Array/prototype/setFromBase64/detached-buffer.js similarity index 73% rename from test/built-ins/Uint8Array/fromBase64Into/detached-buffer.js rename to test/built-ins/Uint8Array/prototype/setFromBase64/detached-buffer.js index 80ebbcf4f41..11597b55a61 100644 --- a/test/built-ins/Uint8Array/fromBase64Into/detached-buffer.js +++ b/test/built-ins/Uint8Array/prototype/setFromBase64/detached-buffer.js @@ -1,15 +1,15 @@ // Copyright (C) 2024 Kevin Gibbons. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- -esid: sec-uint8array.frombase64into -description: Uint8Array.fromBase64Into does not write to or error on detatched buffers +esid: sec-uint8array.prototype.setfrombase64 +description: Uint8Array.prototype.setFromBase64 does not write to or error on detatched buffers includes: [detachArrayBuffer.js] features: [uint8array-base64] ---*/ var target = new Uint8Array([255, 255, 255]); $DETACHBUFFER(target.buffer); -var result = Uint8Array.fromBase64Into('Zg==', target); +var result = target.setFromBase64('Zg=='); assert.sameValue(result.read, 0); assert.sameValue(result.written, 0); @@ -23,7 +23,7 @@ Object.defineProperty(targetDetachingOptions, 'alphabet', { } }); var target = new Uint8Array([255, 255, 255]); -var result = Uint8Array.fromBase64Into('Zg==', target, targetDetachingOptions); +var result = target.setFromBase64('Zg==', targetDetachingOptions); assert.sameValue(getterCalls, 1); assert.sameValue(result.read, 0); assert.sameValue(result.written, 0); diff --git a/test/built-ins/Uint8Array/fromBase64Into/illegal-characters.js b/test/built-ins/Uint8Array/prototype/setFromBase64/illegal-characters.js similarity index 72% rename from test/built-ins/Uint8Array/fromBase64Into/illegal-characters.js rename to test/built-ins/Uint8Array/prototype/setFromBase64/illegal-characters.js index 899d934c91f..c3978f89ca9 100644 --- a/test/built-ins/Uint8Array/fromBase64Into/illegal-characters.js +++ b/test/built-ins/Uint8Array/prototype/setFromBase64/illegal-characters.js @@ -1,8 +1,8 @@ // Copyright (C) 2024 Kevin Gibbons. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- -esid: sec-uint8array.frombase64into -description: Uint8Array.fromBase64 throws a SyntaxError when input has non-base64, non-ascii-whitespace characters +esid: sec-uint8array.prototype.setfrombase64 +description: Uint8Array.prototype.setFromBase64 throws a SyntaxError when input has non-base64, non-ascii-whitespace characters features: [uint8array-base64] ---*/ @@ -19,6 +19,6 @@ var illegal = [ illegal.forEach(function(value) { assert.throws(SyntaxError, function() { var target = new Uint8Array([255, 255, 255, 255, 255]); - Uint8Array.fromBase64Into(value, target); + target.setFromBase64(value); }); }); diff --git a/test/built-ins/Uint8Array/fromBase64Into/last-chunk-handling.js b/test/built-ins/Uint8Array/prototype/setFromBase64/last-chunk-handling.js similarity index 67% rename from test/built-ins/Uint8Array/fromBase64Into/last-chunk-handling.js rename to test/built-ins/Uint8Array/prototype/setFromBase64/last-chunk-handling.js index 1c0ab248d62..3f0656af564 100644 --- a/test/built-ins/Uint8Array/fromBase64Into/last-chunk-handling.js +++ b/test/built-ins/Uint8Array/prototype/setFromBase64/last-chunk-handling.js @@ -1,33 +1,33 @@ // Copyright (C) 2024 Kevin Gibbons. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- -esid: sec-uint8array.frombase64into -description: Handling of final chunks in Uint8Array.fromBase64Into +esid: sec-uint8array.prototype.setfrombase64 +description: Handling of final chunks in target.setFromBase64 includes: [compareArray.js] features: [uint8array-base64] ---*/ // padding var target = new Uint8Array([255, 255, 255, 255, 255, 255]); -var result = Uint8Array.fromBase64Into('ZXhhZg==', target); +var result = target.setFromBase64('ZXhhZg=='); assert.sameValue(result.read, 8); assert.sameValue(result.written, 4); assert.compareArray(target, [101, 120, 97, 102, 255, 255]); var target = new Uint8Array([255, 255, 255, 255, 255, 255]); -var result = Uint8Array.fromBase64Into('ZXhhZg==', target, { lastChunkHandling: 'loose' }); +var result = target.setFromBase64('ZXhhZg==', { lastChunkHandling: 'loose' }); assert.sameValue(result.read, 8); assert.sameValue(result.written, 4); assert.compareArray(target, [101, 120, 97, 102, 255, 255]); var target = new Uint8Array([255, 255, 255, 255, 255, 255]); -var result = Uint8Array.fromBase64Into('ZXhhZg==', target, { lastChunkHandling: 'stop-before-partial' }); +var result = target.setFromBase64('ZXhhZg==', { lastChunkHandling: 'stop-before-partial' }); assert.sameValue(result.read, 8); assert.sameValue(result.written, 4); assert.compareArray(target, [101, 120, 97, 102, 255, 255]); var target = new Uint8Array([255, 255, 255, 255, 255, 255]); -var result = Uint8Array.fromBase64Into('ZXhhZg==', target, { lastChunkHandling: 'strict' }); +var result = target.setFromBase64('ZXhhZg==', { lastChunkHandling: 'strict' }); assert.sameValue(result.read, 8); assert.sameValue(result.written, 4); assert.compareArray(target, [101, 120, 97, 102, 255, 255]); @@ -35,97 +35,97 @@ assert.compareArray(target, [101, 120, 97, 102, 255, 255]); // no padding var target = new Uint8Array([255, 255, 255, 255, 255, 255]); -var result = Uint8Array.fromBase64Into('ZXhhZg', target); +var result = target.setFromBase64('ZXhhZg'); assert.sameValue(result.read, 6); assert.sameValue(result.written, 4); assert.compareArray(target, [101, 120, 97, 102, 255, 255]); var target = new Uint8Array([255, 255, 255, 255, 255, 255]); -var result = Uint8Array.fromBase64Into('ZXhhZg', target, { lastChunkHandling: 'loose' }); +var result = target.setFromBase64('ZXhhZg', { lastChunkHandling: 'loose' }); assert.sameValue(result.read, 6); assert.sameValue(result.written, 4); assert.compareArray(target, [101, 120, 97, 102, 255, 255]); var target = new Uint8Array([255, 255, 255, 255, 255, 255]); -var result = Uint8Array.fromBase64Into('ZXhhZg', target, { lastChunkHandling: 'stop-before-partial' }); +var result = target.setFromBase64('ZXhhZg', { lastChunkHandling: 'stop-before-partial' }); assert.sameValue(result.read, 4); assert.sameValue(result.written, 3); assert.compareArray(target, [101, 120, 97, 255, 255, 255]); assert.throws(SyntaxError, function() { var target = new Uint8Array([255, 255, 255, 255, 255, 255]); - Uint8Array.fromBase64Into('ZXhhZg', target, { lastChunkHandling: 'strict' }); + target.setFromBase64('ZXhhZg', { lastChunkHandling: 'strict' }); }); // non-zero padding bits var target = new Uint8Array([255, 255, 255, 255, 255, 255]); -var result = Uint8Array.fromBase64Into('ZXhhZh==', target); +var result = target.setFromBase64('ZXhhZh=='); assert.sameValue(result.read, 8); assert.sameValue(result.written, 4); assert.compareArray(target, [101, 120, 97, 102, 255, 255]); var target = new Uint8Array([255, 255, 255, 255, 255, 255]); -var result = Uint8Array.fromBase64Into('ZXhhZh==', target, { lastChunkHandling: 'loose' }); +var result = target.setFromBase64('ZXhhZh==', { lastChunkHandling: 'loose' }); assert.sameValue(result.read, 8); assert.sameValue(result.written, 4); assert.compareArray(target, [101, 120, 97, 102, 255, 255]); var target = new Uint8Array([255, 255, 255, 255, 255, 255]); -var result = Uint8Array.fromBase64Into('ZXhhZh==', target, { lastChunkHandling: 'stop-before-partial' }); +var result = target.setFromBase64('ZXhhZh==', { lastChunkHandling: 'stop-before-partial' }); assert.sameValue(result.read, 8); assert.sameValue(result.written, 4); assert.compareArray(target, [101, 120, 97, 102, 255, 255]); assert.throws(SyntaxError, function() { var target = new Uint8Array([255, 255, 255, 255, 255, 255]); - Uint8Array.fromBase64Into('ZXhhZh==', target, { lastChunkHandling: 'strict' }); + target.setFromBase64('ZXhhZh==', { lastChunkHandling: 'strict' }); }); // non-zero padding bits, no padding var target = new Uint8Array([255, 255, 255, 255, 255, 255]); -var result = Uint8Array.fromBase64Into('ZXhhZh', target); +var result = target.setFromBase64('ZXhhZh'); assert.sameValue(result.read, 6); assert.sameValue(result.written, 4); assert.compareArray(target, [101, 120, 97, 102, 255, 255]); var target = new Uint8Array([255, 255, 255, 255, 255, 255]); -var result = Uint8Array.fromBase64Into('ZXhhZh', target, { lastChunkHandling: 'loose' }); +var result = target.setFromBase64('ZXhhZh', { lastChunkHandling: 'loose' }); assert.sameValue(result.read, 6); assert.sameValue(result.written, 4); assert.compareArray(target, [101, 120, 97, 102, 255, 255]); var target = new Uint8Array([255, 255, 255, 255, 255, 255]); -var result = Uint8Array.fromBase64Into('ZXhhZh', target, { lastChunkHandling: 'stop-before-partial' }); +var result = target.setFromBase64('ZXhhZh', { lastChunkHandling: 'stop-before-partial' }); assert.sameValue(result.read, 4); assert.sameValue(result.written, 3); assert.compareArray(target, [101, 120, 97, 255, 255, 255]); assert.throws(SyntaxError, function() { var target = new Uint8Array([255, 255, 255, 255, 255, 255]); - Uint8Array.fromBase64Into('ZXhhZh', target, { lastChunkHandling: 'strict' }); + target.setFromBase64('ZXhhZh', { lastChunkHandling: 'strict' }); }); // malformed padding assert.throws(SyntaxError, function() { var target = new Uint8Array([255, 255, 255, 255, 255, 255]); - Uint8Array.fromBase64Into('ZXhhZg=', target); + target.setFromBase64('ZXhhZg='); }); assert.throws(SyntaxError, function() { var target = new Uint8Array([255, 255, 255, 255, 255, 255]); - Uint8Array.fromBase64Into('ZXhhZg=', target, { lastChunkHandling: 'loose' }); + target.setFromBase64('ZXhhZg=', { lastChunkHandling: 'loose' }); }); var target = new Uint8Array([255, 255, 255, 255, 255, 255]); -var result = Uint8Array.fromBase64Into('ZXhhZg=', target, { lastChunkHandling: 'stop-before-partial' }); +var result = target.setFromBase64('ZXhhZg=', { lastChunkHandling: 'stop-before-partial' }); assert.sameValue(result.read, 4); assert.sameValue(result.written, 3); assert.compareArray(target, [101, 120, 97, 255, 255, 255]); assert.throws(SyntaxError, function() { var target = new Uint8Array([255, 255, 255, 255, 255, 255]); - Uint8Array.fromBase64Into('ZXhhZg=', target, { lastChunkHandling: 'strict' }); + target.setFromBase64('ZXhhZg=', { lastChunkHandling: 'strict' }); }); diff --git a/test/built-ins/Uint8Array/fromBase64Into/length.js b/test/built-ins/Uint8Array/prototype/setFromBase64/length.js similarity index 62% rename from test/built-ins/Uint8Array/fromBase64Into/length.js rename to test/built-ins/Uint8Array/prototype/setFromBase64/length.js index a97be01f695..bc7a976967a 100644 --- a/test/built-ins/Uint8Array/fromBase64Into/length.js +++ b/test/built-ins/Uint8Array/prototype/setFromBase64/length.js @@ -1,15 +1,15 @@ // Copyright (C) 2024 Kevin Gibbons. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- -esid: sec-uint8array.frombase64into +esid: sec-uint8array.prototype.setfrombase64 description: > - Uint8Array.fromBase64Into.length is 2. + Uint8Array.prototype.setFromBase64.length is 1. includes: [propertyHelper.js] features: [uint8array-base64] ---*/ -verifyProperty(Uint8Array.fromBase64Into, 'length', { - value: 2, +verifyProperty(Uint8Array.prototype.setFromBase64, 'length', { + value: 1, enumerable: false, writable: false, configurable: true diff --git a/test/built-ins/Uint8Array/fromHexInto/name.js b/test/built-ins/Uint8Array/prototype/setFromBase64/name.js similarity index 59% rename from test/built-ins/Uint8Array/fromHexInto/name.js rename to test/built-ins/Uint8Array/prototype/setFromBase64/name.js index 7bf3d9761f7..18f124fb6a6 100644 --- a/test/built-ins/Uint8Array/fromHexInto/name.js +++ b/test/built-ins/Uint8Array/prototype/setFromBase64/name.js @@ -1,15 +1,15 @@ // Copyright (C) 2024 Kevin Gibbons. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- -esid: sec-uint8array.fromhexinto +esid: sec-uint8array.prototype.setfrombase64 description: > - Uint8Array.fromHexInto.name is "fromHexInto". + Uint8Array.prototype.setFromBase64.name is "setFromBase64". includes: [propertyHelper.js] features: [uint8array-base64] ---*/ -verifyProperty(Uint8Array.fromHexInto, 'name', { - value: 'fromHexInto', +verifyProperty(Uint8Array.prototype.setFromBase64, 'name', { + value: 'setFromBase64', enumerable: false, writable: false, configurable: true diff --git a/test/built-ins/Uint8Array/fromBase64Into/nonconstructor.js b/test/built-ins/Uint8Array/prototype/setFromBase64/nonconstructor.js similarity index 54% rename from test/built-ins/Uint8Array/fromBase64Into/nonconstructor.js rename to test/built-ins/Uint8Array/prototype/setFromBase64/nonconstructor.js index a5e9f0ec7a2..14b429f4f04 100644 --- a/test/built-ins/Uint8Array/fromBase64Into/nonconstructor.js +++ b/test/built-ins/Uint8Array/prototype/setFromBase64/nonconstructor.js @@ -1,16 +1,16 @@ // Copyright (C) 2024 Kevin Gibbons. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- -esid: sec-uint8array.frombase64into +esid: sec-uint8array.prototype.setfrombase64 description: > - Uint8Array.fromBase64Into is not a constructor function. + Uint8Array.prototype.setFromBase64 is not a constructor function. includes: [isConstructor.js] features: [uint8array-base64, Reflect.construct] ---*/ -assert(!isConstructor(Uint8Array.fromBase64Into), "Uint8Array.fromBase64Into is not a constructor"); +assert(!isConstructor(Uint8Array.prototype.setFromBase64), "Uint8Array.prototype.setFromBase64 is not a constructor"); assert.throws(TypeError, function() { var target = new Uint8Array(10); - new Uint8Array.fromBase64Into('', target); + new target.setFromBase64(''); }); diff --git a/test/built-ins/Uint8Array/fromBase64Into/option-coercion.js b/test/built-ins/Uint8Array/prototype/setFromBase64/option-coercion.js similarity index 74% rename from test/built-ins/Uint8Array/fromBase64Into/option-coercion.js rename to test/built-ins/Uint8Array/prototype/setFromBase64/option-coercion.js index 174712f9325..fbe07427aec 100644 --- a/test/built-ins/Uint8Array/fromBase64Into/option-coercion.js +++ b/test/built-ins/Uint8Array/prototype/setFromBase64/option-coercion.js @@ -1,8 +1,8 @@ // Copyright (C) 2024 Kevin Gibbons. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- -esid: sec-uint8array.frombase64into -description: Uint8Array.fromBase64Into triggers effects of the "alphabet" and "lastChunkHandling" getters, but does not perform toString on the results +esid: sec-uint8array.prototype.setfrombase64 +description: Uint8Array.prototype.setFromBase64 triggers effects of the "alphabet" and "lastChunkHandling" getters, but does not perform toString on the results includes: [compareArray.js] features: [uint8array-base64] ---*/ @@ -16,13 +16,13 @@ var throwyToString = { }; assert.throws(TypeError, function() { var target = new Uint8Array([255, 255, 255]); - Uint8Array.fromBase64Into("Zg==", target, { alphabet: throwyToString }); + target.setFromBase64("Zg==", { alphabet: throwyToString }); }); assert.sameValue(toStringCalls, 0); assert.throws(TypeError, function() { var target = new Uint8Array([255, 255, 255]); - Uint8Array.fromBase64Into("Zg==", target, { lastChunkHandling: throwyToString }); + target.setFromBase64("Zg==", { lastChunkHandling: throwyToString }); }); assert.sameValue(toStringCalls, 0); @@ -36,7 +36,7 @@ Object.defineProperty(base64UrlOptions, "alphabet", { } }); var target = new Uint8Array([255, 255, 255, 255]); -var result = Uint8Array.fromBase64Into("x-_y", target, base64UrlOptions); +var result = target.setFromBase64("x-_y", base64UrlOptions); assert.sameValue(result.read, 4); assert.sameValue(result.written, 3); assert.compareArray(target, [199, 239, 242, 255]); @@ -51,7 +51,7 @@ Object.defineProperty(strictOptions, "lastChunkHandling", { } }); var target = new Uint8Array([255, 255, 255, 255]); -var result = Uint8Array.fromBase64Into("Zg==", target, strictOptions); +var result = target.setFromBase64("Zg==", strictOptions); assert.sameValue(result.read, 4); assert.sameValue(result.written, 1); assert.compareArray(target, [102, 255, 255, 255]); diff --git a/test/built-ins/Uint8Array/fromBase64Into/results.js b/test/built-ins/Uint8Array/prototype/setFromBase64/results.js similarity index 90% rename from test/built-ins/Uint8Array/fromBase64Into/results.js rename to test/built-ins/Uint8Array/prototype/setFromBase64/results.js index 35b02b40783..cfd87afc012 100644 --- a/test/built-ins/Uint8Array/fromBase64Into/results.js +++ b/test/built-ins/Uint8Array/prototype/setFromBase64/results.js @@ -1,7 +1,7 @@ // Copyright (C) 2024 Kevin Gibbons. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- -esid: sec-uint8array.frombase64into +esid: sec-uint8array.prototype.setfrombase64 description: Conversion of base64 strings to Uint8Arrays includes: [compareArray.js] features: [uint8array-base64] @@ -21,7 +21,7 @@ var standardBase64Vectors = [ standardBase64Vectors.forEach(function (pair) { var allFF = [255, 255, 255, 255, 255, 255, 255, 255]; var target = new Uint8Array(allFF); - var result = Uint8Array.fromBase64Into(pair[0], target); + var result = target.setFromBase64(pair[0]); assert.sameValue(result.read, pair[0].length); assert.sameValue(result.written, pair[1].length); diff --git a/test/built-ins/Uint8Array/fromBase64Into/string-coercion.js b/test/built-ins/Uint8Array/prototype/setFromBase64/string-coercion.js similarity index 79% rename from test/built-ins/Uint8Array/fromBase64Into/string-coercion.js rename to test/built-ins/Uint8Array/prototype/setFromBase64/string-coercion.js index 17ad8b48f67..22499d3493e 100644 --- a/test/built-ins/Uint8Array/fromBase64Into/string-coercion.js +++ b/test/built-ins/Uint8Array/prototype/setFromBase64/string-coercion.js @@ -1,8 +1,8 @@ // Copyright (C) 2024 Kevin Gibbons. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- -esid: sec-uint8array.frombase64into -description: Uint8Array.fromBase64Into throws if its first argument is not a string +esid: sec-uint8array.prototype.setfrombase64 +description: Uint8Array.prototype.setFromBase64 throws if its first argument is not a string features: [uint8array-base64] ---*/ @@ -16,7 +16,7 @@ var throwyToString = { assert.throws(TypeError, function() { var target = new Uint8Array(10); - Uint8Array.fromBase64Into(throwyToString, target); + target.setFromBase64(throwyToString); }); assert.sameValue(toStringCalls, 0); @@ -37,7 +37,7 @@ Object.defineProperty(touchyOptions, "lastChunkHandling", { }); assert.throws(TypeError, function() { var target = new Uint8Array(10); - Uint8Array.fromBase64Into(throwyToString, target, touchyOptions); + target.setFromBase64(throwyToString, touchyOptions); }); assert.sameValue(toStringCalls, 0); assert.sameValue(optionAccesses, 0); diff --git a/test/built-ins/Uint8Array/fromBase64Into/subarray.js b/test/built-ins/Uint8Array/prototype/setFromBase64/subarray.js similarity index 71% rename from test/built-ins/Uint8Array/fromBase64Into/subarray.js rename to test/built-ins/Uint8Array/prototype/setFromBase64/subarray.js index 6c5bb95e549..5c864aab21f 100644 --- a/test/built-ins/Uint8Array/fromBase64Into/subarray.js +++ b/test/built-ins/Uint8Array/prototype/setFromBase64/subarray.js @@ -1,8 +1,8 @@ // Copyright (C) 2024 Kevin Gibbons. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- -esid: sec-uint8array.frombase64into -description: Uint8Array.fromBase64Into takes into account the offset of the target Uint8Array +esid: sec-uint8array.prototype.setfrombase64 +description: Uint8Array.prototype.setFromBase64 takes into account the offset of the target Uint8Array includes: [compareArray.js] features: [uint8array-base64] ---*/ @@ -10,7 +10,7 @@ features: [uint8array-base64] var base = new Uint8Array([255, 255, 255, 255, 255, 255, 255]); var subarray = base.subarray(2, 5); -var result = Uint8Array.fromBase64Into('Zm9vYmFy', subarray); +var result = subarray.setFromBase64('Zm9vYmFy'); assert.sameValue(result.read, 4); assert.sameValue(result.written, 3); assert.compareArray(subarray, [102, 111, 111]); diff --git a/test/built-ins/Uint8Array/fromBase64Into/target-size.js b/test/built-ins/Uint8Array/prototype/setFromBase64/target-size.js similarity index 73% rename from test/built-ins/Uint8Array/fromBase64Into/target-size.js rename to test/built-ins/Uint8Array/prototype/setFromBase64/target-size.js index 4b44c9eaeff..5d03f060e8d 100644 --- a/test/built-ins/Uint8Array/fromBase64Into/target-size.js +++ b/test/built-ins/Uint8Array/prototype/setFromBase64/target-size.js @@ -1,64 +1,64 @@ // Copyright (C) 2024 Kevin Gibbons. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- -esid: sec-uint8array.frombase64 -description: Uint8Array.fromBase64Into behavior when target buffer is small +esid: sec-uint8array.prototype.setfrombase64 +description: Uint8Array.prototype.setFromBase64 behavior when target buffer is small includes: [compareArray.js] features: [uint8array-base64] ---*/ // buffer too small var target = new Uint8Array([255, 255, 255, 255, 255]); -var result = Uint8Array.fromBase64Into('Zm9vYmFy', target); +var result = target.setFromBase64('Zm9vYmFy'); assert.sameValue(result.read, 4); assert.sameValue(result.written, 3); assert.compareArray(target, [102, 111, 111, 255, 255]); // buffer too small, padded var target = new Uint8Array([255, 255, 255, 255]); -var result = Uint8Array.fromBase64Into('Zm9vYmE=', target); +var result = target.setFromBase64('Zm9vYmE='); assert.sameValue(result.read, 4); assert.sameValue(result.written, 3); assert.compareArray(target, [102, 111, 111, 255]); // buffer exact var target = new Uint8Array([255, 255, 255, 255, 255, 255]); -var result = Uint8Array.fromBase64Into('Zm9vYmFy', target); +var result = target.setFromBase64('Zm9vYmFy'); assert.sameValue(result.read, 8); assert.sameValue(result.written, 6); assert.compareArray(target, [102, 111, 111, 98, 97, 114]); // buffer exact, padded var target = new Uint8Array([255, 255, 255, 255, 255]); -var result = Uint8Array.fromBase64Into('Zm9vYmE=', target); +var result = target.setFromBase64('Zm9vYmE='); assert.sameValue(result.read, 8); assert.sameValue(result.written, 5); assert.compareArray(target, [102, 111, 111, 98, 97]); // buffer exact, not padded var target = new Uint8Array([255, 255, 255, 255, 255]); -var result = Uint8Array.fromBase64Into('Zm9vYmE', target); +var result = target.setFromBase64('Zm9vYmE'); assert.sameValue(result.read, 7); assert.sameValue(result.written, 5); assert.compareArray(target, [102, 111, 111, 98, 97]); // buffer exact, padded, stop-before-partial var target = new Uint8Array([255, 255, 255, 255, 255]); -var result = Uint8Array.fromBase64Into('Zm9vYmE=', target, { lastChunkHandling: 'stop-before-partial' }); +var result = target.setFromBase64('Zm9vYmE=', { lastChunkHandling: 'stop-before-partial' }); assert.sameValue(result.read, 8); assert.sameValue(result.written, 5); assert.compareArray(target, [102, 111, 111, 98, 97]); // buffer exact, not padded, stop-before-partial var target = new Uint8Array([255, 255, 255, 255, 255]); -var result = Uint8Array.fromBase64Into('Zm9vYmE', target, { lastChunkHandling: 'stop-before-partial' }); +var result = target.setFromBase64('Zm9vYmE', { lastChunkHandling: 'stop-before-partial' }); assert.sameValue(result.read, 4); assert.sameValue(result.written, 3); assert.compareArray(target, [102, 111, 111, 255, 255]); // buffer too large var target = new Uint8Array([255, 255, 255, 255, 255, 255, 255]); -var result = Uint8Array.fromBase64Into('Zm9vYmFy', target); +var result = target.setFromBase64('Zm9vYmFy'); assert.sameValue(result.read, 8); assert.sameValue(result.written, 6); assert.compareArray(target, [102, 111, 111, 98, 97, 114, 255]); diff --git a/test/built-ins/Uint8Array/fromBase64Into/whitespace.js b/test/built-ins/Uint8Array/prototype/setFromBase64/whitespace.js similarity index 76% rename from test/built-ins/Uint8Array/fromBase64Into/whitespace.js rename to test/built-ins/Uint8Array/prototype/setFromBase64/whitespace.js index 8ba0b01064d..38bcb3d3a05 100644 --- a/test/built-ins/Uint8Array/fromBase64Into/whitespace.js +++ b/test/built-ins/Uint8Array/prototype/setFromBase64/whitespace.js @@ -1,8 +1,8 @@ // Copyright (C) 2024 Kevin Gibbons. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- -esid: sec-uint8array.frombase64into -description: Uint8Array.fromBase64Into ignores ASCII whitespace in the input +esid: sec-uint8array.prototype.setfrombase64 +description: Uint8Array.prototype.setFromBase64 ignores ASCII whitespace in the input includes: [compareArray.js] features: [uint8array-base64] ---*/ @@ -16,7 +16,7 @@ var whitespaceKinds = [ ]; whitespaceKinds.forEach(function(pair) { var target = new Uint8Array([255, 255, 255]); - var result = Uint8Array.fromBase64Into(pair[0], target); + var result = target.setFromBase64(pair[0]); assert.sameValue(result.read, 5); assert.sameValue(result.written, 1); assert.compareArray(target, [102, 255, 255], "ascii whitespace: " + pair[1]); diff --git a/test/built-ins/Uint8Array/fromBase64Into/descriptor.js b/test/built-ins/Uint8Array/prototype/setFromHex/descriptor.js similarity index 62% rename from test/built-ins/Uint8Array/fromBase64Into/descriptor.js rename to test/built-ins/Uint8Array/prototype/setFromHex/descriptor.js index 672a29cb6ae..080cda9411e 100644 --- a/test/built-ins/Uint8Array/fromBase64Into/descriptor.js +++ b/test/built-ins/Uint8Array/prototype/setFromHex/descriptor.js @@ -1,14 +1,14 @@ // Copyright (C) 2024 Kevin Gibbons. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- -esid: sec-uint8array.frombase64into +esid: sec-uint8array.prototype.setfromhex description: > - Uint8Array.fromBase64Into has default data property attributes. + Uint8Array.prototype.setFromHex has default data property attributes. includes: [propertyHelper.js] features: [uint8array-base64] ---*/ -verifyProperty(Uint8Array, 'fromBase64Into', { +verifyProperty(Uint8Array.prototype, 'setFromHex', { enumerable: false, writable: true, configurable: true diff --git a/test/built-ins/Uint8Array/fromHexInto/detached-buffer.js b/test/built-ins/Uint8Array/prototype/setFromHex/detached-buffer.js similarity index 67% rename from test/built-ins/Uint8Array/fromHexInto/detached-buffer.js rename to test/built-ins/Uint8Array/prototype/setFromHex/detached-buffer.js index 0da1767acd6..6f77c4de474 100644 --- a/test/built-ins/Uint8Array/fromHexInto/detached-buffer.js +++ b/test/built-ins/Uint8Array/prototype/setFromHex/detached-buffer.js @@ -1,14 +1,14 @@ // Copyright (C) 2024 Kevin Gibbons. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- -esid: sec-uint8array.fromhexinto -description: Uint8Array.fromHexInto does not write to or error on detatched buffers +esid: sec-uint8array.prototype.setfromhex +description: Uint8Array.prototype.setFromHex does not write to or error on detatched buffers includes: [detachArrayBuffer.js] features: [uint8array-base64] ---*/ var target = new Uint8Array([255, 255, 255]); $DETACHBUFFER(target.buffer); -var result = Uint8Array.fromHexInto('aa', target); +var result = target.setFromHex('aa'); assert.sameValue(result.read, 0); assert.sameValue(result.written, 0); diff --git a/test/built-ins/Uint8Array/fromHexInto/illegal-characters.js b/test/built-ins/Uint8Array/prototype/setFromHex/illegal-characters.js similarity index 74% rename from test/built-ins/Uint8Array/fromHexInto/illegal-characters.js rename to test/built-ins/Uint8Array/prototype/setFromHex/illegal-characters.js index 3b623f2197e..970866078f3 100644 --- a/test/built-ins/Uint8Array/fromHexInto/illegal-characters.js +++ b/test/built-ins/Uint8Array/prototype/setFromHex/illegal-characters.js @@ -1,8 +1,8 @@ // Copyright (C) 2024 Kevin Gibbons. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- -esid: sec-uint8array.fromhexinto -description: Uint8Array.fromHexInto throws a SyntaxError when input has non-hex characters +esid: sec-uint8array.prototype.setfromhex +description: Uint8Array.prototype.setFromHex throws a SyntaxError when input has non-hex characters features: [uint8array-base64] ---*/ @@ -21,6 +21,6 @@ var illegal = [ illegal.forEach(function(value) { assert.throws(SyntaxError, function() { var target = new Uint8Array([255, 255, 255, 255, 255]); - Uint8Array.fromHexInto(value, target); + target.setFromHex(value); }); }); diff --git a/test/built-ins/Uint8Array/fromHexInto/length.js b/test/built-ins/Uint8Array/prototype/setFromHex/length.js similarity index 63% rename from test/built-ins/Uint8Array/fromHexInto/length.js rename to test/built-ins/Uint8Array/prototype/setFromHex/length.js index d41f5242865..3754878ffc0 100644 --- a/test/built-ins/Uint8Array/fromHexInto/length.js +++ b/test/built-ins/Uint8Array/prototype/setFromHex/length.js @@ -1,15 +1,15 @@ // Copyright (C) 2024 Kevin Gibbons. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- -esid: sec-uint8array.fromhexinto +esid: sec-uint8array.prototype.setfromhex description: > - Uint8Array.fromHexInto.length is 2. + Uint8Array.prototype.setFromHex.length is 1. includes: [propertyHelper.js] features: [uint8array-base64] ---*/ -verifyProperty(Uint8Array.fromHexInto, 'length', { - value: 2, +verifyProperty(Uint8Array.prototype.setFromHex, 'length', { + value: 1, enumerable: false, writable: false, configurable: true diff --git a/test/built-ins/Uint8Array/fromBase64Into/name.js b/test/built-ins/Uint8Array/prototype/setFromHex/name.js similarity index 61% rename from test/built-ins/Uint8Array/fromBase64Into/name.js rename to test/built-ins/Uint8Array/prototype/setFromHex/name.js index dcdc49c99b2..808ac1645eb 100644 --- a/test/built-ins/Uint8Array/fromBase64Into/name.js +++ b/test/built-ins/Uint8Array/prototype/setFromHex/name.js @@ -1,15 +1,15 @@ // Copyright (C) 2024 Kevin Gibbons. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- -esid: sec-uint8array.frombase64into +esid: sec-uint8array.prototype.setfromhex description: > - Uint8Array.fromBase64Into.name is "fromBase64Into". + Uint8Array.prototype.setFromHex.name is "setFromHex". includes: [propertyHelper.js] features: [uint8array-base64] ---*/ -verifyProperty(Uint8Array.fromBase64Into, 'name', { - value: 'fromBase64Into', +verifyProperty(Uint8Array.prototype.setFromHex, 'name', { + value: 'setFromHex', enumerable: false, writable: false, configurable: true diff --git a/test/built-ins/Uint8Array/fromHexInto/nonconstructor.js b/test/built-ins/Uint8Array/prototype/setFromHex/nonconstructor.js similarity index 57% rename from test/built-ins/Uint8Array/fromHexInto/nonconstructor.js rename to test/built-ins/Uint8Array/prototype/setFromHex/nonconstructor.js index 5b9ccf79665..435ce51f5a6 100644 --- a/test/built-ins/Uint8Array/fromHexInto/nonconstructor.js +++ b/test/built-ins/Uint8Array/prototype/setFromHex/nonconstructor.js @@ -1,16 +1,16 @@ // Copyright (C) 2024 Kevin Gibbons. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- -esid: sec-uint8array.fromhexinto +esid: sec-uint8array.prototype.setfromhex description: > - Uint8Array.fromHexInto is not a constructor function. + Uint8Array.prototype.setFromHex is not a constructor function. includes: [isConstructor.js] features: [uint8array-base64, Reflect.construct] ---*/ -assert(!isConstructor(Uint8Array.fromHexInto), "Uint8Array.fromHexInto is not a constructor"); +assert(!isConstructor(Uint8Array.prototype.setFromHex), "target.setFromHex is not a constructor"); assert.throws(TypeError, function() { var target = new Uint8Array(10); - new Uint8Array.fromHexInto('', target); + new target.setFromHex(''); }); diff --git a/test/built-ins/Uint8Array/fromHexInto/results.js b/test/built-ins/Uint8Array/prototype/setFromHex/results.js similarity index 90% rename from test/built-ins/Uint8Array/fromHexInto/results.js rename to test/built-ins/Uint8Array/prototype/setFromHex/results.js index 41256e1baf2..2359a9060d5 100644 --- a/test/built-ins/Uint8Array/fromHexInto/results.js +++ b/test/built-ins/Uint8Array/prototype/setFromHex/results.js @@ -1,7 +1,7 @@ // Copyright (C) 2024 Kevin Gibbons. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- -esid: sec-uint8array.fromhexinto +esid: sec-uint8array.prototype.setfromhex description: Conversion of hex strings to Uint8Arrays includes: [compareArray.js] features: [uint8array-base64] @@ -22,7 +22,7 @@ var cases = [ cases.forEach(function (pair) { var allFF = [255, 255, 255, 255, 255, 255, 255, 255]; var target = new Uint8Array(allFF); - var result = Uint8Array.fromHexInto(pair[0], target); + var result = target.setFromHex(pair[0]); assert.sameValue(result.read, pair[0].length); assert.sameValue(result.written, pair[1].length); diff --git a/test/built-ins/Uint8Array/fromHexInto/string-coercion.js b/test/built-ins/Uint8Array/prototype/setFromHex/string-coercion.js similarity index 72% rename from test/built-ins/Uint8Array/fromHexInto/string-coercion.js rename to test/built-ins/Uint8Array/prototype/setFromHex/string-coercion.js index e7f08661caa..822ee7a3493 100644 --- a/test/built-ins/Uint8Array/fromHexInto/string-coercion.js +++ b/test/built-ins/Uint8Array/prototype/setFromHex/string-coercion.js @@ -1,8 +1,8 @@ // Copyright (C) 2024 Kevin Gibbons. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- -esid: sec-uint8array.fromhexinto -description: Uint8Array.fromHexInto throws if its first argument is not a string +esid: sec-uint8array.prototype.setfromhex +description: Uint8Array.prototype.setFromHex throws if its first argument is not a string features: [uint8array-base64] ---*/ @@ -16,6 +16,6 @@ var throwyToString = { assert.throws(TypeError, function() { var target = new Uint8Array(10); - Uint8Array.fromHexInto(throwyToString, target); + target.setFromHex(throwyToString); }); assert.sameValue(toStringCalls, 0); diff --git a/test/built-ins/Uint8Array/fromHexInto/subarray.js b/test/built-ins/Uint8Array/prototype/setFromHex/subarray.js similarity index 72% rename from test/built-ins/Uint8Array/fromHexInto/subarray.js rename to test/built-ins/Uint8Array/prototype/setFromHex/subarray.js index 92330afad2c..3868ace0147 100644 --- a/test/built-ins/Uint8Array/fromHexInto/subarray.js +++ b/test/built-ins/Uint8Array/prototype/setFromHex/subarray.js @@ -1,8 +1,8 @@ // Copyright (C) 2024 Kevin Gibbons. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- -esid: sec-uint8array.fromhexinto -description: Uint8Array.fromHexInto takes into account the offset of the target Uint8Array +esid: sec-uint8array.prototype.setfromhex +description: Uint8Array.prototype.setFromHex takes into account the offset of the target Uint8Array includes: [compareArray.js] features: [uint8array-base64] ---*/ @@ -10,7 +10,7 @@ features: [uint8array-base64] var base = new Uint8Array([255, 255, 255, 255, 255, 255, 255]); var subarray = base.subarray(2, 5); -var result = Uint8Array.fromHexInto('aabbcc', subarray); +var result = subarray.setFromHex('aabbcc'); assert.sameValue(result.read, 6); assert.sameValue(result.written, 3); assert.compareArray(subarray, [170, 187, 204]); diff --git a/test/built-ins/Uint8Array/fromHexInto/target-size.js b/test/built-ins/Uint8Array/prototype/setFromHex/target-size.js similarity index 73% rename from test/built-ins/Uint8Array/fromHexInto/target-size.js rename to test/built-ins/Uint8Array/prototype/setFromHex/target-size.js index b56a8a59059..b794a44ee8b 100644 --- a/test/built-ins/Uint8Array/fromHexInto/target-size.js +++ b/test/built-ins/Uint8Array/prototype/setFromHex/target-size.js @@ -1,29 +1,29 @@ // Copyright (C) 2024 Kevin Gibbons. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- -esid: sec-uint8array.fromhexinto -description: Uint8Array.fromHexInto behavior when target buffer is small +esid: sec-uint8array.prototype.setfromhex +description: Uint8Array.prototype.setFromHex behavior when target buffer is small includes: [compareArray.js] features: [uint8array-base64] ---*/ // buffer too small var target = new Uint8Array([255, 255]); -var result = Uint8Array.fromHexInto('aabbcc', target); +var result = target.setFromHex('aabbcc'); assert.sameValue(result.read, 4); assert.sameValue(result.written, 2); assert.compareArray(target, [170, 187]); // buffer exact var target = new Uint8Array([255, 255, 255]); -var result = Uint8Array.fromHexInto('aabbcc', target); +var result = target.setFromHex('aabbcc'); assert.sameValue(result.read, 6); assert.sameValue(result.written, 3); assert.compareArray(target, [170, 187, 204]); // buffer too large var target = new Uint8Array([255, 255, 255, 255]); -var result = Uint8Array.fromHexInto('aabbcc', target); +var result = target.setFromHex('aabbcc'); assert.sameValue(result.read, 6); assert.sameValue(result.written, 3); assert.compareArray(target, [170, 187, 204, 255]); From 911aa6173dd43cbe01b63ef396d58bd16e7e306c Mon Sep 17 00:00:00 2001 From: Kevin Gibbons Date: Wed, 7 Feb 2024 16:43:17 -0800 Subject: [PATCH 3/8] update detached buffer tests --- .../prototype/setFromBase64/detached-buffer.js | 15 +++++++-------- .../prototype/setFromHex/detached-buffer.js | 8 ++++---- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/test/built-ins/Uint8Array/prototype/setFromBase64/detached-buffer.js b/test/built-ins/Uint8Array/prototype/setFromBase64/detached-buffer.js index 11597b55a61..5c01a7f43b8 100644 --- a/test/built-ins/Uint8Array/prototype/setFromBase64/detached-buffer.js +++ b/test/built-ins/Uint8Array/prototype/setFromBase64/detached-buffer.js @@ -2,16 +2,16 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- esid: sec-uint8array.prototype.setfrombase64 -description: Uint8Array.prototype.setFromBase64 does not write to or error on detatched buffers +description: Uint8Array.prototype.setFromBase64 throws on detatched buffers includes: [detachArrayBuffer.js] features: [uint8array-base64] ---*/ var target = new Uint8Array([255, 255, 255]); $DETACHBUFFER(target.buffer); -var result = target.setFromBase64('Zg=='); -assert.sameValue(result.read, 0); -assert.sameValue(result.written, 0); +assert.throws(TypeError, function() { + target.setFromBase64('Zg=='); +}); var getterCalls = 0; var targetDetachingOptions = {}; @@ -23,7 +23,6 @@ Object.defineProperty(targetDetachingOptions, 'alphabet', { } }); var target = new Uint8Array([255, 255, 255]); -var result = target.setFromBase64('Zg==', targetDetachingOptions); -assert.sameValue(getterCalls, 1); -assert.sameValue(result.read, 0); -assert.sameValue(result.written, 0); +assert.throws(TypeError, function() { + target.setFromBase64('Zg==', targetDetachingOptions); +}); diff --git a/test/built-ins/Uint8Array/prototype/setFromHex/detached-buffer.js b/test/built-ins/Uint8Array/prototype/setFromHex/detached-buffer.js index 6f77c4de474..881ca258ed8 100644 --- a/test/built-ins/Uint8Array/prototype/setFromHex/detached-buffer.js +++ b/test/built-ins/Uint8Array/prototype/setFromHex/detached-buffer.js @@ -2,13 +2,13 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- esid: sec-uint8array.prototype.setfromhex -description: Uint8Array.prototype.setFromHex does not write to or error on detatched buffers +description: Uint8Array.prototype.setFromHex throws on detatched buffers includes: [detachArrayBuffer.js] features: [uint8array-base64] ---*/ var target = new Uint8Array([255, 255, 255]); $DETACHBUFFER(target.buffer); -var result = target.setFromHex('aa'); -assert.sameValue(result.read, 0); -assert.sameValue(result.written, 0); +assert.throws(TypeError, function() { + target.setFromHex('aa'); +}); From 6d7bd551751e890305a7bc00b8600048fa5d2ab4 Mon Sep 17 00:00:00 2001 From: Kevin Gibbons Date: Mon, 11 Mar 2024 22:43:06 -0700 Subject: [PATCH 4/8] address ljharb comments --- .../Uint8Array/prototype/setFromBase64/detached-buffer.js | 1 + .../Uint8Array/prototype/toBase64/detached-buffer.js | 6 +++--- .../Uint8Array/prototype/toBase64/option-coercion.js | 6 +++--- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/test/built-ins/Uint8Array/prototype/setFromBase64/detached-buffer.js b/test/built-ins/Uint8Array/prototype/setFromBase64/detached-buffer.js index 5c01a7f43b8..50550827118 100644 --- a/test/built-ins/Uint8Array/prototype/setFromBase64/detached-buffer.js +++ b/test/built-ins/Uint8Array/prototype/setFromBase64/detached-buffer.js @@ -26,3 +26,4 @@ var target = new Uint8Array([255, 255, 255]); assert.throws(TypeError, function() { target.setFromBase64('Zg==', targetDetachingOptions); }); +assert.sameValue(getterCalls, 1); diff --git a/test/built-ins/Uint8Array/prototype/toBase64/detached-buffer.js b/test/built-ins/Uint8Array/prototype/toBase64/detached-buffer.js index efdf072eafe..2b72f1fdf77 100644 --- a/test/built-ins/Uint8Array/prototype/toBase64/detached-buffer.js +++ b/test/built-ins/Uint8Array/prototype/toBase64/detached-buffer.js @@ -9,8 +9,8 @@ features: [uint8array-base64] var array = new Uint8Array(2); var getterCalls = 0; -var recevierDetachingOptions = {}; -Object.defineProperty(recevierDetachingOptions, "alphabet", { +var receiverDetachingOptions = {}; +Object.defineProperty(receiverDetachingOptions, "alphabet", { get: function() { getterCalls += 1; $DETACHBUFFER(array.buffer); @@ -18,7 +18,7 @@ Object.defineProperty(recevierDetachingOptions, "alphabet", { } }); assert.throws(TypeError, function() { - array.toBase64(recevierDetachingOptions); + array.toBase64(receiverDetachingOptions); }); assert.sameValue(getterCalls, 1); diff --git a/test/built-ins/Uint8Array/prototype/toBase64/option-coercion.js b/test/built-ins/Uint8Array/prototype/toBase64/option-coercion.js index c63deca5719..d3c61a8235b 100644 --- a/test/built-ins/Uint8Array/prototype/toBase64/option-coercion.js +++ b/test/built-ins/Uint8Array/prototype/toBase64/option-coercion.js @@ -31,13 +31,13 @@ assert.sameValue(alphabetAccesses, 1); // side-effects from the getter on the receiver are reflected in the result var array = new Uint8Array([0]); -var recevierMutatingOptions = {}; -Object.defineProperty(recevierMutatingOptions, "alphabet", { +var receiverMutatingOptions = {}; +Object.defineProperty(receiverMutatingOptions, "alphabet", { get: function() { array[0] = 255; return "base64"; } }); -var result = array.toBase64(recevierMutatingOptions); +var result = array.toBase64(receiverMutatingOptions); assert.sameValue(result, "/w=="); assert.sameValue(array[0], 255); From 070d7ee87ede5e617597853b5ec6503206ef4f7a Mon Sep 17 00:00:00 2001 From: Kevin Gibbons Date: Mon, 11 Mar 2024 22:47:43 -0700 Subject: [PATCH 5/8] add tests that boxed strings are not valid values for options --- .../Uint8Array/fromBase64/option-coercion.js | 9 +++++++++ .../prototype/setFromBase64/option-coercion.js | 11 +++++++++++ .../Uint8Array/prototype/toBase64/option-coercion.js | 5 +++++ 3 files changed, 25 insertions(+) diff --git a/test/built-ins/Uint8Array/fromBase64/option-coercion.js b/test/built-ins/Uint8Array/fromBase64/option-coercion.js index 917aa3d1b52..510e52692ce 100644 --- a/test/built-ins/Uint8Array/fromBase64/option-coercion.js +++ b/test/built-ins/Uint8Array/fromBase64/option-coercion.js @@ -7,6 +7,15 @@ includes: [compareArray.js] features: [uint8array-base64] ---*/ +assert.throws(TypeError, function() { + Uint8Array.fromBase64("Zg==", { alphabet: Object("base64") }); +}); + +assert.throws(TypeError, function() { + Uint8Array.fromBase64("Zg==", { lastChunkHandling: Object("loose") }); +}); + + var toStringCalls = 0; var throwyToString = { toString: function() { diff --git a/test/built-ins/Uint8Array/prototype/setFromBase64/option-coercion.js b/test/built-ins/Uint8Array/prototype/setFromBase64/option-coercion.js index fbe07427aec..b3022352d77 100644 --- a/test/built-ins/Uint8Array/prototype/setFromBase64/option-coercion.js +++ b/test/built-ins/Uint8Array/prototype/setFromBase64/option-coercion.js @@ -7,6 +7,17 @@ includes: [compareArray.js] features: [uint8array-base64] ---*/ +assert.throws(TypeError, function() { + var target = new Uint8Array([255, 255, 255]); + target.setFromBase64("Zg==", { alphabet: Object("base64") }); +}); + +assert.throws(TypeError, function() { + var target = new Uint8Array([255, 255, 255]); + target.setFromBase64("Zg==", { lastChunkHandling: Object("strict") }); +}); + + var toStringCalls = 0; var throwyToString = { toString: function() { diff --git a/test/built-ins/Uint8Array/prototype/toBase64/option-coercion.js b/test/built-ins/Uint8Array/prototype/toBase64/option-coercion.js index d3c61a8235b..94c0b3942e5 100644 --- a/test/built-ins/Uint8Array/prototype/toBase64/option-coercion.js +++ b/test/built-ins/Uint8Array/prototype/toBase64/option-coercion.js @@ -6,6 +6,11 @@ description: Uint8Array.prototype.toBase64 triggers effects of the "alphabet" ge features: [uint8array-base64] ---*/ +assert.throws(TypeError, function() { + (new Uint8Array(2)).toBase64({ alphabet: Object("base64") }); +}); + + var toStringCalls = 0; var throwyToString = { toString: function() { From 44803f799ca3518a46a9768ff530c1d19558d849 Mon Sep 17 00:00:00 2001 From: Kevin Gibbons Date: Mon, 11 Mar 2024 22:51:35 -0700 Subject: [PATCH 6/8] add test for excess padding --- .../fromBase64/last-chunk-handling.js | 16 ++++++++++++- .../setFromBase64/last-chunk-handling.js | 24 ++++++++++++++++++- 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/test/built-ins/Uint8Array/fromBase64/last-chunk-handling.js b/test/built-ins/Uint8Array/fromBase64/last-chunk-handling.js index edade6f2ab2..2cb96e0d018 100644 --- a/test/built-ins/Uint8Array/fromBase64/last-chunk-handling.js +++ b/test/built-ins/Uint8Array/fromBase64/last-chunk-handling.js @@ -37,7 +37,7 @@ assert.throws(SyntaxError, function() { Uint8Array.fromBase64('ZXhhZh', { lastChunkHandling: 'strict' }); }); -// malformed padding +// partial padding assert.throws(SyntaxError, function() { Uint8Array.fromBase64('ZXhhZg='); }); @@ -48,3 +48,17 @@ assert.compareArray(Uint8Array.fromBase64('ZXhhZg=', { lastChunkHandling: 'stop- assert.throws(SyntaxError, function() { Uint8Array.fromBase64('ZXhhZg=', { lastChunkHandling: 'strict' }); }); + +// excess padding +assert.throws(SyntaxError, function() { + Uint8Array.fromBase64('ZXhhZg==='); +}); +assert.throws(SyntaxError, function() { + Uint8Array.fromBase64('ZXhhZg===', { lastChunkHandling: 'loose' }); +}); +assert.throws(SyntaxError, function() { + Uint8Array.fromBase64('ZXhhZg===', { lastChunkHandling: 'stop-before-partial' }); +}); +assert.throws(SyntaxError, function() { + Uint8Array.fromBase64('ZXhhZg===', { lastChunkHandling: 'strict' }); +}); diff --git a/test/built-ins/Uint8Array/prototype/setFromBase64/last-chunk-handling.js b/test/built-ins/Uint8Array/prototype/setFromBase64/last-chunk-handling.js index 3f0656af564..fa402ba90aa 100644 --- a/test/built-ins/Uint8Array/prototype/setFromBase64/last-chunk-handling.js +++ b/test/built-ins/Uint8Array/prototype/setFromBase64/last-chunk-handling.js @@ -108,7 +108,7 @@ assert.throws(SyntaxError, function() { }); -// malformed padding +// partial padding assert.throws(SyntaxError, function() { var target = new Uint8Array([255, 255, 255, 255, 255, 255]); target.setFromBase64('ZXhhZg='); @@ -129,3 +129,25 @@ assert.throws(SyntaxError, function() { var target = new Uint8Array([255, 255, 255, 255, 255, 255]); target.setFromBase64('ZXhhZg=', { lastChunkHandling: 'strict' }); }); + + +// excess padding +assert.throws(SyntaxError, function() { + var target = new Uint8Array([255, 255, 255, 255, 255, 255]); + target.setFromBase64('ZXhhZg==='); +}); + +assert.throws(SyntaxError, function() { + var target = new Uint8Array([255, 255, 255, 255, 255, 255]); + target.setFromBase64('ZXhhZg===', { lastChunkHandling: 'loose' }); +}); + +assert.throws(SyntaxError, function() { + var target = new Uint8Array([255, 255, 255, 255, 255, 255]); + target.setFromBase64('ZXhhZg===', { lastChunkHandling: 'stop-before-partial' }); +}); + +assert.throws(SyntaxError, function() { + var target = new Uint8Array([255, 255, 255, 255, 255, 255]); + target.setFromBase64('ZXhhZg===', { lastChunkHandling: 'strict' }); +}); From 080c5490a2f14a7467204827d81f2d3ff63f3bba Mon Sep 17 00:00:00 2001 From: Kevin Gibbons Date: Mon, 11 Mar 2024 22:56:22 -0700 Subject: [PATCH 7/8] assert on the length of the backing buffer of the result --- test/built-ins/Uint8Array/fromBase64/results.js | 2 ++ test/built-ins/Uint8Array/fromBase64/whitespace.js | 2 ++ test/built-ins/Uint8Array/fromHex/results.js | 2 ++ 3 files changed, 6 insertions(+) diff --git a/test/built-ins/Uint8Array/fromBase64/results.js b/test/built-ins/Uint8Array/fromBase64/results.js index 48910c32cf5..31fc8a7c3f6 100644 --- a/test/built-ins/Uint8Array/fromBase64/results.js +++ b/test/built-ins/Uint8Array/fromBase64/results.js @@ -21,5 +21,7 @@ var standardBase64Vectors = [ standardBase64Vectors.forEach(function (pair) { var arr = Uint8Array.fromBase64(pair[0]); assert.sameValue(Object.getPrototypeOf(arr), Uint8Array.prototype, "decoding " + pair[0]); + assert.sameValue(arr.length, pair[1].length, "decoding " + pair[0]); + assert.sameValue(arr.buffer.byteLength, pair[1].length, "decoding " + pair[0]); assert.compareArray(arr, pair[1], "decoding " + pair[0]); }); diff --git a/test/built-ins/Uint8Array/fromBase64/whitespace.js b/test/built-ins/Uint8Array/fromBase64/whitespace.js index ce9f7f239c8..e052601c436 100644 --- a/test/built-ins/Uint8Array/fromBase64/whitespace.js +++ b/test/built-ins/Uint8Array/fromBase64/whitespace.js @@ -16,5 +16,7 @@ var whitespaceKinds = [ ]; whitespaceKinds.forEach(function(pair) { var arr = Uint8Array.fromBase64(pair[0]); + assert.sameValue(arr.length, 1); + assert.sameValue(arr.buffer.byteLength, 1); assert.compareArray(arr, [102], "ascii whitespace: " + pair[1]); }); diff --git a/test/built-ins/Uint8Array/fromHex/results.js b/test/built-ins/Uint8Array/fromHex/results.js index 58cd5648c5e..810e63b0953 100644 --- a/test/built-ins/Uint8Array/fromHex/results.js +++ b/test/built-ins/Uint8Array/fromHex/results.js @@ -22,5 +22,7 @@ var cases = [ cases.forEach(function (pair) { var arr = Uint8Array.fromHex(pair[0]); assert.sameValue(Object.getPrototypeOf(arr), Uint8Array.prototype, "decoding " + pair[0]); + assert.sameValue(arr.length, pair[1].length, "decoding " + pair[0]); + assert.sameValue(arr.buffer.byteLength, pair[1].length, "decoding " + pair[0]); assert.compareArray(arr, pair[1], "decoding " + pair[0]); }); From 5132804523bd0493cb51ef654fffd3193224fdac Mon Sep 17 00:00:00 2001 From: Kevin Gibbons Date: Mon, 11 Mar 2024 22:59:56 -0700 Subject: [PATCH 8/8] add TypedArray feature to all new tests --- test/built-ins/Uint8Array/fromBase64/alphabet.js | 2 +- test/built-ins/Uint8Array/fromBase64/descriptor.js | 2 +- test/built-ins/Uint8Array/fromBase64/ignores-receiver.js | 2 +- test/built-ins/Uint8Array/fromBase64/illegal-characters.js | 2 +- test/built-ins/Uint8Array/fromBase64/last-chunk-handling.js | 2 +- test/built-ins/Uint8Array/fromBase64/length.js | 2 +- test/built-ins/Uint8Array/fromBase64/name.js | 2 +- test/built-ins/Uint8Array/fromBase64/nonconstructor.js | 2 +- test/built-ins/Uint8Array/fromBase64/option-coercion.js | 2 +- test/built-ins/Uint8Array/fromBase64/results.js | 2 +- test/built-ins/Uint8Array/fromBase64/string-coercion.js | 2 +- test/built-ins/Uint8Array/fromBase64/whitespace.js | 2 +- test/built-ins/Uint8Array/fromHex/descriptor.js | 2 +- test/built-ins/Uint8Array/fromHex/ignores-receiver.js | 2 +- test/built-ins/Uint8Array/fromHex/illegal-characters.js | 2 +- test/built-ins/Uint8Array/fromHex/length.js | 2 +- test/built-ins/Uint8Array/fromHex/name.js | 2 +- test/built-ins/Uint8Array/fromHex/nonconstructor.js | 2 +- test/built-ins/Uint8Array/fromHex/odd-length-input.js | 2 +- test/built-ins/Uint8Array/fromHex/results.js | 2 +- test/built-ins/Uint8Array/fromHex/string-coercion.js | 2 +- test/built-ins/Uint8Array/prototype/setFromBase64/alphabet.js | 2 +- test/built-ins/Uint8Array/prototype/setFromBase64/descriptor.js | 2 +- .../Uint8Array/prototype/setFromBase64/detached-buffer.js | 2 +- .../Uint8Array/prototype/setFromBase64/illegal-characters.js | 2 +- .../Uint8Array/prototype/setFromBase64/last-chunk-handling.js | 2 +- test/built-ins/Uint8Array/prototype/setFromBase64/length.js | 2 +- test/built-ins/Uint8Array/prototype/setFromBase64/name.js | 2 +- .../Uint8Array/prototype/setFromBase64/nonconstructor.js | 2 +- .../Uint8Array/prototype/setFromBase64/option-coercion.js | 2 +- test/built-ins/Uint8Array/prototype/setFromBase64/results.js | 2 +- .../Uint8Array/prototype/setFromBase64/string-coercion.js | 2 +- test/built-ins/Uint8Array/prototype/setFromBase64/subarray.js | 2 +- .../built-ins/Uint8Array/prototype/setFromBase64/target-size.js | 2 +- test/built-ins/Uint8Array/prototype/setFromBase64/whitespace.js | 2 +- test/built-ins/Uint8Array/prototype/setFromHex/descriptor.js | 2 +- .../Uint8Array/prototype/setFromHex/detached-buffer.js | 2 +- .../Uint8Array/prototype/setFromHex/illegal-characters.js | 2 +- test/built-ins/Uint8Array/prototype/setFromHex/length.js | 2 +- test/built-ins/Uint8Array/prototype/setFromHex/name.js | 2 +- .../built-ins/Uint8Array/prototype/setFromHex/nonconstructor.js | 2 +- test/built-ins/Uint8Array/prototype/setFromHex/results.js | 2 +- .../Uint8Array/prototype/setFromHex/string-coercion.js | 2 +- test/built-ins/Uint8Array/prototype/setFromHex/subarray.js | 2 +- test/built-ins/Uint8Array/prototype/setFromHex/target-size.js | 2 +- test/built-ins/Uint8Array/prototype/toBase64/alphabet.js | 2 +- test/built-ins/Uint8Array/prototype/toBase64/descriptor.js | 2 +- test/built-ins/Uint8Array/prototype/toBase64/detached-buffer.js | 2 +- test/built-ins/Uint8Array/prototype/toBase64/length.js | 2 +- test/built-ins/Uint8Array/prototype/toBase64/name.js | 2 +- test/built-ins/Uint8Array/prototype/toBase64/nonconstructor.js | 2 +- test/built-ins/Uint8Array/prototype/toBase64/option-coercion.js | 2 +- .../Uint8Array/prototype/toBase64/receiver-not-uint8array.js | 2 +- test/built-ins/Uint8Array/prototype/toBase64/results.js | 2 +- test/built-ins/Uint8Array/prototype/toHex/descriptor.js | 2 +- test/built-ins/Uint8Array/prototype/toHex/detached-buffer.js | 2 +- test/built-ins/Uint8Array/prototype/toHex/length.js | 2 +- test/built-ins/Uint8Array/prototype/toHex/name.js | 2 +- test/built-ins/Uint8Array/prototype/toHex/nonconstructor.js | 2 +- .../Uint8Array/prototype/toHex/receiver-not-uint8array.js | 2 +- test/built-ins/Uint8Array/prototype/toHex/results.js | 2 +- 61 files changed, 61 insertions(+), 61 deletions(-) diff --git a/test/built-ins/Uint8Array/fromBase64/alphabet.js b/test/built-ins/Uint8Array/fromBase64/alphabet.js index a5d28b7a1a4..4abc429db5c 100644 --- a/test/built-ins/Uint8Array/fromBase64/alphabet.js +++ b/test/built-ins/Uint8Array/fromBase64/alphabet.js @@ -4,7 +4,7 @@ esid: sec-uint8array.frombase64 description: Conversion of base64 strings to Uint8Arrays exercising the alphabet option includes: [compareArray.js] -features: [uint8array-base64] +features: [uint8array-base64, TypedArray] ---*/ assert.compareArray(Uint8Array.fromBase64('x+/y'), [199, 239, 242]); diff --git a/test/built-ins/Uint8Array/fromBase64/descriptor.js b/test/built-ins/Uint8Array/fromBase64/descriptor.js index dfcc913a3ca..a39b51cd82e 100644 --- a/test/built-ins/Uint8Array/fromBase64/descriptor.js +++ b/test/built-ins/Uint8Array/fromBase64/descriptor.js @@ -5,7 +5,7 @@ esid: sec-uint8array.frombase64 description: > Uint8Array.fromBase64 has default data property attributes. includes: [propertyHelper.js] -features: [uint8array-base64] +features: [uint8array-base64, TypedArray] ---*/ verifyProperty(Uint8Array, 'fromBase64', { diff --git a/test/built-ins/Uint8Array/fromBase64/ignores-receiver.js b/test/built-ins/Uint8Array/fromBase64/ignores-receiver.js index 811ebc517a9..62aa60a3c38 100644 --- a/test/built-ins/Uint8Array/fromBase64/ignores-receiver.js +++ b/test/built-ins/Uint8Array/fromBase64/ignores-receiver.js @@ -3,7 +3,7 @@ /*--- esid: sec-uint8array.frombase64 description: Uint8Array.fromBase64 ignores its receiver -features: [uint8array-base64] +features: [uint8array-base64, TypedArray] ---*/ var fromBase64 = Uint8Array.fromBase64; diff --git a/test/built-ins/Uint8Array/fromBase64/illegal-characters.js b/test/built-ins/Uint8Array/fromBase64/illegal-characters.js index 5f2d7a8438a..be3b66b0206 100644 --- a/test/built-ins/Uint8Array/fromBase64/illegal-characters.js +++ b/test/built-ins/Uint8Array/fromBase64/illegal-characters.js @@ -3,7 +3,7 @@ /*--- esid: sec-uint8array.frombase64 description: Uint8Array.fromBase64 throws a SyntaxError when input has non-base64, non-ascii-whitespace characters -features: [uint8array-base64] +features: [uint8array-base64, TypedArray] ---*/ var illegal = [ diff --git a/test/built-ins/Uint8Array/fromBase64/last-chunk-handling.js b/test/built-ins/Uint8Array/fromBase64/last-chunk-handling.js index 2cb96e0d018..80d3f1654e2 100644 --- a/test/built-ins/Uint8Array/fromBase64/last-chunk-handling.js +++ b/test/built-ins/Uint8Array/fromBase64/last-chunk-handling.js @@ -4,7 +4,7 @@ esid: sec-uint8array.frombase64 description: Handling of final chunks in Uint8Array.fromBase64 includes: [compareArray.js] -features: [uint8array-base64] +features: [uint8array-base64, TypedArray] ---*/ // padding diff --git a/test/built-ins/Uint8Array/fromBase64/length.js b/test/built-ins/Uint8Array/fromBase64/length.js index 23b70729546..d251d7754f2 100644 --- a/test/built-ins/Uint8Array/fromBase64/length.js +++ b/test/built-ins/Uint8Array/fromBase64/length.js @@ -5,7 +5,7 @@ esid: sec-uint8array.frombase64 description: > Uint8Array.fromBase64.length is 1. includes: [propertyHelper.js] -features: [uint8array-base64] +features: [uint8array-base64, TypedArray] ---*/ verifyProperty(Uint8Array.fromBase64, 'length', { diff --git a/test/built-ins/Uint8Array/fromBase64/name.js b/test/built-ins/Uint8Array/fromBase64/name.js index 9e38d3158eb..71ed9a3b7d0 100644 --- a/test/built-ins/Uint8Array/fromBase64/name.js +++ b/test/built-ins/Uint8Array/fromBase64/name.js @@ -5,7 +5,7 @@ esid: sec-uint8array.frombase64 description: > Uint8Array.fromBase64.name is "fromBase64". includes: [propertyHelper.js] -features: [uint8array-base64] +features: [uint8array-base64, TypedArray] ---*/ verifyProperty(Uint8Array.fromBase64, 'name', { diff --git a/test/built-ins/Uint8Array/fromBase64/nonconstructor.js b/test/built-ins/Uint8Array/fromBase64/nonconstructor.js index 219e6399f2e..469e00400fa 100644 --- a/test/built-ins/Uint8Array/fromBase64/nonconstructor.js +++ b/test/built-ins/Uint8Array/fromBase64/nonconstructor.js @@ -5,7 +5,7 @@ esid: sec-uint8array.frombase64 description: > Uint8Array.fromBase64 is not a constructor function. includes: [isConstructor.js] -features: [uint8array-base64, Reflect.construct] +features: [uint8array-base64, TypedArray, Reflect.construct] ---*/ assert(!isConstructor(Uint8Array.fromBase64), "Uint8Array.fromBase64 is not a constructor"); diff --git a/test/built-ins/Uint8Array/fromBase64/option-coercion.js b/test/built-ins/Uint8Array/fromBase64/option-coercion.js index 510e52692ce..5a3a98a7140 100644 --- a/test/built-ins/Uint8Array/fromBase64/option-coercion.js +++ b/test/built-ins/Uint8Array/fromBase64/option-coercion.js @@ -4,7 +4,7 @@ esid: sec-uint8array.frombase64 description: Uint8Array.fromBase64 triggers effects of the "alphabet" and "lastChunkHandling" getters, but does not perform toString on the results includes: [compareArray.js] -features: [uint8array-base64] +features: [uint8array-base64, TypedArray] ---*/ assert.throws(TypeError, function() { diff --git a/test/built-ins/Uint8Array/fromBase64/results.js b/test/built-ins/Uint8Array/fromBase64/results.js index 31fc8a7c3f6..cf98d0808a0 100644 --- a/test/built-ins/Uint8Array/fromBase64/results.js +++ b/test/built-ins/Uint8Array/fromBase64/results.js @@ -4,7 +4,7 @@ esid: sec-uint8array.frombase64 description: Conversion of base64 strings to Uint8Arrays includes: [compareArray.js] -features: [uint8array-base64] +features: [uint8array-base64, TypedArray] ---*/ // standard test vectors from https://datatracker.ietf.org/doc/html/rfc4648#section-10 diff --git a/test/built-ins/Uint8Array/fromBase64/string-coercion.js b/test/built-ins/Uint8Array/fromBase64/string-coercion.js index 56f0648330d..da52fd5403b 100644 --- a/test/built-ins/Uint8Array/fromBase64/string-coercion.js +++ b/test/built-ins/Uint8Array/fromBase64/string-coercion.js @@ -3,7 +3,7 @@ /*--- esid: sec-uint8array.frombase64 description: Uint8Array.fromBase64 throws if its argument is not a string -features: [uint8array-base64] +features: [uint8array-base64, TypedArray] ---*/ var toStringCalls = 0; diff --git a/test/built-ins/Uint8Array/fromBase64/whitespace.js b/test/built-ins/Uint8Array/fromBase64/whitespace.js index e052601c436..bf7d104e3d3 100644 --- a/test/built-ins/Uint8Array/fromBase64/whitespace.js +++ b/test/built-ins/Uint8Array/fromBase64/whitespace.js @@ -4,7 +4,7 @@ esid: sec-uint8array.frombase64 description: Uint8Array.fromBase64 ignores ASCII whitespace in the input includes: [compareArray.js] -features: [uint8array-base64] +features: [uint8array-base64, TypedArray] ---*/ var whitespaceKinds = [ diff --git a/test/built-ins/Uint8Array/fromHex/descriptor.js b/test/built-ins/Uint8Array/fromHex/descriptor.js index 1ae033cb1ee..44fdd904e17 100644 --- a/test/built-ins/Uint8Array/fromHex/descriptor.js +++ b/test/built-ins/Uint8Array/fromHex/descriptor.js @@ -5,7 +5,7 @@ esid: sec-uint8array.fromhex description: > Uint8Array.fromHex has default data property attributes. includes: [propertyHelper.js] -features: [uint8array-base64] +features: [uint8array-base64, TypedArray] ---*/ verifyProperty(Uint8Array, 'fromHex', { diff --git a/test/built-ins/Uint8Array/fromHex/ignores-receiver.js b/test/built-ins/Uint8Array/fromHex/ignores-receiver.js index 48bb0698c90..2b96a674930 100644 --- a/test/built-ins/Uint8Array/fromHex/ignores-receiver.js +++ b/test/built-ins/Uint8Array/fromHex/ignores-receiver.js @@ -3,7 +3,7 @@ /*--- esid: sec-uint8array.fromhex description: Uint8Array.fromHex ignores its receiver -features: [uint8array-base64] +features: [uint8array-base64, TypedArray] ---*/ var fromHex = Uint8Array.fromHex; diff --git a/test/built-ins/Uint8Array/fromHex/illegal-characters.js b/test/built-ins/Uint8Array/fromHex/illegal-characters.js index dd0ae6d55b4..4b870a7b0a9 100644 --- a/test/built-ins/Uint8Array/fromHex/illegal-characters.js +++ b/test/built-ins/Uint8Array/fromHex/illegal-characters.js @@ -3,7 +3,7 @@ /*--- esid: sec-uint8array.fromhex description: Uint8Array.fromHex throws a SyntaxError when input has non-hex characters -features: [uint8array-base64] +features: [uint8array-base64, TypedArray] ---*/ var illegal = [ diff --git a/test/built-ins/Uint8Array/fromHex/length.js b/test/built-ins/Uint8Array/fromHex/length.js index ef9dca8def0..0f52a22f3e8 100644 --- a/test/built-ins/Uint8Array/fromHex/length.js +++ b/test/built-ins/Uint8Array/fromHex/length.js @@ -5,7 +5,7 @@ esid: sec-uint8array.fromhex description: > Uint8Array.fromHex.length is 1. includes: [propertyHelper.js] -features: [uint8array-base64] +features: [uint8array-base64, TypedArray] ---*/ verifyProperty(Uint8Array.fromHex, 'length', { diff --git a/test/built-ins/Uint8Array/fromHex/name.js b/test/built-ins/Uint8Array/fromHex/name.js index 083cff7b794..6397c3bd33c 100644 --- a/test/built-ins/Uint8Array/fromHex/name.js +++ b/test/built-ins/Uint8Array/fromHex/name.js @@ -5,7 +5,7 @@ esid: sec-uint8array.fromhex description: > Uint8Array.fromHex.name is "fromHex". includes: [propertyHelper.js] -features: [uint8array-base64] +features: [uint8array-base64, TypedArray] ---*/ verifyProperty(Uint8Array.fromHex, 'name', { diff --git a/test/built-ins/Uint8Array/fromHex/nonconstructor.js b/test/built-ins/Uint8Array/fromHex/nonconstructor.js index e06d1c54f3d..ca3b52a834e 100644 --- a/test/built-ins/Uint8Array/fromHex/nonconstructor.js +++ b/test/built-ins/Uint8Array/fromHex/nonconstructor.js @@ -5,7 +5,7 @@ esid: sec-uint8array.fromhex description: > Uint8Array.fromHex is not a constructor function. includes: [isConstructor.js] -features: [uint8array-base64, Reflect.construct] +features: [uint8array-base64, TypedArray, Reflect.construct] ---*/ assert(!isConstructor(Uint8Array.fromHex), "Uint8Array.fromHex is not a constructor"); diff --git a/test/built-ins/Uint8Array/fromHex/odd-length-input.js b/test/built-ins/Uint8Array/fromHex/odd-length-input.js index 798be139c18..9097fb700f0 100644 --- a/test/built-ins/Uint8Array/fromHex/odd-length-input.js +++ b/test/built-ins/Uint8Array/fromHex/odd-length-input.js @@ -3,7 +3,7 @@ /*--- esid: sec-uint8array.fromhex description: Uint8Array.fromHex throws if given an odd number of input hex characters -features: [uint8array-base64] +features: [uint8array-base64, TypedArray] ---*/ assert.throws(SyntaxError, function() { diff --git a/test/built-ins/Uint8Array/fromHex/results.js b/test/built-ins/Uint8Array/fromHex/results.js index 810e63b0953..c4bf09dd336 100644 --- a/test/built-ins/Uint8Array/fromHex/results.js +++ b/test/built-ins/Uint8Array/fromHex/results.js @@ -4,7 +4,7 @@ esid: sec-uint8array.fromhex description: Conversion of hex strings to Uint8Arrays includes: [compareArray.js] -features: [uint8array-base64] +features: [uint8array-base64, TypedArray] ---*/ var cases = [ diff --git a/test/built-ins/Uint8Array/fromHex/string-coercion.js b/test/built-ins/Uint8Array/fromHex/string-coercion.js index 2290f254993..fd6efcc0f04 100644 --- a/test/built-ins/Uint8Array/fromHex/string-coercion.js +++ b/test/built-ins/Uint8Array/fromHex/string-coercion.js @@ -3,7 +3,7 @@ /*--- esid: sec-uint8array.fromhex description: Uint8Array.fromHex throws if its argument is not a string -features: [uint8array-base64] +features: [uint8array-base64, TypedArray] ---*/ var toStringCalls = 0; diff --git a/test/built-ins/Uint8Array/prototype/setFromBase64/alphabet.js b/test/built-ins/Uint8Array/prototype/setFromBase64/alphabet.js index d931f7ca05e..ec33eaf6c93 100644 --- a/test/built-ins/Uint8Array/prototype/setFromBase64/alphabet.js +++ b/test/built-ins/Uint8Array/prototype/setFromBase64/alphabet.js @@ -4,7 +4,7 @@ esid: sec-uint8array.prototype.setfrombase64 description: Conversion of base64 strings to Uint8Arrays exercising the alphabet option includes: [compareArray.js] -features: [uint8array-base64] +features: [uint8array-base64, TypedArray] ---*/ var target = new Uint8Array([255, 255, 255, 255]); diff --git a/test/built-ins/Uint8Array/prototype/setFromBase64/descriptor.js b/test/built-ins/Uint8Array/prototype/setFromBase64/descriptor.js index f6765bb60c9..3bfc1a4ecda 100644 --- a/test/built-ins/Uint8Array/prototype/setFromBase64/descriptor.js +++ b/test/built-ins/Uint8Array/prototype/setFromBase64/descriptor.js @@ -5,7 +5,7 @@ esid: sec-uint8array.prototype.setfrombase64 description: > Uint8Array.prototype.setFromBase64 has default data property attributes. includes: [propertyHelper.js] -features: [uint8array-base64] +features: [uint8array-base64, TypedArray] ---*/ verifyProperty(Uint8Array.prototype, 'setFromBase64', { diff --git a/test/built-ins/Uint8Array/prototype/setFromBase64/detached-buffer.js b/test/built-ins/Uint8Array/prototype/setFromBase64/detached-buffer.js index 50550827118..50c65c4e5b0 100644 --- a/test/built-ins/Uint8Array/prototype/setFromBase64/detached-buffer.js +++ b/test/built-ins/Uint8Array/prototype/setFromBase64/detached-buffer.js @@ -4,7 +4,7 @@ esid: sec-uint8array.prototype.setfrombase64 description: Uint8Array.prototype.setFromBase64 throws on detatched buffers includes: [detachArrayBuffer.js] -features: [uint8array-base64] +features: [uint8array-base64, TypedArray] ---*/ var target = new Uint8Array([255, 255, 255]); diff --git a/test/built-ins/Uint8Array/prototype/setFromBase64/illegal-characters.js b/test/built-ins/Uint8Array/prototype/setFromBase64/illegal-characters.js index c3978f89ca9..3d22adddcaf 100644 --- a/test/built-ins/Uint8Array/prototype/setFromBase64/illegal-characters.js +++ b/test/built-ins/Uint8Array/prototype/setFromBase64/illegal-characters.js @@ -3,7 +3,7 @@ /*--- esid: sec-uint8array.prototype.setfrombase64 description: Uint8Array.prototype.setFromBase64 throws a SyntaxError when input has non-base64, non-ascii-whitespace characters -features: [uint8array-base64] +features: [uint8array-base64, TypedArray] ---*/ var illegal = [ diff --git a/test/built-ins/Uint8Array/prototype/setFromBase64/last-chunk-handling.js b/test/built-ins/Uint8Array/prototype/setFromBase64/last-chunk-handling.js index fa402ba90aa..9142633a584 100644 --- a/test/built-ins/Uint8Array/prototype/setFromBase64/last-chunk-handling.js +++ b/test/built-ins/Uint8Array/prototype/setFromBase64/last-chunk-handling.js @@ -4,7 +4,7 @@ esid: sec-uint8array.prototype.setfrombase64 description: Handling of final chunks in target.setFromBase64 includes: [compareArray.js] -features: [uint8array-base64] +features: [uint8array-base64, TypedArray] ---*/ // padding diff --git a/test/built-ins/Uint8Array/prototype/setFromBase64/length.js b/test/built-ins/Uint8Array/prototype/setFromBase64/length.js index bc7a976967a..23fe10c3526 100644 --- a/test/built-ins/Uint8Array/prototype/setFromBase64/length.js +++ b/test/built-ins/Uint8Array/prototype/setFromBase64/length.js @@ -5,7 +5,7 @@ esid: sec-uint8array.prototype.setfrombase64 description: > Uint8Array.prototype.setFromBase64.length is 1. includes: [propertyHelper.js] -features: [uint8array-base64] +features: [uint8array-base64, TypedArray] ---*/ verifyProperty(Uint8Array.prototype.setFromBase64, 'length', { diff --git a/test/built-ins/Uint8Array/prototype/setFromBase64/name.js b/test/built-ins/Uint8Array/prototype/setFromBase64/name.js index 18f124fb6a6..a80e8ffb3ff 100644 --- a/test/built-ins/Uint8Array/prototype/setFromBase64/name.js +++ b/test/built-ins/Uint8Array/prototype/setFromBase64/name.js @@ -5,7 +5,7 @@ esid: sec-uint8array.prototype.setfrombase64 description: > Uint8Array.prototype.setFromBase64.name is "setFromBase64". includes: [propertyHelper.js] -features: [uint8array-base64] +features: [uint8array-base64, TypedArray] ---*/ verifyProperty(Uint8Array.prototype.setFromBase64, 'name', { diff --git a/test/built-ins/Uint8Array/prototype/setFromBase64/nonconstructor.js b/test/built-ins/Uint8Array/prototype/setFromBase64/nonconstructor.js index 14b429f4f04..e2344f2d26a 100644 --- a/test/built-ins/Uint8Array/prototype/setFromBase64/nonconstructor.js +++ b/test/built-ins/Uint8Array/prototype/setFromBase64/nonconstructor.js @@ -5,7 +5,7 @@ esid: sec-uint8array.prototype.setfrombase64 description: > Uint8Array.prototype.setFromBase64 is not a constructor function. includes: [isConstructor.js] -features: [uint8array-base64, Reflect.construct] +features: [uint8array-base64, TypedArray, Reflect.construct] ---*/ assert(!isConstructor(Uint8Array.prototype.setFromBase64), "Uint8Array.prototype.setFromBase64 is not a constructor"); diff --git a/test/built-ins/Uint8Array/prototype/setFromBase64/option-coercion.js b/test/built-ins/Uint8Array/prototype/setFromBase64/option-coercion.js index b3022352d77..bf54e4d0735 100644 --- a/test/built-ins/Uint8Array/prototype/setFromBase64/option-coercion.js +++ b/test/built-ins/Uint8Array/prototype/setFromBase64/option-coercion.js @@ -4,7 +4,7 @@ esid: sec-uint8array.prototype.setfrombase64 description: Uint8Array.prototype.setFromBase64 triggers effects of the "alphabet" and "lastChunkHandling" getters, but does not perform toString on the results includes: [compareArray.js] -features: [uint8array-base64] +features: [uint8array-base64, TypedArray] ---*/ assert.throws(TypeError, function() { diff --git a/test/built-ins/Uint8Array/prototype/setFromBase64/results.js b/test/built-ins/Uint8Array/prototype/setFromBase64/results.js index cfd87afc012..016c6a34fd4 100644 --- a/test/built-ins/Uint8Array/prototype/setFromBase64/results.js +++ b/test/built-ins/Uint8Array/prototype/setFromBase64/results.js @@ -4,7 +4,7 @@ esid: sec-uint8array.prototype.setfrombase64 description: Conversion of base64 strings to Uint8Arrays includes: [compareArray.js] -features: [uint8array-base64] +features: [uint8array-base64, TypedArray] ---*/ // standard test vectors from https://datatracker.ietf.org/doc/html/rfc4648#section-10 diff --git a/test/built-ins/Uint8Array/prototype/setFromBase64/string-coercion.js b/test/built-ins/Uint8Array/prototype/setFromBase64/string-coercion.js index 22499d3493e..eb1be0aac84 100644 --- a/test/built-ins/Uint8Array/prototype/setFromBase64/string-coercion.js +++ b/test/built-ins/Uint8Array/prototype/setFromBase64/string-coercion.js @@ -3,7 +3,7 @@ /*--- esid: sec-uint8array.prototype.setfrombase64 description: Uint8Array.prototype.setFromBase64 throws if its first argument is not a string -features: [uint8array-base64] +features: [uint8array-base64, TypedArray] ---*/ var toStringCalls = 0; diff --git a/test/built-ins/Uint8Array/prototype/setFromBase64/subarray.js b/test/built-ins/Uint8Array/prototype/setFromBase64/subarray.js index 5c864aab21f..98cea3aaf33 100644 --- a/test/built-ins/Uint8Array/prototype/setFromBase64/subarray.js +++ b/test/built-ins/Uint8Array/prototype/setFromBase64/subarray.js @@ -4,7 +4,7 @@ esid: sec-uint8array.prototype.setfrombase64 description: Uint8Array.prototype.setFromBase64 takes into account the offset of the target Uint8Array includes: [compareArray.js] -features: [uint8array-base64] +features: [uint8array-base64, TypedArray] ---*/ var base = new Uint8Array([255, 255, 255, 255, 255, 255, 255]); diff --git a/test/built-ins/Uint8Array/prototype/setFromBase64/target-size.js b/test/built-ins/Uint8Array/prototype/setFromBase64/target-size.js index 5d03f060e8d..7566d8122e2 100644 --- a/test/built-ins/Uint8Array/prototype/setFromBase64/target-size.js +++ b/test/built-ins/Uint8Array/prototype/setFromBase64/target-size.js @@ -4,7 +4,7 @@ esid: sec-uint8array.prototype.setfrombase64 description: Uint8Array.prototype.setFromBase64 behavior when target buffer is small includes: [compareArray.js] -features: [uint8array-base64] +features: [uint8array-base64, TypedArray] ---*/ // buffer too small diff --git a/test/built-ins/Uint8Array/prototype/setFromBase64/whitespace.js b/test/built-ins/Uint8Array/prototype/setFromBase64/whitespace.js index 38bcb3d3a05..733970884cc 100644 --- a/test/built-ins/Uint8Array/prototype/setFromBase64/whitespace.js +++ b/test/built-ins/Uint8Array/prototype/setFromBase64/whitespace.js @@ -4,7 +4,7 @@ esid: sec-uint8array.prototype.setfrombase64 description: Uint8Array.prototype.setFromBase64 ignores ASCII whitespace in the input includes: [compareArray.js] -features: [uint8array-base64] +features: [uint8array-base64, TypedArray] ---*/ var whitespaceKinds = [ diff --git a/test/built-ins/Uint8Array/prototype/setFromHex/descriptor.js b/test/built-ins/Uint8Array/prototype/setFromHex/descriptor.js index 080cda9411e..8d5e4f3321e 100644 --- a/test/built-ins/Uint8Array/prototype/setFromHex/descriptor.js +++ b/test/built-ins/Uint8Array/prototype/setFromHex/descriptor.js @@ -5,7 +5,7 @@ esid: sec-uint8array.prototype.setfromhex description: > Uint8Array.prototype.setFromHex has default data property attributes. includes: [propertyHelper.js] -features: [uint8array-base64] +features: [uint8array-base64, TypedArray] ---*/ verifyProperty(Uint8Array.prototype, 'setFromHex', { diff --git a/test/built-ins/Uint8Array/prototype/setFromHex/detached-buffer.js b/test/built-ins/Uint8Array/prototype/setFromHex/detached-buffer.js index 881ca258ed8..ccfc9f1031b 100644 --- a/test/built-ins/Uint8Array/prototype/setFromHex/detached-buffer.js +++ b/test/built-ins/Uint8Array/prototype/setFromHex/detached-buffer.js @@ -4,7 +4,7 @@ esid: sec-uint8array.prototype.setfromhex description: Uint8Array.prototype.setFromHex throws on detatched buffers includes: [detachArrayBuffer.js] -features: [uint8array-base64] +features: [uint8array-base64, TypedArray] ---*/ var target = new Uint8Array([255, 255, 255]); diff --git a/test/built-ins/Uint8Array/prototype/setFromHex/illegal-characters.js b/test/built-ins/Uint8Array/prototype/setFromHex/illegal-characters.js index 970866078f3..f8c8dbdb00a 100644 --- a/test/built-ins/Uint8Array/prototype/setFromHex/illegal-characters.js +++ b/test/built-ins/Uint8Array/prototype/setFromHex/illegal-characters.js @@ -3,7 +3,7 @@ /*--- esid: sec-uint8array.prototype.setfromhex description: Uint8Array.prototype.setFromHex throws a SyntaxError when input has non-hex characters -features: [uint8array-base64] +features: [uint8array-base64, TypedArray] ---*/ var illegal = [ diff --git a/test/built-ins/Uint8Array/prototype/setFromHex/length.js b/test/built-ins/Uint8Array/prototype/setFromHex/length.js index 3754878ffc0..479d0f12d8b 100644 --- a/test/built-ins/Uint8Array/prototype/setFromHex/length.js +++ b/test/built-ins/Uint8Array/prototype/setFromHex/length.js @@ -5,7 +5,7 @@ esid: sec-uint8array.prototype.setfromhex description: > Uint8Array.prototype.setFromHex.length is 1. includes: [propertyHelper.js] -features: [uint8array-base64] +features: [uint8array-base64, TypedArray] ---*/ verifyProperty(Uint8Array.prototype.setFromHex, 'length', { diff --git a/test/built-ins/Uint8Array/prototype/setFromHex/name.js b/test/built-ins/Uint8Array/prototype/setFromHex/name.js index 808ac1645eb..9967d38ee2e 100644 --- a/test/built-ins/Uint8Array/prototype/setFromHex/name.js +++ b/test/built-ins/Uint8Array/prototype/setFromHex/name.js @@ -5,7 +5,7 @@ esid: sec-uint8array.prototype.setfromhex description: > Uint8Array.prototype.setFromHex.name is "setFromHex". includes: [propertyHelper.js] -features: [uint8array-base64] +features: [uint8array-base64, TypedArray] ---*/ verifyProperty(Uint8Array.prototype.setFromHex, 'name', { diff --git a/test/built-ins/Uint8Array/prototype/setFromHex/nonconstructor.js b/test/built-ins/Uint8Array/prototype/setFromHex/nonconstructor.js index 435ce51f5a6..4af13303912 100644 --- a/test/built-ins/Uint8Array/prototype/setFromHex/nonconstructor.js +++ b/test/built-ins/Uint8Array/prototype/setFromHex/nonconstructor.js @@ -5,7 +5,7 @@ esid: sec-uint8array.prototype.setfromhex description: > Uint8Array.prototype.setFromHex is not a constructor function. includes: [isConstructor.js] -features: [uint8array-base64, Reflect.construct] +features: [uint8array-base64, TypedArray, Reflect.construct] ---*/ assert(!isConstructor(Uint8Array.prototype.setFromHex), "target.setFromHex is not a constructor"); diff --git a/test/built-ins/Uint8Array/prototype/setFromHex/results.js b/test/built-ins/Uint8Array/prototype/setFromHex/results.js index 2359a9060d5..870d49656d4 100644 --- a/test/built-ins/Uint8Array/prototype/setFromHex/results.js +++ b/test/built-ins/Uint8Array/prototype/setFromHex/results.js @@ -4,7 +4,7 @@ esid: sec-uint8array.prototype.setfromhex description: Conversion of hex strings to Uint8Arrays includes: [compareArray.js] -features: [uint8array-base64] +features: [uint8array-base64, TypedArray] ---*/ var cases = [ diff --git a/test/built-ins/Uint8Array/prototype/setFromHex/string-coercion.js b/test/built-ins/Uint8Array/prototype/setFromHex/string-coercion.js index 822ee7a3493..5e877b3d0b8 100644 --- a/test/built-ins/Uint8Array/prototype/setFromHex/string-coercion.js +++ b/test/built-ins/Uint8Array/prototype/setFromHex/string-coercion.js @@ -3,7 +3,7 @@ /*--- esid: sec-uint8array.prototype.setfromhex description: Uint8Array.prototype.setFromHex throws if its first argument is not a string -features: [uint8array-base64] +features: [uint8array-base64, TypedArray] ---*/ var toStringCalls = 0; diff --git a/test/built-ins/Uint8Array/prototype/setFromHex/subarray.js b/test/built-ins/Uint8Array/prototype/setFromHex/subarray.js index 3868ace0147..72a33b6dafb 100644 --- a/test/built-ins/Uint8Array/prototype/setFromHex/subarray.js +++ b/test/built-ins/Uint8Array/prototype/setFromHex/subarray.js @@ -4,7 +4,7 @@ esid: sec-uint8array.prototype.setfromhex description: Uint8Array.prototype.setFromHex takes into account the offset of the target Uint8Array includes: [compareArray.js] -features: [uint8array-base64] +features: [uint8array-base64, TypedArray] ---*/ var base = new Uint8Array([255, 255, 255, 255, 255, 255, 255]); diff --git a/test/built-ins/Uint8Array/prototype/setFromHex/target-size.js b/test/built-ins/Uint8Array/prototype/setFromHex/target-size.js index b794a44ee8b..f3aed06f255 100644 --- a/test/built-ins/Uint8Array/prototype/setFromHex/target-size.js +++ b/test/built-ins/Uint8Array/prototype/setFromHex/target-size.js @@ -4,7 +4,7 @@ esid: sec-uint8array.prototype.setfromhex description: Uint8Array.prototype.setFromHex behavior when target buffer is small includes: [compareArray.js] -features: [uint8array-base64] +features: [uint8array-base64, TypedArray] ---*/ // buffer too small diff --git a/test/built-ins/Uint8Array/prototype/toBase64/alphabet.js b/test/built-ins/Uint8Array/prototype/toBase64/alphabet.js index 64f4959a5e7..a20b3c14463 100644 --- a/test/built-ins/Uint8Array/prototype/toBase64/alphabet.js +++ b/test/built-ins/Uint8Array/prototype/toBase64/alphabet.js @@ -3,7 +3,7 @@ /*--- esid: sec-uint8array.prototype.tobase64 description: Conversion of Uint8Arrays to base64 strings exercising the alphabet option -features: [uint8array-base64] +features: [uint8array-base64, TypedArray] ---*/ assert.sameValue((new Uint8Array([199, 239, 242])).toBase64(), "x+/y"); diff --git a/test/built-ins/Uint8Array/prototype/toBase64/descriptor.js b/test/built-ins/Uint8Array/prototype/toBase64/descriptor.js index 6db2b911a73..52ba4ecad15 100644 --- a/test/built-ins/Uint8Array/prototype/toBase64/descriptor.js +++ b/test/built-ins/Uint8Array/prototype/toBase64/descriptor.js @@ -5,7 +5,7 @@ esid: sec-uint8array.prototype.tobase64 description: > Uint8Array.prototype.toBase64 has default data property attributes. includes: [propertyHelper.js] -features: [uint8array-base64] +features: [uint8array-base64, TypedArray] ---*/ verifyProperty(Uint8Array.prototype, 'toBase64', { diff --git a/test/built-ins/Uint8Array/prototype/toBase64/detached-buffer.js b/test/built-ins/Uint8Array/prototype/toBase64/detached-buffer.js index 2b72f1fdf77..b8b1c2999ab 100644 --- a/test/built-ins/Uint8Array/prototype/toBase64/detached-buffer.js +++ b/test/built-ins/Uint8Array/prototype/toBase64/detached-buffer.js @@ -4,7 +4,7 @@ esid: sec-uint8array.prototype.tobase64 description: Uint8Array.prototype.toBase64 checks for detachedness after side-effects are finished includes: [detachArrayBuffer.js] -features: [uint8array-base64] +features: [uint8array-base64, TypedArray] ---*/ var array = new Uint8Array(2); diff --git a/test/built-ins/Uint8Array/prototype/toBase64/length.js b/test/built-ins/Uint8Array/prototype/toBase64/length.js index a31b79151bb..8f08a291567 100644 --- a/test/built-ins/Uint8Array/prototype/toBase64/length.js +++ b/test/built-ins/Uint8Array/prototype/toBase64/length.js @@ -5,7 +5,7 @@ esid: sec-uint8array.prototype.tobase64 description: > Uint8Array.prototype.toBase64.length is 0. includes: [propertyHelper.js] -features: [uint8array-base64] +features: [uint8array-base64, TypedArray] ---*/ verifyProperty(Uint8Array.prototype.toBase64, 'length', { diff --git a/test/built-ins/Uint8Array/prototype/toBase64/name.js b/test/built-ins/Uint8Array/prototype/toBase64/name.js index f13cb969274..71cd95403c3 100644 --- a/test/built-ins/Uint8Array/prototype/toBase64/name.js +++ b/test/built-ins/Uint8Array/prototype/toBase64/name.js @@ -5,7 +5,7 @@ esid: sec-uint8array.prototype.tobase64 description: > Uint8Array.prototype.toBase64.name is "toBase64". includes: [propertyHelper.js] -features: [uint8array-base64] +features: [uint8array-base64, TypedArray] ---*/ verifyProperty(Uint8Array.prototype.toBase64, 'name', { diff --git a/test/built-ins/Uint8Array/prototype/toBase64/nonconstructor.js b/test/built-ins/Uint8Array/prototype/toBase64/nonconstructor.js index 6d36216a9ea..9b07eb26604 100644 --- a/test/built-ins/Uint8Array/prototype/toBase64/nonconstructor.js +++ b/test/built-ins/Uint8Array/prototype/toBase64/nonconstructor.js @@ -5,7 +5,7 @@ esid: sec-uint8array.prototype.tobase64 description: > Uint8Array.prototype.toBase64 is not a constructor function. includes: [isConstructor.js] -features: [uint8array-base64, Reflect.construct] +features: [uint8array-base64, TypedArray, Reflect.construct] ---*/ assert(!isConstructor(Uint8Array.prototype.toBase64), "Uint8Array.prototype.toBase64 is not a constructor"); diff --git a/test/built-ins/Uint8Array/prototype/toBase64/option-coercion.js b/test/built-ins/Uint8Array/prototype/toBase64/option-coercion.js index 94c0b3942e5..4cd96152729 100644 --- a/test/built-ins/Uint8Array/prototype/toBase64/option-coercion.js +++ b/test/built-ins/Uint8Array/prototype/toBase64/option-coercion.js @@ -3,7 +3,7 @@ /*--- esid: sec-uint8array.prototype.tobase64 description: Uint8Array.prototype.toBase64 triggers effects of the "alphabet" getter, but does not perform toString on the result -features: [uint8array-base64] +features: [uint8array-base64, TypedArray] ---*/ assert.throws(TypeError, function() { diff --git a/test/built-ins/Uint8Array/prototype/toBase64/receiver-not-uint8array.js b/test/built-ins/Uint8Array/prototype/toBase64/receiver-not-uint8array.js index e360b53da62..0ade97bad21 100644 --- a/test/built-ins/Uint8Array/prototype/toBase64/receiver-not-uint8array.js +++ b/test/built-ins/Uint8Array/prototype/toBase64/receiver-not-uint8array.js @@ -4,7 +4,7 @@ esid: sec-uint8array.prototype.tobase64 description: Uint8Array.prototype.toBase64 throws if the receiver is not a Uint8Array includes: [testTypedArray.js] -features: [uint8array-base64] +features: [uint8array-base64, TypedArray] ---*/ var toBase64 = Uint8Array.prototype.toBase64; diff --git a/test/built-ins/Uint8Array/prototype/toBase64/results.js b/test/built-ins/Uint8Array/prototype/toBase64/results.js index d44e42d753e..88d2ba111f5 100644 --- a/test/built-ins/Uint8Array/prototype/toBase64/results.js +++ b/test/built-ins/Uint8Array/prototype/toBase64/results.js @@ -3,7 +3,7 @@ /*--- esid: sec-uint8array.prototype.tobase64 description: Conversion of Uint8Arrays to base64 strings -features: [uint8array-base64] +features: [uint8array-base64, TypedArray] ---*/ // standard test vectors from https://datatracker.ietf.org/doc/html/rfc4648#section-10 diff --git a/test/built-ins/Uint8Array/prototype/toHex/descriptor.js b/test/built-ins/Uint8Array/prototype/toHex/descriptor.js index 16762d452b5..c70b782539c 100644 --- a/test/built-ins/Uint8Array/prototype/toHex/descriptor.js +++ b/test/built-ins/Uint8Array/prototype/toHex/descriptor.js @@ -5,7 +5,7 @@ esid: sec-uint8array.prototype.tohex description: > Uint8Array.prototype.toHex has default data property attributes. includes: [propertyHelper.js] -features: [uint8array-base64] +features: [uint8array-base64, TypedArray] ---*/ verifyProperty(Uint8Array.prototype, 'toHex', { diff --git a/test/built-ins/Uint8Array/prototype/toHex/detached-buffer.js b/test/built-ins/Uint8Array/prototype/toHex/detached-buffer.js index d98d62aa2eb..016d2c8ed44 100644 --- a/test/built-ins/Uint8Array/prototype/toHex/detached-buffer.js +++ b/test/built-ins/Uint8Array/prototype/toHex/detached-buffer.js @@ -4,7 +4,7 @@ esid: sec-uint8array.prototype.tohex description: Uint8Array.prototype.toHex throws if called on a detached buffer includes: [detachArrayBuffer.js] -features: [uint8array-base64] +features: [uint8array-base64, TypedArray] ---*/ var array = new Uint8Array(2); diff --git a/test/built-ins/Uint8Array/prototype/toHex/length.js b/test/built-ins/Uint8Array/prototype/toHex/length.js index 0cd4450c273..6bc061be014 100644 --- a/test/built-ins/Uint8Array/prototype/toHex/length.js +++ b/test/built-ins/Uint8Array/prototype/toHex/length.js @@ -5,7 +5,7 @@ esid: sec-uint8array.prototype.tohex description: > Uint8Array.prototype.toHex.length is 0. includes: [propertyHelper.js] -features: [uint8array-base64] +features: [uint8array-base64, TypedArray] ---*/ verifyProperty(Uint8Array.prototype.toHex, 'length', { diff --git a/test/built-ins/Uint8Array/prototype/toHex/name.js b/test/built-ins/Uint8Array/prototype/toHex/name.js index beca824e229..8cfa9528730 100644 --- a/test/built-ins/Uint8Array/prototype/toHex/name.js +++ b/test/built-ins/Uint8Array/prototype/toHex/name.js @@ -5,7 +5,7 @@ esid: sec-uint8array.prototype.tohex description: > Uint8Array.prototype.toHex.name is "toHex". includes: [propertyHelper.js] -features: [uint8array-base64] +features: [uint8array-base64, TypedArray] ---*/ verifyProperty(Uint8Array.prototype.toHex, 'name', { diff --git a/test/built-ins/Uint8Array/prototype/toHex/nonconstructor.js b/test/built-ins/Uint8Array/prototype/toHex/nonconstructor.js index 7d4d9eac9b2..bb3d9e155ad 100644 --- a/test/built-ins/Uint8Array/prototype/toHex/nonconstructor.js +++ b/test/built-ins/Uint8Array/prototype/toHex/nonconstructor.js @@ -5,7 +5,7 @@ esid: sec-uint8array.prototype.tohex description: > Uint8Array.prototype.toHex is not a constructor function. includes: [isConstructor.js] -features: [uint8array-base64, Reflect.construct] +features: [uint8array-base64, TypedArray, Reflect.construct] ---*/ assert(!isConstructor(Uint8Array.prototype.toHex), "Uint8Array.prototype.toHex is not a constructor"); diff --git a/test/built-ins/Uint8Array/prototype/toHex/receiver-not-uint8array.js b/test/built-ins/Uint8Array/prototype/toHex/receiver-not-uint8array.js index c5d967a7218..42ac67ec977 100644 --- a/test/built-ins/Uint8Array/prototype/toHex/receiver-not-uint8array.js +++ b/test/built-ins/Uint8Array/prototype/toHex/receiver-not-uint8array.js @@ -4,7 +4,7 @@ esid: sec-uint8array.prototype.tohex description: Uint8Array.prototype.toHex throws if the receiver is not a Uint8Array includes: [testTypedArray.js] -features: [uint8array-base64] +features: [uint8array-base64, TypedArray] ---*/ var toHex = Uint8Array.prototype.toHex; diff --git a/test/built-ins/Uint8Array/prototype/toHex/results.js b/test/built-ins/Uint8Array/prototype/toHex/results.js index 108b9730458..8d0bcf4310e 100644 --- a/test/built-ins/Uint8Array/prototype/toHex/results.js +++ b/test/built-ins/Uint8Array/prototype/toHex/results.js @@ -3,7 +3,7 @@ /*--- esid: sec-uint8array.prototype.tohex description: Conversion of Uint8Arrays to hex strings -features: [uint8array-base64] +features: [uint8array-base64, TypedArray] ---*/ assert.sameValue((new Uint8Array([])).toHex(), "");