--- a/testing/marionette/element.js
+++ b/testing/marionette/element.js
@@ -752,17 +752,16 @@ element.generateUUID = function() {
* Target node.
* @param {number=} x
* Horizontal offset relative to target. Defaults to the centre of
* the target's bounding box.
* @param {number=} y
* Vertical offset relative to target. Defaults to the centre of
* the target's bounding box.
*/
-// TODO(ato): Replicated from listener.js for the time being
element.coordinates = function(node, x = undefined, y = undefined) {
let box = node.getBoundingClientRect();
if (!x) {
x = box.width / 2.0;
}
if (!y) {
y = box.height / 2.0;
}
--- a/testing/marionette/listener.js
+++ b/testing/marionette/listener.js
@@ -844,52 +844,32 @@ function emitTouchEvent(type, touch) {
marionetteLogObj.clearLogs();
*/
let domWindowUtils = curContainer.frame.QueryInterface(Components.interfaces.nsIInterfaceRequestor).getInterface(Components.interfaces.nsIDOMWindowUtils);
domWindowUtils.sendTouchEvent(type, [touch.identifier], [touch.clientX], [touch.clientY], [touch.radiusX], [touch.radiusY], [touch.rotationAngle], [touch.force], 1, 0);
}
}
/**
- * This function generates a pair of coordinates relative to the viewport given a
- * target element and coordinates relative to that element's top-left corner.
- * @param 'x', and 'y' are the relative to the target.
- * If they are not specified, then the center of the target is used.
- */
-function coordinates(target, x, y) {
- let box = target.getBoundingClientRect();
- if (x == null) {
- x = box.width / 2;
- }
- if (y == null) {
- y = box.height / 2;
- }
- let coords = {};
- coords.x = box.left + x;
- coords.y = box.top + y;
- return coords;
-}
-
-/**
* Function that perform a single tap
*/
function singleTap(id, corx, cory) {
let el = elementManager.getKnownElement(id, curContainer);
// after this block, the element will be scrolled into view
let visible = element.isVisible(el, corx, cory);
if (!visible) {
throw new ElementNotVisibleError("Element is not currently visible and may not be manipulated");
}
return interactions.accessibility.getAccessibleObject(el, true).then(acc => {
interactions.accessibility.checkVisible(acc, el, visible);
interactions.accessibility.checkActionable(acc, el);
if (!curContainer.frame.document.createTouch) {
actions.mouseEventsOnly = true;
}
- let c = coordinates(el, corx, cory);
+ let c = element.coordinates(el, corx, cory);
if (!actions.mouseEventsOnly) {
let touchId = actions.nextTouchId++;
let touch = createATouch(el, c.x, c.y, touchId);
emitTouchEvent('touchstart', touch);
emitTouchEvent('touchend', touch);
}
actions.mouseTap(el.ownerDocument, c.x, c.y);
});
@@ -991,34 +971,34 @@ function setDispatch(batches, touches, b
for (let i = 0; i < batch.length; i++) {
pack = batch[i];
touchId = pack[0];
command = pack[1];
switch (command) {
case "press":
el = elementManager.getKnownElement(pack[2], curContainer);
- c = coordinates(el, pack[3], pack[4]);
+ c = element.coordinates(el, pack[3], pack[4]);
touch = createATouch(el, c.x, c.y, touchId);
multiLast[touchId] = touch;
touches.push(touch);
emitMultiEvents("touchstart", touch, touches);
break;
case "release":
touch = multiLast[touchId];
// the index of the previous touch for the finger may change in the touches array
touchIndex = touches.indexOf(touch);
touches.splice(touchIndex, 1);
emitMultiEvents("touchend", touch, touches);
break;
case "move":
el = elementManager.getKnownElement(pack[2], curContainer);
- c = coordinates(el);
+ c = element.coordinates(el);
touch = createATouch(multiLast[touchId].target, c.x, c.y, touchId);
touchIndex = touches.indexOf(lastTouch);
touches[touchIndex] = touch;
multiLast[touchId] = touch;
emitMultiEvents("touchmove", touch, touches);
break;
case "moveByOffset":