gfx/layers/apz/test/mochitest/helper_bug1326290.html
author James Teh <jteh@mozilla.com>
Wed, 01 Feb 2023 05:02:01 +0000
changeset 651150 dd0fdd1daa69783be36acd5c50544f3694eaa8f9
parent 572521 ed5c38a59629d53b960a6973b4d16b8b959884f8
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

<!DOCTYPE HTML>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width; initial-scale=1.0">
  <title>Dragging the mouse on a inactive scrollframe's 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>
  <style>
    #scrollable {
      overflow: scroll;
      height: 200px;
      width: 200px;
    }
    .content {
      width: 1000px;
      height: 2000px;
    }
  </style>
  <script type="text/javascript">

async function test() {
  var scrollableDiv = document.getElementById("scrollable");
  let scrollPromise = new Promise(resolve => {
    scrollableDiv.addEventListener("scroll", resolve, {once: true});
  });

  var dragFinisher = await promiseVerticalScrollbarDrag(scrollableDiv);
  if (!dragFinisher) {
    ok(true, "No scrollbar, can't do this test");
    return;
  }

  // the events above might be stuck in APZ input queue for a bit until the
  // layer is activated, so we wait here until the scroll event listener is
  // triggered.
  await scrollPromise;

  await dragFinisher();

  // Flush everything just to be safe
  await promiseOnlyApzControllerFlushed();

  // After dragging the scrollbar 20px on a 200px-high scrollable div, we should
  // have scrolled approx 10% of the 2000px high content. There might have been
  // scroll arrows and such so let's just have a minimum bound of 50px to be safe.
  ok(scrollableDiv.scrollTop > 50, "Scrollbar drag resulted in a scroll position of " + scrollableDiv.scrollTop);
}

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

  </script>
</head>
<body>
  <div id="scrollable">
    <div class="content">Some content inside the inactive scrollframe</div>
  </div>
  <div class="content">Some content to ensure the root scrollframe is scrollable and the overflow:scroll div remains inactive</div>
</body>
</html>