tor-browser

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

reading-scroll-forces-anchoring.html (973B)


      1 <!DOCTYPE html>
      2 <link rel="help" href="https://drafts.csswg.org/css-scroll-anchoring-1/">
      3 <script src="/resources/testharness.js"></script>
      4 <script src="/resources/testharnessreport.js"></script>
      5 <style>
      6 body { height: 1000px }
      7 div { height: 100px }
      8 </style>
      9 <div id="block1">abc</div>
     10 <div id="block2">def</div>
     11 <script>
     12  // This test verifies that reading window.scrollY forces any pending scroll
     13  // anchoring adjustment to occur before computing the return value.
     14  async_test((t) => {
     15    scrollTo(0, 150);
     16    requestAnimationFrame(() => {
     17      step_timeout(() => {
     18        // Queue scroll anchoring adjustment.
     19        document.querySelector("#block1").style.height = "200px";
     20 
     21        // Reading scrollY should force both the layout and the adjustment to
     22        // occur synchronously.
     23        var y = scrollY;
     24 
     25        assert_equals(y, 250);
     26        t.done();
     27      }, 0);
     28    });
     29  }, 'Reading scroll position forces scroll anchoring adjustment.');
     30 </script>