script-src-report-only-policy-works-with-external-hash-policy.html (1029B)
1 <!DOCTYPE HTML> 2 <html> 3 <head> 4 <title>A report-only policy that does not allow a script should not affect an enforcing policy using hashes.</title> 5 <!-- nonces are here just to let all of our scripts run --> 6 <script nonce="abc" src='/resources/testharness.js'></script> 7 <script nonce="abc" src='/resources/testharnessreport.js'></script> 8 </head> 9 <body> 10 <script nonce="abc"> 11 var t_spv = async_test("Should fire securitypolicyviolation event"); 12 window.addEventListener("securitypolicyviolation", t_spv.step_func_done(function(e) { 13 assert_equals(e.violatedDirective, "script-src-elem"); 14 assert_equals(e.disposition, "report"); 15 })); 16 var externalRan = false; 17 </script> 18 <script src='./externalScript.js' 19 integrity="sha256-wIc3KtqOuTFEu6t17sIBuOswgkV406VJvhSk79Gw6U0="></script> 20 <script nonce="abc"> 21 test(function() { 22 assert_true(externalRan, 'External script ran.'); 23 }, 'External script in a script tag with matching SRI hash should run.'); 24 </script></body> 25 </html>