iframe-first-load-canceled-second-load-blank.html (1483B)
1 <script src="/resources/testharness.js"></script> 2 <script src="/resources/testharnessreport.js"></script> 3 <script> 4 5 // Check about:blank navigation is asynchronous, even if the initial navigation 6 // is canceled. 7 promise_test(async test => { 8 // Wait for document.body to exist, before appending the <iframe>. 9 await new Promise(resolve => window.onload = resolve); 10 11 // The initial navigation in this new iframe will result in a 204 No Content. 12 // As a result the navigation will be canceled. The <iframe> will stay on the 13 // initial empty document. 14 const iframe = document.createElement("iframe"); 15 iframe.src = "/common/blank.html?pipe=status(204)" 16 document.body.appendChild(iframe); 17 18 // The navigation in the iframe will be canceled. There are no good ways to 19 // detect when it will happen. Anyway, any additional navigation must be 20 // asynchronous. To test what happens when there are no pending navigation, 21 // waiting one second should be enough, most of the time. 22 await new Promise(resolve => test.step_timeout(resolve, 1000)); 23 24 let load_event_fired = false; 25 const load_event_promise = new Promise(resolve => { 26 iframe.onload = () => { 27 load_event_fired = true; 28 resolve(); 29 }; 30 }); 31 iframe.src = "about:blank"; 32 assert_equals(load_event_fired, false, 33 "about:blank must not commit synchronously"); 34 await load_event_promise; 35 }, "about:blank navigation is asynchronous, even if the initial one is " + 36 "canceled."); 37 38 </script>