tor-browser

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

referrer-same-origin.sub.html (3297B)


      1 <!DOCTYPE html>
      2 <html>
      3 <head>
      4 <title>Referrer with the same-origin policy</title>
      5 <meta name="referrer" content="same-origin">
      6 <script src="/resources/testharness.js"></script>
      7 <script src="/resources/testharnessreport.js"></script>
      8 </head>
      9 <body>
     10 <script type="module">
     11 
     12 // "name" parameter is necessary for bypassing the module map.
     13 
     14 import { referrer as referrerSame } from "./resources/referrer-checker.py?name=same";
     15 
     16 import { referrer as referrerRemote } from "http://{{domains[www1]}}:{{ports[http][0]}}/html/semantics/scripting-1/the-script-element/module/resources/referrer-checker.py?name=remote";
     17 
     18 import { referrer as referrerSameSame } from "./resources/import-referrer-checker.sub.js?name=same_same";
     19 
     20 import { referrer as referrerSameRemote } from "./resources/import-remote-origin-referrer-checker.sub.js?name=same_remote";
     21 
     22 import { referrer as referrerRemoteRemote } from "http://{{domains[www1]}}:{{ports[http][0]}}/html/semantics/scripting-1/the-script-element/module/resources/import-referrer-checker.sub.js?name=remote_remote";
     23 
     24 import { referrer as referrerRemoteSame } from "http://{{domains[www1]}}:{{ports[http][0]}}/html/semantics/scripting-1/the-script-element/module/resources/import-same-origin-referrer-checker-from-remote-origin.sub.js?name=remote_same";
     25 
     26 const remoteOrigin = "http://{{domains[www1]}}:{{ports[http][0]}}/";
     27 
     28 test(t => {
     29  assert_equals(
     30      referrerSame, location.href,
     31      "Referrer should be sent for the same-origin top-level script.");
     32 }, "Importing a same-origin top-level script with the same-origin policy.");
     33 
     34 test(t => {
     35  assert_equals(
     36      referrerRemote, "",
     37      "Referrer should not be sent for the remote-origin top-level script.");
     38 }, "Importing a remote-origin top-level script with the same-origin policy.");
     39 
     40 test(t => {
     41  const path =
     42      new URL("resources/import-referrer-checker.sub.js", location.href);
     43  assert_equals(
     44      referrerSameSame, path + `?name=same_same`,
     45      "Referrer should be sent for the same-origin descendant script.");
     46 }, "Importing a same-origin descendant script from a same-origin top-level " +
     47   "script with the same-origin policy.");
     48 
     49 test(t => {
     50  assert_equals(
     51      referrerSameRemote, "",
     52      "Referrer should not be sent for the remote-origin descendant script.");
     53 }, "Importing a remote-origin descendant script from a same-origin top-level " +
     54   "script with the same-origin policy.");
     55 
     56 test(t => {
     57  const scriptURL = new URL(
     58    "html/semantics/scripting-1/the-script-element/module/resources/" +
     59    "import-referrer-checker.sub.js", remoteOrigin);
     60  assert_equals(
     61      referrerRemoteRemote, scriptURL + "?name=remote_remote",
     62      "Referrer should be sent for the remote-origin descendant script " +
     63      "when it is imported from a top-level script in the same remote-origin.");
     64 }, "Importing a remote-origin descendant script from a remote-origin " +
     65   "top-level script with the same-origin policy.");
     66 
     67 test(t => {
     68  assert_equals(
     69      referrerRemoteSame, "",
     70      "Referrer should not be sent for the same-origin descendant script " +
     71      "when it is imported from a top-level remote-origin script.");
     72 }, "Importing a same-origin descendant script from a remote-origin " +
     73   "top-level script with the same-origin policy.");
     74 
     75 </script>
     76 </body>
     77 </html>