| OLD | NEW |
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 <title>Encoding API: UTF encoding round trips</title> | 2 <title>Encoding API: UTF encoding round trips</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/encodings.js"></script> |
| 6 <script> | 6 <script> |
| 7 | 7 |
| 8 var BATCH_SIZE = 0x1000; // Convert in batches spanning this many code points. | 8 var BATCH_SIZE = 0x1000; // Convert in batches spanning this many code points. |
| 9 var SKIP_SIZE = 0x77; // For efficiency, don't test every code point. | 9 var SKIP_SIZE = 0x77; // For efficiency, don't test every code point. |
| 10 | 10 |
| 11 function fromCodePoint(cp) { | 11 function fromCodePoint(cp) { |
| 12 if (0xD800 <= cp && cp <= 0xDFFF) throw new Error('Invalid code point'); | 12 if (0xD800 <= cp && cp <= 0xDFFF) throw new Error('Invalid code point'); |
| 13 | 13 |
| 14 if (cp <= 0xFFFF) | 14 if (cp <= 0xFFFF) |
| 15 return String.fromCharCode(cp); | 15 return String.fromCharCode(cp); |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 for (var i = 0; i < 0x10FFFF; i += BATCH_SIZE) { | 70 for (var i = 0; i < 0x10FFFF; i += BATCH_SIZE) { |
| 71 var string = makeBatch(i); | 71 var string = makeBatch(i); |
| 72 var encoded = encode_utf8(string); | 72 var encoded = encode_utf8(string); |
| 73 var expected = decode_utf8(encoded); | 73 var expected = decode_utf8(encoded); |
| 74 var actual = new TextDecoder('UTF-8').decode(new Uint8Array(encoded)); | 74 var actual = new TextDecoder('UTF-8').decode(new Uint8Array(encoded)); |
| 75 assert_equals(actual, expected); | 75 assert_equals(actual, expected); |
| 76 } | 76 } |
| 77 }, 'UTF-8 decoding (compare against decodeURIComponent/escape)'); | 77 }, 'UTF-8 decoding (compare against decodeURIComponent/escape)'); |
| 78 | 78 |
| 79 </script> | 79 </script> |
| OLD | NEW |