Bug 1885337 - Part 3: Import tests from test262 PR. r=spidermonkey-reviewers,dminor
[gecko.git] / js / src / tests / test262 / prs / 3994 / built-ins / Uint8Array / prototype / toBase64 / alphabet.js
blob7edf0a379e1193b7aceb44d7dc1db445d59849ea
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.
4 /*---
5 esid: sec-uint8array.prototype.tobase64
6 description: Conversion of Uint8Arrays to base64 strings exercising the alphabet option
7 features: [uint8array-base64, TypedArray]
8 ---*/
10 assert.sameValue((new Uint8Array([199, 239, 242])).toBase64(), "x+/y");
12 assert.sameValue((new Uint8Array([199, 239, 242])).toBase64({ alphabet: 'base64' }), "x+/y");
14 assert.sameValue((new Uint8Array([199, 239, 242])).toBase64({ alphabet: 'base64url' }), "x-_y");
16 assert.throws(TypeError, function() {
17   (new Uint8Array([199, 239, 242])).toBase64({ alphabet: 'other' });
18 });
20 reportCompare(0, 0);