From 540dbc7814e33b7aab7807b94a16b250ace0c0ea Mon Sep 17 00:00:00 2001 From: "L. David Baron" Date: Mon, 11 Oct 2010 11:03:12 -0700 Subject: [PATCH] Add method to synthesize mouse events at the center of elements. (Bug 595652) r=Mossop a2.0=blocking2.0:betaN --- testing/mochitest/tests/SimpleTest/EventUtils.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/testing/mochitest/tests/SimpleTest/EventUtils.js b/testing/mochitest/tests/SimpleTest/EventUtils.js index 27fbbc77db9..189823eb39c 100644 --- a/testing/mochitest/tests/SimpleTest/EventUtils.js +++ b/testing/mochitest/tests/SimpleTest/EventUtils.js @@ -230,6 +230,14 @@ function synthesizeMouse(aTarget, aOffsetX, aOffsetY, aEvent, aWindow) } } +// Call synthesizeMouse with coordinates at the center of aTarget. +function synthesizeMouseAtCenter(aTarget, aEvent, aWindow) +{ + var rect = aTarget.getBoundingClientRect(); + synthesizeMouse(aTarget, rect.width / 2, rect.height / 2, aEvent, + aWindow); +} + /** * Synthesize a mouse scroll event on a target. The actual client point is determined * by taking the aTarget's client box and offseting it by aOffsetX and