filesystem-urls-match-filesystem.sub.html (2424B)
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' filesystem:; connect-src 'self';"> 7 <title>filesystem-urls-match-filesystem</title> 8 <script src="/resources/testharness.js"></script> 9 <script src="/resources/testharnessreport.js"></script> 10 <script src='../support/logTest.sub.js?logs=["PASS (1/1)"]'></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, but should match filesystem: source. 17 </p> 18 <script> 19 window.addEventListener('securitypolicyviolation', function(e) { 20 log("Fail"); 21 }); 22 23 if(!window.webkitRequestFileSystem) { 24 t_log.set_status(t_log.NOTRUN, "No filesystem:// support, cannot run test."); 25 t_log.phase = t_log.phases.HAS_RESULT; 26 t_log.done(); 27 log("PASS (1/1)"); // simulate needed logs to pass test 28 } else { 29 function pass() { 30 log("PASS (1/1)"); 31 } 32 window.webkitRequestFileSystem( 33 TEMPORARY, 1024 * 1024 /*1MB*/ , function(fs) { 34 fs.root.getFile('pass.js', { 35 create: true 36 }, function(fileEntry) { 37 fileEntry.createWriter(function(fileWriter) { 38 fileWriter.onwriteend = function(e) { 39 var script = document.createElement('script'); 40 script.src = fileEntry.toURL('application/javascript'); 41 document.body.appendChild(script); 42 }; 43 // Create a new Blob and write it to pass.js. 44 var b = new Blob(['pass();'], { 45 type: 'application/javascript' 46 }); 47 fileWriter.write(b); 48 }); 49 }); 50 }); 51 } 52 53 </script> 54 <div id="log"></div> 55 </body> 56 57 </html>