tor-browser

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

internal-import-stylesheet-with-differentorigin-base-url-from-preload.tentative.html (1825B)


      1 <!DOCTYPE html>
      2 <title>CSS integration - child CSS fetch from inline stylesheet</title>
      3 <link rel="help" href="https://crbug.com/1158645" />
      4 
      5 <head>
      6  <meta name="referrer" content="origin">
      7 </head>
      8 
      9 <body>
     10 
     11  <script src="/resources/testharness.js"></script>
     12  <script src="/resources/testharnessreport.js"></script>
     13  <script src="/common/utils.js"></script>
     14  <!-- Common global functions for referrer-policy tests. -->
     15  <script src="/common/security-features/resources/common.sub.js"></script>
     16 
     17  <script>
     18    promise_test(function (css_test) {
     19        let id = token();
     20        let url_prefix = location.protocol + "//www." + location.hostname +
     21          ":" + location.port;
     22        let css_url = url_prefix +
     23          "/common/security-features/subresource/stylesheet.py?id=" + id +
     24          "&type=stylesheet-only";
     25        let check_url = url_prefix +
     26          "/common/security-features/subresource/stylesheet.py" +
     27          "?id=" + id + "&report-headers";
     28 
     29        const frame = document.createElement('iframe');
     30        const contents = `
     31              <base href="http://other-site.example" />
     32              <style type=text/css>
     33                @import url('${css_url}');
     34              </style>`;
     35        frame.srcdoc = contents;
     36        document.body.appendChild(frame);
     37        return timeoutPromise(css_test, 1000)
     38          .then(() => requestViaXhr(check_url))
     39          .then(function (message) {
     40            assert_own_property(message, "headers");
     41            assert_own_property(message, "referrer");
     42            assert_equals(message.referrer, location.origin + "/");
     43          });
     44      }, "A child stylesheet from inline style should use the document's" +
     45      " URL, not the document's base URL, as its referrer, even when the " +
     46      "HTML parser preloads the stylesheet.");
     47  </script>