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

Side by Side Diff: LayoutTests/fast/encoding/api/utf16-surrogates.html

Issue 240283013: Convert Encoding API tests to W3C testharness.js (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Move UTF-16 surrogate tests to separate file Created 6 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 | Annotate | Revision Log
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 src="resources/shared.js"></script>
6 <script>
7
8 var bad = [
9 {
10 encoding: 'utf-16le',
11 input: [0x00, 0xd8],
12 expected: '\uFFFD',
13 name: 'lone surrogate lead'
14 },
15 {
16 encoding: 'utf-16le',
17 input: [0x00, 0xdc],
18 expected: '\uFFFD',
19 name: 'lone surrogate trail'
20 },
21 {
22 encoding: 'utf-16le',
23 input: [0x00, 0xd8, 0x00, 0x00],
24 expected: '\uFFFD\u0000',
25 name: 'unmatched surrogate lead'
26 },
27 {
28 encoding: 'utf-16le',
29 input: [0x00, 0xdc, 0x00, 0x00],
30 expected: '\uFFFD\u0000',
31 name: 'unmatched surrogate trail'
32 },
33 {
34 encoding: 'utf-16le',
35 input: [0x00, 0xdc, 0x00, 0xd8],
36 expected: '\uFFFD\uFFFD',
37 name: 'swapped surrogate pair'
38 }
39 ];
40
41 bad.forEach(function(t) {
42 test(function() {
43 assert_equals(new TextDecoder(t.encoding).decode(new Uint8Array(t.input) ), t.expected);
44 }, t.encoding + " - " + t.name);
45 test(function() {
46 assert_throws({name: 'EncodingError'}, function() {
47 new TextDecoder(t.encoding, {fatal: true}).decode(new Uint8Array(t.i nput))
48 });
49 }, t.encoding + " - " + t.name + ' (fatal flag set)');
50 });
51
52 </script>
OLDNEW
« no previous file with comments | « LayoutTests/fast/encoding/api/utf-round-trip-expected.txt ('k') | LayoutTests/fast/encoding/api/utf16-surrogates-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698