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

Unified Diff: LayoutTests/fast/encoding/api/textdecoder-ignorebom.html

Issue 232513003: Encoding API: Add ignoreBOM flag to decoder options (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebased Created 6 years, 8 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
« no previous file with comments | « no previous file | LayoutTests/fast/encoding/api/textdecoder-ignorebom-expected.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: LayoutTests/fast/encoding/api/textdecoder-ignorebom.html
diff --git a/LayoutTests/fast/encoding/api/textdecoder-ignorebom.html b/LayoutTests/fast/encoding/api/textdecoder-ignorebom.html
new file mode 100644
index 0000000000000000000000000000000000000000..ce0d471bde2efdc40a2e16cb0b62d3bfe0d3a42f
--- /dev/null
+++ b/LayoutTests/fast/encoding/api/textdecoder-ignorebom.html
@@ -0,0 +1,38 @@
+<!DOCTYPE html>
+<title>Encoding API: TextDecoder ignoreBOM option</title>
+<script src="../../../resources/testharness.js"></script>
+<script src="../../../resources/testharnessreport.js"></script>
+<script>
+
+test(function() {
+
+ var cases = [
+ {encoding: 'utf-8', bytes: [0xEF, 0xBB, 0xBF, 0x61, 0x62, 0x63]},
+ {encoding: 'utf-16le', bytes: [0xFF, 0xFE, 0x61, 0x00, 0x62, 0x00, 0x63, 0x00]},
+ {encoding: 'utf-16be', bytes: [0xFE, 0xFF, 0x00, 0x61, 0x00, 0x62, 0x00, 0x63]}
+ ];
+
+ var BOM = '\uFEFF';
+
+ cases.forEach(function(testCase) {
+ var decoder = new TextDecoder(testCase.encoding, {ignoreBOM: true});
+ assert_equals(
+ decoder.decode(new Uint8Array(testCase.bytes)),
+ BOM + 'abc',
+ testCase.encoding + ': BOM should be present in decoded string if ignored');
+
+ decoder = new TextDecoder(testCase.encoding, {ignoreBOM: false});
+ assert_equals(
+ decoder.decode(new Uint8Array(testCase.bytes)),
+ 'abc',
+ testCase.encoding + ': BOM should be absent from decoded string if not ignored');
+
+ decoder = new TextDecoder(testCase.encoding);
+ assert_equals(
+ decoder.decode(new Uint8Array(testCase.bytes)),
+ 'abc',
+ testCase.encoding + ': Default is to ignore the BOM');
jungshik at Google 2014/05/27 17:09:11 Default is to "eat" the BOM (no BOM in the decoded
jsbell 2014/05/27 17:40:46 Yes.
+ });
+
+}, "BOM is ignored if ignoreBOM option is specified");
+</script>
« no previous file with comments | « no previous file | LayoutTests/fast/encoding/api/textdecoder-ignorebom-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698