Bug 1401128 - Part 2: Modify test to change the way to send mouse event. r?pbro draft
authorDaisuke Akatsuka <dakatsuka@mozilla.com>
Wed, 20 Sep 2017 22:15:26 +0900
changeset 667633 6e9e44dedb881c4fe0379e1247b97bf86a303e91
parent 667632 f9be708a4b9f0df744f71eea7b247a133c088d45
child 732457 5032d9e3143e66ce3fb724c826721c4da9211c22
push id80790
push userbmo:dakatsuka@mozilla.com
push dateWed, 20 Sep 2017 13:16:46 +0000
reviewerspbro
bugs1401128
milestone57.0a1
Bug 1401128 - Part 2: Modify test to change the way to send mouse event. r?pbro MozReview-Commit-ID: GOGJjRowa0W
devtools/client/animationinspector/test/head.js
--- a/devtools/client/animationinspector/test/head.js
+++ b/devtools/client/animationinspector/test/head.js
@@ -435,18 +435,26 @@ function* clickOnAnimation(panel, index,
 
   // Expect a selection event.
   let onSelectionChanged = timeline.once(shouldAlreadySelected
                                          ? "animation-already-selected"
                                          : "animation-selected");
 
   info("Click on animation " + index + " in the timeline");
   let timeBlock = timeline.rootWrapperEl.querySelectorAll(".time-block")[index];
-  EventUtils.sendMouseEvent({type: "click"}, timeBlock,
-                            timeBlock.ownerDocument.defaultView);
+  // Scroll to show the timeBlock since the element may be out of displayed area.
+  timeBlock.scrollIntoView(false);
+  let timeBlockBounds = timeBlock.getBoundingClientRect();
+  let x = timeBlockBounds.width / 2;
+  let y = timeBlockBounds.height / 2;
+  if (timeBlock != timeBlock.ownerDocument.elementFromPoint(x, y)) {
+    // Move the mouse pointer a little since scrubber element may be at the point.
+    x += timeBlockBounds.width / 4;
+  }
+  EventUtils.synthesizeMouse(timeBlock, x, y, {}, timeBlock.ownerDocument.defaultView);
 
   return yield onSelectionChanged;
 }
 
 /**
  * Get an instance of the Keyframes component from the timeline.
  * @param {AnimationsPanel} panel The panel instance.
  * @param {String} propertyName The name of the animated property.