tor-browser

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

force-load-at-top.js (1030B)


      1 function checkScroll() {
      2  // Ensure two animation frames on load to test the fallback to element
      3  // anchor, which gets queued for the next frame if the text fragment is not
      4  // found.
      5  requestAnimationFrame(() => {
      6    requestAnimationFrame(() => {
      7      let results = {
      8        scrolled: (window.pageYOffset != 0),
      9      };
     10 
     11      let key = (new URL(document.location)).searchParams.get("key");
     12      stashResultsThenClose(key, results);
     13    });
     14  });
     15 }
     16 
     17 window.addEventListener('pageshow', () => {
     18  if (location.hash == "#history") {
     19    // This is the "history" test - on the first load we'll navigate to a page
     20    // that calls history.back(). When we load a second time (from the back
     21    // navigation), record the scroll state at that point to check how history
     22    // scroll restoration is handled.
     23    if (history.state == null) {
     24      history.pushState("test", "test", "");
     25      requestAnimationFrame(() => {
     26        location.href = "navigate-back.html";
     27      });
     28      return;
     29    }
     30  }
     31 
     32  checkScroll();
     33 });