Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
michael@0 | 1 | <!doctype html> |
michael@0 | 2 | <!-- |
michael@0 | 3 | The Content-Security-Policy header for this file is: |
michael@0 | 4 | |
michael@0 | 5 | Content-Security-Policy: default-src 'self'; |
michael@0 | 6 | |
michael@0 | 7 | The Content-Security-Policy header for this file includes the default-src |
michael@0 | 8 | directive, which triggers the default behavior of blocking unsafe-inline and |
michael@0 | 9 | unsafe-eval on scripts, and unsafe-inline on styles. |
michael@0 | 10 | --> |
michael@0 | 11 | <html> |
michael@0 | 12 | <body> |
michael@0 | 13 | <ol> |
michael@0 | 14 | <li id="unsafe-inline-script-blocked">Inline script blocked (this text should be black)</li> |
michael@0 | 15 | <li id="unsafe-eval-script-blocked">Eval script blocked (this text should be black)</li> |
michael@0 | 16 | <li id="unsafe-inline-style-blocked">Inline style blocked (this text should be black)</li> |
michael@0 | 17 | </ol> |
michael@0 | 18 | |
michael@0 | 19 | <script> |
michael@0 | 20 | // Use inline script to set a style attribute |
michael@0 | 21 | document.getElementById("unsafe-inline-script-blocked").style.color = "green"; |
michael@0 | 22 | |
michael@0 | 23 | // Use eval to set a style attribute |
michael@0 | 24 | // try/catch is used because CSP causes eval to throw an exception when it |
michael@0 | 25 | // is blocked, which would derail the rest of the tests in this file. |
michael@0 | 26 | try { |
michael@0 | 27 | eval('document.getElementById("unsafe-eval-script-blocked").style.color = "green";'); |
michael@0 | 28 | } catch (e) {} |
michael@0 | 29 | </script> |
michael@0 | 30 | |
michael@0 | 31 | <style> |
michael@0 | 32 | li#unsafe-inline-style-blocked { |
michael@0 | 33 | color: green; |
michael@0 | 34 | } |
michael@0 | 35 | </style> |
michael@0 | 36 | </body> |
michael@0 | 37 | </html> |