OLD | NEW |
1 <!doctype html> | 1 <!doctype html> |
2 <meta http-equiv="Content-Security-Policy" content="block-all-mixed-content"> | 2 <meta http-equiv="Content-Security-Policy" content="block-all-mixed-content"> |
3 <script src="/resources/testharness.js"></script> | 3 <script src="/resources/testharness.js"></script> |
4 <script src="/resources/testharnessreport.js"></script> | 4 <script src="/resources/testharnessreport.js"></script> |
5 <body> | 5 <body> |
6 <script> | 6 <script> |
7 function waitForEvent(t, el, name) { | 7 function waitForEvent(t, el, name) { |
8 return new EventWatcher(t, el, [name]).wait_for(name); | 8 return new EventWatcher(t, el, [name]).wait_for(name); |
9 } | 9 } |
10 | 10 |
11 async_test(t => { | 11 async_test(t => { |
12 var i = document.createElement('img'); | 12 var i = document.createElement('img'); |
13 i.onload = t.unreached_func(); | 13 i.onload = t.unreached_func(); |
14 | 14 |
15 Promise.all([ | 15 Promise.all([ |
16 waitForEvent(t, i, 'error').then(_ => { | 16 waitForEvent(t, i, 'error').then(_ => { |
17 assert_equals(0, i.naturalWidth); | 17 assert_equals(0, i.naturalWidth); |
18 assert_equals(0, i.naturalHeight); | 18 assert_equals(0, i.naturalHeight); |
19 }), | 19 }), |
20 waitForEvent(t, document, 'securitypolicyviolation').then(e => { | 20 waitForEvent(t, document, 'securitypolicyviolation').then(e => { |
21 var expectations = { | 21 var expectations = { |
22 'documentURI': document.location.toString(), | 22 'documentURI': document.location.toString(), |
23 'referrer': document.referrer, | 23 'referrer': document.referrer, |
24 'blockedURI': 'http://example.test:8080/security/resources/c
ompass.jpg?t=1', | 24 'blockedURI': 'http://example.test:8080/security/resources/c
ompass.jpg?t=1', |
25 'violatedDirective': 'block-all-mixed-content', | 25 'violatedDirective': 'block-all-mixed-content', |
26 'effectiveDirective': 'block-all-mixed-content', | 26 'effectiveDirective': 'block-all-mixed-content', |
27 'originalPolicy': 'block-all-mixed-content', | 27 'originalPolicy': 'block-all-mixed-content', |
| 28 'disposition': 'enforce', |
28 'sourceFile': '', | 29 'sourceFile': '', |
29 'lineNumber': 0, | 30 'lineNumber': 0, |
30 'columnNumber': 0, | 31 'columnNumber': 0, |
31 'statusCode': 0 | 32 'statusCode': 0 |
32 }; | 33 }; |
33 for (key in expectations) | 34 for (key in expectations) |
34 assert_equals(expectations[key], e[key], key); | 35 assert_equals(expectations[key], e[key], key); |
35 }) | 36 }) |
36 ]).then(t.step_func_done()); | 37 ]).then(t.step_func_done()); |
37 | 38 |
38 i.src = "http://example.test:8080/security/resources/compass.jpg?t=1"; | 39 i.src = "http://example.test:8080/security/resources/compass.jpg?t=1"; |
39 }, "Mixed images are blocked and generate CSP violation reports in the prese
nce of 'block-all-mixed-content'."); | 40 }, "Mixed images are blocked and generate CSP violation reports in the prese
nce of 'block-all-mixed-content'."); |
40 </script> | 41 </script> |
OLD | NEW |