11cb0ef41Sopenharmony_cifunction blob_url_reload_test(t, revoke_before_reload) { 21cb0ef41Sopenharmony_ci const run_result = 'test_frame_OK'; 31cb0ef41Sopenharmony_ci const blob_contents = '<!doctype html>\n<meta charset="utf-8">\n' + 41cb0ef41Sopenharmony_ci '<script>window.test_result = "' + run_result + '";</script>'; 51cb0ef41Sopenharmony_ci const blob = new Blob([blob_contents], {type: 'text/html'}); 61cb0ef41Sopenharmony_ci const url = URL.createObjectURL(blob); 71cb0ef41Sopenharmony_ci 81cb0ef41Sopenharmony_ci const frame = document.createElement('iframe'); 91cb0ef41Sopenharmony_ci frame.setAttribute('src', url); 101cb0ef41Sopenharmony_ci frame.setAttribute('style', 'display:none;'); 111cb0ef41Sopenharmony_ci document.body.appendChild(frame); 121cb0ef41Sopenharmony_ci 131cb0ef41Sopenharmony_ci frame.onload = t.step_func(() => { 141cb0ef41Sopenharmony_ci if (revoke_before_reload) 151cb0ef41Sopenharmony_ci URL.revokeObjectURL(url); 161cb0ef41Sopenharmony_ci assert_equals(frame.contentWindow.test_result, run_result); 171cb0ef41Sopenharmony_ci frame.contentWindow.test_result = null; 181cb0ef41Sopenharmony_ci frame.onload = t.step_func_done(() => { 191cb0ef41Sopenharmony_ci assert_equals(frame.contentWindow.test_result, run_result); 201cb0ef41Sopenharmony_ci }); 211cb0ef41Sopenharmony_ci // Slight delay before reloading to ensure revoke actually has had a chance 221cb0ef41Sopenharmony_ci // to be processed. 231cb0ef41Sopenharmony_ci t.step_timeout(() => { 241cb0ef41Sopenharmony_ci frame.contentWindow.location.reload(); 251cb0ef41Sopenharmony_ci }, 250); 261cb0ef41Sopenharmony_ci }); 271cb0ef41Sopenharmony_ci} 281cb0ef41Sopenharmony_ci 291cb0ef41Sopenharmony_ciasync_test(t => { 301cb0ef41Sopenharmony_ci blob_url_reload_test(t, false); 311cb0ef41Sopenharmony_ci}, 'Reloading a blob URL succeeds.'); 321cb0ef41Sopenharmony_ci 331cb0ef41Sopenharmony_ci 341cb0ef41Sopenharmony_ciasync_test(t => { 351cb0ef41Sopenharmony_ci blob_url_reload_test(t, true); 361cb0ef41Sopenharmony_ci}, 'Reloading a blob URL succeeds even if the URL was revoked.'); 37