gfx/layers/apz/test/mochitest/helper_scroll_over_scrollbar.html
author James Teh <jteh@mozilla.com>
Wed, 01 Feb 2023 05:02:01 +0000
changeset 651150 dd0fdd1daa69783be36acd5c50544f3694eaa8f9
parent 568166 73824cc3c66a3aa170d3b0c688e7dee58d06f1d7
permissions -rw-r--r--
Bug 1813980: Check IsDoc before Parent in RemoteAccessibleBase::ApplyCrossDocOffset. r=morgan We call this function on every ancestor when calculating bounds. RemoteParent() currently requires a hash lookup, so it's more efficient to early return for !IsDoc() first. This is a micro-optimisation, but it might have some impact given that we call this on every ancestor, especially when hit testing, where we call Bounds() a lot. As a bit of drive-by cleanup, use RemoteParent() rather than calling Parent() and IsRemote/AsRemote(). Differential Revision: https://phabricator.services.mozilla.com/D168346

<head>
  <meta name="viewport" content="width=device-width; initial-scale=1.0">
  <title>Wheel-scrolling over scrollbar</title>
  <script type="application/javascript" src="apz_test_native_event_utils.js"></script>
  <script type="application/javascript" src="apz_test_utils.js"></script>
  <script src="/tests/SimpleTest/paint_listener.js"></script>
  <script type="application/javascript">

async function test() {
  var subframe = document.getElementById("scroll");

  // scroll over the scrollbar, and make sure the subframe scrolls
  var scrollPos = subframe.scrollTop;
  if (subframe.clientWidth == 200) {
    // No scrollbar, abort the test. This can happen e.g. on local macOS runs
    // with OS settings to only show scrollbars on trackpad/mouse activity.
    ok(false, "No scrollbars found, cannot run this test!");
    return;
  }
  var scrollbarX = (200 + subframe.clientWidth) / 2;
  await promiseNativeWheelAndWaitForScrollEvent(subframe, scrollbarX, 100,
      0, -10);
  ok(subframe.scrollTop > scrollPos, "subframe scrolled after wheeling over scrollbar");
}

waitUntilApzStable()
.then(test)
.then(subtestDone, subtestFailed);

  </script>
  <style>
    #scroll {
      width: 200px;
      height: 200px;
      overflow: scroll;
    }
    #scrolled {
      width: 200px;
      height: 1000px; /* so the subframe has room to scroll */
      will-change: transform; /* to force active layers */
    }
  </style>
</head>
<body>
  <div id="scroll">
    <div id="scrolled"></div>
  </div>
</body>