Update web-platform-tests to revision 60220357131c65146444da1f54624d5b54d0975d

This commit is contained in:
WPT Sync Bot 2018-07-18 15:43:58 +00:00 committed by Tom Servo
parent c45192614c
commit 775b784f79
2144 changed files with 58115 additions and 29658 deletions

View file

@ -0,0 +1,32 @@
// META: title=Encoding API: Encoding labels
// META: script=resources/encodings.js
var whitespace = [' ', '\t', '\n', '\f', '\r'];
encodings_table.forEach(function(section) {
section.encodings.filter(function(encoding) {
return encoding.name !== 'replacement';
}).forEach(function(encoding) {
encoding.labels.forEach(function(label) {
const textDecoderName = encoding.name.toLowerCase(); // ASCII names only, so safe
test(function(t) {
assert_equals(
new TextDecoder(label).encoding, textDecoderName,
'label for encoding should match');
assert_equals(
new TextDecoder(label.toUpperCase()).encoding, textDecoderName,
'label matching should be case-insensitive');
whitespace.forEach(function(ws) {
assert_equals(
new TextDecoder(ws + label).encoding, textDecoderName,
'label for encoding with leading whitespace should match');
assert_equals(
new TextDecoder(label + ws).encoding, textDecoderName,
'label for encoding with trailing whitespace should match');
assert_equals(
new TextDecoder(ws + label + ws).encoding, textDecoderName,
'label for encoding with surrounding whitespace should match');
});
}, label + ' => ' + encoding.name);
});
});
});