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.tentative.html (1733B)


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