Bug 1282833 - Make Set Window Position type checks spec compliant; r?automatedtester
parseInt accepts any value and coerces it to a number. isNaN allows
floats, and the specification says we should only have integers.
MozReview-Commit-ID: HeZ1eA0duWe
--- a/testing/marionette/driver.js
+++ b/testing/marionette/driver.js
@@ -1248,20 +1248,19 @@ GeckoDriver.prototype.getWindowPosition
* Y coordinate of the top/left of the window that it will be
* moved to.
*/
GeckoDriver.prototype.setWindowPosition = function(cmd, resp) {
if (this.appName != "Firefox") {
throw new UnsupportedOperationError("Unable to set the window position on mobile");
}
- let x = parseInt(cmd.parameters.x);
- let y = parseInt(cmd.parameters.y);
- if (isNaN(x) || isNaN(y)) {
- throw new UnknownError("x and y arguments should be integers");
+ let {x, y} = cmd.parameters;
+ if (!Number.isInteger(x) || !Number.isInteger(y)) {
+ throw new InvalidArgumentError();
}
let win = this.getCurrentWindow();
win.moveTo(x, y);
};
/**
* Switch current top-level browsing context by name or server-assigned ID.