tor-browser

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

scrollsnapchange-with-proximity-strictness.tentative.html (2444B)


      1 <!DOCTYPE html>
      2 <html>
      3 <head>
      4 <title>
      5  <title> CSS Scroll Snap 2 Test: scrollsnapchange events on proximity strictness container</title>
      6  <link rel="help" href="https://drafts.csswg.org/css-scroll-snap-2/#snap-events"/>
      7 </title>
      8 <script src="/resources/testharness.js"></script>
      9 <script src="/resources/testharnessreport.js"></script>
     10 <script src="/dom/events/scrolling/scroll_support.js"></script>
     11 <script src="/css/css-scroll-snap/snap-events/resources/common.js"></script>
     12 <style>
     13  div {
     14    position: absolute;
     15    margin: 0;
     16  }
     17 
     18  #scroller {
     19    height: 600px;
     20    width: 600px;
     21    overflow: hidden;
     22    scroll-snap-type: y proximity;
     23  }
     24 
     25  .snap {
     26    width: 300px;
     27    height: 300px;
     28    background-color: green;
     29    scroll-snap-align: start;
     30  }
     31 
     32  .area {
     33    width: 2000px;
     34    height: 2000px;
     35  }
     36  </style>
     37 </head>
     38 <body>
     39 <div id="scroller">
     40  <div class="area"></div>
     41  <div id="target" class="snap" style="top: 0px;"></div>
     42 </div>
     43 
     44 <script>
     45  const target = document.getElementById("target");
     46  let resolve_func = null;
     47 
     48  promise_test(async (test) => {
     49    checkSnapEventSupport("scrollsnapchange");
     50    await waitForCompositorCommit();
     51    // The initial snap position is at (0, 0).
     52    assert_equals(scroller.scrollTop, 0);
     53    assert_equals(scroller.scrollLeft, 0);
     54 
     55    let scrollsnapchange_promise = waitForScrollSnapChangeEvent(scroller);
     56    // Scroll to a position where it's outside of the scroll-snap proximity
     57    // threshold, so that it won't trigger snapping.
     58    scroller.scrollTo(0, 250);
     59 
     60    // scrollsnapchange should fire as we've moved from within the proximity range
     61    // to outside the proximity range and are no longer snapped.
     62    let evt = await scrollsnapchange_promise;
     63    assert_equals(scroller.scrollTop, 250);
     64    assertSnapEvent(evt, { block: null, inline: null });
     65    evt = null;
     66 
     67    scrollsnapchange_promise = waitForScrollSnapChangeEvent(scroller);
     68    // Scroll to a position within the scroll-snap proximity
     69    // threshold, so that it triggers snapping.
     70    scroller.scrollTo(0, 190);
     71 
     72    evt = await scrollsnapchange_promise;
     73    assert_equals(scroller.scrollTop, 0);
     74    // scrollsnapchange should fire as we've moved from outside the proximity range
     75    // to inside the proximity range and are once again snapped.
     76    assertSnapEvent(evt, { block: target, inline: null });
     77  }, "Scrollsnapchange fires when scrolling outside proximity range.");
     78  </script>
     79 </body>
     80 </html>