file_bug1706090.html (1288B)
1 <html> 2 <head> 3 <script> 4 onpageshow = function(pageShowEvent) { 5 if (location.hostname == "example.com" || 6 location.hostname == "test1.mochi.test") { 7 // BroadcastChannel doesn't work across domains, so just go to the 8 // previous page explicitly. 9 history.back(); 10 return; 11 } 12 13 var bc = new BroadcastChannel("bug1706090"); 14 bc.onmessage = function(event) { 15 if (event.data == "close") { 16 bc.postMessage("closed"); 17 bc.close(); 18 window.close(); 19 } else if (event.data == "sameOrigin") { 20 bc.close(); 21 location.href = location.href + "?foo" 22 } else if (event.data == "back") { 23 history.back(); 24 } else if (event.data == "crossOrigin") { 25 bc.close(); 26 location.href = "https://example.com:443" + location.pathname; 27 } else if (event.data == "sameSite") { 28 bc.close(); 29 // eslint-disable-next-line @microsoft/sdl/no-insecure-url 30 location.href = "http://test1.mochi.test:8888" + location.pathname; 31 } 32 } 33 34 bc.postMessage({type: pageShowEvent.type, persisted: pageShowEvent.persisted}); 35 } 36 </script> 37 </head> 38 <body onunload="/* dummy listener*/"> 39 </body> 40 </html>