file_inlinestyle_main.html (3132B)
1 <?xml version="1.0" encoding="UTF-8" standalone="no"?> 2 <html> 3 <head> 4 <title>CSP inline script tests</title> 5 <!-- content= "div#linkstylediv { color: #0f0; }" --> 6 <link rel="stylesheet" type="text/css" 7 href='file_CSP.sjs?type=text/css&content=div%23linkstylediv%20%7B%20color%3A%20%230f0%3B%20%7D' /> 8 <!-- content= "div#modifycsstextdiv { color: #0f0; }" --> 9 <link rel="stylesheet" type="text/css" 10 href='file_CSP.sjs?type=text/css&content=div%23modifycsstextdiv%20%7B%20color%3A%20%23f00%3B%20%7D' /> 11 <script> 12 function cssTest() { 13 var elem = document.getElementById('csstextstylediv'); 14 elem.style.cssText = "color: #00FF00;"; 15 getComputedStyle(elem, null).color; 16 17 document.styleSheets[1].cssRules[0].style.cssText = "color: #00FF00;"; 18 elem = document.getElementById('modifycsstextdiv'); 19 getComputedStyle(elem, null).color; 20 } 21 </script> 22 </head> 23 <body onload='cssTest()'> 24 25 <style type="text/css"> 26 div#inlinestylediv { 27 color: #FF0000; 28 } 29 </style> 30 31 <div id='linkstylediv'>Link tag (external) stylesheet test (should be green)</div> 32 <div id='inlinestylediv'>Inline stylesheet test (should be black)</div> 33 <div id='attrstylediv' style="color: #FF0000;">Attribute stylesheet test (should be black)</div> 34 <div id='csstextstylediv'>cssText test (should be black)</div> 35 <div id='modifycsstextdiv'> modify rule from style sheet via cssText(should be green) </div> 36 37 <!-- tests for SMIL stuff - animations --> 38 <svg xmlns="http://www.w3.org/2000/svg" 39 xmlns:xlink="http://www.w3.org/1999/xlink" 40 width="100%" 41 height="100px"> 42 43 <!-- Animates XML attribute, which is mapped into style. --> 44 <text id="xmlTest" x="0" y="15"> 45 This shouldn't be red since the animation should be blocked by CSP. 46 47 <animate attributeName="fill" attributeType="XML" 48 values="red;orange;red" dur="2s" 49 repeatCount="indefinite" /> 50 </text> 51 52 <!-- Animates override value for CSS property. --> 53 <text id="cssOverrideTest" x="0" y="35"> 54 This shouldn't be red since the animation should be blocked by CSP. 55 56 <animate attributeName="fill" attributeType="CSS" 57 values="red;orange;red" dur="2s" 58 repeatCount="indefinite" /> 59 </text> 60 61 <!-- Animates override value for CSS property targeted via ID. --> 62 <text id="cssOverrideTestById" x="0" y="55"> 63 This shouldn't be red since the animation should be blocked by CSP. 64 </text> 65 <animate xlink:href="#cssOverrideTestById" 66 attributeName="fill" 67 values="red;orange;red" 68 dur="2s" repeatCount="indefinite" /> 69 70 <!-- Sets value for CSS property targeted via ID. --> 71 <text id="cssSetTestById" x="0" y="75"> 72 This shouldn't be red since the <set> should be blocked by CSP. 73 </text> 74 <set xlink:href="#cssSetTestById" 75 attributeName="fill" 76 to="red" /> 77 </svg> 78 </body> 79 </html>