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

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

Issue 1196733003: Remove duplicate Encoding API tests (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 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
OLDNEW
(Empty)
1 <!DOCTYPE html>
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>
6 <script>
7
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' },
20
21 // Overlong encodings
22 { encoding: 'utf-8', input: [0xC0, 0x80], name: 'overlong U+0000 - 2 bytes' },
23 { encoding: 'utf-8', input: [0xE0, 0x80, 0x80], name: 'overlong U+0000 - 3 b ytes' },
24 { encoding: 'utf-8', input: [0xF0, 0x80, 0x80, 0x80], name: 'overlong U+0000 - 4 bytes' },
25 { encoding: 'utf-8', input: [0xF8, 0x80, 0x80, 0x80, 0x80], name: 'overlong U+0000 - 5 bytes' },
26 { encoding: 'utf-8', input: [0xFC, 0x80, 0x80, 0x80, 0x80, 0x80], name: 'ove rlong U+0000 - 6 bytes' },
27
28 { encoding: 'utf-8', input: [0xC1, 0xBF], name: 'overlong U+007F - 2 bytes' },
29 { encoding: 'utf-8', input: [0xE0, 0x81, 0xBF], name: 'overlong U+007F - 3 b ytes' },
30 { encoding: 'utf-8', input: [0xF0, 0x80, 0x81, 0xBF], name: 'overlong U+007F - 4 bytes' },
31 { encoding: 'utf-8', input: [0xF8, 0x80, 0x80, 0x81, 0xBF], name: 'overlong U+007F - 5 bytes' },
32 { encoding: 'utf-8', input: [0xFC, 0x80, 0x80, 0x80, 0x81, 0xBF], name: 'ove rlong U+007F - 6 bytes' },
33
34 { encoding: 'utf-8', input: [0xE0, 0x9F, 0xBF], name: 'overlong U+07FF - 3 b ytes' },
35 { encoding: 'utf-8', input: [0xF0, 0x80, 0x9F, 0xBF], name: 'overlong U+07FF - 4 bytes' },
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
55 ];
56
57 bad.forEach(function(t) {
58 test(function() {
59 assert_throws({name: 'TypeError'}, function() {
60 new TextDecoder(t.encoding, {fatal: true}).decode(new Uint8Array(t.i nput))
61 });
62 }, 'Fatal flag: ' + t.encoding + ' - ' + t.name);
63 });
64
65 test(function() {
66 assert_true('fatal' in new TextDecoder(), 'The fatal attribute should exist on TextDecoder.');
67 assert_equals(typeof new TextDecoder().fatal, 'boolean', 'The type of the f atal attribute should be boolean.');
68 assert_false(new TextDecoder().fatal, 'The fatal attribute should default to false.');
69 assert_true(new TextDecoder('utf-8', {fatal: true}).fatal, 'The fatal attrib ute can be set using an option.');
70
71 }, 'The fatal attribute of TextDecoder');
72
73 </script>
OLDNEW
« no previous file with comments | « LayoutTests/fast/encoding/api/end-of-file.html ('k') | LayoutTests/fast/encoding/api/latin-1.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698