Bug 1197146 - Part 5: Use dispatcher for listener getElementLocation. r=dburns, a=test-only
☠☠ backed out by 66e9b94c4066 ☠ ☠
authorAndreas Tolfsen <ato@mozilla.com>
Fri, 21 Aug 2015 15:34:09 +0100
changeset 277289 62fa600295843ebffcf1abac328d7019ecef2542
parent 277288 6e0802b05f7b92b84f3f4474371b6ba60a3b9989
child 277290 33d9c59ab315f32a34a7d06905e7071128739f5e
push id8347
push userryanvm@gmail.com
push dateWed, 26 Aug 2015 00:11:37 +0000
treeherdermozilla-aurora@95ea1b781b0f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdburns, test-only
bugs1197146
milestone42.0a2
Bug 1197146 - Part 5: Use dispatcher for listener getElementLocation. r=dburns, a=test-only
testing/marionette/driver.js
testing/marionette/listener.js
--- a/testing/marionette/driver.js
+++ b/testing/marionette/driver.js
@@ -2320,18 +2320,17 @@ GeckoDriver.prototype.clearElement = fun
  * 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 {Object.<string, number>}
  *     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. */
 GeckoDriver.prototype.addCookie = function(cmd, resp) {
   yield this.listener.addCookie({cookie: cmd.parameters.cookie});
 };
 
 /**
--- a/testing/marionette/listener.js
+++ b/testing/marionette/listener.js
@@ -203,16 +203,17 @@ let getElementAttributeFn = dispatch(get
 let getElementTextFn = dispatch(getElementText);
 let getElementTagNameFn = dispatch(getElementTagName);
 let getElementRectFn = dispatch(getElementRect);
 let isElementEnabledFn = dispatch(isElementEnabled);
 let getCurrentUrlFn = dispatch(getCurrentUrl);
 let findElementContentFn = dispatch(findElementContent);
 let findElementsContentFn = dispatch(findElementsContent);
 let isElementSelectedFn = dispatch(isElementSelected);
+let getElementLocationFn = dispatch(getElementLocation);
 
 /**
  * Start all message listeners
  */
 function startListeners() {
   addMessageListenerId("Marionette:receiveFiles", receiveFiles);
   addMessageListenerId("Marionette:newSession", newSession);
   addMessageListenerId("Marionette:executeScript", executeScript);
@@ -239,17 +240,17 @@ function startListeners() {
   addMessageListenerId("Marionette:getElementTagName", getElementTagNameFn);
   addMessageListenerId("Marionette:isElementDisplayed", isElementDisplayed);
   addMessageListenerId("Marionette:getElementValueOfCssProperty", getElementValueOfCssProperty);
   addMessageListenerId("Marionette:getElementSize", getElementSizeFn);  // deprecated
   addMessageListenerId("Marionette:getElementRect", getElementRectFn);
   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);
   addMessageListenerId("Marionette:sleepSession", sleepSession);
   addMessageListenerId("Marionette:emulatorCmdResult", emulatorCmdResult);
   addMessageListenerId("Marionette:importScript", importScript);
   addMessageListenerId("Marionette:getAppCacheStatus", getAppCacheStatus);
   addMessageListenerId("Marionette:setTestName", setTestName);
@@ -344,17 +345,17 @@ function deleteSession(msg) {
   removeMessageListenerId("Marionette:getElementTagName", getElementTagNameFn);
   removeMessageListenerId("Marionette:isElementDisplayed", isElementDisplayed);
   removeMessageListenerId("Marionette:getElementValueOfCssProperty", getElementValueOfCssProperty);
   removeMessageListenerId("Marionette:getElementSize", getElementSizeFn); // deprecated
   removeMessageListenerId("Marionette:getElementRect", getElementRectFn);
   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);
   removeMessageListenerId("Marionette:sleepSession", sleepSession);
   removeMessageListenerId("Marionette:emulatorCmdResult", emulatorCmdResult);
   removeMessageListenerId("Marionette:importScript", importScript);
   removeMessageListenerId("Marionette:getAppCacheStatus", getAppCacheStatus);
   removeMessageListenerId("Marionette:setTestName", setTestName);
@@ -1577,30 +1578,20 @@ function sendKeysToElement(msg) {
   } else {
     utils.sendKeysToElement(curFrame, el, val, sendOk, sendError, command_id);
   }
 }
 
 /**
  * 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};
 }
 
 /**
  * Clear the text of an element
  */
 function clearElement(msg) {
   let command_id = msg.json.command_id;
   try {