diff options
| author | jsbell@chromium.org <jsbell@chromium.org> | 2015-06-20 03:40:31 +0000 |
|---|---|---|
| committer | jsbell@chromium.org <jsbell@chromium.org> | 2015-06-20 03:40:31 +0000 |
| commit | d7c198275e890b771a1a7b8f780c3683be97adde (patch) | |
| tree | 8d43bb4de8a0e75905f108ea40a806360a8aae4b | |
| parent | 7fcee6e0a75079be48065ada7035f5e0aa5a180f (diff) | |
| download | chromium_src-d7c198275e890b771a1a7b8f780c3683be97adde.zip chromium_src-d7c198275e890b771a1a7b8f780c3683be97adde.tar.gz chromium_src-d7c198275e890b771a1a7b8f780c3683be97adde.tar.bz2 | |
Remove duplicate Encoding API tests
Several of the fast/encoding/api tests were upstreamed to
web-platform-tests and can be deleted. A few were redundant
already or had cases shuffled between files.
fast/encoding/api imported/web-platform-tests/encoding
-----------------------------------------------------------------
basics.html api-basics.html
byte-order-marks.html textdecoder-byte-order-marks.html
encoding-labels.html textdecoder-labels.html
encoding-names.html textdecoder-labels.html
end-of-file.html textdecoder-fatal-streaming.html
fatal-flag.html textdecoder-fatal.html
legacy-encode.html textencoder-constructor-non-utf.html
replacement-encoding.html api-replacement-encodings.html
streaming-decode.html textdecoder-streaming.html
textdecoder-ignorebom.html textdecoder-ignorebom.html
textdecoder-labels.html textdecoder-labels.html
utf16-surrogates-encode.html textencoder-utf16-surrogates.html
utf16-surrogates.html textdecoder-utf16-surrogates.html
utf8-surrogates.html api-surrogates-utf8.html
Also rename resources/shared.js to resources/encodings.js to
align with web-platform-tests's equivalent.
R=dpranke@chromium.org
BUG=493927
Review URL: https://codereview.chromium.org/1196733003
git-svn-id: svn://svn.chromium.org/blink/trunk@197525 bbb929c8-8fbe-4397-9dbb-9b2b20218538
20 files changed, 4 insertions, 644 deletions
diff --git a/third_party/WebKit/LayoutTests/fast/encoding/api/ascii-supersets.html b/third_party/WebKit/LayoutTests/fast/encoding/api/ascii-supersets.html index fe7a1ab..312c754 100644 --- a/third_party/WebKit/LayoutTests/fast/encoding/api/ascii-supersets.html +++ b/third_party/WebKit/LayoutTests/fast/encoding/api/ascii-supersets.html @@ -2,7 +2,7 @@ <title>Encoding API: ASCII supersets</title> <script src="../../../resources/testharness.js"></script> <script src="../../../resources/testharnessreport.js"></script> -<script src="resources/shared.js"></script> +<script src="resources/encodings.js"></script> <script> // Encodings that have escape codes in 0x00-0x7F diff --git a/third_party/WebKit/LayoutTests/fast/encoding/api/basics.html b/third_party/WebKit/LayoutTests/fast/encoding/api/basics.html deleted file mode 100644 index dd33d30..0000000 --- a/third_party/WebKit/LayoutTests/fast/encoding/api/basics.html +++ /dev/null @@ -1,63 +0,0 @@ -<!DOCTYPE html> -<title>Encoding API: Basics</title> -<script src="../../../resources/testharness.js"></script> -<script src="../../../resources/testharnessreport.js"></script> -<script> - -test(function() { - - assert_true('TextEncoder' in window); - assert_true('TextDecoder' in window); - - assert_true('encoding' in new TextEncoder); - assert_true('encoding' in new TextDecoder); - assert_equals(typeof (new TextEncoder).encoding, 'string'); - assert_equals(typeof (new TextDecoder).encoding, 'string'); - - assert_true('encode' in new TextEncoder); - assert_true('decode' in new TextDecoder); - - assert_equals(typeof (new TextEncoder).encode, 'function'); - assert_equals(typeof (new TextDecoder).decode, 'function'); - - assert_equals((new TextEncoder).encoding, 'utf-8', 'default encoding is utf-8'); - assert_equals((new TextDecoder).encoding, 'utf-8', 'default encoding is utf-8'); - - 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') - - function testEncodeDecodeSample(encoding, string, bytes) { - 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); - } - - // 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] - ); - testEncodeDecodeSample( - 'utf-16le', - sample, - [0x7A, 0x00, 0xA2, 0x00, 0x34, 0x6C, 0x34, 0xD8, 0x1E, 0xDD, 0xFF, 0xF8, 0xFF, 0xDB, 0xFD, 0xDF, 0xFE, 0xFF] - ); - testEncodeDecodeSample( - 'utf-16be', - sample, - [0x00, 0x7A, 0x00, 0xA2, 0x6C, 0x34, 0xD8, 0x34, 0xDD, 0x1E, 0xF8, 0xFF, 0xDB, 0xFF, 0xDF, 0xFD, 0xFF, 0xFE] - ); - testEncodeDecodeSample( - 'utf-16', - sample, - [0x7A, 0x00, 0xA2, 0x00, 0x34, 0x6C, 0x34, 0xD8, 0x1E, 0xDD, 0xFF, 0xF8, 0xFF, 0xDB, 0xFD, 0xDF, 0xFE, 0xFF] - ); -}, 'Encoding API basics'); - -</script> diff --git a/third_party/WebKit/LayoutTests/fast/encoding/api/byte-order-marks.html b/third_party/WebKit/LayoutTests/fast/encoding/api/byte-order-marks.html deleted file mode 100644 index bf8516d..0000000 --- a/third_party/WebKit/LayoutTests/fast/encoding/api/byte-order-marks.html +++ /dev/null @@ -1,48 +0,0 @@ -<!DOCTYPE html> -<title>Encoding API: Byte-order marks</title> -<script src="../../../resources/testharness.js"></script> -<script src="../../../resources/testharnessreport.js"></script> -<script> - -var testCases = [ - { - encoding: 'utf-8', - bom: [0xEF, 0xBB, 0xBF], - bytes: [0x7A, 0xC2, 0xA2, 0xE6, 0xB0, 0xB4, 0xF0, 0x9D, 0x84, 0x9E, 0xF4, 0x8F, 0xBF, 0xBD] - }, - { - encoding: 'utf-16le', - bom: [0xff, 0xfe], - bytes: [0x7A, 0x00, 0xA2, 0x00, 0x34, 0x6C, 0x34, 0xD8, 0x1E, 0xDD, 0xFF, 0xDB, 0xFD, 0xDF] - }, - { - encoding: 'utf-16be', - bom: [0xfe, 0xff], - bytes: [0x00, 0x7A, 0x00, 0xA2, 0x6C, 0x34, 0xD8, 0x34, 0xDD, 0x1E, 0xDB, 0xFF, 0xDF, 0xFD] - } -]; - -var string = 'z\xA2\u6C34\uD834\uDD1E\uDBFF\uDFFD'; // z, cent, CJK water, G-Clef, Private-use character - -testCases.forEach(function(t) { - test(function() { - - var decoder = new TextDecoder(t.encoding); - assert_equals(decoder.decode(new Uint8Array(t.bytes)), string, - 'Sequence without BOM should decode successfully'); - - assert_equals(decoder.decode(new Uint8Array(t.bom.concat(t.bytes))), string, - 'Sequence with BOM should decode successfully (with no BOM present in output)'); - - testCases.forEach(function(o) { - if (o === t) - return; - - assert_not_equals(decoder.decode(new Uint8Array(o.bom.concat(t.bytes))), string, - 'Mismatching BOM should not be ignored - treated as garbage bytes.'); - }); - - }, 'Byte-order marks: ' + t.encoding); -}); - -</script> diff --git a/third_party/WebKit/LayoutTests/fast/encoding/api/encoding-labels.html b/third_party/WebKit/LayoutTests/fast/encoding/api/encoding-labels.html deleted file mode 100644 index 653aa88..0000000 --- a/third_party/WebKit/LayoutTests/fast/encoding/api/encoding-labels.html +++ /dev/null @@ -1,21 +0,0 @@ -<!DOCTYPE html> -<title>Encoding API: Encoding labels</title> -<script src="../../../resources/testharness.js"></script> -<script src="../../../resources/testharnessreport.js"></script> -<script src="resources/shared.js"></script> -<script> - -encodings_table.forEach(function(section) { - section.encodings.filter(function(encoding) { - return encoding.name !== 'replacement'; - }).forEach(function(encoding) { - var name = encoding.name; - encoding.labels.forEach(function(label) { - test(function(){ - assert_equals(new TextDecoder(label).encoding, encoding.name); - }, 'name=' + name + ' label=' + label); - }); - }); -}); - -</script> diff --git a/third_party/WebKit/LayoutTests/fast/encoding/api/encoding-names.html b/third_party/WebKit/LayoutTests/fast/encoding/api/encoding-names.html deleted file mode 100644 index cbc3ff4..0000000 --- a/third_party/WebKit/LayoutTests/fast/encoding/api/encoding-names.html +++ /dev/null @@ -1,29 +0,0 @@ -<!DOCTYPE html> -<title>Encoding API: Encoding names</title> -<script src="../../../resources/testharness.js"></script> -<script src="../../../resources/testharnessreport.js"></script> -<script src="resources/shared.js"></script> -<script> - -test(function() { - - var encodings = [ - { label: 'utf-8', encoding: 'utf-8' }, - { label: 'utf-16', encoding: 'utf-16le' }, - { label: 'utf-16le', encoding: 'utf-16le' }, - { label: 'utf-16be', encoding: 'utf-16be' }, - { label: 'ascii', encoding: 'windows-1252' }, - { label: 'iso-8859-1', encoding: 'windows-1252' } - ]; - - // encoding-labels.html tests the full set of names/labels; this test just - // exercises some common cases and case-insensitivity. - - encodings.forEach(function(t) { - assert_equals(new TextDecoder(t.label.toLowerCase()).encoding, t.encoding); - assert_equals(new TextDecoder(t.label.toUpperCase()).encoding, t.encoding); - }); - -}, 'Encoding labels are case-insensitive'); - -</script> diff --git a/third_party/WebKit/LayoutTests/fast/encoding/api/end-of-file.html b/third_party/WebKit/LayoutTests/fast/encoding/api/end-of-file.html deleted file mode 100644 index 3c32b60..0000000 --- a/third_party/WebKit/LayoutTests/fast/encoding/api/end-of-file.html +++ /dev/null @@ -1,50 +0,0 @@ -<!DOCTYPE html> -<title>Encoding API: End-of-file</title> -<script src="../../../resources/testharness.js"></script> -<script src="../../../resources/testharnessreport.js"></script> -<script> - -test(function() { - [ - {encoding: 'utf-8', sequence: [0xC0]}, - {encoding: 'utf-16le', sequence: [0x00]}, - {encoding: 'utf-16be', sequence: [0x00]} - ].forEach(function(testCase) { - - assert_throws({name: 'TypeError'}, function() { - var decoder = new TextDecoder(testCase.encoding, {fatal: true}); - decoder.decode(new Uint8Array(testCase.sequence)); - }, 'Unterminated ' + testCase.encoding + ' sequence should throw if fatal flag is set'); - - assert_equals( - new TextDecoder(testCase.encoding).decode(new Uint8Array([testCase.sequence])), - '\uFFFD', - 'Unterminated UTF-8 sequence should emit replacement character if fatal flag is unset'); - }); -}, 'Fatal flag, non-streaming cases'); - -test(function() { - - var decoder = new TextDecoder('utf-16le', {fatal: true}); - var odd = new Uint8Array([0x00]); - var even = new Uint8Array([0x00, 0x00]); - - assert_equals(decoder.decode(odd, {stream: true}), ''); - assert_equals(decoder.decode(odd), '\u0000'); - - assert_throws({name: 'TypeError'}, function() { - decoder.decode(even, {stream: true}); - decoder.decode(odd) - }); - - assert_throws({name: 'TypeError'}, function() { - decoder.decode(odd, {stream: true}); - decoder.decode(even); - }); - - assert_equals(decoder.decode(even, {stream: true}), '\u0000'); - assert_equals(decoder.decode(even), '\u0000'); - -}, 'Fatal flag, streaming cases'); - -</script> diff --git a/third_party/WebKit/LayoutTests/fast/encoding/api/fatal-flag.html b/third_party/WebKit/LayoutTests/fast/encoding/api/fatal-flag.html deleted file mode 100644 index 7cf19376..0000000 --- a/third_party/WebKit/LayoutTests/fast/encoding/api/fatal-flag.html +++ /dev/null @@ -1,73 +0,0 @@ -<!DOCTYPE html> -<title>Encoding API: Fatal flag</title> -<script src="../../../resources/testharness.js"></script> -<script src="../../../resources/testharnessreport.js"></script> -<script src="resources/shared.js"></script> -<script> - -var bad = [ - { encoding: 'utf-8', input: [0xFF], name: 'invalid code' }, - { encoding: 'utf-8', input: [0xC0], name: 'ends early' }, - { encoding: 'utf-8', input: [0xC0, 0x00], name: 'invalid trail' }, - { encoding: 'utf-8', input: [0xC0, 0xC0], name: 'invalid trail' }, - { encoding: 'utf-8', input: [0xE0], name: 'ends early' }, - { encoding: 'utf-8', input: [0xE0, 0x00], name: 'invalid trail' }, - { encoding: 'utf-8', input: [0xE0, 0xC0], name: 'invalid trail' }, - { encoding: 'utf-8', input: [0xE0, 0x80, 0x00], name: 'invalid trail' }, - { encoding: 'utf-8', input: [0xE0, 0x80, 0xC0], name: 'invalid trail' }, - { encoding: 'utf-8', input: [0xFC, 0x80, 0x80, 0x80, 0x80, 0x80], name: '> 0x10FFFF' }, - { encoding: 'utf-8', input: [0xFE, 0x80, 0x80, 0x80, 0x80, 0x80], name: 'obsolete lead byte' }, - - // Overlong encodings - { encoding: 'utf-8', input: [0xC0, 0x80], name: 'overlong U+0000 - 2 bytes' }, - { encoding: 'utf-8', input: [0xE0, 0x80, 0x80], name: 'overlong U+0000 - 3 bytes' }, - { encoding: 'utf-8', input: [0xF0, 0x80, 0x80, 0x80], name: 'overlong U+0000 - 4 bytes' }, - { encoding: 'utf-8', input: [0xF8, 0x80, 0x80, 0x80, 0x80], name: 'overlong U+0000 - 5 bytes' }, - { encoding: 'utf-8', input: [0xFC, 0x80, 0x80, 0x80, 0x80, 0x80], name: 'overlong U+0000 - 6 bytes' }, - - { encoding: 'utf-8', input: [0xC1, 0xBF], name: 'overlong U+007F - 2 bytes' }, - { encoding: 'utf-8', input: [0xE0, 0x81, 0xBF], name: 'overlong U+007F - 3 bytes' }, - { encoding: 'utf-8', input: [0xF0, 0x80, 0x81, 0xBF], name: 'overlong U+007F - 4 bytes' }, - { encoding: 'utf-8', input: [0xF8, 0x80, 0x80, 0x81, 0xBF], name: 'overlong U+007F - 5 bytes' }, - { encoding: 'utf-8', input: [0xFC, 0x80, 0x80, 0x80, 0x81, 0xBF], name: 'overlong U+007F - 6 bytes' }, - - { encoding: 'utf-8', input: [0xE0, 0x9F, 0xBF], name: 'overlong U+07FF - 3 bytes' }, - { encoding: 'utf-8', input: [0xF0, 0x80, 0x9F, 0xBF], name: 'overlong U+07FF - 4 bytes' }, - { encoding: 'utf-8', input: [0xF8, 0x80, 0x80, 0x9F, 0xBF], name: 'overlong U+07FF - 5 bytes' }, - { encoding: 'utf-8', input: [0xFC, 0x80, 0x80, 0x80, 0x9F, 0xBF], name: 'overlong U+07FF - 6 bytes' }, - - { encoding: 'utf-8', input: [0xF0, 0x8F, 0xBF, 0xBF], name: 'overlong U+FFFF - 4 bytes' }, - { encoding: 'utf-8', input: [0xF8, 0x80, 0x8F, 0xBF, 0xBF], name: 'overlong U+FFFF - 5 bytes' }, - { encoding: 'utf-8', input: [0xFC, 0x80, 0x80, 0x8F, 0xBF, 0xBF], name: 'overlong U+FFFF - 6 bytes' }, - - { encoding: 'utf-8', input: [0xF8, 0x84, 0x8F, 0xBF, 0xBF], name: 'overlong U+10FFFF - 5 bytes' }, - { encoding: 'utf-8', input: [0xFC, 0x80, 0x84, 0x8F, 0xBF, 0xBF], name: 'overlong U+10FFFF - 6 bytes' }, - - // UTF-16 surrogates encoded as code points in UTF-8 - { encoding: 'utf-8', input: [0xED, 0xA0, 0x80], name: 'lead surrogate' }, - { encoding: 'utf-8', input: [0xED, 0xB0, 0x80], name: 'trail surrogate' }, - { encoding: 'utf-8', input: [0xED, 0xA0, 0x80, 0xED, 0xB0, 0x80], name: 'surrogate pair' }, - - { encoding: 'utf-16le', input: [0x00], name: 'truncated code unit' }, - // Mismatched UTF-16 surrogates are exercised in utf16-surrogates.html - - // FIXME: Add legacy encoding cases -]; - -bad.forEach(function(t) { - test(function() { - assert_throws({name: 'TypeError'}, function() { - new TextDecoder(t.encoding, {fatal: true}).decode(new Uint8Array(t.input)) - }); - }, 'Fatal flag: ' + t.encoding + ' - ' + t.name); -}); - -test(function() { - assert_true('fatal' in new TextDecoder(), 'The fatal attribute should exist on TextDecoder.'); - assert_equals(typeof new TextDecoder().fatal, 'boolean', 'The type of the fatal attribute should be boolean.'); - assert_false(new TextDecoder().fatal, 'The fatal attribute should default to false.'); - assert_true(new TextDecoder('utf-8', {fatal: true}).fatal, 'The fatal attribute can be set using an option.'); - -}, 'The fatal attribute of TextDecoder'); - -</script> diff --git a/third_party/WebKit/LayoutTests/fast/encoding/api/latin-1.html b/third_party/WebKit/LayoutTests/fast/encoding/api/latin-1.html index 6d8fafa..b5815fd 100644 --- a/third_party/WebKit/LayoutTests/fast/encoding/api/latin-1.html +++ b/third_party/WebKit/LayoutTests/fast/encoding/api/latin-1.html @@ -2,7 +2,7 @@ <title>Encoding API: Latin-1 decoders</title> <script src="../../../resources/testharness.js"></script> <script src="../../../resources/testharnessreport.js"></script> -<script src="resources/shared.js"></script> +<script src="resources/encodings.js"></script> <script> // Blink uses separate decoder object intances for these encoding aliases, diff --git a/third_party/WebKit/LayoutTests/fast/encoding/api/legacy-encode.html b/third_party/WebKit/LayoutTests/fast/encoding/api/legacy-encode.html deleted file mode 100644 index 0eb291a..0000000 --- a/third_party/WebKit/LayoutTests/fast/encoding/api/legacy-encode.html +++ /dev/null @@ -1,26 +0,0 @@ -<!DOCTYPE html> -<title>Encoding API: Legacy encodings</title> -<script src="../../../resources/testharness.js"></script> -<script src="../../../resources/testharnessreport.js"></script> -<script src="resources/shared.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) { - 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({name: 'RangeError'}, function() { new TextEncoder(encoding.name); }); - }, 'Non-UTF encodings supported only for decode, not encode: ' + encoding.name); - } - }); -}); - -</script> diff --git a/third_party/WebKit/LayoutTests/fast/encoding/api/replacement-encoding.html b/third_party/WebKit/LayoutTests/fast/encoding/api/replacement-encoding.html deleted file mode 100644 index 0099519..0000000 --- a/third_party/WebKit/LayoutTests/fast/encoding/api/replacement-encoding.html +++ /dev/null @@ -1,26 +0,0 @@ -<!DOCTYPE html> -<title>Encoding API: replacement encoding</title> -<script src="../../../resources/testharness.js"></script> -<script src="../../../resources/testharnessreport.js"></script> -<script src="resources/shared.js"></script> -<script> - -test(function() { - assert_throws({name: 'RangeError'}, function() { new TextEncoder('replacement'); }); - assert_throws({name: '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({name: 'RangeError'}, function() { new TextEncoder(label); }); - assert_throws({name: 'RangeError'}, function() { new TextDecoder(label); }); - }, 'Label for "replacement" should be rejected by API: ' + label); - }); - }); -}); - -</script> diff --git a/third_party/WebKit/LayoutTests/fast/encoding/api/resources/shared.js b/third_party/WebKit/LayoutTests/fast/encoding/api/resources/encodings.js index 0c9e5e6..0c9e5e6 100644 --- a/third_party/WebKit/LayoutTests/fast/encoding/api/resources/shared.js +++ b/third_party/WebKit/LayoutTests/fast/encoding/api/resources/encodings.js diff --git a/third_party/WebKit/LayoutTests/fast/encoding/api/streaming-decode.html b/third_party/WebKit/LayoutTests/fast/encoding/api/streaming-decode.html deleted file mode 100644 index 34ffccc..0000000 --- a/third_party/WebKit/LayoutTests/fast/encoding/api/streaming-decode.html +++ /dev/null @@ -1,29 +0,0 @@ -<!DOCTYPE html> -<title>Encoding API: Streaming decode</title> -<script src="../../../resources/testharness.js"></script> -<script src="../../../resources/testharnessreport.js"></script> -<script src="resources/shared.js"></script> -<script> - -var string = '\\x00123ABCabc\\x80\\xFF\\u0100\\u1000\\uFFFD\\uD800\\uDC00\\uDBFF\\uDFFF'; - -utf_encodings.forEach(function (encoding) { - for (var len = 1; len <= 5; ++len) { - test(function() { - var encoded = 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}); - } - out += decoder.decode(); - assert_equals(out, string); - }, 'Streaming decode: ' + encoding + ', ' + len + ' byte window'); - } -}); - -</script> diff --git a/third_party/WebKit/LayoutTests/fast/encoding/api/textdecoder-ignorebom.html b/third_party/WebKit/LayoutTests/fast/encoding/api/textdecoder-ignorebom.html deleted file mode 100644 index 6770b53..0000000 --- a/third_party/WebKit/LayoutTests/fast/encoding/api/textdecoder-ignorebom.html +++ /dev/null @@ -1,45 +0,0 @@ -<!DOCTYPE html> -<title>Encoding API: TextDecoder ignoreBOM option</title> -<script src="../../../resources/testharness.js"></script> -<script src="../../../resources/testharnessreport.js"></script> -<script> - -var cases = [ - {encoding: 'utf-8', bytes: [0xEF, 0xBB, 0xBF, 0x61, 0x62, 0x63]}, - {encoding: 'utf-16le', bytes: [0xFF, 0xFE, 0x61, 0x00, 0x62, 0x00, 0x63, 0x00]}, - {encoding: 'utf-16be', bytes: [0xFE, 0xFF, 0x00, 0x61, 0x00, 0x62, 0x00, 0x63]} -]; - -cases.forEach(function(testCase) { - test(function() { - var BOM = '\uFEFF'; - var decoder = new TextDecoder(testCase.encoding, {ignoreBOM: true}); - var bytes = new Uint8Array(testCase.bytes); - assert_equals( - decoder.decode(bytes), - BOM + 'abc', - testCase.encoding + ': BOM should be present in decoded string if ignored'); - - decoder = new TextDecoder(testCase.encoding, {ignoreBOM: false}); - assert_equals( - decoder.decode(bytes), - 'abc', - testCase.encoding + ': BOM should be absent from decoded string if not ignored'); - - decoder = new TextDecoder(testCase.encoding); - assert_equals( - decoder.decode(bytes), - 'abc', - testCase.encoding + ': BOM should be absent from decoded string by default'); - }, 'BOM is ignored if ignoreBOM option is specified: ' + testCase.encoding); -}); - -test(function() { - assert_true('ignoreBOM' in new TextDecoder(), 'The ignoreBOM attribute should exist on TextDecoder.'); - assert_equals(typeof new TextDecoder().ignoreBOM, 'boolean', 'The type of the ignoreBOM attribute should be boolean.'); - assert_false(new TextDecoder().ignoreBOM, 'The ignoreBOM attribute should default to false.'); - assert_true(new TextDecoder('utf-8', {ignoreBOM: true}).ignoreBOM, 'The ignoreBOM attribute can be set using an option.'); - -}, 'The ignoreBOM attribute of TextDecoder'); - -</script> diff --git a/third_party/WebKit/LayoutTests/fast/encoding/api/textdecoder-labels.html b/third_party/WebKit/LayoutTests/fast/encoding/api/textdecoder-labels.html deleted file mode 100644 index 1b38ce3..0000000 --- a/third_party/WebKit/LayoutTests/fast/encoding/api/textdecoder-labels.html +++ /dev/null @@ -1,51 +0,0 @@ -<!DOCTYPE html> -<title>Encoding API: TextDecoder labels and whitespace</title> -<script src="../../../resources/testharness.js"></script> -<script src="../../../resources/testharnessreport.js"></script> -<script src="resources/shared.js"></script> -<script> -var tests = [], failure_tests = []; -setup(function() { - var whitespace = [' ', '\t', '\n', '\f', '\r']; - var bad_whitespace = ['\u000B', '\u00A0', '\u2028', '\u2029']; - encodings_table.forEach(function(section) { - section.encodings.filter(function(encoding) { - return encoding.name !== 'replacement'; - }).forEach(function(encoding) { - var name = encoding.name; - encoding.labels.forEach(function(label) { - tests.push([label, encoding.name]); - whitespace.forEach(function(ws) { - tests.push([ws + label, encoding.name]); - tests.push([label + ws, encoding.name]); - tests.push([ws + label + ws, encoding.name]); - }); - bad_whitespace.forEach(function(ws) { - failure_tests.push([ws + label, encoding.name]); - failure_tests.push([label + ws, encoding.name]); - failure_tests.push([ws + label + ws, encoding.name]); - }); - }); - }); - }); -}); - -tests.forEach(function(t) { - var input = t[0], output = t[1]; - test(function() { - assert_equals(new TextDecoder(input).encoding, output, - 'label for encoding should match'); - assert_equals(new TextDecoder(input.toUpperCase()).encoding, output, - 'label matching should be case-insensitive'); - }, format_value(input) + " => " + format_value(output)); -}); - -failure_tests.forEach(function(t) { - var input = t[0], output = t[1]; - test(function() { - assert_throws({name:'RangeError'}, - function() { new TextDecoder(input); }, - 'non-ASCII whitespace should not be stripped'); - }, format_value(input) + " => " + format_value(output)); -}); -</script> diff --git a/third_party/WebKit/LayoutTests/fast/encoding/api/textencoder-labels.html b/third_party/WebKit/LayoutTests/fast/encoding/api/textencoder-labels.html index c71bdab..1ec3daf 100644 --- a/third_party/WebKit/LayoutTests/fast/encoding/api/textencoder-labels.html +++ b/third_party/WebKit/LayoutTests/fast/encoding/api/textencoder-labels.html @@ -2,7 +2,7 @@ <title>Encoding API: TextEncoder labels and whitespace</title> <script src="../../../resources/testharness.js"></script> <script src="../../../resources/testharnessreport.js"></script> -<script src="resources/shared.js"></script> +<script src="resources/encodings.js"></script> <script> var tests = [], failure_tests = []; setup(function() { 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 70c17ba..b190fff 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 @@ -2,7 +2,7 @@ <title>Encoding API: UTF encoding round trips</title> <script src="../../../resources/testharness.js"></script> <script src="../../../resources/testharnessreport.js"></script> -<script src="resources/shared.js"></script> +<script src="resources/encodings.js"></script> <script> var BATCH_SIZE = 0x1000; // Convert in batches spanning this many code points. diff --git a/third_party/WebKit/LayoutTests/fast/encoding/api/utf16-surrogates-encode.html b/third_party/WebKit/LayoutTests/fast/encoding/api/utf16-surrogates-encode.html deleted file mode 100644 index 03e545c..0000000 --- a/third_party/WebKit/LayoutTests/fast/encoding/api/utf16-surrogates-encode.html +++ /dev/null @@ -1,55 +0,0 @@ -<!DOCTYPE html> -<title>Encoding API: USVString surrogate handling when encoding</title> -<script src="../../../resources/testharness.js"></script> -<script src="../../../resources/testharnessreport.js"></script> -<script src="resources/shared.js"></script> -<script> - -var bad = [ - { - input: '\uD800', - expected: '\uFFFD', - name: 'lone surrogate lead' - }, - { - input: '\uDC00', - expected: '\uFFFD', - name: 'lone surrogate trail' - }, - { - input: '\uD800\u0000', - expected: '\uFFFD\u0000', - name: 'unmatched surrogate lead' - }, - { - input: '\uDC00\u0000', - expected: '\uFFFD\u0000', - name: 'unmatched surrogate trail' - }, - { - input: '\uDC00\uD800', - expected: '\uFFFD\uFFFD', - name: 'swapped surrogate pair' - }, - { - input: '\uD834\uDD1E', - expected: '\uD834\uDD1E', - name: 'properly encoded MUSICAL SYMBOL G CLEF (U+1D11E)' - } -]; - -var encoding = 'utf-8'; - -bad.forEach(function(t) { - test(function() { - var encoded = new TextEncoder(encoding).encode(t.input); - var decoded = new TextDecoder(encoding).decode(encoded); - assert_equals(decoded, t.expected); - }, 'USVString handling: ' + t.name); -}); - -test(function() { - assert_equals(new TextEncoder(encoding).encode().length, 0, 'Should default to empty string'); -}, 'USVString default'); - -</script> diff --git a/third_party/WebKit/LayoutTests/fast/encoding/api/utf16-surrogates-expected.txt b/third_party/WebKit/LayoutTests/fast/encoding/api/utf16-surrogates-expected.txt deleted file mode 100644 index dd90007c..0000000 --- a/third_party/WebKit/LayoutTests/fast/encoding/api/utf16-surrogates-expected.txt +++ /dev/null @@ -1,18 +0,0 @@ -This is a testharness.js-based test. -FAIL utf-16le - lone surrogate lead assert_equals: expected "�" but got "í €" -FAIL utf-16le - lone surrogate lead (fatal flag set) assert_throws: function "function () { - new TextDecoder(t.encoding, {fa..." did not throw -FAIL utf-16le - lone surrogate trail assert_equals: expected "�" but got "í°€" -FAIL utf-16le - lone surrogate trail (fatal flag set) assert_throws: function "function () { - new TextDecoder(t.encoding, {fa..." did not throw -FAIL utf-16le - unmatched surrogate lead assert_equals: expected "�\0" but got "í €\0" -FAIL utf-16le - unmatched surrogate lead (fatal flag set) assert_throws: function "function () { - new TextDecoder(t.encoding, {fa..." did not throw -FAIL utf-16le - unmatched surrogate trail assert_equals: expected "�\0" but got "í°€\0" -FAIL utf-16le - unmatched surrogate trail (fatal flag set) assert_throws: function "function () { - new TextDecoder(t.encoding, {fa..." did not throw -FAIL utf-16le - swapped surrogate pair assert_equals: expected "��" but got "í°€í €" -FAIL utf-16le - swapped surrogate pair (fatal flag set) assert_throws: function "function () { - new TextDecoder(t.encoding, {fa..." did not throw -Harness: the test ran to completion. - diff --git a/third_party/WebKit/LayoutTests/fast/encoding/api/utf16-surrogates.html b/third_party/WebKit/LayoutTests/fast/encoding/api/utf16-surrogates.html deleted file mode 100644 index cbdcdef..0000000 --- a/third_party/WebKit/LayoutTests/fast/encoding/api/utf16-surrogates.html +++ /dev/null @@ -1,52 +0,0 @@ -<!DOCTYPE html> -<title>Encoding API: UTF-16 surrogate handling</title> -<script src="../../../resources/testharness.js"></script> -<script src="../../../resources/testharnessreport.js"></script> -<script src="resources/shared.js"></script> -<script> - -var bad = [ - { - encoding: 'utf-16le', - input: [0x00, 0xd8], - expected: '\uFFFD', - name: 'lone surrogate lead' - }, - { - encoding: 'utf-16le', - input: [0x00, 0xdc], - expected: '\uFFFD', - name: 'lone surrogate trail' - }, - { - encoding: 'utf-16le', - input: [0x00, 0xd8, 0x00, 0x00], - expected: '\uFFFD\u0000', - name: 'unmatched surrogate lead' - }, - { - encoding: 'utf-16le', - input: [0x00, 0xdc, 0x00, 0x00], - expected: '\uFFFD\u0000', - name: 'unmatched surrogate trail' - }, - { - encoding: 'utf-16le', - input: [0x00, 0xdc, 0x00, 0xd8], - expected: '\uFFFD\uFFFD', - name: 'swapped surrogate pair' - } -]; - -bad.forEach(function(t) { - test(function() { - assert_equals(new TextDecoder(t.encoding).decode(new Uint8Array(t.input)), t.expected); - }, t.encoding + ' - ' + t.name); - test(function() { - assert_throws({name: 'TypeError'}, function() { - new TextDecoder(t.encoding, {fatal: true}).decode(new Uint8Array(t.input)) - }); - }, t.encoding + ' - ' + t.name + ' (fatal flag set)'); -}); - -</script> diff --git a/third_party/WebKit/LayoutTests/fast/encoding/api/utf8-surrogates.html b/third_party/WebKit/LayoutTests/fast/encoding/api/utf8-surrogates.html deleted file mode 100644 index 96f2caf..0000000 --- a/third_party/WebKit/LayoutTests/fast/encoding/api/utf8-surrogates.html +++ /dev/null @@ -1,54 +0,0 @@ -<!DOCTYPE html> -<title>Encoding API: Invalid UTF-16 surrogates with UTF-8 encoding</title> -<script src="../../../resources/testharness.js"></script> -<script src="../../../resources/testharnessreport.js"></script> -<script> - -var badStrings = [ - { - input: 'abc123', - expected: [0x61, 0x62, 0x63, 0x31, 0x32, 0x33], - decoded: 'abc123', - name: 'Sanity check' - }, - { - input: '\uD800', - expected: [0xef, 0xbf, 0xbd], - decoded: '\uFFFD', - name: 'Surrogate half (low)' - }, - { - input: '\uDC00', - expected: [0xef, 0xbf, 0xbd], - decoded: '\uFFFD', - name: 'Surrogate half (high)' - }, - { - input: 'abc\uD800123', - expected: [0x61, 0x62, 0x63, 0xef, 0xbf, 0xbd, 0x31, 0x32, 0x33], - decoded: 'abc\uFFFD123', - name: 'Surrogate half (low), in a string' - }, - { - input: 'abc\uDC00123', - expected: [0x61, 0x62, 0x63, 0xef, 0xbf, 0xbd, 0x31, 0x32, 0x33], - decoded: 'abc\uFFFD123', - name: 'Surrogate half (high), in a string' - }, - { - input: '\uDC00\uD800', - expected: [0xef, 0xbf, 0xbd, 0xef, 0xbf, 0xbd], - decoded: '\uFFFD\uFFFD', - name: 'Wrong order' - } -]; - -badStrings.forEach(function(t) { - test(function() { - var encoded = new TextEncoder('utf-8').encode(t.input); - assert_array_equals([].slice.call(encoded), t.expected); - assert_equals(new TextDecoder('utf-8').decode(encoded), t.decoded); - }, 'Invalid surrogates encoded into UTF-8: ' + t.name); -}); - -</script> |
