Bug 1282833 - Make Set Window Position type checks spec compliant; r?automatedtester draft
authorAndreas Tolfsen <ato@mozilla.com>
Thu, 06 Oct 2016 13:10:56 +0100
changeset 421550 b65660a10f3c2ed34ebecbd17ba68146d2ce5962
parent 421549 16963c64de5f11af3e3e82aa1a13236d2b672867
child 421551 849ad7cbd2697e91ab291219359dd012fb5a48e1
push id31547
push userbmo:ato@mozilla.com
push dateThu, 06 Oct 2016 12:27:41 +0000
reviewersautomatedtester
bugs1282833
milestone52.0a1
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
testing/marionette/driver.js
--- 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.