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 / setFromBase64 / illegal-characters.js
blob9c6b827df85619799fa3587b0c36080fa2b0a233
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.setfrombase64
6 description: Uint8Array.prototype.setFromBase64 throws a SyntaxError when input has non-base64, non-ascii-whitespace characters
7 features: [uint8array-base64, TypedArray]
8 ---*/
10 var illegal = [
11   'Zm.9v',
12   'Zm9v^',
13   'Zg==&',
14   'Z−==', // U+2212 'Minus Sign'
15   'Z+==', // U+FF0B 'Fullwidth Plus Sign'
16   'Zg\u00A0==', // nbsp
17   'Zg\u2009==', // thin space
18   'Zg\u2028==', // line separator
20 illegal.forEach(function(value) {
21   assert.throws(SyntaxError, function() {
22     var target = new Uint8Array([255, 255, 255, 255, 255]);
23     target.setFromBase64(value);
24   });
25 });
27 reportCompare(0, 0);