1 // |reftest| shell-option(--enable-uint8array-base64) skip-if(!Uint8Array.fromBase64||!xulRuntime.shell) -- uint8array-base64 is not enabled unconditionally, requires shell-options
2 // Copyright (C) 2024 Kevin Gibbons. All rights reserved.
3 // This code is governed by the BSD license found in the LICENSE file.
5 esid: sec-uint8array.prototype.tobase64
6 description: Uint8Array.prototype.toBase64 throws if the receiver is not a Uint8Array
7 includes: [testTypedArray.js]
8 features: [uint8array-base64, TypedArray]
11 var toBase64 = Uint8Array.prototype.toBase64;
14 Object.defineProperty(options, "alphabet", {
16 throw new Test262Error("options.alphabet accessed despite incompatible receiver");
20 testWithTypedArrayConstructors(function(TA) {
21 if (TA === Uint8Array) return;
22 var sample = new TA(2);
23 assert.throws(TypeError, function() {
24 Uint8Array.prototype.toBase64.call(sample, options);
28 assert.throws(TypeError, function() {
29 Uint8Array.prototype.toBase64.call([], options);
32 assert.throws(TypeError, function() {