tor-browser

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

helper_scroll_linked_effect_by_wheel.html (1924B)


      1 <!DOCTYPE html>
      2 <html>
      3 <meta charset="utf-8">
      4 <script src="/tests/SimpleTest/EventUtils.js"></script>
      5 <script src="/tests/SimpleTest/paint_listener.js"></script>
      6 <script src="apz_test_utils.js"></script>
      7 <script src="apz_test_native_event_utils.js"></script>
      8 <title>A scroll linked effect scrolled by wheel events</title>
      9 <style>
     10 html, body { margin: 0; }
     11 body {
     12  height: 1000vh;
     13 }
     14 #target {
     15  position: absolute;
     16  height: 800px;
     17  background-color: #cc00cc;
     18  top: 0;
     19  left: 0;
     20  right: 0;
     21 }
     22 </style>
     23 <div id="target"></div>
     24 <script>
     25 // Set up a scroll linked effect element.
     26 window.addEventListener("scroll", () => {
     27  target.style.top = window.scrollY + "px";
     28 });
     29 
     30 async function test() {
     31  let rect = rectRelativeToScreen(target);
     32  // We only care the top 10px here since the scroll linked effect on the
     33  // main-thread can't keep up with the async scrolling by wheel events so that
     34  // the position absolute element is often partially scrolled out.
     35  rect.height = 10.0;
     36  const initialSnapshot = await getSnapshot(rect);
     37 
     38  let snapshots = [];
     39  for (let i = 0; i < 10; i++) {
     40    await synthesizeNativeWheel(window, 50, 50, 0, -10);
     41    snapshots.push(await getSnapshot(rect));
     42  }
     43 
     44  const sampledData = collectSampledScrollOffsets(document.scrollingElement);
     45  const hasPoint5FractionalOffset = sampledData.some(data => {
     46    return SpecialPowers.wrap(data).scrollOffsetY.toString().split(".")?.[1] === "5"
     47  });
     48 
     49  if (hasPoint5FractionalOffset) {
     50    todo(false, "Bug 1752789: There's at least one sampled scroll offset " +
     51         "having .5 fractional part in such cases scroll linked effects can " +
     52         "not be rendered at the same position of the async scroll offset");
     53    return;
     54  }
     55 
     56  snapshots.forEach(snapshot => {
     57    is(initialSnapshot, snapshot);
     58  });
     59 }
     60 
     61 pushPrefs([["apz.test.logging_enabled", true]])
     62 .then(waitUntilApzStable)
     63 .then(test)
     64 .then(subtestDone, subtestFailed);
     65 </script>