OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <html> |
| 3 |
| 4 <head> |
| 5 <!-- Programmatically converted from a WebKit Reftest, please forgive result
ing idiosyncracies.--> |
| 6 <title>scriptnonce-and-scripthash</title> |
| 7 <script src="/resources/testharness.js"></script> |
| 8 <script src="/resources/testharnessreport.js"></script> |
| 9 <script nonce="nonceynonce"> |
| 10 function log(msg) { |
| 11 test(function() { |
| 12 assert_unreached(msg) |
| 13 }); |
| 14 } |
| 15 |
| 16 </script> |
| 17 <script nonce="nonceynonce"> |
| 18 var t_alert = async_test('Expecting alerts: ["PASS (1/3)","PASS (2/3)","
PASS (3/3)"]'); |
| 19 var expected_alerts = ["PASS (1/3)", "PASS (2/3)", "PASS (3/3)"]; |
| 20 |
| 21 function alert_assert(msg) { |
| 22 t_alert.step(function() { |
| 23 if (msg.match(/^FAIL/i)) { |
| 24 assert_unreached(msg); |
| 25 t_alert.done(); |
| 26 } |
| 27 for (var i = 0; i < expected_alerts.length; i++) { |
| 28 if (expected_alerts[i] == msg) { |
| 29 assert_true(expected_alerts[i] == msg); |
| 30 expected_alerts.splice(i, 1); |
| 31 if (expected_alerts.length == 0) { |
| 32 t_alert.done(); |
| 33 } |
| 34 return; |
| 35 } |
| 36 } |
| 37 assert_unreached('unexpected alert: ' + msg); |
| 38 t_log.done(); |
| 39 }); |
| 40 } |
| 41 |
| 42 </script> |
| 43 <!-- enforcing policy: |
| 44 script-src 'self' 'sha256-LS8v1E1Ff0Hc8FobgWKNKY3sbW4rljPlZNQHyyutfKU=' 'nonce-n
onceynonce'; connect-src 'self'; |
| 45 --> |
| 46 <script nonce="nonceynonce"> |
| 47 alert_assert('PASS (1/3)'); |
| 48 |
| 49 </script> |
| 50 <script> |
| 51 alert_assert('PASS (2/3)'); |
| 52 |
| 53 </script> |
| 54 <script nonce="nonceynonce"> |
| 55 alert_assert('PASS (3/3)'); |
| 56 |
| 57 </script> |
| 58 <script> |
| 59 alert_assert('FAIL (1/2)'); |
| 60 |
| 61 </script> |
| 62 <script nonce="notanonce"> |
| 63 alert_assert('FAIL (2/2)'); |
| 64 |
| 65 </script> |
| 66 </head> |
| 67 |
| 68 <body> |
| 69 <p> |
| 70 This tests the combined use of script hash and script nonce. It passes i
f a CSP violation is generated and the three alerts show PASS. |
| 71 </p> |
| 72 <div id="log"></div> |
| 73 <script async defer src="../support/checkReport.sub.js?reportExists=true&
;reportField=violated-directive&reportValue=script-src%20'sha1-MfuEFRkC
2LmR31AMy9KW2ZLDegA='%20'sha1-p70t5PXyndLfjKNjbyBBOL1gFiM='%20&ap
os;nonce-nonceynonce'"></script> |
| 74 </body> |
| 75 |
| 76 </html> |
OLD | NEW |