OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE HTML> |
| 2 <html> |
| 3 |
| 4 <head> |
| 5 <title>A separate Report-Only policy does not influence `strict-dynamic` in
the script-src directive.</title> |
| 6 <script src='/resources/testharness.js' nonce='dummy'></script> |
| 7 <script src='/resources/testharnessreport.js' nonce='dummy'></script> |
| 8 |
| 9 <!-- CSP served: |
| 10 1) Content-Security-Policy: script-src 'strict-dynamic' 'nonce-dummy' |
| 11 2) Content-Security-Policy-Report-Only: script-src 'none' |
| 12 --> |
| 13 </head> |
| 14 |
| 15 <body> |
| 16 <h1>A separate Report-Only policy does not influence `strict-dynamic` in the
script-src directive.</h1> |
| 17 <div id='log'></div> |
| 18 |
| 19 <script nonce='dummy'> |
| 20 async_test(function(t) { |
| 21 window.addEventListener('message', t.step_func(function(e) { |
| 22 if (e.data === 'appendChild-reportOnly') { |
| 23 t.done(); |
| 24 } |
| 25 })); |
| 26 window.addEventListener('securitypolicyviolation', t.step_func(funct
ion(violation) { |
| 27 if (violation.blockedURI.split('?')[1] !== 'appendChild-reportOn
ly') { |
| 28 return; |
| 29 } |
| 30 assert_equals(violation.effectiveDirective, 'script-src'); |
| 31 // Check that the violation comes from the Report-Only policy. |
| 32 assert_equals(violation.originalPolicy, "script-src 'none'"); |
| 33 t.done(); |
| 34 })); |
| 35 var e = document.createElement('script'); |
| 36 e.id = 'appendChild-reportOnly'; |
| 37 e.src = 'simpleSourcedScript.js?' + e.id; |
| 38 e.onerror = t.unreached_func('Error should not be triggered.'); |
| 39 document.body.appendChild(e); |
| 40 }, 'Script injected via `appendChild` is allowed with `strict-dynamic` +
Report-Only `script-src \'none\'` policy.'); |
| 41 </script> |
| 42 </body> |
| 43 |
| 44 </html> |
OLD | NEW |