OLD | NEW |
---|---|
1 <!doctype html> | 1 <!doctype html> |
2 <html> | 2 <meta http-equiv="Content-Security-Policy" content="block-all-mixed-content"> |
3 <head> | 3 <script src="/resources/testharness.js"></script> |
4 <meta http-equiv="Content-Security-Policy" content="block-all-mixed-content" > | 4 <script src="/resources/testharnessreport.js"></script> |
5 <script> | |
6 if (window.testRunner) { | |
7 testRunner.dumpAsText(); | |
8 } | |
9 </script> | |
10 </head> | |
11 <body> | 5 <body> |
12 <p>This test passes if the image below is treated as blockable content.</p> | 6 <script> |
13 <img src="http://127.0.0.1:8080/security/resources/compass.jpg"> | 7 async_test(t => { |
14 </body> | 8 var i = document.createElement('img'); |
15 </html> | 9 i.onload = t.assert_unreached; |
10 i.onerror = t.step_func_done(_ => { | |
11 assert_equals(0, i.naturalWidth); | |
12 assert_equals(0, i.naturalHeight); | |
13 }); | |
14 i.src = "http://127.0.0.1:8080/security/resources/compass.jpg?t=1"; | |
15 }, "Mixed images are blocked in the presence of 'block-all-mixed-content'.") ; | |
16 | |
17 async_test(t => { | |
18 var i = document.createElement('img'); | |
19 i.onload = t.assert_unreached; | |
20 document.addEventListener('securitypolicyviolation', t.step_func_done(e => { | |
21 var expectations = { | |
22 'documentURI': document.location.toString(), | |
23 'referrer': document.referrer, | |
24 'blockedURI': 'http://127.0.0.1:8080', | |
25 'violatedDirective': 'block-all-mixed-content', | |
26 'effectiveDirective': 'block-all-mixed-content', | |
27 'originalPolicy': 'block-all-mixed-content', | |
28 'sourceFile': '', | |
29 'lineNumber': 0, | |
30 'columnNumber': 0, | |
31 'statusCode': 0 | |
32 }; | |
33 for (key in expectations) | |
34 assert_equals(expectations[key], e[key], key); | |
35 })); | |
36 i.src = "http://127.0.0.1:8080/security/resources/compass.jpg?t=2"; | |
37 }, "Mixed images generate CSP violation reports in the presence of 'block-al l-mixed-content'."); | |
jww
2016/05/26 00:30:34
Would it be worth add a second test file for a rep
| |
38 </script> | |
OLD | NEW |