test_sendbeacon.html (1094B)
1 <!DOCTYPE HTML> 2 <html> 3 <head> 4 <meta charset="utf-8"> 5 <title>Bug 1234813 - sendBeacon should not throw if blocked by Content Policy</title> 6 <!-- Including SimpleTest.js so we can use waitForExplicitFinish !--> 7 <script src="/tests/SimpleTest/SimpleTest.js"></script> 8 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> 9 </head> 10 <body> 11 <p id="display"></p> 12 <iframe style="width:100%;" id="testframe" src="file_sendbeacon.html"></iframe> 13 14 <script class="testbody" type="text/javascript"> 15 16 /* Description of the test: 17 * Let's try to fire a sendBeacon which gets blocked by CSP. Let's make sure 18 * sendBeacon does not throw an exception. 19 */ 20 SimpleTest.waitForExplicitFinish(); 21 22 // a postMessage handler used to bubble up the 23 // result from within the iframe. 24 window.addEventListener("message", receiveMessage); 25 function receiveMessage(event) { 26 var result = event.data.result; 27 is(result, "blocked-beacon-does-not-throw", "sendBeacon should not throw"); 28 window.removeEventListener("message", receiveMessage); 29 SimpleTest.finish(); 30 } 31 32 </script> 33 </body> 34 </html>