Source code
Revision control
Copy as Markdown
Other Tools
<!DOCTYPE HTML>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=2100"/>
  <title>Check that double tapping on a square img doesn't cut off parts of the image</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");
  // Check that double-tapping once on the element zooms in
  info("sending first double tap");
  await doubleTapOn(target, 20, 20, useTouchpad);
  let prev_resolution = resolution;
  resolution = await getResolution();
  ok(resolution > prev_resolution, "The first double-tap has increased the resolution to " + resolution);
  let rect = target.getBoundingClientRect();
  ok(visualViewport.pageLeft < rect.x, `left: ${visualViewport.pageLeft} < ${rect.x}`);
  ok(visualViewport.pageTop < rect.y, `top: ${visualViewport.pageTop} < ${rect.y}`);
  ok(visualViewport.pageLeft + visualViewport.width > rect.x + rect.width,
    `right: ${visualViewport.pageLeft} + ${visualViewport.width} > ${rect.x} + ${rect.width}`);
  ok(visualViewport.pageTop + visualViewport.height > rect.y + rect.height,
    `bottom: ${visualViewport.pageTop} + ${visualViewport.height} > ${rect.y} + ${rect.height}`);
  // Check that double-tapping the second time on the element zooms out
  info("sending second double tap");
  await doubleTapOn(target, 20, 20, useTouchpad);
  prev_resolution = resolution;
  resolution = await getResolution();
  ok(resolution < prev_resolution, "The second double-tap has decreased the resolution to " + resolution);
  ok(resolution == initial_resolution, "The second double-tap has restored the resolution to " + resolution);
}
waitUntilApzStable()
.then(test)
.then(subtestDone, subtestFailed);
  </script>
  <style>
    .bigsquare {
      width: 40vh;
      height: 40vh;
    }
</style>
</head>
<body>
<img id="target" class="bigsquare" src="green100x100.png">
</body>
</html>