tor-browser

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

history-length-test-helper.js (906B)


      1 // Perform real navigations as well as history.pushState navigations to the
      2 // loaded page until we reach the specified navigation limit. This will be the
      3 // first function that runs in the test, and will result in the test
      4 // reloading/restarting until we reach the desired history length.
      5 function maybeNavigateForHistory() {
      6  const kNavigationLimit = 5
      7 
      8  const url = new URL(location.href);
      9 
     10  // First, perform some real navigations as well as history.pushState to this
     11  // same page. Normally this would increase `history.length`.
     12  if (url.searchParams.get("navigationCount") == null)
     13    url.searchParams.append("navigationCount", 1);
     14 
     15  let navigationCount = parseInt(url.searchParams.get("navigationCount"));
     16 
     17  if (navigationCount <= kNavigationLimit) {
     18    url.searchParams.set('navigationCount', ++navigationCount);
     19    location.href = url;
     20    history.pushState({} , "");
     21    return;
     22  }
     23 }