1async_test(t => { 2 // This could be detected as ISO-2022-JP, in which case there would be no 3 // <textarea>, and thus the script inside would be interpreted as actual 4 // script. 5 const blob = new Blob( 6 [ 7 `aaa\u001B$@<textarea>\u001B(B<script>/* xss */<\/script></textarea>bbb` 8 ], 9 {type: 'text/html;charset=utf-8'}); 10 const url = URL.createObjectURL(blob); 11 const win = window.open(url); 12 t.add_cleanup(() => { 13 win.close(); 14 }); 15 16 win.onload = t.step_func_done(() => { 17 assert_equals(win.document.charset, 'UTF-8'); 18 }); 19}, 'Blob charset should override any auto-detected charset.'); 20 21async_test(t => { 22 const blob = new Blob( 23 [`<!doctype html>\n<meta charset="ISO-8859-1">`], 24 {type: 'text/html;charset=utf-8'}); 25 const url = URL.createObjectURL(blob); 26 const win = window.open(url); 27 t.add_cleanup(() => { 28 win.close(); 29 }); 30 31 win.onload = t.step_func_done(() => { 32 assert_equals(win.document.charset, 'UTF-8'); 33 }); 34}, 'Blob charset should override <meta charset>.'); 35