OLD | NEW |
1 <html> | 1 <html> |
2 | 2 |
3 <head><title>Click noreferrer links</title> | 3 <head><title>Click noreferrer links</title> |
4 <script> | 4 <script> |
5 function simulateClick(target) { | 5 function simulateClick(target) { |
6 var evt = document.createEvent("MouseEvents"); | 6 var evt = document.createEvent("MouseEvents"); |
7 evt.initMouseEvent("click", true, true, window, | 7 evt.initMouseEvent("click", true, true, window, |
8 0, 0, 0, 0, 0, false, false, | 8 0, 0, 0, 0, 0, false, false, |
9 false, false, 0, null); | 9 false, false, 0, null); |
10 | 10 |
11 return target.dispatchEvent(evt); | 11 return target.dispatchEvent(evt); |
12 } | 12 } |
13 | 13 |
14 function clickNoRefTargetBlankLink() { | 14 function clickNoRefTargetBlankLink() { |
15 return simulateClick(document.getElementById("noref_and_tblank_link")); | 15 return simulateClick(document.getElementById("noref_and_tblank_link")); |
16 } | 16 } |
17 | 17 |
18 function clickSameSiteNoRefTargetedLink() { | 18 function clickSameSiteNoRefTargetedLink() { |
19 return simulateClick( | 19 return simulateClick( |
20 document.getElementById("samesite_noref_and_targeted_link")); | 20 document.getElementById("samesite_noref_and_targeted_link")); |
21 } | 21 } |
22 | 22 |
23 function clickSameSiteTargetedLink() { | 23 function clickSameSiteTargetedLink() { |
24 return simulateClick(document.getElementById("samesite_targeted_link")); | 24 return simulateClick(document.getElementById("samesite_targeted_link")); |
25 } | 25 } |
26 | 26 |
| 27 function clickSameSiteTargetBlankLink() { |
| 28 return simulateClick(document.getElementById("samesite_tblank_link")); |
| 29 } |
| 30 |
27 function clickTargetBlankLink() { | 31 function clickTargetBlankLink() { |
28 return simulateClick(document.getElementById("tblank_link")); | 32 return simulateClick(document.getElementById("tblank_link")); |
29 } | 33 } |
30 | 34 |
31 function clickNoRefLink() { | 35 function clickNoRefLink() { |
32 return simulateClick(document.getElementById("noref_link")); | 36 return simulateClick(document.getElementById("noref_link")); |
33 } | 37 } |
34 | 38 |
35 function testScriptAccessToWindow() { | 39 function testScriptAccessToWindow() { |
36 // Grab a reference to the existing foo window and access its location. | 40 // Grab a reference to the existing foo window and access its location. |
37 var w = window.open("", "foo"); | 41 var w = window.open("", "foo"); |
38 var url = w.location.href; | 42 var url = w.location.href; |
39 return url != undefined; | 43 return url != undefined; |
40 } | 44 } |
41 | 45 |
42 function testCloseWindow() { | 46 function testCloseWindow() { |
43 // Grab a reference to the existing foo window and close it. | 47 // Grab a reference to the existing foo window and close it. |
44 var w = window.open("", "foo"); | 48 var w = window.open("", "foo"); |
45 w.close(); | 49 w.close(); |
46 return true; | 50 return true; |
47 } | 51 } |
48 | 52 |
| 53 // Listen to incoming messages and reply to them. |
| 54 var receivedMessages = 0; |
| 55 window.addEventListener("message", messageReceived, false); |
| 56 function messageReceived(event) { |
| 57 receivedMessages++; |
| 58 event.source.postMessage(event.data, "*"); |
| 59 } |
49 </script> | 60 </script> |
50 </head> | 61 </head> |
51 | 62 |
52 <a href="https://REPLACE_WITH_HOST_AND_PORT/files/title2.html" | 63 <a href="https://REPLACE_WITH_HOST_AND_PORT/files/title2.html" |
53 id="noref_and_tblank_link" rel="noreferrer" target="_blank"> | 64 id="noref_and_tblank_link" rel="noreferrer" target="_blank"> |
54 rel=noreferrer and target=_blank</a><br> | 65 rel=noreferrer and target=_blank</a><br> |
55 <a href="title2.html" id="samesite_noref_and_targeted_link" | 66 <a href="title2.html" id="samesite_noref_and_targeted_link" |
56 rel="noreferrer" target="foo"> | 67 rel="noreferrer" target="foo"> |
57 same-site rel=noreferrer and target=foo</a><br> | 68 same-site rel=noreferrer and target=foo</a><br> |
58 <a href="navigate_opener.html" id="samesite_targeted_link" target="foo"> | 69 <a href="navigate_opener.html" id="samesite_targeted_link" target="foo"> |
| 70 same-site target=foo</a><br> |
| 71 <a href="title2.html" id="samesite_tblank_link" target="_blank"> |
| 72 same-site target=_blank</a><br> |
59 <a href="https://REPLACE_WITH_HOST_AND_PORT/files/title2.html" id="tblank_link" | 73 <a href="https://REPLACE_WITH_HOST_AND_PORT/files/title2.html" id="tblank_link" |
60 target="_blank">target=_blank</a><br> | 74 target="_blank">target=_blank</a><br> |
61 <a href="https://REPLACE_WITH_HOST_AND_PORT/files/title2.html" id="noref_link" | 75 <a href="https://REPLACE_WITH_HOST_AND_PORT/files/title2.html" id="noref_link" |
62 rel="noreferrer">rel=noreferrer</a><br> | 76 rel="noreferrer">rel=noreferrer</a><br> |
63 | 77 |
64 </html> | 78 </html> |
OLD | NEW |