file_fragment.html (1192B)
1 <!DOCTYPE HTML> 2 <html> 3 <script> 4 5 function beforeunload(){ 6 window.opener.postMessage({ 7 info: "before-unload", 8 result: window.location.hash, 9 button: false, 10 }, "*"); 11 } 12 13 window.onload = function (){ 14 let button = window.document.getElementById("clickMeButton"); 15 let buttonExist = button !== null; 16 window.opener.postMessage({ 17 info: "onload", 18 result: window.location.href, 19 button: buttonExist, 20 }, "*"); 21 button.click(); 22 23 } 24 25 // after button clicked and paged scrolled sends URL of current window 26 window.onscroll = function(){ 27 window.opener.postMessage({ 28 info: "scrolled-to-foo", 29 result: window.location.href, 30 button: true, 31 documentURI: document.documentURI, 32 }, "*"); 33 } 34 35 36 </script> 37 <body onbeforeunload="/*just to notify if we load a new page*/ beforeunload()";> 38 <a id="clickMeButton" href="http://example.com/tests/dom/security/test/https-first/file_fragment.html#foo">Click me</a> 39 <div style="height: 1000px; border: 1px solid black;"> space</div> 40 <a name="foo" href="http://example.com/tests/dom/security/test/https-first/file_fragment.html">foo</a> 41 <div style="height: 1000px; border: 1px solid black;">space</div> 42 </body> 43 </html>