11cb0ef41Sopenharmony_ci// META: timeout=long 21cb0ef41Sopenharmony_ci// META: title=Encoding API: Fatal flag for single byte encodings 31cb0ef41Sopenharmony_ci// META: timeout=long 41cb0ef41Sopenharmony_ci// META: variant=?1-1000 51cb0ef41Sopenharmony_ci// META: variant=?1001-2000 61cb0ef41Sopenharmony_ci// META: variant=?2001-3000 71cb0ef41Sopenharmony_ci// META: variant=?3001-4000 81cb0ef41Sopenharmony_ci// META: variant=?4001-5000 91cb0ef41Sopenharmony_ci// META: variant=?5001-6000 101cb0ef41Sopenharmony_ci// META: variant=?6001-7000 111cb0ef41Sopenharmony_ci// META: variant=?7001-last 121cb0ef41Sopenharmony_ci// META: script=/common/subset-tests.js 131cb0ef41Sopenharmony_ci 141cb0ef41Sopenharmony_civar singleByteEncodings = [ 151cb0ef41Sopenharmony_ci {encoding: 'IBM866', bad: []}, 161cb0ef41Sopenharmony_ci {encoding: 'ISO-8859-2', bad: []}, 171cb0ef41Sopenharmony_ci {encoding: 'ISO-8859-3', bad: [0xA5, 0xAE, 0xBE, 0xC3, 0xD0, 0xE3, 0xF0]}, 181cb0ef41Sopenharmony_ci {encoding: 'ISO-8859-4', bad: []}, 191cb0ef41Sopenharmony_ci {encoding: 'ISO-8859-5', bad: []}, 201cb0ef41Sopenharmony_ci {encoding: 'ISO-8859-6', bad: [0xA1, 0xA2, 0xA3, 0xA5, 0xA6, 0xA7, 0xA8, 0xA9, 0xAA, 0xAB, 0xAE, 0xAF, 0xB0, 0xB1, 0xB2, 0xB3, 0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0xB9, 0xBA, 0xBC, 0xBD, 0xBE, 0xC0, 0xDB, 0xDC, 0xDD, 0xDE, 0xDF, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xFF]}, 211cb0ef41Sopenharmony_ci {encoding: 'ISO-8859-7', bad: [0xAE, 0xD2, 0xFF]}, 221cb0ef41Sopenharmony_ci {encoding: 'ISO-8859-8', bad: [0xA1, 0xBF, 0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF, 0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7, 0xD8, 0xD9, 0xDA, 0xDB, 0xDC, 0xDD, 0xDE, 0xFB, 0xFC, 0xFF]}, 231cb0ef41Sopenharmony_ci {encoding: 'ISO-8859-8-I', bad: [0xA1, 0xBF, 0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF, 0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7, 0xD8, 0xD9, 0xDA, 0xDB, 0xDC, 0xDD, 0xDE, 0xFB, 0xFC, 0xFF]}, 241cb0ef41Sopenharmony_ci {encoding: 'ISO-8859-10', bad: []}, 251cb0ef41Sopenharmony_ci {encoding: 'ISO-8859-13', bad: []}, 261cb0ef41Sopenharmony_ci {encoding: 'ISO-8859-14', bad: []}, 271cb0ef41Sopenharmony_ci {encoding: 'ISO-8859-15', bad: []}, 281cb0ef41Sopenharmony_ci {encoding: 'ISO-8859-16', bad: []}, 291cb0ef41Sopenharmony_ci {encoding: 'KOI8-R', bad: []}, 301cb0ef41Sopenharmony_ci {encoding: 'KOI8-U', bad: []}, 311cb0ef41Sopenharmony_ci {encoding: 'macintosh', bad: []}, 321cb0ef41Sopenharmony_ci {encoding: 'windows-874', bad: [0xDB, 0xDC, 0xDD, 0xDE, 0xFC, 0xFD, 0xFE, 0xFF]}, 331cb0ef41Sopenharmony_ci {encoding: 'windows-1250', bad: []}, 341cb0ef41Sopenharmony_ci {encoding: 'windows-1251', bad: []}, 351cb0ef41Sopenharmony_ci {encoding: 'windows-1252', bad: []}, 361cb0ef41Sopenharmony_ci {encoding: 'windows-1253', bad: [0xAA, 0xD2, 0xFF]}, 371cb0ef41Sopenharmony_ci {encoding: 'windows-1254', bad: []}, 381cb0ef41Sopenharmony_ci {encoding: 'windows-1255', bad: [0xD9, 0xDA, 0xDB, 0xDC, 0xDD, 0xDE, 0xDF, 0xFB, 0xFC, 0xFF]}, 391cb0ef41Sopenharmony_ci {encoding: 'windows-1256', bad: []}, 401cb0ef41Sopenharmony_ci {encoding: 'windows-1257', bad: [0xA1, 0xA5]}, 411cb0ef41Sopenharmony_ci {encoding: 'windows-1258', bad: []}, 421cb0ef41Sopenharmony_ci {encoding: 'x-mac-cyrillic', bad: []}, 431cb0ef41Sopenharmony_ci]; 441cb0ef41Sopenharmony_ci 451cb0ef41Sopenharmony_cisingleByteEncodings.forEach(function(t) { 461cb0ef41Sopenharmony_ci for (var i = 0; i < 256; ++i) { 471cb0ef41Sopenharmony_ci if (t.bad.indexOf(i) != -1) { 481cb0ef41Sopenharmony_ci subsetTest(test, function() { 491cb0ef41Sopenharmony_ci assert_throws_js(TypeError, function() { 501cb0ef41Sopenharmony_ci new TextDecoder(t.encoding, {fatal: true}).decode(new Uint8Array([i])); 511cb0ef41Sopenharmony_ci }); 521cb0ef41Sopenharmony_ci }, 'Throw due to fatal flag: ' + t.encoding + ' doesn\'t have a pointer ' + i); 531cb0ef41Sopenharmony_ci } 541cb0ef41Sopenharmony_ci else { 551cb0ef41Sopenharmony_ci subsetTest(test, function() { 561cb0ef41Sopenharmony_ci assert_equals(typeof new TextDecoder(t.encoding, {fatal: true}).decode(new Uint8Array([i])), "string"); 571cb0ef41Sopenharmony_ci }, 'Not throw: ' + t.encoding + ' has a pointer ' + i); 581cb0ef41Sopenharmony_ci } 591cb0ef41Sopenharmony_ci } 601cb0ef41Sopenharmony_ci}); 61