Bug 1500732 [wpt PR 13640] - Add action_sequence in testdriver, a=testonly
authormoz-wptsync-bot <wptsync@mozilla.com>
Thu, 15 Nov 2018 10:00:46 +0000
changeset 503400 7f4b0f74c54cbe0daaf884e5e90d7f4a658d4036
parent 503399 a02d1c15aaed438c907ba519efe7c9f5f44345cb
child 503401 8d6cf0f73cd0aa63996c632140ee436d249528b0
push id10290
push userffxbld-merge
push dateMon, 03 Dec 2018 16:23:23 +0000
treeherdermozilla-beta@700bed2445e6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstestonly
bugs1500732, 13640, 893480, 1289119, 606882
milestone65.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 1500732 [wpt PR 13640] - Add action_sequence in testdriver, a=testonly Automatic update from web-platform-testsAdd action_sequence in testdriver After we expose test_driver.Actions API to web users, we add their implementation in our testdriver file, and fix the wpt tests of Actions API. Bug: 893480 Change-Id: Ib02c0223208eeb2cc30c2ca35b98d5fc938baa2c Reviewed-on: https://chromium-review.googlesource.com/c/1289119 Commit-Queue: Lan Wei <lanwei@chromium.org> Reviewed-by: Navid Zolghadr <nzolghadr@chromium.org> Reviewed-by: Dave Tapuska <dtapuska@chromium.org> Cr-Commit-Position: refs/heads/master@{#606882} -- Update infrastructure/metadata/ to match Chrome and Firefox results -- wpt-commits: 29a37f9c951913bfab45f280d99eaade671fa68f, 683ea003fe4c377eea847e2bccbd13d42c8e030e wpt-pr: 13640
testing/web-platform/tests/infrastructure/metadata/infrastructure/testdriver/actions/elementPosition.html.ini
testing/web-platform/tests/infrastructure/metadata/infrastructure/testdriver/actions/eventOrder.html.ini
testing/web-platform/tests/infrastructure/testdriver/actions/elementPosition.html
testing/web-platform/tests/infrastructure/testdriver/actions/eventOrder.html
testing/web-platform/tests/pointerevents/pointerevent_pointermove-manual.html
testing/web-platform/tests/pointerevents/pointerevent_pointermove.html
testing/web-platform/tests/resources/testdriver-actions.js
testing/web-platform/tests/resources/testdriver.js
--- a/testing/web-platform/tests/infrastructure/metadata/infrastructure/testdriver/actions/elementPosition.html.ini
+++ b/testing/web-platform/tests/infrastructure/metadata/infrastructure/testdriver/actions/elementPosition.html.ini
@@ -1,3 +1,3 @@
 [elementPosition.html]
-  expected:
-    if product == "chrome": ERROR
+  [TestDriver actions: element position]
+    expected: FAIL
--- a/testing/web-platform/tests/infrastructure/metadata/infrastructure/testdriver/actions/eventOrder.html.ini
+++ b/testing/web-platform/tests/infrastructure/metadata/infrastructure/testdriver/actions/eventOrder.html.ini
@@ -1,3 +1,3 @@
 [eventOrder.html]
-  expected:
-    if product == "chrome": ERROR
+  [TestDriver actions: event order]
+    expected: FAIL
--- a/testing/web-platform/tests/infrastructure/testdriver/actions/elementPosition.html
+++ b/testing/web-platform/tests/infrastructure/testdriver/actions/elementPosition.html
@@ -29,15 +29,15 @@ async_test(t => {
   test.addEventListener("click", e => {
     events.push(e.clientX);
     events.push(e.clientY)
   });
 
   let div = document.getElementById("test");
   let actions = new test_driver.Actions()
     .pointerMove(0, 0, {origin: test})
-    .pointerDown()
+    .pointerDown(0, 0, {origin: test})
     .pointerUp()
     .send()
     .then(t.step_func_done(() => assert_array_equals(events, [50, 25])))
     .catch(e => t.step_func(() => assert_unreached("Actions sequence failed " + e)));
 });
 </script>
