| OLD | NEW |
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 <script src="../../../resources/js-test.js"></script> | 2 <title>Encoding API: Legacy encodings</title> |
| 3 <script src="../../../resources/testharness.js"></script> |
| 4 <script src="../../../resources/testharnessreport.js"></script> |
| 3 <script src="resources/shared.js"></script> | 5 <script src="resources/shared.js"></script> |
| 4 <script> | 6 <script> |
| 5 | 7 |
| 6 description("Non-UTF encodings supported only for decode, not encode"); | |
| 7 | |
| 8 encodings_table.forEach(function(section) { | 8 encodings_table.forEach(function(section) { |
| 9 section.encodings.forEach(function(encoding) { | 9 section.encodings.forEach(function(encoding) { |
| 10 if (encoding.name === "replacement") | 10 if (encoding.name === "replacement") |
| 11 return; | 11 return; |
| 12 |
| 12 if (utf_encodings.indexOf(encoding.name) !== -1) { | 13 if (utf_encodings.indexOf(encoding.name) !== -1) { |
| 13 shouldBeEqualToString("new TextDecoder(" + JSON.stringify(encoding.n
ame) + ").encoding", encoding.name); | 14 test(function() { |
| 14 shouldBeEqualToString("new TextEncoder(" + JSON.stringify(encoding.n
ame) + ").encoding", encoding.name); | 15 assert_equals(new TextDecoder(encoding.name).encoding, encoding.
name); |
| 16 assert_equals(new TextEncoder(encoding.name).encoding, encoding.
name); |
| 17 }, "UTF encodings are supported for encode and decode"); |
| 15 } else { | 18 } else { |
| 16 shouldBeEqualToString("new TextDecoder(" + JSON.stringify(encoding.n
ame) + ").encoding", encoding.name); | 19 test(function() { |
| 17 shouldThrow("new TextEncoder(" + JSON.stringify(encoding.name) + ").
encoding"); | 20 assert_equals(new TextDecoder(encoding.name).encoding, encoding.
name); |
| 21 assert_throws({name:'TypeError'}, function() { new TextEncoder(e
ncoding.name); }); |
| 22 }, "Non-UTF encodings supported only for decode, not encode"); |
| 18 } | 23 } |
| 19 }); | 24 }); |
| 20 }); | 25 }); |
| 21 | 26 |
| 22 </script> | 27 </script> |
| OLD | NEW |