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

Side by Side Diff: third_party/WebKit/LayoutTests/imported/web-platform-tests/encoding/textdecoder-byte-order-marks.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: Byte-order marks</title>
3 <script src="../../../resources/testharness.js"></script>
4 <script src="../../../resources/testharnessreport.js"></script>
5 <script>
6
7 var testCases = [
8 {
9 encoding: 'utf-8',
10 bom: [0xEF, 0xBB, 0xBF],
11 bytes: [0x7A, 0xC2, 0xA2, 0xE6, 0xB0, 0xB4, 0xF0, 0x9D, 0x84, 0x9E, 0xF4 , 0x8F, 0xBF, 0xBD]
12 },
13 {
14 encoding: 'utf-16le',
15 bom: [0xff, 0xfe],
16 bytes: [0x7A, 0x00, 0xA2, 0x00, 0x34, 0x6C, 0x34, 0xD8, 0x1E, 0xDD, 0xFF , 0xDB, 0xFD, 0xDF]
17 },
18 {
19 encoding: 'utf-16be',
20 bom: [0xfe, 0xff],
21 bytes: [0x00, 0x7A, 0x00, 0xA2, 0x6C, 0x34, 0xD8, 0x34, 0xDD, 0x1E, 0xDB , 0xFF, 0xDF, 0xFD]
22 }
23 ];
24
25 var string = 'z\xA2\u6C34\uD834\uDD1E\uDBFF\uDFFD'; // z, cent, CJK water, G-Cle f, Private-use character
26
27 testCases.forEach(function(t) {
28 test(function() {
29
30 var decoder = new TextDecoder(t.encoding);
31 assert_equals(decoder.decode(new Uint8Array(t.bytes)), string,
32 'Sequence without BOM should decode successfully');
33
34 assert_equals(decoder.decode(new Uint8Array(t.bom.concat(t.bytes))), str ing,
35 'Sequence with BOM should decode successfully (with no BOM present in output)');
36
37 testCases.forEach(function(o) {
38 if (o === t)
39 return;
40
41 assert_not_equals(decoder.decode(new Uint8Array(o.bom.concat(t.bytes ))), string,
42 'Mismatching BOM should not be ignored - treated a s garbage bytes.');
43 });
44
45 }, 'Byte-order marks: ' + t.encoding);
46 });
47
48 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698