--- a/testing/web-platform/tests/infrastructure/testdriver/actions/eventOrder.html
+++ b/testing/web-platform/tests/infrastructure/testdriver/actions/eventOrder.html
@@ -12,26 +12,24 @@
 
 <script>
 // Pointer 1 is added before Pointer 2 so it comes first in the list of sources
 // Therefore its actions happen first
 let events = [];
 
 async_test(t => {
   Array.prototype.forEach.call(document.getElementsByTagName("button"),
-                               (x) => x.addEventListener("mousedown", () => {events.push(x.id)}));
+                               (x) => x.addEventListener("pointerdown", () => {events.push(x.id)}));
 
   let button_a = document.getElementById("a");
   let button_b = document.getElementById("b");
   let actions = new test_driver.Actions()
-    .addPointer("pointer1")
-    .addPointer("pointer2")
-    .pointerMove(0, 0, {origin: button_a, sourceName: "pointer1"})
-    .pointerMove(0, 0, {origin: button_b, sourceName: "pointer2"})
-    .pointerDown({sourceName: "pointer2"})
-    .pointerDown({sourceName: "pointer1"})
+    .addPointer("pointer1", "touch")
+    .addPointer("pointer2", "touch")
+    .pointerDown(0, 0, {origin: button_a, sourceName: "pointer1"})
+    .pointerDown(0, 0, {origin: button_b, sourceName: "pointer2"})
+    .pointerUp({sourceName: "pointer1"})
     .pointerUp({sourceName: "pointer2"})
-    .pointerUp({sourceName: "pointer1"})
     .send()
     .then(t.step_func_done(() => assert_array_equals(events, ["a", "b"])))
     .catch(e => t.step_func(() => assert_unreached("Actions sequence failed " + e)));
 });
 </script>
