1'use strict'; 2// From: https://github.com/w3c/web-platform-tests/blob/master/encoding/api-invalid-label.html 3// With the twist that we specifically test for Node.js error codes 4 5require('../common'); 6const assert = require('assert'); 7 8[ 9 'utf-8', 10 'unicode-1-1-utf-8', 11 'utf8', 12 'utf-16be', 13 'utf-16le', 14 'utf-16', 15].forEach((i) => { 16 ['\u0000', '\u000b', '\u00a0', '\u2028', '\u2029'].forEach((ws) => { 17 assert.throws( 18 () => new TextDecoder(`${ws}${i}`), 19 { 20 code: 'ERR_ENCODING_NOT_SUPPORTED', 21 name: 'RangeError' 22 } 23 ); 24 25 assert.throws( 26 () => new TextDecoder(`${i}${ws}`), 27 { 28 code: 'ERR_ENCODING_NOT_SUPPORTED', 29 name: 'RangeError' 30 } 31 ); 32 33 assert.throws( 34 () => new TextDecoder(`${ws}${i}${ws}`), 35 { 36 code: 'ERR_ENCODING_NOT_SUPPORTED', 37 name: 'RangeError' 38 } 39 ); 40 }); 41}); 42