Bug 1526732 [wpt PR 14911] - Set click count correctly to dispatch "dblclick" event, a=testonly
authorLan Wei <lanwei@chromium.org>
Tue, 19 Feb 2019 14:39:15 +0000
changeset 519244 280b4d2466dd8a963e620016702dbd1194915f87
parent 519243 ae47c9bc4af628e9143bbe8daced47c8f0016561
child 519245 c4418df3a573a860348eb8343f12454af6ad2689
push id10862
push userffxbld-merge
push dateMon, 11 Mar 2019 13:01:11 +0000
treeherdermozilla-beta@a2e7f5c935da [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstestonly
bugs1526732, 14911, 606367, 1413362, 630933
milestone67.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 1526732 [wpt PR 14911] - Set click count correctly to dispatch "dblclick" event, a=testonly Automatic update from web-platform-tests Set click count correctly to dispatch "dblclick" event In order to dispatch the "dblclick" event to DOM by sending synthetic mouse events, we have to check the most recent two mouse press events. If their dispatched times and locations are close enough, we will set the mouse event's click count to 2, which will generate the "dblclick" event. Bug: 606367 Change-Id: I049d6463c6bf1393c9e8b496662359eeeef7682b Reviewed-on: https://chromium-review.googlesource.com/c/1413362 Commit-Queue: Lan Wei <lanwei@chromium.org> Reviewed-by: Navid Zolghadr <nzolghadr@chromium.org> Cr-Commit-Position: refs/heads/master@{#630933} -- wpt-commits: 1ddffbeeb6faed345ce7f999544ed1d29c7a203f wpt-pr: 14911
testing/web-platform/tests/uievents/click/auxclick_event-manual.html
testing/web-platform/tests/uievents/click/auxclick_event.html
testing/web-platform/tests/uievents/click/mouse-dblclick-event.html
deleted file mode 100644
--- a/testing/web-platform/tests/uievents/click/auxclick_event-manual.html
+++ /dev/null
@@ -1,65 +0,0 @@
-<!DOCTYPE html>
-<html>
-  <head>
-    <meta charset="utf-8">
-    <title>Clicking with primary vs non-primary buttons</title>
-    <link rel="help" href="https://wicg.github.io/auxclick/">
-    <script src="/resources/testharness.js"></script>
-    <script src="/resources/testharnessreport.js"></script>
-    <style>
-#target {
-  background-color: green;
-  height: 200px;
-  width: 200px;
-}
-    </style>
-  </head>
-  <body>
-    <h1>Clicking with primary vs non-primary buttons</h1>
-    <p>Double-click on the green box with a non-primary button. When using mouse any button other than the left button is non-primary. If a "PASS" result appears, the test passes; otherwise, it fails.</p>
-    <div id="target"></div>
-    <script>
-    var test_auxclick = async_test("auxclick event sequence received.");
-    var target = document.querySelector('#target');
-    document.addEventListener('contextmenu', event => { event.preventDefault(); });
-    ['click', 'dblclick'].forEach(eventName => {
-        target.addEventListener(eventName, () => {
-            test_auxclick.step(() => {
-                assert_unreached(eventName + ' event should not be dispatched for non-primary buttons.');
-            });
-        });
-        document.addEventListener(eventName, () => {
-            test_auxclick.step(() => {
-                assert_unreached('document should not receive ' + eventName + ' for non-primary buttons.');
-            });
-        }, true);
-    });
-    var click_count = 0;
-    var events = [];
-    ['mousedown', 'mouseup'].forEach(eventName => {
-        target.addEventListener(eventName, event => {
-            events.push(event.type);
-        });
-    });
-    target.addEventListener('auxclick', event => {
-        events.push(event.type);
-        click_count++;
-        if (click_count==1) {
-           test (() => {
-               assert_equals(event.detail, click_count, 'detail attribute of auxclick should be the click count.');
-           }, "First auxclick should have detail=1 indicating the fire click");
-        } else {
-           test (() => {
-               assert_equals(event.detail, click_count, 'detail attribute of auxclick should be the click count.');
-           }, "Second auxclick should have detail=2 indicating the fire click");
-            test_auxclick.step(() => {
-                assert_array_equals(events, ['mousedown', 'mouseup', 'auxclick', 'mousedown', 'mouseup', 'auxclick'],
-                    'There should be two auxclick events for a non-primary button double click each preceded by one mousemove and one mouseup');
-                assert_equals(event.detail, click_count, 'detail attribute of auxclick should be the click count.');
-            });
-            test_auxclick.done();
-        }
-    });
-    </script>
-  </body>
-</html>
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/uievents/click/auxclick_event.html
@@ -0,0 +1,77 @@
+<!DOCTYPE html>
+<html>
+  <head>
+    <meta charset="utf-8">
+    <title>Clicking with primary vs non-primary buttons</title>
+    <link rel="help" href="https://wicg.github.io/auxclick/">
+    <script src="/resources/testharness.js"></script>
+    <script src="/resources/testharnessreport.js"></script>
+    <script src="/resources/testdriver.js"></script>
+    <script src="/resources/testdriver-actions.js"></script>
+    <script src="/resources/testdriver-vendor.js"></script>
+    <style>
+#target {
+  background-color: green;
+  height: 200px;
+  width: 200px;
+}
+    </style>
+  </head>
+  <body>
+    <h1>Clicking with primary vs non-primary buttons</h1>
+    <p>Double-click on the green box with a non-primary button. When using mouse any button other than the left button is non-primary. If a "PASS" result appears, the test passes; otherwise, it fails.</p>
+    <div id="target"></div>
+    <script>
+    var test_auxclick = async_test("auxclick event sequence received.");
+    var target = document.querySelector('#target');
+    document.addEventListener('contextmenu', event => { event.preventDefault(); });
+    ['click', 'dblclick'].forEach(eventName => {
+        target.addEventListener(eventName, () => {
+            test_auxclick.step(() => {
+                assert_unreached(eventName + ' event should not be dispatched for non-primary buttons.');
+            });
+        });
+        document.addEventListener(eventName, () => {
+            test_auxclick.step(() => {
+                assert_unreached('document should not receive ' + eventName + ' for non-primary buttons.');
+            });
+        }, true);
+    });
+    var click_count = 0;
+    var events = [];
+    ['mousedown', 'mouseup'].forEach(eventName => {
+        target.addEventListener(eventName, event => {
+            events.push(event.type);
+        });
+    });
+    target.addEventListener('auxclick', event => {
+        events.push(event.type);
+        click_count++;
+        if (click_count==1) {
+           test (() => {
+               assert_equals(event.detail, click_count, 'detail attribute of auxclick should be the click count.');
+           }, "First auxclick should have detail=1 indicating the fire click");
+        } else {
+           test (() => {
+               assert_equals(event.detail, click_count, 'detail attribute of auxclick should be the click count.');
+           }, "Second auxclick should have detail=2 indicating the fire click");
+            test_auxclick.step(() => {
+                assert_array_equals(events, ['mousedown', 'mouseup', 'auxclick', 'mousedown', 'mouseup', 'auxclick'],
+                    'There should be two auxclick events for a non-primary button double click each preceded by one mousemove and one mouseup');
+                assert_equals(event.detail, click_count, 'detail attribute of auxclick should be the click count.');
+            });
+            test_auxclick.done();
+        }
+    });
+
+    // Inject mouse double click events.
+    var actions = new test_driver.Actions();
+    actions.pointerMove(0, 0, {origin: target})
+           .pointerDown({button: actions.ButtonType.MIDDLE})
+           .pointerUp({button: actions.ButtonType.MIDDLE})
+           .pointerDown({button: actions.ButtonType.MIDDLE})
+           .pointerUp({button: actions.ButtonType.MIDDLE})
+           .send();
+    </script>
+  </body>
+</html>
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/uievents/click/mouse-dblclick-event.html
@@ -0,0 +1,51 @@
+<!DOCTYPE html>
+<html>
+  <head>
+    <meta charset="utf-8">
+    <title>Double Click</title>
+    <link rel="author" title="Google" href="http://www.google.com/" />
+    <script src="/resources/testharness.js"></script>
+    <script src="/resources/testharnessreport.js"></script>
+    <script src="/resources/testdriver.js"></script>
+    <script src="/resources/testdriver-actions.js"></script>
+    <script src="/resources/testdriver-vendor.js"></script>
+    <style type="text/css">
+    .textarea
+    {
+        background:	red;
+        width: 100px;
+        height: 100px;
+        color: white;
+        text-align: center;
+        font-family: monospace;
+    }
+    </style>
+    <script type="text/javascript">
+        // Send two continuous clicks.
+        function run() {
+            var testDoubleClick = async_test('Tests that the double click event is correctly generated by sending pointerDown, pointerUp, pointerDown and pointerUp for the mouse type.');
+            var elem = document.getElementById("click_area");
+            elem.addEventListener('dblclick', function(e) {
+                testDoubleClick.step(function () {
+                  assert_equals(e.target.id, "click_area");
+                  assert_equals(e.detail, 2);
+                });
+                testDoubleClick.done();
+            });
+
+            new test_driver.Actions()
+              .pointerMove(0, 0, {origin: elem})
+              .pointerDown()
+              .pointerUp()
+              .pointerDown()
+              .pointerUp()
+              .send();
+        }
+    </script>
+  </head>
+  <body onload="run()">
+    <h1>Double Click</h1>
+    <p>Double-click on the text area and check if the "dblclick" event is received.</p>
+    <div id="click_area" class="textarea"></div>
+  </body>
+</html>
\ No newline at end of file