tor-browser

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

file_bug1300461.html (2460B)


      1 <!DOCTYPE html>
      2 <html lang="en">
      3  <head>
      4    <meta http-equiv="content-type" content="text/html; charset=utf-8">
      5    <title>Bug 1300461</title>
      6  </head>
      7  <body onload="test();">
      8    <script>
      9      /**
     10       * Bug 1300461 identifies that if a history entry was not bfcached, and
     11       * a http redirection happens when navigating to that entry, the history
     12       * index would mess up.
     13       *
     14       * The test case emulates the circumstance by the following steps
     15       * 1) Navigate to file_bug1300461_back.html which is not bf-cachable.
     16       * 2) In file_bug1300461_back.html, replace its own history state to
     17       *    file_bug1300461_redirect.html.
     18       * 3) Back, and then forward. Since the document is not in bfcache, it
     19       *    tries to load file_bug1300461_redirect.html directly.
     20       * 4) file_bug1300461_redirect.html redirects UA to
     21       *    file_bug1300461_back.html through HTTP 301 header.
     22       *
     23       * We verify the history index, canGoBack, canGoForward, etc. keep correct
     24       * in this process.
     25       */
     26      let Ci = SpecialPowers.Ci;
     27      let webNav = SpecialPowers.wrap(window)
     28                     .docShell
     29                     .QueryInterface(Ci.nsIWebNavigation);
     30      let shistory = webNav.sessionHistory;
     31      let testSteps = [
     32        function() {
     33          opener.is(shistory.count, 1, "check history length");
     34          opener.is(shistory.index, 0, "check history index");
     35          opener.ok(!webNav.canGoForward, "check canGoForward");
     36          setTimeout(() => window.location = "file_bug1300461_back.html", 0);
     37        },
     38        function() {
     39          opener.is(shistory.count, 2, "check history length");
     40          opener.is(shistory.index, 0, "check history index");
     41          opener.ok(webNav.canGoForward, "check canGoForward");
     42          window.history.forward();
     43        },
     44        function() {
     45          opener.is(shistory.count, 2, "check history length");
     46          opener.is(shistory.index, 0, "check history index");
     47          opener.ok(webNav.canGoForward, "check canGoForward");
     48          opener.info("file_bug1300461.html tests finished");
     49          opener.finishTest();
     50        },
     51      ];
     52 
     53      function test() {
     54        SpecialPowers.wrap(document).notifyUserGestureActivation();
     55 
     56        if (opener) {
     57          opener.info("file_bug1300461.html test " + opener.testCount);
     58          testSteps[opener.testCount++]();
     59        }
     60      }
     61    </script>
     62  </body>
     63 </html>