filesystem-urls-do-not-match-self.sub.html (2495B)
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';"> 7 <title>filesystem-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 filesystem: 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 23 if(!window.webkitRequestFileSystem) { 24 t_log = async_test(); 25 t_log.set_status(t_log.NOTRUN, "No filesystem:// support, cannot run test."); 26 t_log.phase = t_log.phases.HAS_RESULT; 27 t_log.done(); 28 log("violated-directive=script-src"); // simulate needed logs to pass test 29 } else { 30 function fail() { 31 alert_assert("FAIL!"); 32 } 33 window.webkitRequestFileSystem( 34 TEMPORARY, 1024 * 1024 /*1MB*/ , function(fs) { 35 fs.root.getFile('fail.js', { 36 create: true 37 }, function(fileEntry) { 38 fileEntry.createWriter(function(fileWriter) { 39 fileWriter.onwriteend = function(e) { 40 var script = document.createElement('script'); 41 script.src = fileEntry.toURL('application/javascript'); 42 document.body.appendChild(script); 43 }; 44 // Create a new Blob and write it to pass.js. 45 var b = new Blob(['fail();'], { 46 type: 'application/javascript' 47 }); 48 fileWriter.write(b); 49 }); 50 }); 51 }); 52 } 53 54 55 </script> 56 <div id="log"></div> 57 58 </body> 59 60 </html>