3 <head><title>Click noreferrer links
</title>
5 function simulateClick(target
) {
6 var evt
= document
.createEvent("MouseEvents");
7 evt
.initMouseEvent("click", true, true, window
,
8 0, 0, 0, 0, 0, false, false,
9 false, false, 0, null);
11 return target
.dispatchEvent(evt
);
14 function clickNoRefTargetBlankLink() {
15 return simulateClick(document
.getElementById("noref_and_tblank_link"));
18 function clickSameSiteNoRefTargetedLink() {
20 document
.getElementById("samesite_noref_and_targeted_link"));
23 function clickSameSiteTargetedLink() {
24 return simulateClick(document
.getElementById("samesite_targeted_link"));
27 function clickSameSiteTargetBlankLink() {
28 return simulateClick(document
.getElementById("samesite_tblank_link"));
31 function clickTargetBlankLink() {
32 return simulateClick(document
.getElementById("tblank_link"));
35 function clickNoRefLink() {
36 return simulateClick(document
.getElementById("noref_link"));
39 function testScriptAccessToWindow() {
40 // Grab a reference to the existing foo window and access its location.
41 var w
= window
.open("", "foo");
42 var url
= w
.location
.href
;
43 return url
!= undefined;
46 function testCloseWindow() {
47 // Grab a reference to the existing foo window and close it.
48 var w
= window
.open("", "foo");
53 // Listen to incoming messages and reply to them.
54 var receivedMessages
= 0;
55 window
.addEventListener("message", messageReceived
, false);
56 function messageReceived(event
) {
58 event
.source
.postMessage(event
.data
, "*");
61 // Send a message which contains a message port.
63 function postWithPortToFoo() {
64 mc
= new MessageChannel();
65 mc
.port1
.onmessage
= portMessageReceived
;
67 var w
= window
.open("", "foo");
68 w
.postMessage({message
: "msg-with-port", port
: mc
.port2
}, "*", [mc
.port2
]);
72 var receivedMessagesViaPort
= 0;
73 function portMessageReceived(event
) {
74 receivedMessagesViaPort
++;
75 // Change the title to generate a notification.
76 document
.title
= event
.data
;
81 <a href=
"https://REPLACE_WITH_HOST_AND_PORT/files/title2.html"
82 id=
"noref_and_tblank_link" rel=
"noreferrer" target=
"_blank">
83 rel=noreferrer and target=_blank
</a><br>
84 <a href=
"title2.html" id=
"samesite_noref_and_targeted_link"
85 rel=
"noreferrer" target=
"foo">
86 same-site rel=noreferrer and target=foo
</a><br>
87 <a href=
"navigate_opener.html" id=
"samesite_targeted_link" target=
"foo">
88 same-site target=foo
</a><br>
89 <a href=
"title2.html" id=
"samesite_tblank_link" target=
"_blank">
90 same-site target=_blank
</a><br>
91 <a href=
"https://REPLACE_WITH_HOST_AND_PORT/files/title2.html" id=
"tblank_link"
92 target=
"_blank">target=_blank
</a><br>
93 <a href=
"https://REPLACE_WITH_HOST_AND_PORT/files/title2.html" id=
"noref_link"
94 rel=
"noreferrer">rel=noreferrer
</a><br>
96 <iframe id=
"frame1" src=
"frame_tree/1-1.html"></iframe>