gfx/layers/apz/test/mochitest/helper_bug1544966_zoom_on_touch_action_none.html
author Dana Keeler <dkeeler@mozilla.com>
Fri, 27 Jan 2023 04:07:10 +0000
changeset 650755 f75c73066b887c2379158c73c994b5ef95460238
parent 616557 918ef225713fa9fc188f42355a6cd4a2bfb3b64c
permissions -rw-r--r--
Bug 1811633 - use updated, vendored version of PKI.js, remove old version r=Gijs This also converts certDecoder.jsm to an ES module (as certDecoder.mjs) and updates all uses of it. Differential Revision: https://phabricator.services.mozilla.com/D167466

<!DOCTYPE HTML>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width; initial-scale=1.0">
  <title>Test for Bug 1544966</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 src="/tests/SimpleTest/EventUtils.js"></script>
  <script type="application/javascript">

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

  var pointersDown = 0;
  var pointersUp = 0;
  var pointerMoveCount = 0;

  target.addEventListener("pointerdown", function(e) {
    dump(`Got pointerdown, pointer id ${e.pointerId}\n`);
    pointersDown++;
  });
  target.addEventListener("pointermove", function(e) {
    dump(`Got pointermove, pointer id ${e.pointerId}, at ${e.clientX}, ${e.clientY}\n`);
    pointerMoveCount++;
  });
  let pointersUpPromise = new Promise(resolve => {
    target.addEventListener("pointercancel", function(e) {
      dump(`Got pointercancel, pointer id ${e.pointerId}\n`);
      ok(false, "Should not have gotten pointercancel");
      pointersUp++;
      if (pointersDown == pointersUp) {
        // All pointers lifted, let's continue the test
        resolve();
      }
    });
    target.addEventListener("pointerup", function(e) {
      dump(`Got pointerup, pointer id ${e.pointerId}\n`);
      pointersUp++;
      if (pointersDown == pointersUp) {
        // All pointers lifted, let's continue the test
        resolve();
      }
    });
  });

  var zoom_in = [
      [ { x: 125, y: 175 }, { x: 175, y: 225 } ],
      [ { x: 120, y: 150 }, { x: 180, y: 250 } ],
      [ { x: 115, y: 125 }, { x: 185, y: 275 } ],
      [ { x: 110, y: 100 }, { x: 190, y: 300 } ],
      [ { x: 105, y:  75 }, { x: 195, y: 325 } ],
      [ { x: 100, y:  50 }, { x: 200, y: 350 } ],
  ];

  var touchIds = [0, 1];
  await synthesizeNativeTouchSequences(document.getElementById("target"), zoom_in, null, touchIds);

  dump("All touch events synthesized, waiting for final pointerup...\n");
  await pointersUpPromise;

  // Should get at least one pointermove per pointer, even if the events
  // get coalesced somewhere.
  is(pointersDown, 2, "Got expected numbers of pointers recorded");
  ok(pointerMoveCount >= 2, "Got " + pointerMoveCount + " pointermove events");
}

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

  </script>
  <style>
    body {
        height: 5000px;
    }
    #target {
        touch-action: none;
        height: 400px
    }
  </style>
</head>
<body>
 <div id="target">
  Put down two fingers at the same time and do a pinch action.
 </div>
</body>
</html>