deleted file mode 100644
--- a/testing/web-platform/tests/pointerevents/pointerevent_pointermove-manual.html
+++ /dev/null
@@ -1,44 +0,0 @@
-<!doctype html>
-<html>
-    <head>
-        <title>Pointermove</title>
-        <meta name="viewport" content="width=device-width">
-        <meta name="assert" content="When a pointer changes coordinates, the pointermove event must be dispatched."/>
-        <link rel="stylesheet" type="text/css" href="pointerevent_styles.css">
-        <script src="/resources/testharness.js"></script>
-        <script src="/resources/testharnessreport.js"></script>
-        <!-- Additional helper script for common checks across event types -->
-        <script type="text/javascript" src="pointerevent_support.js"></script>
-    </head>
-    <body onload="run()">
-        <h2>PointerMove</h2>
-        <h4>Test Description: This test checks if pointermove event triggers. Move your mouse over the black rectangle or slide it if you are using touchscreen.</h4>
-        <div id="target0" style="background:black"></div>
-        <script>
-            var eventTested = false;
-            var detected_pointertypes = {};
-            var test_pointermove = async_test("pointermove event received");
-            add_completion_callback(showPointerTypes);
-
-            function run() {
-                var target0 = document.getElementById("target0");
-
-                // When a pointer changes coordinates, the pointermove event must be dispatched.
-                // TA: 5.3
-                on_event(target0, "pointermove", function (event) {
-                    detected_pointertypes[event.pointerType] = true;
-                    if (eventTested == false) {
-                        test_pointermove.done();
-                        eventTested = true;
-                    }
-                });
-            }
-        </script>
-        <h1>Pointer Events pointermove Tests</h1>
-        <div id="complete-notice">
-            <p>The following pointer types were detected: <span id="pointertype-log"></span>.</p>
-            <p>Refresh the page to run the tests again with a different pointer type.</p>
-        </div>
-        <div id="log"></div>
-    </body>
-</html>
\ No newline at end of file
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/pointerevents/pointerevent_pointermove.html
@@ -0,0 +1,50 @@
+<!doctype html>
+<html>
+    <head>
+        <title>Pointermove</title>
+        <meta name="viewport" content="width=device-width">
+        <meta name="assert" content="When a pointer changes coordinates, the pointermove event must be dispatched."/>
+        <link rel="stylesheet" type="text/css" href="pointerevent_styles.css">
+        <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>
+        <!-- Additional helper script for common checks across event types -->
+        <script type="text/javascript" src="pointerevent_support.js"></script>
+    </head>
+    <body onload="run()">
+        <h2>PointerMove</h2>
+        <h4>Test Description: This test checks if pointermove event triggers. Move your mouse over the black rectangle or slide it if you are using touchscreen.</h4>
+        <div id="target0" style="background:black"></div>
+        <script>
+            var eventTested = false;
+            var detected_pointertypes = {};
+            var test_pointermove = async_test("pointermove event received");
+            add_completion_callback(showPointerTypes);
+
+            function run() {
+                var target0 = document.getElementById("target0");
+
+                // When a pointer changes coordinates, the pointermove event must be dispatched.
+                // TA: 5.3
+                on_event(target0, "pointermove", function (event) {
+                    detected_pointertypes[event.pointerType] = true;
+                    if (eventTested == false) {
+                        test_pointermove.done();
+                        eventTested = true;
+                    }
+                });
+
+                // Inject the inputs to run this test.
+                new test_driver.Actions().pointerMove(0, 0, {origin: target0}).send();
+            }
+        </script>
+        <h1>Pointer Events pointermove Tests</h1>
+        <div id="complete-notice">
+            <p>The following pointer types were detected: <span id="pointertype-log"></span>.</p>
+            <p>Refresh the page to run the tests again with a different pointer type.</p>
+        </div>
+        <div id="log"></div>
+    </body>
+</html>
\ No newline at end of file
--- a/testing/web-platform/tests/resources/testdriver-actions.js
+++ b/testing/web-platform/tests/resources/testdriver-actions.js
@@ -17,16 +17,24 @@
     for (let sourceType of this.sourceTypes.keys()) {
       this.currentSources.set(sourceType, null);
     }
     this.createSource("general");
     this.tickIdx = 0;
   }
 
   Actions.prototype = {
+    ButtonType: {
+      LEFT: 0,
+      MIDDLE: 1,
+      RIGHT: 2,
+      BACK: 3,
+      FORWARD: 4,
+    },
+
     /**
      * Generate the action sequence suitable for passing to
      * test_driver.action_sequence
      *
      * @returns {Array} Array of WebDriver-compatible actions sequences
      */
     serialize: function() {
       let actions = [];
@@ -93,17 +101,17 @@
     /**
      * Add a new key input source with the given name
      *
      * @param {String} name - Name of the key source
      * @param {Bool} set - Set source as the default key source
      * @returns {Actions}
      */
     addKeyboard: function(name, set=true) {
-      this.createSource("key", name, true);
+      this.createSource("key", name);
       if (set) {
         this.setKeyboard(name);
       }
       return this;
     },
 
     /**
      * Set the current default key source
@@ -120,17 +128,17 @@
      * Add a new pointer input source with the given name
      *
      * @param {String} type - Name of the key source
      * @param {String} pointerType - Type of pointing device
      * @param {Bool} set - Set source as the default key source
      * @returns {Actions}
      */
     addPointer: function(name, pointerType="mouse", set=true) {
-      this.createSource("pointer", name, true, {pointerType: pointerType});
+      this.createSource("pointer", name, {pointerType: pointerType});
       if (set) {
         this.setPointer(name);
       }
       return this;
     },
 
     /**
      * Set the current default pointer source
@@ -220,31 +228,31 @@
     /**
      * Create a pointerDown event for the current default pointer source
      *
      * @param {String} button - Button to press
      * @param {String?} sourceName - Named pointer source to use or null for the default
      *                               pointer source
      * @returns {Actions}
      */
-    pointerDown: function({button=0, sourceName=null}={}) {
+    pointerDown: function(x, y, {origin="viewport", button=this.ButtonType.LEFT, sourceName=null}={}) {
       let source = this.getSource("pointer", sourceName);
-      source.pointerDown(this, button);
+      source.pointerDown(this, button, x, y, origin);
       return this;
     },
 
     /**
      * Create a pointerUp event for the current default pointer source
      *
      * @param {String} button - Button to release
      * @param {String?} sourceName - Named pointer source to use or null for the default pointer
      *                               source
      * @returns {Actions}
      */
-    pointerUp: function({button=0, sourceName=null}={}) {
+    pointerUp: function({button=this.ButtonType.LEFT, sourceName=null}={}) {
       let source = this.getSource("pointer", sourceName);
       source.pointerUp(this, button);
       return this;
     },
 
     /**
      * Create a move event for the current default pointer source
      *
@@ -354,22 +362,22 @@
           actions.push(this.actions.get(i));
         } else {
           actions.push({"type": "pause"});
         }
       }
       return data;
     },
 
-    pointerDown: function(actions, button) {
+    pointerDown: function(actions, button, x, y, origin) {
       let tick = actions.tickIdx;
       if (this.actions.has(tick)) {
         tick = actions.addTick().tickIdx;
       }
-      this.actions.set(tick, {type: "pointerDown", button});
+      this.actions.set(tick, {type: "pointerDown", button, x, y, origin});
     },
 
     pointerUp: function(actions, button) {
       let tick = actions.tickIdx;
       if (this.actions.has(tick)) {
         tick = actions.addTick().tickIdx;
       }
       this.actions.set(tick, {type: "pointerUp", button});
--- a/testing/web-platform/tests/resources/testdriver.js
+++ b/testing/web-platform/tests/resources/testdriver.js
@@ -187,17 +187,17 @@
                                     input source and each input source itself has an actions
                                     property detailing the behaviour of that source at each timestep
                                     (or tick). Authors are not expected to construct the actions
                                     sequence by hand, but to use the builder api provided in
                                     testdriver-actions.js
          * @returns {Promise} fufiled after the actions are performed, or rejected in
          *                    the cases the WebDriver command errors
          */
-        action_sequence(actions) {
+        action_sequence: function(actions) {
             return window.test_driver_internal.action_sequence(actions);
         }
     };
 
     window.test_driver_internal = {
         /**
          * Triggers a user-initiated click
          *
@@ -228,16 +228,16 @@
          */
         freeze: function() {
             return Promise.reject(new Error("unimplemented"));
         },
 
         /**
          * Send a sequence of pointer actions
          *
-         * @returns {Promise} fufilled after actions are sent, rejected if any actions
+         * @returns {Promise} fulfilled after actions are sent, rejected if any actions
          *                    fail
          */
         action_sequence: function(actions) {
             return Promise.reject(new Error("unimplemented"));
         }
     };
 })();