OLD | NEW |
| (Empty) |
1 <!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> | |
7 var tests = []; | |
8 setup(function() { | |
9 var whitespace = [' ', '\t', '\n', '\f', '\r']; | |
10 encodings_table.forEach(function(section) { | |
11 section.encodings.filter(function(encoding) { | |
12 return encoding.name !== 'replacement'; | |
13 }).forEach(function(encoding) { | |
14 var name = encoding.name; | |
15 encoding.labels.forEach(function(label) { | |
16 tests.push([label, encoding.name]); | |
17 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 }); | |
22 }); | |
23 }); | |
24 }); | |
25 }); | |
26 | |
27 tests.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 }); | |
36 </script> | |
OLD | NEW |