Bug 1634781 [wpt PR 23368] - Move mouse pointerevents compat events to wpt, a=testonly
authorNavid Zolghadr <nzolghadr@chromium.org>
Wed, 13 May 2020 09:47:17 +0000
changeset 531143 8745c436c63c9bcc767b3bc90e6137824c2522cf
parent 531142 e7e913365a0064b11b18c25fb0e97c8eb93bbdea
child 531144 1e8c846597a02dfb67f05936eaef1f3fbc5c66e8
push id37435
push userapavel@mozilla.com
push dateWed, 20 May 2020 15:28:23 +0000
treeherdermozilla-central@5415da14ec9a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstestonly
bugs1634781, 23368, 2176104, 766684
milestone78.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1634781 [wpt PR 23368] - Move mouse pointerevents compat events to wpt, a=testonly Automatic update from web-platform-tests Move mouse pointerevents compat events to wpt Change-Id: Ie5b8bdbb36e23ddee4d2445502971b9a5c14d2a1 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2176104 Commit-Queue: Navid Zolghadr <nzolghadr@chromium.org> Auto-Submit: Navid Zolghadr <nzolghadr@chromium.org> Reviewed-by: Mustaq Ahmed <mustaq@chromium.org> Cr-Commit-Position: refs/heads/master@{#766684} -- wpt-commits: a3ffd5bd3a13aae75ca728c1744fa548dfa453e3 wpt-pr: 23368
testing/web-platform/tests/pointerevents/compat/pointerevent_compat-mouse-events-when-removing-nodes.html
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/pointerevents/compat/pointerevent_compat-mouse-events-when-removing-nodes.html
@@ -0,0 +1,103 @@
+<!DOCTYPE HTML>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/resources/testdriver.js"></script>
+<script src="/resources/testdriver-vendor.js"></script>
+<script src="/resources/testdriver-actions.js"></script>
+<script type="text/javascript" src="../pointerevent_support.js"></script>
+
+<style>
+div.box {
+  margin: 5px;
+  padding: 20px;
+  float: left;
+}
+#grey {
+  width: 50px;
+  height: 50px;
+}
+</style>
+
+<h1>Verifies the compatibility mouse events are sent correctly when the node is deleted on pointer event handler.</h1>
+
+<div id="grey" class="box" style="background-color:grey">
+</div>
+
+<div id="console"></div>
+
+<script>
+
+var receivedEvents = [];
+
+var eventList = ["mousedown", "mouseup", "mousemove",
+                 "pointerdown", "pointerup", "pointermove"];
+
+
+var removeNodeEvent = "";
+
+var greyDiv = document.getElementById("grey");
+eventList.forEach(function(eventName) {
+  greyDiv.addEventListener(eventName, function(event) {
+    if (event.eventPhase == Event.AT_TARGET) {
+      receivedEvents.push(event.type+"@grey");
+    }
+  });
+});
+
+function createGreenBoxAndAddListeners() {
+  var greenDiv = document.createElement("div");
+  greenDiv.setAttribute("class", "box");
+  greenDiv.id = "green";
+  greyDiv.innerHTML = "";
+  greyDiv.appendChild(greenDiv);
+  eventList.forEach(function(eventName) {
+    greenDiv.addEventListener(eventName, function(event) {
+      if (event.eventPhase == Event.AT_TARGET) {
+        receivedEvents.push(event.type+"@green");
+        if (event.type == removeNodeEvent) {
+          greenDiv.parentNode.removeChild(greenDiv);
+        }
+      }
+    });
+  });
+}
+
+function performActions() {
+  var rect = document.getElementById("green").getBoundingClientRect();
+  var x1 = rect.left + 5;
+  var y1 = rect.top + 5;
+
+  return new test_driver.Actions()
+              .pointerMove(0, 0)
+              .pointerMove(rect.left + 5, rect.top + 5)
+              .pointerDown(0)
+              .pointerUp(0)
+              .send()
+              .then( () => {
+    return resolveWhen( () => receivedEvents.length == 6 );
+  });
+}
+
+function testScenario(targetEvent, expectedEvents, description) {
+  promise_test(async () => {
+    removeNodeEvent = targetEvent;
+    receivedEvents = [];
+    createGreenBoxAndAddListeners();
+
+    await performActions();
+    assert_array_equals(receivedEvents, expectedEvents);
+  }, description);
+}
+
+testScenario("", ["pointermove@green", "mousemove@green", "pointerdown@green", "mousedown@green", "pointerup@green", "mouseup@green"],
+              "Compat mouse events with no node removal");
+
+testScenario("pointermove", ["pointermove@green", "mousemove@grey", "pointerdown@grey", "mousedown@grey", "pointerup@grey", "mouseup@grey"],
+              "Compat mouse events with node removal on pointermove");
+
+testScenario("pointerdown", ["pointermove@green", "mousemove@green", "pointerdown@green", "mousedown@grey", "pointerup@grey", "mouseup@grey"],
+              "Compat mouse events with node removal on pointerdown");
+
+testScenario("pointerup", ["pointermove@green", "mousemove@green", "pointerdown@green", "mousedown@green", "pointerup@green", "mouseup@grey"],
+              "Compat mouse events with node removal on pointerup");
+</script>