blob-urls-do-not-match-self.sub.html (1364B)
1 <!DOCTYPE html> 2 <html> 3 4 <head> 5 <!-- Programmatically converted from a WebKit Reftest, please forgive resulting idiosyncracies.--> 6 <meta http-equiv="Content-Security-Policy" content="script-src 'self' 'unsafe-inline'; connect-src 'self'; child-src 'self';"> 7 <title>blob-urls-do-not-match-self</title> 8 <script src="/resources/testharness.js"></script> 9 <script src="/resources/testharnessreport.js"></script> 10 <script src='../support/logTest.sub.js?logs=["violated-directive=script-src-elem"]'></script> 11 <script src='../support/alertAssert.sub.js?alerts=[]'></script> 12 </head> 13 14 <body> 15 <p> 16 blob: URLs are same-origin with the page in which they were created, but explicitly do not match the 'self' or '*' source in CSP directives because they are more akin to 'unsafe-inline' content. 17 </p> 18 <script> 19 window.addEventListener('securitypolicyviolation', function(e) { 20 log("violated-directive=" + e.violatedDirective); 21 }); 22 function fail() { 23 alert_assert("FAIL!"); 24 } 25 var b = new Blob(['fail();'], { 26 type: 'application/javascript' 27 }); 28 var script = document.createElement('script'); 29 script.src = URL.createObjectURL(b); 30 document.body.appendChild(script); 31 32 </script> 33 <div id="log"></div> 34 </body> 35 36 </html>