From fe855f06e6b314a833a377490bb6773f7f38e3d2 Mon Sep 17 00:00:00 2001 From: Andreas Tolfsen Date: Tue, 21 Jan 2014 13:31:31 -0500 Subject: [PATCH] Bug 941132 - getElementPosition not matching webdriver command. r=dburns --- .../marionette/client/marionette/marionette.py | 15 +++++++++++---- testing/marionette/marionette-listener.js | 10 +++++----- testing/marionette/marionette-server.js | 17 +++++++++++++---- 3 files changed, 29 insertions(+), 13 deletions(-) diff --git a/testing/marionette/client/marionette/marionette.py b/testing/marionette/client/marionette/marionette.py index 7a68aa113c53..d85352a5c7eb 100644 --- a/testing/marionette/client/marionette/marionette.py +++ b/testing/marionette/client/marionette/marionette.py @@ -148,10 +148,17 @@ class HTMLElement(object): @property def location(self): - ''' - A dictionary with the x and y location of an element - ''' - return self.marionette._send_message('getElementPosition', 'value', id=self.id) + """Get an element's location on the page. + + The returned point will contain the x and y coordinates of the + top left-hand corner of the given element. The point (0,0) + refers to the upper-left corner of the document. + + :returns: a dictionary containing x and y as entries + + """ + + return self.marionette._send_message("getElementLocation", "value", id=self.id) def value_of_css_property(self, property_name): ''' diff --git a/testing/marionette/marionette-listener.js b/testing/marionette/marionette-listener.js index 3f8a0c475c13..3d142bb1ab25 100644 --- a/testing/marionette/marionette-listener.js +++ b/testing/marionette/marionette-listener.js @@ -151,7 +151,7 @@ function startListeners() { addMessageListenerId("Marionette:isElementEnabled", isElementEnabled); addMessageListenerId("Marionette:isElementSelected", isElementSelected); addMessageListenerId("Marionette:sendKeysToElement", sendKeysToElement); - addMessageListenerId("Marionette:getElementPosition", getElementPosition); + addMessageListenerId("Marionette:getElementLocation", getElementLocation); addMessageListenerId("Marionette:clearElement", clearElement); addMessageListenerId("Marionette:switchToFrame", switchToFrame); addMessageListenerId("Marionette:deleteSession", deleteSession); @@ -251,7 +251,7 @@ function deleteSession(msg) { removeMessageListenerId("Marionette:isElementEnabled", isElementEnabled); removeMessageListenerId("Marionette:isElementSelected", isElementSelected); removeMessageListenerId("Marionette:sendKeysToElement", sendKeysToElement); - removeMessageListenerId("Marionette:getElementPosition", getElementPosition); + removeMessageListenerId("Marionette:getElementLocation", getElementLocation); removeMessageListenerId("Marionette:clearElement", clearElement); removeMessageListenerId("Marionette:switchToFrame", switchToFrame); removeMessageListenerId("Marionette:deleteSession", deleteSession); @@ -1708,11 +1708,11 @@ function sendKeysToElement(msg) { } /** - * Get the position of an element + * Get the element's top left-hand corner point. */ -function getElementPosition(msg) { +function getElementLocation(msg) { let command_id = msg.json.command_id; - try{ + try { let el = elementManager.getKnownElement(msg.json.id, curFrame); let rect = el.getBoundingClientRect(); diff --git a/testing/marionette/marionette-server.js b/testing/marionette/marionette-server.js index dbad77bfff86..460e34e52169 100644 --- a/testing/marionette/marionette-server.js +++ b/testing/marionette/marionette-server.js @@ -1907,10 +1907,18 @@ MarionetteServerConnection.prototype = { } }, - getElementPosition: function MDA_getElementPosition(aRequest) { + /** + * Get an element's location on the page. + * + * The returned point will contain the x and y coordinates of the + * top left-hand corner of the given element. The point (0,0) + * refers to the upper-left corner of the document. + * + * @return a point containing x and y coordinates as properties + */ + getElementLocation: function MDA_getElementLocation(aRequest) { this.command_id = this.getCommandId(); - this.sendAsync("getElementPosition", - { id:aRequest.parameters.id }, + this.sendAsync("getElementLocation", {id: aRequest.parameters.id}, this.command_id); }, @@ -2376,7 +2384,8 @@ MarionetteServerConnection.prototype.requestTypes = { "isElementEnabled": MarionetteServerConnection.prototype.isElementEnabled, "isElementSelected": MarionetteServerConnection.prototype.isElementSelected, "sendKeysToElement": MarionetteServerConnection.prototype.sendKeysToElement, - "getElementPosition": MarionetteServerConnection.prototype.getElementPosition, + "getElementLocation": MarionetteServerConnection.protocol.getElementLocation, + "getElementPosition": MarionetteServerConnection.prototype.getElementLocation, // deprecated "clearElement": MarionetteServerConnection.prototype.clearElement, "getTitle": MarionetteServerConnection.prototype.getTitle, "getWindowType": MarionetteServerConnection.prototype.getWindowType,