| OLD | NEW |
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 <title>Encoding API: ScalarValueString surrogate handling when encoding</title> | 2 <title>Encoding API: USVString surrogate handling when encoding</title> |
| 3 <script src="../../../resources/testharness.js"></script> | 3 <script src="../../../resources/testharness.js"></script> |
| 4 <script src="../../../resources/testharnessreport.js"></script> | 4 <script src="../../../resources/testharnessreport.js"></script> |
| 5 <script src="resources/shared.js"></script> | 5 <script src="resources/shared.js"></script> |
| 6 <script> | 6 <script> |
| 7 | 7 |
| 8 var bad = [ | 8 var bad = [ |
| 9 { | 9 { |
| 10 input: '\uD800', | 10 input: '\uD800', |
| 11 expected: '\uFFFD', | 11 expected: '\uFFFD', |
| 12 name: 'lone surrogate lead' | 12 name: 'lone surrogate lead' |
| (...skipping 25 matching lines...) Expand all Loading... |
| 38 } | 38 } |
| 39 ]; | 39 ]; |
| 40 | 40 |
| 41 var encoding = 'utf-8'; | 41 var encoding = 'utf-8'; |
| 42 | 42 |
| 43 bad.forEach(function(t) { | 43 bad.forEach(function(t) { |
| 44 test(function() { | 44 test(function() { |
| 45 var encoded = new TextEncoder(encoding).encode(t.input); | 45 var encoded = new TextEncoder(encoding).encode(t.input); |
| 46 var decoded = new TextDecoder(encoding).decode(encoded); | 46 var decoded = new TextDecoder(encoding).decode(encoded); |
| 47 assert_equals(decoded, t.expected); | 47 assert_equals(decoded, t.expected); |
| 48 }, 'ScalarValueString handling: ' + t.name); | 48 }, 'USVString handling: ' + t.name); |
| 49 }); | 49 }); |
| 50 | 50 |
| 51 test(function() { | 51 test(function() { |
| 52 assert_equals(new TextEncoder(encoding).encode().length, 0, 'Should default
to empty string'); | 52 assert_equals(new TextEncoder(encoding).encode().length, 0, 'Should default
to empty string'); |
| 53 }, 'ScalarValueString default'); | 53 }, 'USVString default'); |
| 54 | 54 |
| 55 </script> | 55 </script> |
| OLD | NEW |