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

Unified 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, 5 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 side-by-side diff with in-line comments
Download patch
Index: LayoutTests/fast/encoding/api/byte-order-marks.html
diff --git a/LayoutTests/fast/encoding/api/byte-order-marks.html b/LayoutTests/fast/encoding/api/byte-order-marks.html
new file mode 100644
index 0000000000000000000000000000000000000000..921bc625cce0c7b7cf4c617310f1f0dd46362fd7
--- /dev/null
+++ b/LayoutTests/fast/encoding/api/byte-order-marks.html
@@ -0,0 +1,37 @@
+<!DOCTYPE html>
+<script src="../../js/resources/js-test-pre.js"></script>
+<script>
+
+description("Test the Encoding API's handling of byte-order marks (BOMs).");
+
+var utf8_bom = [0xEF, 0xBB, 0xBF];
+var utf8 = [0x7A, 0xC2, 0xA2, 0xE6, 0xB0, 0xB4, 0xF0, 0x9D, 0x84, 0x9E, 0xF4, 0x8F, 0xBF, 0xBD];
+
+var utf16le_bom = [0xff, 0xfe];
+var utf16le = [0x7A, 0x00, 0xA2, 0x00, 0x34, 0x6C, 0x34, 0xD8, 0x1E, 0xDD, 0xFF, 0xDB, 0xFD, 0xDF];
+
+var utf16be_bom = [0xfe, 0xff];
+var utf16be = [0x00, 0x7A, 0x00, 0xA2, 0x6C, 0x34, 0xD8, 0x34, 0xDD, 0x1E, 0xDB, 0xFF, 0xDF, 0xFD];
+
+var string = "z\xA2\u6C34\uD834\uDD1E\uDBFF\uDFFD"; // z, cent, CJK water, G-Clef, Private-use character
+
+// missing BOMs
+shouldBeEqualToString("new TextDecoder('utf-8').decode(new Uint8Array(utf8))", string);
+shouldBeEqualToString("new TextDecoder('utf-16le').decode(new Uint8Array(utf16le))", string);
+shouldBeEqualToString("new TextDecoder('utf-16be').decode(new Uint8Array(utf16be))", string);
+
+// matching BOMs
+shouldBeEqualToString("new TextDecoder('utf-8').decode(new Uint8Array(utf8_bom.concat(utf8)))", string);
+shouldBeEqualToString("new TextDecoder('utf-16le').decode(new Uint8Array(utf16le_bom.concat(utf16le)))", string);
+shouldBeEqualToString("new TextDecoder('utf-16be').decode(new Uint8Array(utf16be_bom.concat(utf16be)))", string);
+
+// mismatching BOMs
+shouldNotBe("new TextDecoder('utf-8').decode(new Uint8Array(utf16le_bom.concat(utf8)))", JSON.stringify(string));
+shouldNotBe("new TextDecoder('utf-8').decode(new Uint8Array(utf16be_bom.concat(utf8)))", JSON.stringify(string));
+shouldNotBe("new TextDecoder('utf-16le').decode(new Uint8Array(utf8_bom.concat(utf16le)))", JSON.stringify(string));
+shouldNotBe("new TextDecoder('utf-16le').decode(new Uint8Array(utf16be_bom.concat(utf16le)))", JSON.stringify(string));
+shouldNotBe("new TextDecoder('utf-16be').decode(new Uint8Array(utf8_bom.concat(utf16be)))", JSON.stringify(string));
+shouldNotBe("new TextDecoder('utf-16be').decode(new Uint8Array(utf16le_bom.concat(utf16be)))", JSON.stringify(string));
+
+</script>
+<script src="../../js/resources/js-test-post.js"></script>
« 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