11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_ci// From: https://github.com/w3c/web-platform-tests/blob/master/encoding/api-invalid-label.html 31cb0ef41Sopenharmony_ci// With the twist that we specifically test for Node.js error codes 41cb0ef41Sopenharmony_ci 51cb0ef41Sopenharmony_cirequire('../common'); 61cb0ef41Sopenharmony_ciconst assert = require('assert'); 71cb0ef41Sopenharmony_ci 81cb0ef41Sopenharmony_ci[ 91cb0ef41Sopenharmony_ci 'utf-8', 101cb0ef41Sopenharmony_ci 'unicode-1-1-utf-8', 111cb0ef41Sopenharmony_ci 'utf8', 121cb0ef41Sopenharmony_ci 'utf-16be', 131cb0ef41Sopenharmony_ci 'utf-16le', 141cb0ef41Sopenharmony_ci 'utf-16', 151cb0ef41Sopenharmony_ci].forEach((i) => { 161cb0ef41Sopenharmony_ci ['\u0000', '\u000b', '\u00a0', '\u2028', '\u2029'].forEach((ws) => { 171cb0ef41Sopenharmony_ci assert.throws( 181cb0ef41Sopenharmony_ci () => new TextDecoder(`${ws}${i}`), 191cb0ef41Sopenharmony_ci { 201cb0ef41Sopenharmony_ci code: 'ERR_ENCODING_NOT_SUPPORTED', 211cb0ef41Sopenharmony_ci name: 'RangeError' 221cb0ef41Sopenharmony_ci } 231cb0ef41Sopenharmony_ci ); 241cb0ef41Sopenharmony_ci 251cb0ef41Sopenharmony_ci assert.throws( 261cb0ef41Sopenharmony_ci () => new TextDecoder(`${i}${ws}`), 271cb0ef41Sopenharmony_ci { 281cb0ef41Sopenharmony_ci code: 'ERR_ENCODING_NOT_SUPPORTED', 291cb0ef41Sopenharmony_ci name: 'RangeError' 301cb0ef41Sopenharmony_ci } 311cb0ef41Sopenharmony_ci ); 321cb0ef41Sopenharmony_ci 331cb0ef41Sopenharmony_ci assert.throws( 341cb0ef41Sopenharmony_ci () => new TextDecoder(`${ws}${i}${ws}`), 351cb0ef41Sopenharmony_ci { 361cb0ef41Sopenharmony_ci code: 'ERR_ENCODING_NOT_SUPPORTED', 371cb0ef41Sopenharmony_ci name: 'RangeError' 381cb0ef41Sopenharmony_ci } 391cb0ef41Sopenharmony_ci ); 401cb0ef41Sopenharmony_ci }); 411cb0ef41Sopenharmony_ci}); 42