mirror of
https://github.com/servo/servo.git
synced 2025-10-04 02:29:12 +01:00
Update web-platform-tests to revision 8a2ceb5f18911302b7a5c1cd2791f4ab50ad4326
This commit is contained in:
parent
462c272380
commit
1f531f66ea
5377 changed files with 174916 additions and 84369 deletions
|
@ -8,9 +8,7 @@
|
|||
var tests = ["invalid-invalidLabel"];
|
||||
setup(function() {
|
||||
encodings_table.forEach(function(section) {
|
||||
section.encodings.filter(function(encoding) {
|
||||
return encoding.name !== 'replacement';
|
||||
}).forEach(function(encoding) {
|
||||
section.encodings.forEach(function(encoding) {
|
||||
encoding.labels.forEach(function(label) {
|
||||
["\u0000", "\u000b", "\u00a0", "\u2028", "\u2029"].forEach(function(ws) {
|
||||
tests.push(ws + label);
|
||||
|
|
|
@ -5,10 +5,6 @@
|
|||
<script src="resources/encodings.js"></script>
|
||||
<script>
|
||||
|
||||
test(function() {
|
||||
assert_throws(new RangeError(), function() { new TextDecoder('replacement'); });
|
||||
}, 'The "replacement" label should not be a known encoding.');
|
||||
|
||||
encodings_table.forEach(function(section) {
|
||||
section.encodings.filter(function(encoding) {
|
||||
return encoding.name === 'replacement';
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
<!doctype html>
|
||||
<meta charset=shift_jis>
|
||||
<title>Shift_JIS file ending with a truncated sequence</title>
|
||||
One-byte truncated sequence:�
|
5
tests/wpt/web-platform-tests/encoding/eof-shift_jis.html
Normal file
5
tests/wpt/web-platform-tests/encoding/eof-shift_jis.html
Normal file
|
@ -0,0 +1,5 @@
|
|||
<!doctype html>
|
||||
<meta charset=shift_jis>
|
||||
<title>Shift_JIS file ending with a truncated sequence</title>
|
||||
<link rel=match href=/encoding/eof-shift_jis-ref.html>
|
||||
One-byte truncated sequence:ƒ
|
|
@ -0,0 +1,4 @@
|
|||
<!doctype html>
|
||||
<meta charset=utf-8>
|
||||
<title>UTF-8 file ending with a one-byte truncated sequence</title>
|
||||
One-byte truncated sequence:�
|
5
tests/wpt/web-platform-tests/encoding/eof-utf-8-one.html
Normal file
5
tests/wpt/web-platform-tests/encoding/eof-utf-8-one.html
Normal file
|
@ -0,0 +1,5 @@
|
|||
<!doctype html>
|
||||
<meta charset=utf-8>
|
||||
<title>UTF-8 file ending with a one-byte truncated sequence</title>
|
||||
<link rel=match href="eof-utf-8-one-ref.html">
|
||||
One-byte truncated sequence:ð
|
|
@ -0,0 +1,4 @@
|
|||
<!doctype html>
|
||||
<meta charset=utf-8>
|
||||
<title>UTF-8 file ending with a three-byte truncated sequence</title>
|
||||
Three-byte truncated sequence:�
|
|
@ -0,0 +1,5 @@
|
|||
<!doctype html>
|
||||
<meta charset=utf-8>
|
||||
<title>UTF-8 file ending with a three-byte truncated sequence</title>
|
||||
<link rel=match href="eof-utf-8-three-ref.html">
|
||||
Three-byte truncated sequence:ðŸ’
|
|
@ -0,0 +1,4 @@
|
|||
<!doctype html>
|
||||
<meta charset=utf-8>
|
||||
<title>UTF-8 file ending with a two-byte truncated sequence</title>
|
||||
Two-byte truncated sequence:�
|
5
tests/wpt/web-platform-tests/encoding/eof-utf-8-two.html
Normal file
5
tests/wpt/web-platform-tests/encoding/eof-utf-8-two.html
Normal file
|
@ -0,0 +1,5 @@
|
|||
<!doctype html>
|
||||
<meta charset=utf-8>
|
||||
<title>UTF-8 file ending with a two-byte truncated sequence</title>
|
||||
<link rel=match href="eof-utf-8-two-ref.html">
|
||||
Two-byte truncated sequence:ðŸ
|
|
@ -17,8 +17,8 @@
|
|||
}
|
||||
decode([0x1b, 0x24], "<22>$", "Error ESC")
|
||||
decode([0x1b, 0x24, 0x50], "<22>$P", "Error ESC, character")
|
||||
decode([0x1b, 0x28, 0x42, 0x50], "<EFBFBD>P", "ASCII ESC, character")
|
||||
decode([0x1b, 0x28, 0x42, 0x1b, 0x28, 0x42, 0x50], "<22><EFBFBD>P", "Double ASCII ESC, character")
|
||||
decode([0x1b, 0x28, 0x42, 0x50], "P", "ASCII ESC, character")
|
||||
decode([0x1b, 0x28, 0x42, 0x1b, 0x28, 0x42, 0x50], "<22>P", "Double ASCII ESC, character")
|
||||
decode([0x50, 0x1b, 0x28, 0x42, 0x50], "PP", "character, ASCII ESC, character")
|
||||
decode([0x5C, 0x5D, 0x7E], "\\]~", "characters")
|
||||
decode([0x0D, 0x0E, 0x0F, 0x10], "\x0D<30><44>\x10", "SO / SI")
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
<!DOCTYPE html>
|
||||
<title>Encoding API: replacement encoding</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="resources/encodings.js"></script>
|
||||
<script src="resources/decoding-helpers.js"></script>
|
||||
<script>
|
||||
|
||||
const replacement_labels = [];
|
||||
encodings_table.forEach(section => {
|
||||
section.encodings
|
||||
.filter(encoding => encoding.name === 'replacement')
|
||||
.forEach(encoding => {
|
||||
encoding.labels.forEach(label => { replacement_labels.push(label); })
|
||||
});
|
||||
});
|
||||
|
||||
replacement_labels.forEach(label => {
|
||||
decode_test(
|
||||
label,
|
||||
'%41%42%43%61%62%63%31%32%33%A0',
|
||||
'U+FFFD',
|
||||
`${label} - non-empty input decodes to one replacement character.`);
|
||||
|
||||
decode_test(
|
||||
label,
|
||||
'',
|
||||
'', `${label} - empty input decodes to empty output.`);
|
||||
});
|
||||
</script>
|
|
@ -0,0 +1,32 @@
|
|||
// Decode an URL encoded string, using XHR and data: URL. Returns a Promise.
|
||||
function decode(label, url_encoded_string) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const req = new XMLHttpRequest;
|
||||
req.open('GET', `data:text/plain,${url_encoded_string}`);
|
||||
req.overrideMimeType(`text/plain; charset="${label}"`);
|
||||
req.send();
|
||||
req.onload = () => resolve(req.responseText);
|
||||
req.onerror = () => reject(new Error(req.statusText));
|
||||
});
|
||||
}
|
||||
|
||||
// Convert code units in a decoded string into: "U+0001/U+0002/...'
|
||||
function to_code_units(string) {
|
||||
return string.split('')
|
||||
.map(unit => unit.charCodeAt(0))
|
||||
.map(code => 'U+' + ('0000' + code.toString(16).toUpperCase()).slice(-4))
|
||||
.join('/');
|
||||
}
|
||||
|
||||
function decode_test(label,
|
||||
url_encoded_input,
|
||||
expected_code_units,
|
||||
description) {
|
||||
promise_test(() => {
|
||||
return decode(label, url_encoded_input)
|
||||
.then(decoded => to_code_units(decoded))
|
||||
.then(actual => {
|
||||
assert_equals(actual, expected_code_units, `Decoding with ${label}`);
|
||||
});
|
||||
}, description);
|
||||
}
|
|
@ -431,7 +431,8 @@ var encodings_table =
|
|||
"hz-gb-2312",
|
||||
"iso-2022-cn",
|
||||
"iso-2022-cn-ext",
|
||||
"iso-2022-kr"
|
||||
"iso-2022-kr",
|
||||
"replacement"
|
||||
],
|
||||
"name": "replacement"
|
||||
},
|
||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -25,7 +25,7 @@
|
|||
"ISO-8859-15":[128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,8364,165,352,167,353,169,170,171,172,173,174,175,176,177,178,179,381,181,182,183,382,185,186,187,338,339,376,191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255],
|
||||
"ISO-8859-16":[128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,260,261,321,8364,8222,352,167,353,169,536,171,377,173,378,379,176,177,268,322,381,8221,182,183,382,269,537,187,338,339,376,380,192,193,194,258,196,262,198,199,200,201,202,203,204,205,206,207,272,323,210,211,212,336,214,346,368,217,218,219,220,280,538,223,224,225,226,259,228,263,230,231,232,233,234,235,236,237,238,239,273,324,242,243,244,337,246,347,369,249,250,251,252,281,539,255],
|
||||
"KOI8-R":[9472,9474,9484,9488,9492,9496,9500,9508,9516,9524,9532,9600,9604,9608,9612,9616,9617,9618,9619,8992,9632,8729,8730,8776,8804,8805,160,8993,176,178,183,247,9552,9553,9554,1105,9555,9556,9557,9558,9559,9560,9561,9562,9563,9564,9565,9566,9567,9568,9569,1025,9570,9571,9572,9573,9574,9575,9576,9577,9578,9579,9580,169,1102,1072,1073,1094,1076,1077,1092,1075,1093,1080,1081,1082,1083,1084,1085,1086,1087,1103,1088,1089,1090,1091,1078,1074,1100,1099,1079,1096,1101,1097,1095,1098,1070,1040,1041,1062,1044,1045,1060,1043,1061,1048,1049,1050,1051,1052,1053,1054,1055,1071,1056,1057,1058,1059,1046,1042,1068,1067,1047,1064,1069,1065,1063,1066],
|
||||
"KOI8-U":[9472,9474,9484,9488,9492,9496,9500,9508,9516,9524,9532,9600,9604,9608,9612,9616,9617,9618,9619,8992,9632,8729,8730,8776,8804,8805,160,8993,176,178,183,247,9552,9553,9554,1105,1108,9556,1110,1111,9559,9560,9561,9562,9563,1169,9565,9566,9567,9568,9569,1025,1028,9571,1030,1031,9574,9575,9576,9577,9578,1168,9580,169,1102,1072,1073,1094,1076,1077,1092,1075,1093,1080,1081,1082,1083,1084,1085,1086,1087,1103,1088,1089,1090,1091,1078,1074,1100,1099,1079,1096,1101,1097,1095,1098,1070,1040,1041,1062,1044,1045,1060,1043,1061,1048,1049,1050,1051,1052,1053,1054,1055,1071,1056,1057,1058,1059,1046,1042,1068,1067,1047,1064,1069,1065,1063,1066],
|
||||
"KOI8-U":[9472,9474,9484,9488,9492,9496,9500,9508,9516,9524,9532,9600,9604,9608,9612,9616,9617,9618,9619,8992,9632,8729,8730,8776,8804,8805,160,8993,176,178,183,247,9552,9553,9554,1105,1108,9556,1110,1111,9559,9560,9561,9562,9563,1169,1118,9566,9567,9568,9569,1025,1028,9571,1030,1031,9574,9575,9576,9577,9578,1168,1038,169,1102,1072,1073,1094,1076,1077,1092,1075,1093,1080,1081,1082,1083,1084,1085,1086,1087,1103,1088,1089,1090,1091,1078,1074,1100,1099,1079,1096,1101,1097,1095,1098,1070,1040,1041,1062,1044,1045,1060,1043,1061,1048,1049,1050,1051,1052,1053,1054,1055,1071,1056,1057,1058,1059,1046,1042,1068,1067,1047,1064,1069,1065,1063,1066],
|
||||
"macintosh":[196,197,199,201,209,214,220,225,224,226,228,227,229,231,233,232,234,235,237,236,238,239,241,243,242,244,246,245,250,249,251,252,8224,176,162,163,167,8226,182,223,174,169,8482,180,168,8800,198,216,8734,177,8804,8805,165,181,8706,8721,8719,960,8747,170,186,937,230,248,191,161,172,8730,402,8776,8710,171,187,8230,160,192,195,213,338,339,8211,8212,8220,8221,8216,8217,247,9674,255,376,8260,8364,8249,8250,64257,64258,8225,183,8218,8222,8240,194,202,193,203,200,205,206,207,204,211,212,63743,210,218,219,217,305,710,732,175,728,729,730,184,733,731,711],
|
||||
"windows-874":[8364,129,130,131,132,8230,134,135,136,137,138,139,140,141,142,143,144,8216,8217,8220,8221,8226,8211,8212,152,153,154,155,156,157,158,159,160,3585,3586,3587,3588,3589,3590,3591,3592,3593,3594,3595,3596,3597,3598,3599,3600,3601,3602,3603,3604,3605,3606,3607,3608,3609,3610,3611,3612,3613,3614,3615,3616,3617,3618,3619,3620,3621,3622,3623,3624,3625,3626,3627,3628,3629,3630,3631,3632,3633,3634,3635,3636,3637,3638,3639,3640,3641,3642,null,null,null,null,3647,3648,3649,3650,3651,3652,3653,3654,3655,3656,3657,3658,3659,3660,3661,3662,3663,3664,3665,3666,3667,3668,3669,3670,3671,3672,3673,3674,3675,null,null,null,null],
|
||||
"windows-1250":[8364,129,8218,131,8222,8230,8224,8225,136,8240,352,8249,346,356,381,377,144,8216,8217,8220,8221,8226,8211,8212,152,8482,353,8250,347,357,382,378,160,711,728,321,164,260,166,167,168,169,350,171,172,173,174,379,176,177,731,322,180,181,182,183,184,261,351,187,317,733,318,380,340,193,194,258,196,313,262,199,268,201,280,203,282,205,206,270,272,323,327,211,212,336,214,215,344,366,218,368,220,221,354,223,341,225,226,259,228,314,263,231,269,233,281,235,283,237,238,271,273,324,328,243,244,337,246,247,345,367,250,369,252,253,355,729],
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
<!DOCTYPE html>
|
||||
<title>Encoding API: unsupported encodings</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="resources/decoding-helpers.js"></script>
|
||||
<script>
|
||||
|
||||
// Attempting to decode '<' as UTF-7 (+AD4) ends up as '+AD4'.
|
||||
['UTF-7', 'utf-7'].forEach(label => {
|
||||
decode_test(label, '+AD4', 'U+002B/U+0041/U+0044/U+0034',
|
||||
`${label} should not be supported`);
|
||||
});
|
||||
|
||||
// UTF-32 will be detected as UTF-16LE if leading BOM, or windows-1252 otherwise.
|
||||
['UTF-32', 'utf-32', 'UTF-32LE', 'utf-32le'].forEach(label => {
|
||||
decode_test(label,
|
||||
'%FF%FE%00%00%41%00%00%00%42%00%00%00',
|
||||
'U+0000/U+0041/U+0000/U+0042/U+0000',
|
||||
`${label} with BOM should decode as UTF-16LE`);
|
||||
|
||||
decode_test(label,
|
||||
'%41%00%00%00%42%00%00%00',
|
||||
'U+0041/U+0000/U+0000/U+0000/U+0042/U+0000/U+0000/U+0000',
|
||||
`${label} with no BOM should decode as windows-1252`);;
|
||||
});
|
||||
['UTF-32be', 'utf-32be'].forEach(label => {
|
||||
decode_test(label,
|
||||
'%00%00%00%41%00%00%00%42',
|
||||
'U+0000/U+0000/U+0000/U+0041/U+0000/U+0000/U+0000/U+0042',
|
||||
`${label} with no BOM should decode as windows-1252`);
|
||||
|
||||
decode_test(label,
|
||||
'%00%00%FE%FF%00%00%00%41%00%00%00%42',
|
||||
'U+0000/U+0000/U+00FE/U+00FF/U+0000/U+0000/U+0000/U+0041/U+0000/U+0000/U+0000/U+0042',
|
||||
`${label} with BOM should decode as windows-1252`);
|
||||
});
|
||||
</script>
|
37
tests/wpt/web-platform-tests/encoding/utf-32.html
Normal file
37
tests/wpt/web-platform-tests/encoding/utf-32.html
Normal file
|
@ -0,0 +1,37 @@
|
|||
<!DOCTYPE html>
|
||||
<title>Character Decoding: UTF-32 (not supported)</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<body>
|
||||
<script>
|
||||
|
||||
// Since UTF-32 is not supported, such content will be interpreted
|
||||
// as the default HTML encoding (windows-1252) unless it has a
|
||||
// leading little endian BOM (FF FE 00 00), in which case it will
|
||||
// be interpreted as UTF-16LE.
|
||||
|
||||
const samples = [
|
||||
{file: 'resources/utf-32-big-endian-bom.html', expected: 'windows-1252'},
|
||||
{file: 'resources/utf-32-big-endian-bom.xml', expected: 'windows-1252'},
|
||||
{file: 'resources/utf-32-big-endian-nobom.html', expected: 'windows-1252'},
|
||||
{file: 'resources/utf-32-big-endian-nobom.xml', expected: 'windows-1252'},
|
||||
|
||||
{file: 'resources/utf-32-little-endian-bom.html', expected: 'UTF-16LE'},
|
||||
{file: 'resources/utf-32-little-endian-bom.xml', expected: 'UTF-16LE'},
|
||||
{file: 'resources/utf-32-little-endian-nobom.html', expected: 'windows-1252'},
|
||||
{file: 'resources/utf-32-little-endian-nobom.xml', expected: 'windows-1252'}
|
||||
];
|
||||
|
||||
samples.forEach(sample => async_test(t => {
|
||||
const iframe = document.createElement('iframe');
|
||||
iframe.src = sample.file;
|
||||
iframe.onload = t.step_func(() => {
|
||||
assert_equals(iframe.contentDocument.characterSet, sample.expected);
|
||||
t.done();
|
||||
});
|
||||
document.body.appendChild(iframe);
|
||||
t.add_cleanup(() => iframe.remove());
|
||||
}, `Expect ${sample.file} to parse as ${sample.expected}`));
|
||||
|
||||
</script>
|
||||
</body>
|
Loading…
Add table
Add a link
Reference in a new issue