Skip to content
This repository has been archived by the owner on Aug 4, 2022. It is now read-only.

Commit

Permalink
Bug 1197146: Part 5: Use dispatcher for listener getElementLocation
Browse files Browse the repository at this point in the history
r=dburns
  • Loading branch information
andreastt committed Aug 21, 2015
1 parent cb380e2 commit 37370b1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 18 deletions.
3 changes: 1 addition & 2 deletions testing/marionette/driver.js
Original file line number Diff line number Diff line change
Expand Up @@ -2325,8 +2325,7 @@ GeckoDriver.prototype.clearElement = function(cmd, resp) {
* A point containing X and Y coordinates as properties.
*/
GeckoDriver.prototype.getElementLocation = function(cmd, resp) {
resp.value = yield this.listener.getElementLocation(
{id: cmd.parameters.id});
return this.listener.getElementLocation(cmd.parameters.id);
};

/** Add a cookie to the document. */
Expand Down
23 changes: 7 additions & 16 deletions testing/marionette/listener.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ let getCurrentUrlFn = dispatch(getCurrentUrl);
let findElementContentFn = dispatch(findElementContent);
let findElementsContentFn = dispatch(findElementsContent);
let isElementSelectedFn = dispatch(isElementSelected);
let getElementLocationFn = dispatch(getElementLocation);

/**
* Start all message listeners
Expand Down Expand Up @@ -244,7 +245,7 @@ function startListeners() {
addMessageListenerId("Marionette:isElementEnabled", isElementEnabledFn);
addMessageListenerId("Marionette:isElementSelected", isElementSelectedFn);
addMessageListenerId("Marionette:sendKeysToElement", sendKeysToElement);
addMessageListenerId("Marionette:getElementLocation", getElementLocation); //deprecated
addMessageListenerId("Marionette:getElementLocation", getElementLocationFn); //deprecated
addMessageListenerId("Marionette:clearElement", clearElement);
addMessageListenerId("Marionette:switchToFrame", switchToFrame);
addMessageListenerId("Marionette:deleteSession", deleteSession);
Expand Down Expand Up @@ -349,7 +350,7 @@ function deleteSession(msg) {
removeMessageListenerId("Marionette:isElementEnabled", isElementEnabledFn);
removeMessageListenerId("Marionette:isElementSelected", isElementSelectedFn);
removeMessageListenerId("Marionette:sendKeysToElement", sendKeysToElement);
removeMessageListenerId("Marionette:getElementLocation", getElementLocation);
removeMessageListenerId("Marionette:getElementLocation", getElementLocationFn);
removeMessageListenerId("Marionette:clearElement", clearElement);
removeMessageListenerId("Marionette:switchToFrame", switchToFrame);
removeMessageListenerId("Marionette:deleteSession", deleteSession);
Expand Down Expand Up @@ -1633,20 +1634,10 @@ function sendKeysToElement(msg) {
/**
* Get the element's top left-hand corner point.
*/
function getElementLocation(msg) {
let command_id = msg.json.command_id;
try {
let el = elementManager.getKnownElement(msg.json.id, curFrame);
let rect = el.getBoundingClientRect();

let location = {};
location.x = rect.left;
location.y = rect.top;

sendResponse({value: location}, command_id);
} catch (e) {
sendError(e, command_id);
}
function getElementLocation(id) {
let el = elementManager.getKnownElement(id, curFrame);
let rect = el.getBoundingClientRect();
return {x: rect.left, y: rect.top};
}

/**
Expand Down

0 comments on commit 37370b1

Please sign in to comment.