directive-name-case-insensitive.sub.html (1394B)
1 <!DOCTYPE html> 2 <html> 3 4 <head> 5 <meta http-equiv="Content-Security-Policy" content=" 6 IMg-sRC 'self' 'unsafe-inline' http://{{domains[www1]}}:{{ports[http][0]}}; 7 img-src 'self' 'unsafe-inline' http://{{domains[www2]}}:{{ports[http][0]}};"> 8 <script src="/resources/testharness.js"></script> 9 <script src="/resources/testharnessreport.js"></script> 10 </head> 11 12 <body> 13 <script> 14 var t1 = async_test("Test that the www1 image is allowed to load"); 15 var t2 = async_test("Test that the www2 image is not allowed to load"); 16 var t_spv = async_test("Test that the www2 image throws a violation event"); 17 window.addEventListener("securitypolicyviolation", t_spv.step_func_done(function(e) { 18 assert_equals(e.violatedDirective, "img-src"); 19 assert_equals(e.blockedURI, "http://{{domains[www2]}}:{{ports[http][0]}}/content-security-policy/support/fail.png"); 20 })); 21 </script> 22 23 <img src="http://{{domains[www1]}}:{{ports[http][0]}}/content-security-policy/support/pass.png" 24 onload="t1.done();" 25 onerror="t1.step(function() { assert_unreached('www1 image should have loaded'); t1.done(); });"> 26 27 <img src="http://{{domains[www2]}}:{{ports[http][0]}}/content-security-policy/support/fail.png" 28 onerror="t2.done();" 29 onload="t2.step(function() { assert_unreached('www2 image should not have loaded'); t2.done(); });"> 30 </body> 31 32 </html>