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>stylehash-basic-blocked</title> |
| 7 <script src="/resources/testharness.js"></script> |
| 8 <script src="/resources/testharnessreport.js"></script> |
| 9 <script src="../support/logTest.sub.js?logs=[]"></script> |
| 10 <script> |
| 11 var t_alert = async_test('Expecting alerts: ["PASS: The \'p\' element\'s
text is green, which means the style was correctly applied."]'); |
| 12 var expected_alerts = ["PASS: The 'p' element's text is green, which mea
ns the style was correctly applied."]; |
| 13 |
| 14 function alert_assert(msg) { |
| 15 t_alert.step(function() { |
| 16 if (msg.match(/^FAIL/i)) { |
| 17 assert_unreached(msg); |
| 18 t_alert.done(); |
| 19 } |
| 20 for (var i = 0; i < expected_alerts.length; i++) { |
| 21 if (expected_alerts[i] == msg) { |
| 22 assert_true(expected_alerts[i] == msg); |
| 23 expected_alerts.splice(i, 1); |
| 24 if (expected_alerts.length == 0) { |
| 25 t_alert.done(); |
| 26 } |
| 27 return; |
| 28 } |
| 29 } |
| 30 assert_unreached('unexpected alert: ' + msg); |
| 31 t_log.done(); |
| 32 }); |
| 33 } |
| 34 |
| 35 </script> |
| 36 <!-- enforcing policy: |
| 37 style-src 'sha1-pfeR5wMA6np45oqDTP6Pj3tLpJo='; script-src 'self' 'unsafe-inline'
; connect-src 'self'; |
| 38 --> |
| 39 <style>p { color: green; }</style> |
| 40 <style>p { color: red; }</style> |
| 41 <style>p { color: purple; }</style> |
| 42 <style>p { color: blue; }</style> |
| 43 </head> |
| 44 |
| 45 <body> |
| 46 <p> |
| 47 This tests the effect of a valid style-hash value, with one valid style
and several invalid ones. It passes if the valid style is applied and a CSP viol
ation is generated. |
| 48 </p> |
| 49 <script> |
| 50 var color = window.getComputedStyle(document.querySelector('p')).color; |
| 51 if (color === "rgb(0, 128, 0)") |
| 52 alert_assert("PASS: The 'p' element's text is green, which means the
style was correctly applied."); |
| 53 else |
| 54 alert_assert("FAIL: The 'p' element's text is " + color + ", which m
eans the style was incorrectly applied."); |
| 55 |
| 56 </script> |
| 57 <div id="log"></div> |
| 58 <script async defer src="../support/checkReport.sub.js?reportExists=true&
;reportField=violated-directive&reportValue=style-src%20'sha1-pfeR5wMA6
np45oqDTP6Pj3tLpJo='"></script> |
| 59 </body> |
| 60 |
| 61 </html> |
OLD | NEW |