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

Side by Side 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: More explicit test output, correct assertion comment in default case Created 6 years, 6 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
« no previous file with comments | « no previous file | LayoutTests/fast/encoding/api/textdecoder-ignorebom-expected.txt » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 <!DOCTYPE html>
2 <title>Encoding API: TextDecoder ignoreBOM option</title>
3 <script src="../../../resources/testharness.js"></script>
4 <script src="../../../resources/testharnessreport.js"></script>
5 <script>
6
7 var cases = [
8 {encoding: 'utf-8', bytes: [0xEF, 0xBB, 0xBF, 0x61, 0x62, 0x63]},
9 {encoding: 'utf-16le', bytes: [0xFF, 0xFE, 0x61, 0x00, 0x62, 0x00, 0x63, 0x0 0]},
10 {encoding: 'utf-16be', bytes: [0xFE, 0xFF, 0x00, 0x61, 0x00, 0x62, 0x00, 0x6 3]}
11 ];
12
13 cases.forEach(function(testCase) {
14 test(function() {
15 var BOM = '\uFEFF';
16 var decoder = new TextDecoder(testCase.encoding, {ignoreBOM: true});
17 var bytes = new Uint8Array(testCase.bytes);
18 assert_equals(
19 decoder.decode(bytes),
20 BOM + 'abc',
21 testCase.encoding + ': BOM should be present in decoded string if ig nored');
22
23 decoder = new TextDecoder(testCase.encoding, {ignoreBOM: false});
24 assert_equals(
25 decoder.decode(bytes),
26 'abc',
27 testCase.encoding + ': BOM should be absent from decoded string if n ot ignored');
28
29 decoder = new TextDecoder(testCase.encoding);
30 assert_equals(
31 decoder.decode(bytes),
32 'abc',
33 testCase.encoding + ': BOM should be absent from decoded string by d efault');
34 }, 'BOM is ignored if ignoreBOM option is specified: ' + testCase.encoding);
35 });
36
37 </script>
OLDNEW
« 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