Debian Codegraph @

js/src/tests/test262/built-ins/Uint8Array/fromBase64/illegal-characters.js

raw
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.frombase64
6 description: Uint8Array.fromBase64 throws a SyntaxError when input has non-base64, non-ascii-whitespace characters
7 features: [uint8array-base64, TypedArray]
8 ---*/
9
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
19 ];
20 illegal.forEach(function(value) {
21 assert.throws(SyntaxError, function() {
22 Uint8Array.fromBase64(value)
23 });
24 });
25
26 reportCompare(0, 0);