gfx/layers/apz/test/mochitest/helper_bug1285070.html
author James Teh <jteh@mozilla.com>
Wed, 01 Feb 2023 05:02:01 +0000
changeset 651150 dd0fdd1daa69783be36acd5c50544f3694eaa8f9
parent 616557 918ef225713fa9fc188f42355a6cd4a2bfb3b64c
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>Test pointer events are dispatched once for touch tap</title>
  <script src="/tests/SimpleTest/paint_listener.js"></script>
  <script type="application/javascript" src="apz_test_utils.js"></script>
  <script type="application/javascript" src="apz_test_native_event_utils.js"></script>
  <script type="application/javascript">
    async function test() {
      let eventsList = ["pointerover", "pointerenter", "pointerdown",
                        "pointerup", "pointerleave", "pointerout",
                        "mousedown", "mouseup",
                        "touchstart", "touchend", "click"];
      let eventsCount = {};

      eventsList.forEach((eventName) => {
        eventsCount[eventName] = 0;
        document.getElementById("div1").addEventListener(eventName, (event) => {
          ++eventsCount[event.type];
          ok(true, "Received event " + event.type);
        });
      });

      document.addEventListener("click", (event) => {
        is(event.target, document.getElementById("div1"), "Clicked on div (at " + event.clientX + "," + event.clientY + ")");
        for (var key in eventsCount) {
          is(eventsCount[key], 1, "Event " + key + " should be generated once");
        }
        subtestDone();
      });

      await synthesizeNativeTap(document.getElementById("div1"), 100, 100);
    }

    waitUntilApzStable().then(test);

  </script>
</head>
<body>
  <div id="div1" style="width: 200px; height: 200px; background: black"></div>
</body>
</html>