file_meta_refresh.html (1247B)
1 <html> 2 <head> 3 </head> 4 <body> 5 <script> 6 function addMetaRefresh() { 7 document.head.innerHTML = "<meta http-equiv='refresh' content='5; url=" + 8 location.href.replace("?initial", "?refresh") + "'>"; 9 } 10 11 onpageshow = function() { 12 let bc = new BroadcastChannel("test_meta_refresh"); 13 bc.onmessage = function(event) { 14 if (event.data == "loadnext") { 15 bc.close(); 16 addMetaRefresh(); 17 location.href = location.href.replace("?initial", "?nextpage"); 18 } else if (event.data == "back") { 19 bc.close(); 20 history.back(); 21 } else if (event.data == "ensuremetarefresh") { 22 bc.close(); 23 // This test is designed to work with and without bfcache, but 24 // if bfcache is enabled, meta refresh should be suspended/resumed. 25 if (document.head.firstChild.localName != "meta") { 26 addMetaRefresh(); 27 } 28 } else if (event.data == "close") { 29 bc.postMessage("closed"); 30 bc.close(); 31 window.close(); 32 } 33 }; 34 35 bc.postMessage({ load: location.search.substr(1) }); 36 } 37 </script> 38 </body> 39 </html>