Bug 1282833 - Return position from Set Window Position; r?automatedtester draft
authorAndreas Tolfsen <ato@mozilla.com>
Thu, 06 Oct 2016 13:11:31 +0100
changeset 421551 849ad7cbd2697e91ab291219359dd012fb5a48e1
parent 421550 b65660a10f3c2ed34ebecbd17ba68146d2ce5962
child 421552 43b28fda88b454f864b67f5f862797d1ee8000f9
push id31547
push userbmo:ato@mozilla.com
push dateThu, 06 Oct 2016 12:27:41 +0000
reviewersautomatedtester
bugs1282833
milestone52.0a1
Bug 1282833 - Return position from Set Window Position; r?automatedtester MozReview-Commit-ID: C8R9zAbJXsY
testing/marionette/browser.js
testing/marionette/driver.js
--- a/testing/marionette/browser.js
+++ b/testing/marionette/browser.js
@@ -263,16 +263,26 @@ browser.Context = class {
   executeWhenReady(cb) {
     if (this.hasRemotenessChange()) {
       this.pendingCommands.push(cb);
     } else {
       cb();
     }
   }
 
+  /**
+   * Returns the position of the OS window.
+   */
+  get position() {
+    return {
+      x: this.window.screenX,
+      y: this.window.screenY,
+    };
+  }
+
 };
 
 /**
  * The window storage is used to save outer window IDs mapped to weak
  * references of Window objects.
  *
  * Usage:
  *
--- a/testing/marionette/driver.js
+++ b/testing/marionette/driver.js
@@ -1225,46 +1225,49 @@ GeckoDriver.prototype.getChromeWindowHan
   }
   resp.body = hs;
 };
 
 /**
  * Get the current window position.
  *
  * @return {Object.<string, number>}
- *     Object with x and y coordinates.
+ *     Object with |x| and |y| coordinates.
  */
 GeckoDriver.prototype.getWindowPosition = function(cmd, resp) {
-  let win = this.getCurrentWindow();
-  resp.body.x = win.screenX;
-  resp.body.y = win.screenY;
+  return this.curBrowser.position;
 };
 
 /**
  * Set the window position of the browser on the OS Window Manager
  *
  * @param {number} x
  *     X coordinate of the top/left of the window that it will be
  *     moved to.
  * @param {number} y
  *     Y coordinate of the top/left of the window that it will be
  *     moved to.
+ *
+ * @return {Object.<string, number>}
+ *     Object with |x| and |y| coordinates.
  */
 GeckoDriver.prototype.setWindowPosition = function(cmd, resp) {
   if (this.appName != "Firefox") {
     throw new UnsupportedOperationError("Unable to set the window position on mobile");
   }
 
   let {x, y} = cmd.parameters;
   if (!Number.isInteger(x) || !Number.isInteger(y)) {
     throw new InvalidArgumentError();
   }
 
   let win = this.getCurrentWindow();
   win.moveTo(x, y);
+
+  return this.curBrowser.position;
 };
 
 /**
  * Switch current top-level browsing context by name or server-assigned ID.
  * Searches for windows by name, then ID.  Content windows take precedence.
  *
  * @param {string} name
  *     Target name or ID of the window to switch to.