gfx/layers/apz/test/mochitest/helper_doubletap_zoom_gencon.html
author James Teh <jteh@mozilla.com>
Wed, 01 Feb 2023 05:02:01 +0000
changeset 651150 dd0fdd1daa69783be36acd5c50544f3694eaa8f9
parent 589289 7e795e95ddda3f9b8fb6fe4cff9077834f8b898e
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=2100"/>
  <title>Check that on generated content works</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() {
  let useTouchpad = (location.search == "?touchpad");

  let resolution = await getResolution();
  let initial_resolution = resolution;
  ok(resolution > 0,
     "The initial_resolution is " + resolution + ", which is some sane value");

  let target = document.getElementById("target");

  info("tar " + target.getBoundingClientRect().width);

  // Check that first double tap zooms in
  info("sending first double tap");
  await doubleTapOn(target, 10, 10, useTouchpad);
  let prev_resolution = resolution;
  resolution = await getResolution();
  ok(resolution > prev_resolution, "After double-tap the resolution has increased to " + resolution);

  // Check that second double tap zooms out
  info("sending second double tap");
  await doubleTapOn(target, 10, 10, useTouchpad);
  prev_resolution = resolution;
  resolution = await getResolution();
  ok(resolution < prev_resolution, "After double-tap the resolution has decreased to " + resolution);
  ok(resolution == initial_resolution, "After double-tap the resolution has decreased to initial_resolution");

  info(" window.innerWidth " + window.innerWidth);

  // Check that third double tap zooms in
  info("sending third double tap");
  await doubleTapOn(document.getElementById("placeholder"), 10, 10, useTouchpad);
  prev_resolution = resolution;
  resolution = await getResolution();
  ok(resolution > prev_resolution, "After double-tap the resolution has increased to " + resolution);

  info(" window.innerWidth " + window.innerWidth);

  // Check that fourth double tap zooms out
  info("sending forth double tap");
  await doubleTapOn(document.getElementById("placeholder"), 10, 10, useTouchpad);
  prev_resolution = resolution;
  resolution = await getResolution();
  ok(resolution < prev_resolution, "After double-tap the resolution has decreased to " + resolution);
  ok(resolution == initial_resolution, "After double-tap the resolution has decreased to initial_resolution");

}

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

  </script>
  <style>
body, html {
  margin: 0;
}
.withafter {
  width: 200px;
  height: 200px;
  left: 0;
  background: green;
  position: relative;
}
.withafter::after {
  width: 20vw;
  height: 100px;
  background: blue;
  position: absolute;
  left: 80vw;
  content: 'after';
}
.placeholder {
  width: 20vw;
  height: 100px;
  background: blue;
  position: absolute;
  left: 80vw;
  top:0;
  z-index: -10;
}
</style>
</head>
<body>

<div id="target" class="withafter">some text</div>
<div id="placeholder" class="placeholder"></div>

</body>
</html>