tor-browser

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

test_bug1773192.html (1946B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <head>
      4  <meta charset="utf-8">
      5  <title>Test referrer with going back</title>
      6  <script src="/tests/SimpleTest/SimpleTest.js"></script>
      7  <link rel="stylesheet" href="/tests/SimpleTest/test.css"/>
      8  <script>
      9    SimpleTest.waitForExplicitFinish();
     10 
     11    // file_bug1773192_1.html will send a message with some data on pageshow.
     12    function waitForData(bc) {
     13      return new Promise(resolve => {
     14        bc.addEventListener(
     15          "message",
     16          ({ data }) => {
     17            resolve(data);
     18          },
     19          { once: true }
     20        );
     21      });
     22    }
     23    async function runTest() {
     24      let bc = SpecialPowers.wrap(BroadcastChannel).unpartitionedTestingChannel("bug1743353");
     25 
     26      let getData = waitForData(bc);
     27 
     28      window.open("file_bug1773192_1.html", "", "noreferrer");
     29 
     30      await getData.then(({ referrer }) => {
     31        is(referrer, "", "Referrer should be empty at first.");
     32      });
     33 
     34      getData = waitForData(bc);
     35 
     36      // When file_bug1773192_1.html receives this message it will navigate to
     37      // file_bug1773192_2.html. file_bug1773192_2.html removes itself from
     38      // history with replaceState and submits a form with the POST method to
     39      // file_bug1773192_3.sjs. file_bug1773192_3.sjs goes back in history.
     40      // We should end up back at file_bug1773192_1.html, which will send a
     41      // message with some data on pageshow.
     42      bc.postMessage("next");
     43 
     44      await getData.then(({ location, referrer }) => {
     45        let firstURL = new URL("file_bug1773192_1.html", location).toString();
     46        is(location, firstURL, "Location should be the first page again.");
     47        is(referrer, firstURL, "Referrer should also be the first page.");
     48      });
     49 
     50      bc.postMessage("close");
     51 
     52      SimpleTest.finish();
     53    }
     54  </script>
     55 </head>
     56 <body onload="runTest();">
     57 <p id="display"></p>
     58 <div id="content" style="display: none"></div>
     59 <pre id="test"></pre>
     60 </body>
     61 </html>