mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 10:59:27 +00:00
55fde47b1d
PR-URL: https://github.com/nodejs/node/pull/49610 Refs: https://encoding.spec.whatwg.org/#names-and-labels Reviewed-By: Daeyeon Jeong <daeyeon.dev@gmail.com> Reviewed-By: Minwoo Jung <nodecorelab@gmail.com>
51 lines
1.0 KiB
JavaScript
51 lines
1.0 KiB
JavaScript
'use strict';
|
|
// From: https://github.com/w3c/web-platform-tests/blob/master/encoding/api-invalid-label.html
|
|
// With the twist that we specifically test for Node.js error codes
|
|
|
|
require('../common');
|
|
const assert = require('assert');
|
|
|
|
[
|
|
'utf-8',
|
|
'unicode-1-1-utf-8',
|
|
'unicode11utf8',
|
|
'unicode20utf8',
|
|
'x-unicode20utf8',
|
|
'utf8',
|
|
'unicodefffe',
|
|
'utf-16be',
|
|
'csunicode',
|
|
'iso-10646-ucs-2',
|
|
'ucs-2',
|
|
'unicode',
|
|
'unicodefeff',
|
|
'utf-16le',
|
|
'utf-16',
|
|
].forEach((i) => {
|
|
['\u0000', '\u000b', '\u00a0', '\u2028', '\u2029'].forEach((ws) => {
|
|
assert.throws(
|
|
() => new TextDecoder(`${ws}${i}`),
|
|
{
|
|
code: 'ERR_ENCODING_NOT_SUPPORTED',
|
|
name: 'RangeError'
|
|
}
|
|
);
|
|
|
|
assert.throws(
|
|
() => new TextDecoder(`${i}${ws}`),
|
|
{
|
|
code: 'ERR_ENCODING_NOT_SUPPORTED',
|
|
name: 'RangeError'
|
|
}
|
|
);
|
|
|
|
assert.throws(
|
|
() => new TextDecoder(`${ws}${i}${ws}`),
|
|
{
|
|
code: 'ERR_ENCODING_NOT_SUPPORTED',
|
|
name: 'RangeError'
|
|
}
|
|
);
|
|
});
|
|
});
|