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

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

Issue 1984023002: Move web-platform-tests to wpt (part 1 of 2) (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: UTF-16 surrogate handling</title>
3 <script src="../../../resources/testharness.js"></script>
4 <script src="../../../resources/testharnessreport.js"></script>
5 <script>
6
7 var bad = [
8 {
9 encoding: 'utf-16le',
10 input: [0x00, 0xd8],
11 expected: '\uFFFD',
12 name: 'lone surrogate lead'
13 },
14 {
15 encoding: 'utf-16le',
16 input: [0x00, 0xdc],
17 expected: '\uFFFD',
18 name: 'lone surrogate trail'
19 },
20 {
21 encoding: 'utf-16le',
22 input: [0x00, 0xd8, 0x00, 0x00],
23 expected: '\uFFFD\u0000',
24 name: 'unmatched surrogate lead'
25 },
26 {
27 encoding: 'utf-16le',
28 input: [0x00, 0xdc, 0x00, 0x00],
29 expected: '\uFFFD\u0000',
30 name: 'unmatched surrogate trail'
31 },
32 {
33 encoding: 'utf-16le',
34 input: [0x00, 0xdc, 0x00, 0xd8],
35 expected: '\uFFFD\uFFFD',
36 name: 'swapped surrogate pair'
37 }
38 ];
39
40 bad.forEach(function(t) {
41 test(function() {
42 assert_equals(new TextDecoder(t.encoding).decode(new Uint8Array(t.input) ), t.expected);
43 }, t.encoding + ' - ' + t.name);
44 test(function() {
45 assert_throws(new TypeError(), function() {
46 new TextDecoder(t.encoding, {fatal: true}).decode(new Uint8Array(t.i nput))
47 });
48 }, t.encoding + ' - ' + t.name + ' (fatal flag set)');
49 });
50
51 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698