Bug 1337133 - Add more MouseEvent event properties to synthesizeMouseAtPoint. r=ato, a=test-only
authorMaja Frydrychowicz <mjzffr@gmail.com>
Fri, 17 Feb 2017 16:49:03 -0500
changeset 378823 8910e502db34694c2056dafe5f2a97b3884d192a
parent 378822 4750fbf396d0077c4dd851c213fc5349f5dd05cf
child 378824 e67838014e6bf0492e87b0d903a95eb05e62fd94
push id1419
push userjlund@mozilla.com
push dateMon, 10 Apr 2017 20:44:07 +0000
treeherdermozilla-release@5e6801b73ef6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersato, test-only
bugs1337133
milestone53.0a2
Bug 1337133 - Add more MouseEvent event properties to synthesizeMouseAtPoint. r=ato, a=test-only Provide more control over event properties to caller. Changes are based on testing/mochitest/tests/SimpleTest/EventUtils.js MozReview-Commit-ID: 1p04Fv086Bj
testing/marionette/event.js
--- a/testing/marionette/event.js
+++ b/testing/marionette/event.js
@@ -227,40 +227,51 @@ event.synthesizeMouse = function (
  *
  * If the type of the event is specified, a mouse event of that type is
  * fired. Otherwise, a mousedown followed by a mouse up is performed.
  *
  * @param {number} left
  *     CSS pixels from the left document margin.
  * @param {number} top
  *     CSS pixels from the top document margin.
- * @param {Object.<string, ?>} event
+ * @param {Object.<string, ?>} opts
  *     Object which may contain the properties "shiftKey", "ctrlKey",
  *     "altKey", "metaKey", "accessKey", "clickCount", "button", and
  *     "type".
  * @param {Window=} window
  *     Window object.  Defaults to the current window.
  */
 event.synthesizeMouseAtPoint = function (
     left, top, opts, window = undefined) {
 
   let domutils = getDOMWindowUtils(window);
 
   let button = opts.button || 0;
   let clickCount = opts.clickCount || 1;
   let modifiers = event.parseModifiers_(opts);
+  let pressure = ("pressure" in opts) ? opts.pressure : 0;
+  let inputSource = ("inputSource" in opts) ? opts.inputSource :
+      Ci.nsIDOMMouseEvent.MOZ_SOURCE_MOUSE;
+  let isDOMEventSynthesized =
+      ("isSynthesized" in opts) ? opts.isSynthesized : true;
+  let isWidgetEventSynthesized =
+      ("isWidgetEventSynthesized" in opts) ? opts.isWidgetEventSynthesized : false;
+  let buttons = ("buttons" in opts) ? opts.buttons : domutils.MOUSE_BUTTONS_NOT_SPECIFIED;
 
-  if (("type" in event) && opts.type) {
+  if (("type" in opts) && opts.type) {
     domutils.sendMouseEvent(
-        opts.type, left, top, button, clickCount, modifiers);
+        opts.type, left, top, button, clickCount, modifiers, false, pressure, inputSource,
+        isDOMEventSynthesized, isWidgetEventSynthesized, buttons);
   } else {
     domutils.sendMouseEvent(
-        "mousedown", left, top, button, clickCount, modifiers);
+        "mousedown", left, top, button, clickCount, modifiers, false, pressure, inputSource,
+        isDOMEventSynthesized, isWidgetEventSynthesized, buttons);
     domutils.sendMouseEvent(
-        "mouseup", left, top, button, clickCount, modifiers);
+        "mouseup", left, top, button, clickCount, modifiers, false, pressure, inputSource,
+        isDOMEventSynthesized, isWidgetEventSynthesized, buttons);
   }
 };
 
 /**
  * Call event.synthesizeMouse with coordinates at the centre of the
  * target.
  */
 event.synthesizeMouseAtCenter = function (element, event, window) {