| <html> |
| |
| <head><title>Click noreferrer links</title> |
| <script> |
| function simulateClick(target) { |
| var evt = document.createEvent("MouseEvents"); |
| evt.initMouseEvent("click", true, true, window, |
| 0, 0, 0, 0, 0, false, false, |
| false, false, 0, null); |
| |
| return target.dispatchEvent(evt); |
| } |
| |
| function clickNoRefTargetBlankLink() { |
| return simulateClick(document.getElementById("noref_and_tblank_link")); |
| } |
| |
| function clickSameSiteNoRefTargetedLink() { |
| return simulateClick( |
| document.getElementById("samesite_noref_and_targeted_link")); |
| } |
| |
| function clickSameSiteTargetedLink() { |
| return simulateClick(document.getElementById("samesite_targeted_link")); |
| } |
| |
| function clickSameSiteTargetBlankLink() { |
| return simulateClick(document.getElementById("samesite_tblank_link")); |
| } |
| |
| function clickTargetBlankLink() { |
| return simulateClick(document.getElementById("tblank_link")); |
| } |
| |
| function clickNoRefLink() { |
| return simulateClick(document.getElementById("noref_link")); |
| } |
| |
| function testScriptAccessToWindow() { |
| // Grab a reference to the existing foo window and access its location. |
| try { |
| var w = window.open("", "foo"); |
| var url = w.location.href; |
| return url != undefined; |
| } catch (e) { |
| return false; |
| } |
| } |
| |
| function testCloseWindow() { |
| // Grab a reference to the existing foo window and close it. |
| var w = window.open("", "foo"); |
| w.close(); |
| return true; |
| } |
| |
| // Listen to incoming messages and reply to them. |
| var receivedMessages = 0; |
| window.addEventListener("message", messageReceived, false); |
| function messageReceived(event) { |
| receivedMessages++; |
| event.source.postMessage(event.data, "*"); |
| } |
| |
| // Send a message which contains a message port. |
| var mc; |
| function postWithPortToFoo() { |
| mc = new MessageChannel(); |
| mc.port1.onmessage = portMessageReceived; |
| mc.port1.start(); |
| var w = window.open("", "foo"); |
| w.postMessage({message: "msg-with-port", port: mc.port2}, "*", [mc.port2]); |
| return true; |
| } |
| |
| var receivedMessagesViaPort = 0; |
| function portMessageReceived(event) { |
| receivedMessagesViaPort++; |
| // Change the title to generate a notification. |
| document.title = event.data; |
| } |
| </script> |
| </head> |
| |
| <a href="https://REPLACE_WITH_HOST_AND_PORT/files/title2.html" |
| id="noref_and_tblank_link" rel="noreferrer" target="_blank"> |
| rel=noreferrer and target=_blank</a><br> |
| <a href="title2.html" id="samesite_noref_and_targeted_link" |
| rel="noreferrer" target="foo"> |
| same-site rel=noreferrer and target=foo</a><br> |
| <a href="navigate_opener.html" id="samesite_targeted_link" target="foo"> |
| same-site target=foo</a><br> |
| <a href="title2.html" id="samesite_tblank_link" target="_blank"> |
| same-site target=_blank</a><br> |
| <a href="https://REPLACE_WITH_HOST_AND_PORT/files/title2.html" id="tblank_link" |
| target="_blank">target=_blank</a><br> |
| <a href="https://REPLACE_WITH_HOST_AND_PORT/files/title2.html" id="noref_link" |
| rel="noreferrer">rel=noreferrer</a><br> |
| |
| <iframe id="frame1" src="frame_tree/1-1.html"></iframe> |
| |
| </html> |