Bug 1282833 - Return position from Set Window Position; r?automatedtester
MozReview-Commit-ID: C8R9zAbJXsY
--- 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.