beacon-frame.html (780B)
1 <!DOCTYPE HTML> 2 <html> 3 <head> 4 <title>Inner frame performing a basic sendBeacon from within an iframe</title> 5 <script src="/tests/SimpleTest/SimpleTest.js"></script> 6 </head> 7 <body> 8 <script type="text/javascript"> 9 10 function sendBeacon() { 11 var frame = window.parent.document.getElementById("frame"); 12 // using data as id because it's unique-ish 13 var id = frame.getAttribute("data"); 14 var data = window.parent.beaconConvert(frame.getAttribute("data")); 15 var beaconUri = "http://mochi.test:8888/tests/dom/tests/mochitest/beacon/beacon-handler.sjs?beaconid=" + id; 16 var result = navigator.sendBeacon(beaconUri, data); 17 window.parent.beaconSent(result); 18 } 19 20 window.addEventListener("load", function() { setTimeout(sendBeacon, 0); }); 21 22 </script> 23 </body> 24 </html>