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

Side by Side Diff: LayoutTests/fast/encoding/api/fatal-flag.html

Issue 240283013: Convert Encoding API tests to W3C testharness.js (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Move UTF-16 surrogate tests to separate file Created 6 years, 7 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
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <script src="../../../resources/js-test.js"></script> 2 <title>Encoding API: Fatal flag</title>
3 <script src="../../../resources/testharness.js"></script>
4 <script src="../../../resources/testharnessreport.js"></script>
5 <script src="resources/shared.js"></script>
3 <script> 6 <script>
4 7
5 description("Test the Encoding API's 'fatal' flag"); 8 var bad = [
9 { encoding: 'utf-8', input: [0xFF], name: 'invalid code' },
10 { encoding: 'utf-8', input: [0xC0], name: 'ends early' },
11 { encoding: 'utf-8', input: [0xC0, 0x00], name: 'invalid trail' },
12 { encoding: 'utf-8', input: [0xC0, 0xC0], name: 'invalid trail' },
13 { encoding: 'utf-8', input: [0xE0], name: 'ends early' },
14 { encoding: 'utf-8', input: [0xE0, 0x00], name: 'invalid trail' },
15 { encoding: 'utf-8', input: [0xE0, 0xC0], name: 'invalid trail' },
16 { encoding: 'utf-8', input: [0xE0, 0x80, 0x00], name: 'invalid trail' },
17 { encoding: 'utf-8', input: [0xE0, 0x80, 0xC0], name: 'invalid trail' },
18 { encoding: 'utf-8', input: [0xFC, 0x80, 0x80, 0x80, 0x80, 0x80], name: '> 0 x10FFFF' },
19 { encoding: 'utf-8', input: [0xFE, 0x80, 0x80, 0x80, 0x80, 0x80], name: 'obs olete lead byte' },
6 20
7 var bad = [ 21 // Overlong encodings
8 { encoding: 'utf-8', input: "[0xC0]" }, // ends early 22 { encoding: 'utf-8', input: [0xC0, 0x80], name: 'overlong U+0000 - 2 bytes' },
9 { encoding: 'utf-8', input: "[0xC0, 0x00]" }, // invalid trail 23 { encoding: 'utf-8', input: [0xE0, 0x80, 0x80], name: 'overlong U+0000 - 3 b ytes' },
10 { encoding: 'utf-8', input: "[0xC0, 0xC0]" }, // invalid trail 24 { encoding: 'utf-8', input: [0xF0, 0x80, 0x80, 0x80], name: 'overlong U+0000 - 4 bytes' },
11 { encoding: 'utf-8', input: "[0xE0]" }, // ends early 25 { encoding: 'utf-8', input: [0xF8, 0x80, 0x80, 0x80, 0x80], name: 'overlong U+0000 - 5 bytes' },
12 { encoding: 'utf-8', input: "[0xE0, 0x00]" }, // invalid trail 26 { encoding: 'utf-8', input: [0xFC, 0x80, 0x80, 0x80, 0x80, 0x80], name: 'ove rlong U+0000 - 6 bytes' },
13 { encoding: 'utf-8', input: "[0xE0, 0xC0]" }, // invalid trail 27
14 { encoding: 'utf-8', input: "[0xE0, 0x80, 0x00]" }, // invalid trail 28 { encoding: 'utf-8', input: [0xC1, 0xBF], name: 'overlong U+007F - 2 bytes' },
15 { encoding: 'utf-8', input: "[0xE0, 0x80, 0xC0]" }, // invalid trail 29 { encoding: 'utf-8', input: [0xE0, 0x81, 0xBF], name: 'overlong U+007F - 3 b ytes' },
16 { encoding: 'utf-8', input: "[0xFC, 0x80, 0x80, 0x80, 0x80, 0x80]" }, // > 0 x10FFFF 30 { encoding: 'utf-8', input: [0xF0, 0x80, 0x81, 0xBF], name: 'overlong U+007F - 4 bytes' },
17 { encoding: 'utf-16le', input: "[0x00]" }, // truncated code unit 31 { encoding: 'utf-8', input: [0xF8, 0x80, 0x80, 0x81, 0xBF], name: 'overlong U+007F - 5 bytes' },
18 { encoding: 'utf-16le', input: "[0x00, 0xd8]" }, // surrogate half 32 { encoding: 'utf-8', input: [0xFC, 0x80, 0x80, 0x80, 0x81, 0xBF], name: 'ove rlong U+007F - 6 bytes' },
19 { encoding: 'utf-16le', input: "[0x00, 0xd8, 0x00, 0x00]" }, // surrogate ha lf 33
20 { encoding: 'utf-16le', input: "[0x00, 0xdc, 0x00, 0x00]" }, // trail surrog ate 34 { encoding: 'utf-8', input: [0xE0, 0x9F, 0xBF], name: 'overlong U+07FF - 3 b ytes' },
21 { encoding: 'utf-16le', input: "[0x00, 0xdc, 0x00, 0xd8]" } // swapped surr ogates 35 { encoding: 'utf-8', input: [0xF0, 0x80, 0x9F, 0xBF], name: 'overlong U+07FF - 4 bytes' },
22 // FIXME: Legacy encoding cases 36 { encoding: 'utf-8', input: [0xF8, 0x80, 0x80, 0x9F, 0xBF], name: 'overlong U+07FF - 5 bytes' },
37 { encoding: 'utf-8', input: [0xFC, 0x80, 0x80, 0x80, 0x9F, 0xBF], name: 'ove rlong U+07FF - 6 bytes' },
38
39 { encoding: 'utf-8', input: [0xF0, 0x8F, 0xBF, 0xBF], name: 'overlong U+FFFF - 4 bytes' },
40 { encoding: 'utf-8', input: [0xF8, 0x80, 0x8F, 0xBF, 0xBF], name: 'overlong U+FFFF - 5 bytes' },
41 { encoding: 'utf-8', input: [0xFC, 0x80, 0x80, 0x8F, 0xBF, 0xBF], name: 'ove rlong U+FFFF - 6 bytes' },
42
43 { encoding: 'utf-8', input: [0xF8, 0x84, 0x8F, 0xBF, 0xBF], name: 'overlong U+10FFFF - 5 bytes' },
44 { encoding: 'utf-8', input: [0xFC, 0x80, 0x84, 0x8F, 0xBF, 0xBF], name: 'ove rlong U+10FFFF - 6 bytes' },
45
46 // UTF-16 surrogates encoded as code points in UTF-8
47 { encoding: 'utf-8', input: [0xED, 0xA0, 0x80], name: 'lead surrogate' },
48 { encoding: 'utf-8', input: [0xED, 0xB0, 0x80], name: 'trail surrogate' },
49 { encoding: 'utf-8', input: [0xED, 0xA0, 0x80, 0xED, 0xB0, 0x80], name: 'sur rogate pair' },
50
51 { encoding: 'utf-16le', input: [0x00], name: 'truncated code unit' },
52 // Mismatched UTF-16 surrogates are exercised in utf16-surrogates.html
53
54 // FIXME: Add legacy encoding cases
23 ]; 55 ];
24 56
25 bad.forEach(function(t) { 57 bad.forEach(function(t) {
26 shouldThrow("new TextDecoder('" + t.encoding + "', {fatal: true}).decode(new Uint8Array(" + t.input + "))"); 58 test(function() {
59 assert_throws({name: 'EncodingError'}, function() {
60 new TextDecoder(t.encoding, {fatal: true}).decode(new Uint8Array(t.i nput))
61 });
62 }, 'Fatal flag: ' + t.encoding + " - " + t.name);
27 }); 63 });
28 64
29 </script> 65 </script>
OLDNEW
« no previous file with comments | « LayoutTests/fast/encoding/api/end-of-file-expected.txt ('k') | LayoutTests/fast/encoding/api/fatal-flag-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698