11cb0ef41Sopenharmony_ciasync_test(t => { 21cb0ef41Sopenharmony_ci // This could be detected as ISO-2022-JP, in which case there would be no 31cb0ef41Sopenharmony_ci // <textarea>, and thus the script inside would be interpreted as actual 41cb0ef41Sopenharmony_ci // script. 51cb0ef41Sopenharmony_ci const blob = new Blob( 61cb0ef41Sopenharmony_ci [ 71cb0ef41Sopenharmony_ci `aaa\u001B$@<textarea>\u001B(B<script>/* xss */<\/script></textarea>bbb` 81cb0ef41Sopenharmony_ci ], 91cb0ef41Sopenharmony_ci {type: 'text/html;charset=utf-8'}); 101cb0ef41Sopenharmony_ci const url = URL.createObjectURL(blob); 111cb0ef41Sopenharmony_ci const win = window.open(url); 121cb0ef41Sopenharmony_ci t.add_cleanup(() => { 131cb0ef41Sopenharmony_ci win.close(); 141cb0ef41Sopenharmony_ci }); 151cb0ef41Sopenharmony_ci 161cb0ef41Sopenharmony_ci win.onload = t.step_func_done(() => { 171cb0ef41Sopenharmony_ci assert_equals(win.document.charset, 'UTF-8'); 181cb0ef41Sopenharmony_ci }); 191cb0ef41Sopenharmony_ci}, 'Blob charset should override any auto-detected charset.'); 201cb0ef41Sopenharmony_ci 211cb0ef41Sopenharmony_ciasync_test(t => { 221cb0ef41Sopenharmony_ci const blob = new Blob( 231cb0ef41Sopenharmony_ci [`<!doctype html>\n<meta charset="ISO-8859-1">`], 241cb0ef41Sopenharmony_ci {type: 'text/html;charset=utf-8'}); 251cb0ef41Sopenharmony_ci const url = URL.createObjectURL(blob); 261cb0ef41Sopenharmony_ci const win = window.open(url); 271cb0ef41Sopenharmony_ci t.add_cleanup(() => { 281cb0ef41Sopenharmony_ci win.close(); 291cb0ef41Sopenharmony_ci }); 301cb0ef41Sopenharmony_ci 311cb0ef41Sopenharmony_ci win.onload = t.step_func_done(() => { 321cb0ef41Sopenharmony_ci assert_equals(win.document.charset, 'UTF-8'); 331cb0ef41Sopenharmony_ci }); 341cb0ef41Sopenharmony_ci}, 'Blob charset should override <meta charset>.'); 35