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

Side by Side Diff: third_party/WebKit/LayoutTests/imported/web-platform-tests/encoding/textdecoder-fatal-streaming.html

Issue 1990653002: Move the encoding directory from web-platform-tests/ to wpt/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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
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(new 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(new TypeError(), function() {
36 decoder.decode(even, {stream: true});
37 decoder.decode(odd)
38 });
39
40 assert_throws(new 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

Powered by Google App Engine
This is Rietveld 408576698