author | Masatoshi Kimura <VYV03354@nifty.ne.jp> |
Thu, 24 Mar 2016 19:27:17 +0900 | |
changeset 290230 | fbb40278805ff5a8aac8b1a1dbd8b0a180f82296 |
parent 290229 | cd3799dfd531b8a72becc4c2c78128fd052d8818 |
child 290231 | 05cf733d5b26369caeca4550a0d33e9fd099b622 |
push id | 30117 |
push user | ryanvm@gmail.com |
push date | Fri, 25 Mar 2016 15:36:00 +0000 |
treeherder | mozilla-central@b45ee3e065b7 [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | Ms2ger |
bugs | 1257877 |
milestone | 48.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
--- a/testing/web-platform/tests/encoding/api-basics.html +++ b/testing/web-platform/tests/encoding/api-basics.html @@ -10,47 +10,49 @@ test(function() { }, 'Default encodings'); test(function() { assert_array_equals(new TextEncoder().encode(), [], 'input default should be empty string') assert_array_equals(new TextEncoder().encode(undefined), [], 'input default should be empty string') }, 'Default inputs'); -function testEncodeDecodeSample(encoding, string, bytes) { +function testDecodeSample(encoding, string, bytes) { test(function() { - var encoded = new TextEncoder(encoding).encode(string); - assert_array_equals([].slice.call(encoded), bytes); assert_equals(new TextDecoder(encoding).decode(new Uint8Array(bytes)), string); assert_equals(new TextDecoder(encoding).decode(new Uint8Array(bytes).buffer), string); - }, 'Encode/decode round trip: ' + encoding); + }, 'Decode sample: ' + encoding); } // z (ASCII U+007A), cent (Latin-1 U+00A2), CJK water (BMP U+6C34), // G-Clef (non-BMP U+1D11E), PUA (BMP U+F8FF), PUA (non-BMP U+10FFFD) // byte-swapped BOM (non-character U+FFFE) var sample = 'z\xA2\u6C34\uD834\uDD1E\uF8FF\uDBFF\uDFFD\uFFFE'; -testEncodeDecodeSample( - 'utf-8', - sample, - [0x7A, 0xC2, 0xA2, 0xE6, 0xB0, 0xB4, 0xF0, 0x9D, 0x84, 0x9E, 0xEF, 0xA3, 0xBF, 0xF4, 0x8F, 0xBF, 0xBD, 0xEF, 0xBF, 0xBE] -); +test(function() { + var encoding = 'utf-8'; + var string = sample; + var bytes = [0x7A, 0xC2, 0xA2, 0xE6, 0xB0, 0xB4, 0xF0, 0x9D, 0x84, 0x9E, 0xEF, 0xA3, 0xBF, 0xF4, 0x8F, 0xBF, 0xBD, 0xEF, 0xBF, 0xBE]; + var encoded = new TextEncoder().encode(string); + assert_array_equals([].slice.call(encoded), bytes); + assert_equals(new TextDecoder(encoding).decode(new Uint8Array(bytes)), string); + assert_equals(new TextDecoder(encoding).decode(new Uint8Array(bytes).buffer), string); +}, 'Encode/decode round trip: utf-8'); -testEncodeDecodeSample( +testDecodeSample( 'utf-16le', sample, [0x7A, 0x00, 0xA2, 0x00, 0x34, 0x6C, 0x34, 0xD8, 0x1E, 0xDD, 0xFF, 0xF8, 0xFF, 0xDB, 0xFD, 0xDF, 0xFE, 0xFF] ); -testEncodeDecodeSample( +testDecodeSample( 'utf-16be', sample, [0x00, 0x7A, 0x00, 0xA2, 0x6C, 0x34, 0xD8, 0x34, 0xDD, 0x1E, 0xF8, 0xFF, 0xDB, 0xFF, 0xDF, 0xFD, 0xFF, 0xFE] ); -testEncodeDecodeSample( +testDecodeSample( 'utf-16', sample, [0x7A, 0x00, 0xA2, 0x00, 0x34, 0x6C, 0x34, 0xD8, 0x1E, 0xDD, 0xFF, 0xF8, 0xFF, 0xDB, 0xFD, 0xDF, 0xFE, 0xFF] ); </script>
--- a/testing/web-platform/tests/encoding/api-invalid-label.html +++ b/testing/web-platform/tests/encoding/api-invalid-label.html @@ -19,16 +19,12 @@ setup(function() { }); }); }); }); }); tests.forEach(function(input) { test(function() { - assert_throws(new RangeError(), function() { new TextEncoder(input); }); - }, 'Invalid label ' + format_value(input) + ' should be rejected by TextEncoder.'); - - test(function() { assert_throws(new RangeError(), function() { new TextDecoder(input); }); }, 'Invalid label ' + format_value(input) + ' should be rejected by TextDecoder.'); }); </script>
--- a/testing/web-platform/tests/encoding/api-replacement-encodings.html +++ b/testing/web-platform/tests/encoding/api-replacement-encodings.html @@ -1,26 +1,24 @@ <!DOCTYPE html> <title>Encoding API: replacement encoding</title> <script src="/resources/testharness.js"></script> <script src="/resources/testharnessreport.js"></script> <script src="resources/encodings.js"></script> <script> test(function() { - assert_throws(new RangeError(), function() { new TextEncoder('replacement'); }); assert_throws(new RangeError(), function() { new TextDecoder('replacement'); }); }, 'The "replacement" label should not be a known encoding.'); encodings_table.forEach(function(section) { section.encodings.filter(function(encoding) { return encoding.name === 'replacement'; }).forEach(function(encoding) { encoding.labels.forEach(function(label) { test(function() { - assert_throws(new RangeError(), function() { new TextEncoder(label); }); assert_throws(new RangeError(), function() { new TextDecoder(label); }); }, 'Label for "replacement" should be rejected by API: ' + label); }); }); }); </script>
--- a/testing/web-platform/tests/encoding/idlharness.html +++ b/testing/web-platform/tests/encoding/idlharness.html @@ -33,17 +33,17 @@ interface TextDecoder { readonly attribute DOMString encoding; readonly attribute boolean fatal; readonly attribute boolean ignoreBOM; USVString decode(optional BufferSource input, optional TextDecodeOptions options); }; // 8.2 Interface TextDecoder -[Constructor(optional DOMString utfLabel = "utf-8"), +[Constructor, Exposed=Window,Worker] interface TextEncoder { readonly attribute DOMString encoding; [NewObject] Uint8Array encode(optional USVString input = ""); }; </script> <script>
--- a/testing/web-platform/tests/encoding/textdecoder-streaming.html +++ b/testing/web-platform/tests/encoding/textdecoder-streaming.html @@ -1,21 +1,32 @@ <!DOCTYPE html> <title>Encoding API: Streaming decode</title> <script src="/resources/testharness.js"></script> <script src="/resources/testharnessreport.js"></script> <script src="resources/encodings.js"></script> <script> -var string = '\\x00123ABCabc\\x80\\xFF\\u0100\\u1000\\uFFFD\\uD800\\uDC00\\uDBFF\\uDFFF'; +var string = '\x00123ABCabc\x80\xFF\u0100\u1000\uFFFD\uD800\uDC00\uDBFF\uDFFF'; +var octets = { + 'utf-16le': [0x00,0x00,0x31,0x00,0x32,0x00,0x33,0x00,0x41,0x00,0x42,0x00, + 0x43,0x00,0x61,0x00,0x62,0x00,0x63,0x00,0x80,0x00,0xFF,0x00, + 0x00,0x01,0x00,0x10,0xFD,0xFF,0x00,0xD8,0x00,0xDC,0xFF,0xDB, + 0xFF,0xDF], + 'utf-16be': [0x00,0x00,0x00,0x31,0x00,0x32,0x00,0x33,0x00,0x41,0x00,0x42, + 0x00,0x43,0x00,0x61,0x00,0x62,0x00,0x63,0x00,0x80,0x00,0xFF, + 0x01,0x00,0x10,0x00,0xFF,0xFD,0xD8,0x00,0xDC,0x00,0xDB,0xFF, + 0xDF,0xFF] +}; utf_encodings.forEach(function (encoding) { for (var len = 1; len <= 5; ++len) { test(function() { - var encoded = new TextEncoder(encoding).encode(string); + var encoded = octets[encoding] || + new TextEncoder(encoding).encode(string); var out = ''; var decoder = new TextDecoder(encoding); for (var i = 0; i < encoded.length; i += len) { var sub = []; for (var j = i; j < encoded.length && j < i + len; ++j) sub.push(encoded[j]); out += decoder.decode(new Uint8Array(sub), {stream: true});
--- a/testing/web-platform/tests/encoding/textencoder-constructor-non-utf.html +++ b/testing/web-platform/tests/encoding/textencoder-constructor-non-utf.html @@ -1,26 +1,22 @@ <!DOCTYPE html> <title>Encoding API: Legacy encodings</title> <script src="/resources/testharness.js"></script> <script src="/resources/testharnessreport.js"></script> <script src="resources/encodings.js"></script> <script> encodings_table.forEach(function(section) { - section.encodings.filter(function(encoding) { - return encoding.name !== 'replacement'; - }).forEach(function(encoding) { - if (utf_encodings.indexOf(encoding.name) !== -1) { + section.encodings.forEach(function(encoding) { + if (encoding.name !== 'replacement') { test(function() { assert_equals(new TextDecoder(encoding.name).encoding, encoding.name); - assert_equals(new TextEncoder(encoding.name).encoding, encoding.name); - }, 'UTF encodings are supported for encode and decode: ' + encoding.name); - } else { - test(function() { - assert_equals(new TextDecoder(encoding.name).encoding, encoding.name); - assert_throws(new RangeError(), function() { new TextEncoder(encoding.name); }); - }, 'Non-UTF encodings supported only for decode, not encode: ' + encoding.name); + }, 'Encoding argument supported for decode: ' + encoding.name); } + + test(function() { + assert_equals(new TextEncoder(encoding.name).encoding, 'utf-8'); + }, 'Encoding argument not considered for encode: ' + encoding.name); }); }); </script>