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

Side by Side Diff: LayoutTests/fast/encoding/api/byte-order-marks.html

Issue 15901002: Implement Encoding API (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebaseline webexposed global constructor tests Created 7 years, 4 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 <script src="../../js/resources/js-test-pre.js"></script>
3 <script>
4
5 description("Test the Encoding API's handling of byte-order marks (BOMs).");
6
7 var utf8_bom = [0xEF, 0xBB, 0xBF];
8 var utf8 = [0x7A, 0xC2, 0xA2, 0xE6, 0xB0, 0xB4, 0xF0, 0x9D, 0x84, 0x9E, 0xF4, 0x 8F, 0xBF, 0xBD];
9
10 var utf16le_bom = [0xff, 0xfe];
11 var utf16le = [0x7A, 0x00, 0xA2, 0x00, 0x34, 0x6C, 0x34, 0xD8, 0x1E, 0xDD, 0xFF, 0xDB, 0xFD, 0xDF];
12
13 var utf16be_bom = [0xfe, 0xff];
14 var utf16be = [0x00, 0x7A, 0x00, 0xA2, 0x6C, 0x34, 0xD8, 0x34, 0xDD, 0x1E, 0xDB, 0xFF, 0xDF, 0xFD];
15
16 var string = "z\xA2\u6C34\uD834\uDD1E\uDBFF\uDFFD"; // z, cent, CJK water, G-Cle f, Private-use character
17
18 // missing BOMs
19 shouldBeEqualToString("new TextDecoder('utf-8').decode(new Uint8Array(utf8))", s tring);
20 shouldBeEqualToString("new TextDecoder('utf-16le').decode(new Uint8Array(utf16le ))", string);
21 shouldBeEqualToString("new TextDecoder('utf-16be').decode(new Uint8Array(utf16be ))", string);
22
23 // matching BOMs
24 shouldBeEqualToString("new TextDecoder('utf-8').decode(new Uint8Array(utf8_bom.c oncat(utf8)))", string);
25 shouldBeEqualToString("new TextDecoder('utf-16le').decode(new Uint8Array(utf16le _bom.concat(utf16le)))", string);
26 shouldBeEqualToString("new TextDecoder('utf-16be').decode(new Uint8Array(utf16be _bom.concat(utf16be)))", string);
27
28 // mismatching BOMs
29 shouldNotBe("new TextDecoder('utf-8').decode(new Uint8Array(utf16le_bom.concat(u tf8)))", JSON.stringify(string));
30 shouldNotBe("new TextDecoder('utf-8').decode(new Uint8Array(utf16be_bom.concat(u tf8)))", JSON.stringify(string));
31 shouldNotBe("new TextDecoder('utf-16le').decode(new Uint8Array(utf8_bom.concat(u tf16le)))", JSON.stringify(string));
32 shouldNotBe("new TextDecoder('utf-16le').decode(new Uint8Array(utf16be_bom.conca t(utf16le)))", JSON.stringify(string));
33 shouldNotBe("new TextDecoder('utf-16be').decode(new Uint8Array(utf8_bom.concat(u tf16be)))", JSON.stringify(string));
34 shouldNotBe("new TextDecoder('utf-16be').decode(new Uint8Array(utf16le_bom.conca t(utf16be)))", JSON.stringify(string));
35
36 </script>
37 <script src="../../js/resources/js-test-post.js"></script>
OLDNEW
« no previous file with comments | « LayoutTests/fast/encoding/api/basics-expected.txt ('k') | LayoutTests/fast/encoding/api/byte-order-marks-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698