| OLD | NEW |
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 <title>Encoding API: Fatal flag for single byte encodings</title> | 2 <title>Encoding API: Fatal flag for single byte encodings</title> |
| 3 <script src="/resources/testharness.js"></script> | 3 <script src="/resources/testharness.js"></script> |
| 4 <script src="/resources/testharnessreport.js"></script> | 4 <script src="/resources/testharnessreport.js"></script> |
| 5 <script> | 5 <script> |
| 6 | 6 |
| 7 var singleByteEncodings = [ | 7 var singleByteEncodings = [ |
| 8 {encoding: 'IBM866', bad: []}, | 8 {encoding: 'IBM866', bad: []}, |
| 9 {encoding: 'ISO-8859-2', bad: []}, | 9 {encoding: 'ISO-8859-2', bad: []}, |
| 10 {encoding: 'ISO-8859-3', bad: [0xA5, 0xAE, 0xBE, 0xC3, 0xD0, 0xE3, 0xF0]}, | 10 {encoding: 'ISO-8859-3', bad: [0xA5, 0xAE, 0xBE, 0xC3, 0xD0, 0xE3, 0xF0]}, |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 {encoding: 'ISO-8859-16', bad: []}, | 21 {encoding: 'ISO-8859-16', bad: []}, |
| 22 {encoding: 'KOI8-R', bad: []}, | 22 {encoding: 'KOI8-R', bad: []}, |
| 23 {encoding: 'KOI8-U', bad: []}, | 23 {encoding: 'KOI8-U', bad: []}, |
| 24 {encoding: 'macintosh', bad: []}, | 24 {encoding: 'macintosh', bad: []}, |
| 25 {encoding: 'windows-874', bad: [0xDB, 0xDC, 0xDD, 0xDE, 0xFC, 0xFD, 0xFE, 0
xFF]}, | 25 {encoding: 'windows-874', bad: [0xDB, 0xDC, 0xDD, 0xDE, 0xFC, 0xFD, 0xFE, 0
xFF]}, |
| 26 {encoding: 'windows-1250', bad: []}, | 26 {encoding: 'windows-1250', bad: []}, |
| 27 {encoding: 'windows-1251', bad: []}, | 27 {encoding: 'windows-1251', bad: []}, |
| 28 {encoding: 'windows-1252', bad: []}, | 28 {encoding: 'windows-1252', bad: []}, |
| 29 {encoding: 'windows-1253', bad: [0xAA, 0xD2, 0xFF]}, | 29 {encoding: 'windows-1253', bad: [0xAA, 0xD2, 0xFF]}, |
| 30 {encoding: 'windows-1254', bad: []}, | 30 {encoding: 'windows-1254', bad: []}, |
| 31 {encoding: 'windows-1255', bad: [0xCA, 0xD9, 0xDA, 0xDB, 0xDC, 0xDD, 0xDE,
0xDF, 0xFB, 0xFC, 0xFF]}, | 31 {encoding: 'windows-1255', bad: [0xD9, 0xDA, 0xDB, 0xDC, 0xDD, 0xDE, 0xDF,
0xFB, 0xFC, 0xFF]}, |
| 32 {encoding: 'windows-1256', bad: []}, | 32 {encoding: 'windows-1256', bad: []}, |
| 33 {encoding: 'windows-1257', bad: [0xA1, 0xA5]}, | 33 {encoding: 'windows-1257', bad: [0xA1, 0xA5]}, |
| 34 {encoding: 'windows-1258', bad: []}, | 34 {encoding: 'windows-1258', bad: []}, |
| 35 {encoding: 'x-mac-cyrillic', bad: []}, | 35 {encoding: 'x-mac-cyrillic', bad: []}, |
| 36 ]; | 36 ]; |
| 37 | 37 |
| 38 singleByteEncodings.forEach(function(t) { | 38 singleByteEncodings.forEach(function(t) { |
| 39 for (var i = 0; i < 256; ++i) { | 39 for (var i = 0; i < 256; ++i) { |
| 40 if (t.bad.indexOf(i) != -1) { | 40 if (t.bad.indexOf(i) != -1) { |
| 41 test(function() { | 41 test(function() { |
| 42 assert_throws(new TypeError(), function() { | 42 assert_throws(new TypeError(), function() { |
| 43 new TextDecoder(t.encoding, {fatal: true}).decode(new Uint8A
rray([i])); | 43 new TextDecoder(t.encoding, {fatal: true}).decode(new Uint8A
rray([i])); |
| 44 }); | 44 }); |
| 45 }, 'Throw due to fatal flag: ' + t.encoding + ' doesn\'t have a poin
ter ' + i); | 45 }, 'Throw due to fatal flag: ' + t.encoding + ' doesn\'t have a poin
ter ' + i); |
| 46 } | 46 } |
| 47 else { | 47 else { |
| 48 test(function() { | 48 test(function() { |
| 49 assert_equals(typeof new TextDecoder(t.encoding, {fatal: true}).
decode(new Uint8Array([i])), "string"); | 49 assert_equals(typeof new TextDecoder(t.encoding, {fatal: true}).
decode(new Uint8Array([i])), "string"); |
| 50 }, 'Not throw: ' + t.encoding + ' has a pointer ' + i); | 50 }, 'Not throw: ' + t.encoding + ' has a pointer ' + i); |
| 51 } | 51 } |
| 52 } | 52 } |
| 53 }); | 53 }); |
| 54 | 54 |
| 55 </script> | 55 </script> |
| OLD | NEW |