1function blob_url_reload_test(t, revoke_before_reload) { 2 const run_result = 'test_frame_OK'; 3 const blob_contents = '<!doctype html>\n<meta charset="utf-8">\n' + 4 '<script>window.test_result = "' + run_result + '";</script>'; 5 const blob = new Blob([blob_contents], {type: 'text/html'}); 6 const url = URL.createObjectURL(blob); 7 8 const frame = document.createElement('iframe'); 9 frame.setAttribute('src', url); 10 frame.setAttribute('style', 'display:none;'); 11 document.body.appendChild(frame); 12 13 frame.onload = t.step_func(() => { 14 if (revoke_before_reload) 15 URL.revokeObjectURL(url); 16 assert_equals(frame.contentWindow.test_result, run_result); 17 frame.contentWindow.test_result = null; 18 frame.onload = t.step_func_done(() => { 19 assert_equals(frame.contentWindow.test_result, run_result); 20 }); 21 // Slight delay before reloading to ensure revoke actually has had a chance 22 // to be processed. 23 t.step_timeout(() => { 24 frame.contentWindow.location.reload(); 25 }, 250); 26 }); 27} 28 29async_test(t => { 30 blob_url_reload_test(t, false); 31}, 'Reloading a blob URL succeeds.'); 32 33 34async_test(t => { 35 blob_url_reload_test(t, true); 36}, 'Reloading a blob URL succeeds even if the URL was revoked.'); 37