content/base/test/csp/file_CSP_inlinestyle_main_spec_compliant.html

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     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;
    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()'>
    25     <style type="text/css">
    26       div#inlinestylediv {
    27         color: #FF0000;
    28       }
    29     </style>
    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>
    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">
    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.
    47         <animate attributeName="fill" attributeType="XML"
    48                   values="red;orange;red" dur="2s"
    49                   repeatCount="indefinite" />
    50       </text>
    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.
    56         <animate attributeName="fill" attributeType="CSS"
    57                   values="red;orange;red" dur="2s"
    58                   repeatCount="indefinite" />
    59       </text>
    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" />
    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 &lt;set&gt; should be blocked by CSP.
    73       </text>
    74       <set xlink:href="#cssSetTestById"
    75                attributeName="fill"
    76                to="red" />
    77     </svg>
    78   </body>
    79 </html>

mercurial