OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <title>Encoding API: USVString 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> | 5 <script> |
6 | 6 |
7 var bad = [ | 7 var bad = [ |
8 { | 8 { |
9 input: '\uD800', | 9 input: '\uD800', |
10 expected: '\uFFFD', | 10 expected: '\uFFFD', |
(...skipping 19 matching lines...) Expand all Loading... |
30 expected: '\uFFFD\uFFFD', | 30 expected: '\uFFFD\uFFFD', |
31 name: 'swapped surrogate pair' | 31 name: 'swapped surrogate pair' |
32 }, | 32 }, |
33 { | 33 { |
34 input: '\uD834\uDD1E', | 34 input: '\uD834\uDD1E', |
35 expected: '\uD834\uDD1E', | 35 expected: '\uD834\uDD1E', |
36 name: 'properly encoded MUSICAL SYMBOL G CLEF (U+1D11E)' | 36 name: 'properly encoded MUSICAL SYMBOL G CLEF (U+1D11E)' |
37 } | 37 } |
38 ]; | 38 ]; |
39 | 39 |
40 var encoding = 'utf-8'; | |
41 | |
42 bad.forEach(function(t) { | 40 bad.forEach(function(t) { |
43 test(function() { | 41 test(function() { |
44 var encoded = new TextEncoder(encoding).encode(t.input); | 42 var encoded = new TextEncoder().encode(t.input); |
45 var decoded = new TextDecoder(encoding).decode(encoded); | 43 var decoded = new TextDecoder().decode(encoded); |
46 assert_equals(decoded, t.expected); | 44 assert_equals(decoded, t.expected); |
47 }, 'USVString handling: ' + t.name); | 45 }, 'USVString handling: ' + t.name); |
48 }); | 46 }); |
49 | 47 |
50 test(function() { | 48 test(function() { |
51 assert_equals(new TextEncoder(encoding).encode().length, 0, 'Should default
to empty string'); | 49 assert_equals(new TextEncoder().encode().length, 0, 'Should default to empty
string'); |
52 }, 'USVString default'); | 50 }, 'USVString default'); |
53 | 51 |
54 </script> | 52 </script> |
OLD | NEW |