| OLD | NEW |
| (Empty) | |
| 1 <!DOCTYPE html> |
| 2 <script src="../../js/resources/js-test-pre.js"></script> |
| 3 <script> |
| 4 |
| 5 description("Test invalid UTF-16 surrogate pairs with UTF-8 encoding"); |
| 6 |
| 7 var badStrings = [ |
| 8 { input: 'abc123', expected: 'abc123' }, // Sanity check. |
| 9 { input: '\ud800', expected: '\ufffd' }, // Surrogate half. |
| 10 { input: '\udc00', expected: '\ufffd' }, // Surrogate half. |
| 11 { input: 'abc\ud800def', expected: 'abc\ufffddef' }, // Surrogate half. |
| 12 { input: 'abc\udc00def', expected: 'abc\ufffddef' }, // Surrogate half. |
| 13 { input: '\udc00\ud800', expected: '\ufffd\ufffd' } // Wrong order. |
| 14 ]; |
| 15 |
| 16 badStrings.forEach( |
| 17 function(t) { |
| 18 evalAndLog("encoded = new TextEncoder('utf-8').encode(" + JSON.stringify
(t.input) + ")"); |
| 19 evalAndLog("decoded = new TextDecoder('utf-8').decode(encoded)"); |
| 20 shouldBeEqualToString("decoded", t.expected); |
| 21 debug(""); |
| 22 }); |
| 23 |
| 24 </script> |
| 25 <script src="../../js/resources/js-test-post.js"></script> |
| OLD | NEW |