Bug 1303704 Part3: [Pointer Event] Add test case to ensure preventDefault on pointerdown doesn't impact firing click event. r=masayuki
authorStone Shih <sshih@mozilla.com>
Thu, 10 Nov 2016 10:11:16 +0800
changeset 323005 afa4e843b8e99d7b64cc23a0d42b95638147fc2b
parent 323004 7a61dcea0be348056a5e8103b4f27bc41220d4bf
child 323006 50f830bdb2c836b149bf36b8f9f8b6b6e634c130
push id21
push usermaklebus@msu.edu
push dateThu, 01 Dec 2016 06:22:08 +0000
reviewersmasayuki
bugs1303704
milestone53.0a1
Bug 1303704 Part3: [Pointer Event] Add test case to ensure preventDefault on pointerdown doesn't impact firing click event. r=masayuki MozReview-Commit-ID: LiDffeN7hk6
dom/events/test/pointerevents/mochitest.ini
dom/events/test/pointerevents/test_bug1303704.html
--- a/dom/events/test/pointerevents/mochitest.ini
+++ b/dom/events/test/pointerevents/mochitest.ini
@@ -141,10 +141,11 @@ support-files =
     pointerevent_touch-action-span-test_touch-manual.html
     pointerevent_touch-action-svg-test_touch-manual.html
     pointerevent_touch-action-table-test_touch-manual.html
 [test_bug1285128.html]
 [test_bug1293174_implicit_pointer_capture_for_touch_1.html]
   support-files = bug1293174_implicit_pointer_capture_for_touch_1.html
 [test_bug1293174_implicit_pointer_capture_for_touch_2.html]
   support-files = bug1293174_implicit_pointer_capture_for_touch_2.html
+[test_bug1303704.html]
 [test_empty_file.html]
   disabled = disabled # Bug 1150091 - Issue with support-files
new file mode 100644
--- /dev/null
+++ b/dom/events/test/pointerevents/test_bug1303704.html
@@ -0,0 +1,54 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=1303704
+-->
+<head>
+  <meta charset="utf-8">
+  <title>Test for Bug 1303704</title>
+  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
+  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1303704">Mozilla Bug 1303704</a>
+<p id="display"></p>
+<a id="link1" href="http://www.google.com">Link 1</a>
+<script type="text/javascript">
+
+/** Test for Bug 1303704 **/
+SimpleTest.waitForExplicitFinish();
+
+function runTests() {
+  let link1 = window.document.getElementById("link1");
+  let mouseEvents = ["mousedown", "mouseup", "mousemove"];
+
+  link1.addEventListener("pointerdown", (e) => {
+    e.preventDefault();
+    is(e.defaultPrevented, true, "defaultPrevented should be true");
+  }, false);
+
+  mouseEvents.forEach((elm, index, arr) => {
+    link1.addEventListener(elm, () => {
+      ok(false, "Should not receive " + elm + " after preventDefault on pointerdown");
+    }, false);
+  });
+
+  link1.addEventListener("click", (e) => {
+    e.preventDefault();
+    SimpleTest.finish();
+  }, false);
+
+  synthesizeMouseAtCenter(link1, { type: "mousedown",
+                                   inputSource: SpecialPowers.Ci.nsIDOMMouseEvent.MOZ_SOURCE_MOUSE });
+  synthesizeMouseAtCenter(link1, { type: "mousemove",
+                                   inputSource: SpecialPowers.Ci.nsIDOMMouseEvent.MOZ_SOURCE_MOUSE });
+  synthesizeMouseAtCenter(link1, { type: "mouseup",
+                                   inputSource: SpecialPowers.Ci.nsIDOMMouseEvent.MOZ_SOURCE_MOUSE });
+}
+
+SpecialPowers.pushPrefEnv({"set": [["dom.w3c_pointer_events.enabled", true]]}, runTests);
+
+</script>
+</body>
+</html>