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