tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

file_inlinestyle_main_allowed.html (3427B)


      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: #f00; }" -->
      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        // CSSStyleDeclaration.cssText
     14        var elem = document.getElementById('csstextstylediv');
     15        elem.style.cssText = "color: #00FF00;";
     16 
     17        // If I call getComputedStyle as below, this test passes as the parent page
     18        // correctly detects that the text is colored green - if I remove this, getComputedStyle
     19        // thinks the text is black when called by the parent page.
     20        getComputedStyle(elem, null).color;
     21 
     22        document.styleSheets[1].cssRules[0].style.cssText = "color: #00FF00;";
     23        elem = document.getElementById('modifycsstextdiv');
     24        getComputedStyle(elem, null).color;
     25      }
     26    </script>
     27  </head>
     28  <body onload='cssTest()'>
     29 
     30    <style type="text/css">
     31      div#inlinestylediv {
     32        color: #00FF00;
     33      }
     34    </style>
     35 
     36    <div id='linkstylediv'>Link tag (external) stylesheet test (should be green)</div>
     37    <div id='inlinestylediv'>Inline stylesheet test (should be green)</div>
     38    <div id='attrstylediv' style="color: #00FF00;">Attribute stylesheet test (should be green)</div>
     39    <div id='csstextstylediv'>style.cssText test (should be green)</div>
     40    <div id='modifycsstextdiv'> modify rule from style sheet via cssText(should be green) </div>
     41 
     42    <!-- tests for SMIL stuff - animations -->
     43    <svg xmlns="http://www.w3.org/2000/svg"
     44         xmlns:xlink="http://www.w3.org/1999/xlink"
     45         width="100%"
     46         height="100px">
     47 
     48      <!-- Animates XML attribute, which is mapped into style. -->
     49      <text id="xmlTest" x="0" y="15">
     50         This should be green since the animation should be allowed by CSP.
     51 
     52        <animate attributeName="fill" attributeType="XML"
     53                  values="lime;green;lime" dur="2s"
     54                  repeatCount="indefinite" />
     55      </text>
     56 
     57      <!-- Animates override value for CSS property. -->
     58      <text id="cssOverrideTest" x="0" y="35">
     59         This should be green since the animation should be allowed by CSP.
     60 
     61        <animate attributeName="fill" attributeType="CSS"
     62                  values="lime;green;lime" dur="2s"
     63                  repeatCount="indefinite" />
     64      </text>
     65 
     66      <!-- Animates override value for CSS property targeted via ID. -->
     67      <text id="cssOverrideTestById" x="0" y="55">
     68         This should be green since the animation should be allowed by CSP.
     69      </text>
     70      <animate xlink:href="#cssOverrideTestById"
     71               attributeName="fill"
     72               values="lime;green;lime"
     73               dur="2s" repeatCount="indefinite" />
     74 
     75      <!-- Sets value for CSS property targeted via ID. -->
     76      <text id="cssSetTestById" x="0" y="75">
     77         This should be green since the &lt;set&gt; should be allowed by CSP.
     78      </text>
     79      <set xlink:href="#cssSetTestById"
     80               attributeName="fill"
     81               to="lime" />
     82    </svg>
     83  </body>
     84 </html>