self-doesnt-match-blob.sub.html (1777B)
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="connect-src 'self'; script-src 'self' 'unsafe-inline'; child-src 'self';"> 7 <title>worker-connect-src-blocked</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=worker-src","TEST COMPLETE"]'></script> 11 <script src='../support/alertAssert.sub.js?alerts=[]'></script> 12 </head> 13 <p>This test loads a worker, from a guid. 14 The worker should be blocked from loading with a child-src policy of 'self' 15 as the blob: scheme must be specified explicitly. 16 A report should be sent to the report-uri specified 17 with this resource.</p> 18 <body> 19 <script> 20 window.addEventListener('securitypolicyviolation', function(e) { 21 log("violated-directive=" + e.violatedDirective); 22 }); 23 24 try { 25 var blob = new Blob([ 26 "postMessage('FAIL');" + 27 "postMessage('TEST COMPLETE');" 28 ], 29 {type : 'application/javascript'}); 30 var url = URL.createObjectURL(blob); 31 var worker = new Worker(url); 32 worker.onmessage = function(event) { 33 alert_assert(event.data); 34 }; 35 worker.onerror = function(event) { 36 log('TEST COMPLETE'); 37 event.preventDefault(); 38 } 39 } catch (e) { 40 log('TEST COMPLETE'); 41 } 42 function timeout() { 43 log('TEST COMPLETE'); 44 } 45 </script> 46 <div id="log"></div> 47 </body> 48 49 </html>