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

Side by Side Diff: LayoutTests/fast/encoding/api/end-of-file.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: End-of-file</title>
3 <script src="../../../resources/testharness.js"></script>
4 <script src="../../../resources/testharnessreport.js"></script>
5 <script>
6
7 test(function() {
8 [
9 {encoding: 'utf-8', sequence: [0xC0]},
10 {encoding: 'utf-16le', sequence: [0x00]},
11 {encoding: 'utf-16be', sequence: [0x00]}
12 ].forEach(function(testCase) {
13
14 assert_throws({name: 'TypeError'}, function() {
15 var decoder = new TextDecoder(testCase.encoding, {fatal: true});
16 decoder.decode(new Uint8Array(testCase.sequence));
17 }, 'Unterminated ' + testCase.encoding + ' sequence should throw if fata l flag is set');
18
19 assert_equals(
20 new TextDecoder(testCase.encoding).decode(new Uint8Array([testCase.s equence])),
21 '\uFFFD',
22 'Unterminated UTF-8 sequence should emit replacement character if fa tal flag is unset');
23 });
24 }, 'Fatal flag, non-streaming cases');
25
26 test(function() {
27
28 var decoder = new TextDecoder('utf-16le', {fatal: true});
29 var odd = new Uint8Array([0x00]);
30 var even = new Uint8Array([0x00, 0x00]);
31
32 assert_equals(decoder.decode(odd, {stream: true}), '');
33 assert_equals(decoder.decode(odd), '\u0000');
34
35 assert_throws({name: 'TypeError'}, function() {
36 decoder.decode(even, {stream: true});
37 decoder.decode(odd)
38 });
39
40 assert_throws({name: 'TypeError'}, function() {
41 decoder.decode(odd, {stream: true});
42 decoder.decode(even);
43 });
44
45 assert_equals(decoder.decode(even, {stream: true}), '\u0000');
46 assert_equals(decoder.decode(even), '\u0000');
47
48 }, 'Fatal flag, streaming cases');
49
50 </script>
OLDNEW
« no previous file with comments | « LayoutTests/fast/encoding/api/encoding-names.html ('k') | LayoutTests/fast/encoding/api/fatal-flag.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698