blob: 1f3202c963eb2242a0edcf8c3d363c134524030f [file] [log] [blame]
Joshua Bell7f567fa2015-01-13 17:46:571<!DOCTYPE html>
2<title>Encoding API: Encoding labels</title>
3<script src="/resources/testharness.js"></script>
4<script src="/resources/testharnessreport.js"></script>
5<script src="resources/encodings.js"></script>
6<script>
Ms2ger82514f12015-04-21 17:25:067var tests = [];
8setup(function() {
Ms2ger14536302015-04-21 17:31:599 var whitespace = [' ', '\t', '\n', '\f', '\r'];
Ms2ger82514f12015-04-21 17:25:0610 encodings_table.forEach(function(section) {
Joshua Bell7f567fa2015-01-13 17:46:5711 section.encodings.filter(function(encoding) {
Ms2ger82514f12015-04-21 17:25:0612 return encoding.name !== 'replacement';
Joshua Bell7f567fa2015-01-13 17:46:5713 }).forEach(function(encoding) {
Ms2ger82514f12015-04-21 17:25:0614 var name = encoding.name;
15 encoding.labels.forEach(function(label) {
16 tests.push([label, encoding.name]);
Ms2ger14536302015-04-21 17:31:5917 whitespace.forEach(function(ws) {
18 tests.push([ws + label, encoding.name]);
19 tests.push([label + ws, encoding.name]);
20 tests.push([ws + label + ws, encoding.name]);
21 });
Ms2ger82514f12015-04-21 17:25:0622 });
Joshua Bell7f567fa2015-01-13 17:46:5723 });
Ms2ger82514f12015-04-21 17:25:0624 });
Joshua Bell7f567fa2015-01-13 17:46:5725});
26
Ms2ger82514f12015-04-21 17:25:0627tests.forEach(function(t) {
28 var input = t[0], output = t[1];
29 test(function() {
30 assert_equals(new TextDecoder(input).encoding, output,
31 'label for encoding should match');
32 assert_equals(new TextDecoder(input.toUpperCase()).encoding, output,
33 'label matching should be case-insensitive');
34 }, format_value(input) + " => " + format_value(output));
35});
Joshua Bell7f567fa2015-01-13 17:46:5736</script>