Chromium Code Reviews| Index: third_party/WebKit/LayoutTests/fast/encoding/api/utf-round-trip.html |
| diff --git a/third_party/WebKit/LayoutTests/fast/encoding/api/utf-round-trip.html b/third_party/WebKit/LayoutTests/fast/encoding/api/utf-round-trip.html |
| index b190fffd161cda862c6562aad8bacce8b5451270..319fb623e5a523564270d4c23a1224f634469eba 100644 |
| --- a/third_party/WebKit/LayoutTests/fast/encoding/api/utf-round-trip.html |
| +++ b/third_party/WebKit/LayoutTests/fast/encoding/api/utf-round-trip.html |
| @@ -30,15 +30,31 @@ function makeBatch(cp) { |
| return string; |
| } |
| + |
|
jsbell
2016/05/02 20:20:06
nit: remove this extra whitespace; one or two blan
|
| + |
| utf_encodings.forEach(function(encoding) { |
|
jsbell
2016/05/02 20:20:06
Maybe just split this into a test for utf-8 and th
lpan
2016/05/03 13:42:00
Acknowledged. Will do once I figure out how to han
jsbell
2016/05/03 22:22:48
function encode_utf16(s, littleEndian) {
var a =
|
| - test(function() { |
| - for (var i = 0; i < 0x10FFFF; i += BATCH_SIZE) { |
| - var string = makeBatch(i); |
| - var encoded = new TextEncoder(encoding).encode(string); |
| - var decoded = new TextDecoder(encoding).decode(encoded); |
| - assert_equals(decoded, string); |
| - } |
| - }, encoding + ' - encode/decode round trip'); |
| + var utf16_exception; |
|
jsbell
2016/05/02 20:20:06
this is unused - remove?
lpan
2016/05/03 13:42:00
Done.
|
| + if (encoding == "utf-8") { |
|
jsbell
2016/05/02 20:20:06
nit: prefer ===
lpan
2016/05/03 13:42:00
Acknowledged.
|
| + test(function() { |
| + for (var i = 0; i < 0x10FFFF; i += BATCH_SIZE) { |
| + var string = makeBatch(i); |
| + var encoded = new TextEncoder(encoding).encode(string); |
|
jsbell
2016/05/02 20:20:06
Don't pass argument to TextEncoder
lpan
2016/05/03 13:42:01
Acknowledged.
|
| + var decoded = new TextDecoder(encoding).decode(encoded); |
| + assert_equals(string, decoded); |
| + } |
| + }, encoding + ' - encode/decode round trip'); |
| + } |
| + else { |
|
jsbell
2016/05/02 20:20:06
nit: format as `} else {`
lpan
2016/05/03 13:42:00
Acknowledged.
|
| + test(function() { |
| + for (var i = 0; i < 0x10FFFF; i += BATCH_SIZE) { |
| + var string = makeBatch(i); |
| + var encoded = new TextEncoder(encoding).encode(string); |
|
jsbell
2016/05/02 20:20:06
Since encoding is ignored, how is this test intend
lpan
2016/05/03 13:42:00
This was my (poorly thought out) attempt at showin
jsbell
2016/05/03 22:22:48
Right, it's no longer round-trip, so maybe look to
|
| + var decoded = new TextDecoder(encoding).decode(encoded); |
| + assert_not_equals(encoded, decoded); |
| + } |
| + }, encoding + ' - legacy encoding not supported'); |
| + } |
| + |
| }); |
| @@ -61,7 +77,7 @@ test(function() { |
| for (var i = 0; i < 0x10FFFF; i += BATCH_SIZE) { |
| var string = makeBatch(i); |
| var expected = encode_utf8(string); |
| - var actual = new TextEncoder('UTF-8').encode(string); |
| + var actual = new TextEncoder().encode(string); |
| assert_array_equals(actual, expected); |
| } |
| }, 'UTF-8 encoding (compare against unescape/encodeURIComponent)'); |
| @@ -71,7 +87,7 @@ test(function() { |
| var string = makeBatch(i); |
| var encoded = encode_utf8(string); |
| var expected = decode_utf8(encoded); |
| - var actual = new TextDecoder('UTF-8').decode(new Uint8Array(encoded)); |
| + var actual = new TextDecoder().decode(new Uint8Array(encoded)); |
| assert_equals(actual, expected); |
| } |
| }, 'UTF-8 decoding (compare against decodeURIComponent/escape)'); |