tor-browser

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

style-css-with-json-parser-breaker.sub.html (1502B)


      1 <!DOCTYPE html>
      2 <!-- Test verifies that CORB won't block a stylesheet that
      3     1) is correctly labeled with text/css Content-Type and parsing fine as text/css
      4     2) starts with a JSON parser breaker (like )]}')
      5 -->
      6 <meta charset="utf-8">
      7 <title>CORB doesn't block a stylesheet that has a proper Content-Type and begins with a JSON parser breaker</title>
      8 <script src=/resources/testharness.js></script>
      9 <script src=/resources/testharnessreport.js></script>
     10 
     11 <!-- Default style that will be applied if the external stylesheet resource
     12  below won't load for any reason.  This stylesheet will set h1's
     13  color to green (see |default_color| below). -->
     14 <style>
     15 h1 { color: green; }
     16 </style>
     17 
     18 <!-- This stylesheet (if loaded) should set h1#header's color to red
     19    (see |external_color| below). -->
     20 <!-- www1 is cross-origin, so the HTTP response is CORB-eligible -->
     21 <link rel="stylesheet" type="text/css"
     22      href="http://{{domains[www1]}}:{{ports[http][0]}}/fetch/corb/resources/css-with-json-parser-breaker.css">
     23 
     24 <body>
     25  <h1 id="header">Header example</h1>
     26  <p>Paragraph body</p>
     27 </body>
     28 
     29 <script>
     30 test(() => {
     31  // Verify that CSS got applied / did not get blocked by CORB.
     32  let style = getComputedStyle(document.getElementById('header'));
     33  const external_color = 'rgb(255, 0, 0)';  // red
     34  const default_color = 'rgb(0, 128, 0)';  // green
     35  assert_equals(style.getPropertyValue('color'), external_color);
     36  assert_not_equals(style.getPropertyValue('color'), default_color);
     37 });
     38 </script>