Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(15)

Side by Side Diff: LayoutTests/fast/encoding/api/basics.html

Issue 313393005: Encoding API: Handle null input string (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | Source/modules/encoding/TextEncoder.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <title>Encoding API: Basics</title> 2 <title>Encoding API: Basics</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> 5 <script>
6 6
7 test(function() { 7 test(function() {
8 8
9 assert_true('TextEncoder' in window); 9 assert_true('TextEncoder' in window);
10 assert_true('TextDecoder' in window); 10 assert_true('TextDecoder' in window);
11 11
12 assert_true('encoding' in new TextEncoder); 12 assert_true('encoding' in new TextEncoder);
13 assert_true('encoding' in new TextDecoder); 13 assert_true('encoding' in new TextDecoder);
14 assert_equals(typeof (new TextEncoder).encoding, 'string'); 14 assert_equals(typeof (new TextEncoder).encoding, 'string');
15 assert_equals(typeof (new TextDecoder).encoding, 'string'); 15 assert_equals(typeof (new TextDecoder).encoding, 'string');
16 16
17 assert_true('encode' in new TextEncoder); 17 assert_true('encode' in new TextEncoder);
18 assert_true('decode' in new TextDecoder); 18 assert_true('decode' in new TextDecoder);
19 19
20 assert_equals(typeof (new TextEncoder).encode, 'function'); 20 assert_equals(typeof (new TextEncoder).encode, 'function');
21 assert_equals(typeof (new TextDecoder).decode, 'function'); 21 assert_equals(typeof (new TextDecoder).decode, 'function');
22 22
23 assert_equals((new TextEncoder).encoding, 'utf-8', 'default encoding is utf- 8'); 23 assert_equals((new TextEncoder).encoding, 'utf-8', 'default encoding is utf- 8');
24 assert_equals((new TextDecoder).encoding, 'utf-8', 'default encoding is utf- 8'); 24 assert_equals((new TextDecoder).encoding, 'utf-8', 'default encoding is utf- 8');
25 25
26 assert_array_equals(new TextEncoder().encode(), [], 'input default should be empty string')
27
26 function testEncodeDecodeSample(encoding, string, bytes) { 28 function testEncodeDecodeSample(encoding, string, bytes) {
27 var encoded = new TextEncoder(encoding).encode(string); 29 var encoded = new TextEncoder(encoding).encode(string);
28 assert_array_equals([].slice.call(encoded), bytes); 30 assert_array_equals([].slice.call(encoded), bytes);
29 assert_equals(new TextDecoder(encoding).decode(new Uint8Array(bytes)), s tring); 31 assert_equals(new TextDecoder(encoding).decode(new Uint8Array(bytes)), s tring);
30 } 32 }
31 33
32 // z (ASCII U+007A), cent (Latin-1 U+00A2), CJK water (BMP U+6C34), 34 // z (ASCII U+007A), cent (Latin-1 U+00A2), CJK water (BMP U+6C34),
33 // G-Clef (non-BMP U+1D11E), PUA (BMP U+F8FF), PUA (non-BMP U+10FFFD) 35 // G-Clef (non-BMP U+1D11E), PUA (BMP U+F8FF), PUA (non-BMP U+10FFFD)
34 // byte-swapped BOM (non-character U+FFFE) 36 // byte-swapped BOM (non-character U+FFFE)
35 var sample = 'z\xA2\u6C34\uD834\uDD1E\uF8FF\uDBFF\uDFFD\uFFFE'; 37 var sample = 'z\xA2\u6C34\uD834\uDD1E\uF8FF\uDBFF\uDFFD\uFFFE';
(...skipping 14 matching lines...) Expand all
50 [0x00, 0x7A, 0x00, 0xA2, 0x6C, 0x34, 0xD8, 0x34, 0xDD, 0x1E, 0xF8, 0xFF, 0xDB, 0xFF, 0xDF, 0xFD, 0xFF, 0xFE] 52 [0x00, 0x7A, 0x00, 0xA2, 0x6C, 0x34, 0xD8, 0x34, 0xDD, 0x1E, 0xF8, 0xFF, 0xDB, 0xFF, 0xDF, 0xFD, 0xFF, 0xFE]
51 ); 53 );
52 testEncodeDecodeSample( 54 testEncodeDecodeSample(
53 'utf-16', 55 'utf-16',
54 sample, 56 sample,
55 [0x7A, 0x00, 0xA2, 0x00, 0x34, 0x6C, 0x34, 0xD8, 0x1E, 0xDD, 0xFF, 0xF8, 0xFF, 0xDB, 0xFD, 0xDF, 0xFE, 0xFF] 57 [0x7A, 0x00, 0xA2, 0x00, 0x34, 0x6C, 0x34, 0xD8, 0x1E, 0xDD, 0xFF, 0xF8, 0xFF, 0xDB, 0xFD, 0xDF, 0xFE, 0xFF]
56 ); 58 );
57 }, 'Encoding API basics'); 59 }, 'Encoding API basics');
58 60
59 </script> 61 </script>
OLDNEW
« no previous file with comments | « no previous file | Source/modules/encoding/TextEncoder.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698