navigation-within-beforeunload.html (1087B)
1 <!doctype html> 2 <title>Triggering navigation from within beforeunload event</title> 3 <script src="/resources/testharness.js"></script> 4 <script src="/resources/testharnessreport.js"></script> 5 <div id="log"></div> 6 <script> 7 beforeunload_fired = false; 8 var t = async_test(); 9 10 var base_count = 0; 11 var counter = 0; 12 13 onload = function() {setTimeout(function() { 14 var iframe = document.getElementsByTagName("iframe")[0] 15 16 iframe.onload = function() { 17 setTimeout(function() {iframe.contentWindow.location="navigation-within-beforeunload-2.html";}, 100); 18 // Step 4 of https://html.spec.whatwg.org/multipage/browsing-the-web.html#navigating-across-documents 19 // doesn't seem to allow navigation within a beforeunload handler, 20 // so the counter should not go beyond 1. 21 iframe.onload = t.step_func(function() {assert_equals(counter, 1); t.done()}); 22 }; 23 24 iframe.src = "navigation-within-beforeunload-1.html?" + Math.random(); 25 26 }, 100)}; 27 28 </script> 29 <iframe src="base.html"></iframe>