Bug 1319237 - Make GeckoDriver#setWindowPosition synchronous; r?automatedtester draft
authorAndreas Tolfsen <ato@mozilla.com>
Mon, 21 Nov 2016 23:43:35 +0100
changeset 442942 87f9a058ec1e24a077ae48158024816f581b85d1
parent 442941 5f99ce6405ced8d073a046dcf443adf4f017baf2
child 442943 efd85759eb7fe47035492782bb405b2472802081
push id36873
push userbmo:ato@mozilla.com
push dateWed, 23 Nov 2016 16:03:30 +0000
reviewersautomatedtester
bugs1319237
milestone53.0a1
Bug 1319237 - Make GeckoDriver#setWindowPosition synchronous; r?automatedtester This change makes the Set Window Position command synchronous by waiting for the original window position to change before returning. MozReview-Commit-ID: 3gOv6bNPASV
testing/marionette/driver.js
--- a/testing/marionette/driver.js
+++ b/testing/marionette/driver.js
@@ -29,16 +29,17 @@ Cu.import("chrome://marionette/content/e
 Cu.import("chrome://marionette/content/event.js");
 Cu.import("chrome://marionette/content/interaction.js");
 Cu.import("chrome://marionette/content/l10n.js");
 Cu.import("chrome://marionette/content/legacyaction.js");
 Cu.import("chrome://marionette/content/logging.js");
 Cu.import("chrome://marionette/content/modal.js");
 Cu.import("chrome://marionette/content/proxy.js");
 Cu.import("chrome://marionette/content/simpletest.js");
+Cu.import("chrome://marionette/content/wait.js");
 
 this.EXPORTED_SYMBOLS = ["GeckoDriver", "Context"];
 
 var FRAME_SCRIPT = "chrome://marionette/content/listener.js";
 const BROWSER_STARTUP_FINISHED = "browser-delayed-startup-finished";
 const CLICK_TO_START_PREF = "marionette.debugging.clicktostart";
 const CONTENT_LISTENER_PREF = "marionette.contentListener";
 
@@ -1254,27 +1255,31 @@ GeckoDriver.prototype.getWindowPosition 
  *     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) {
+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;
   assert.positiveInteger(x);
   assert.positiveInteger(y);
 
   let win = this.getCurrentWindow();
+  let orig = {screenX: win.screenX, screenY: win.screenY};
+
   win.moveTo(x, y);
+  yield wait.until(() => win.screenX != orig.screenX ||
+      win.screenY != orig.screenY);
 
   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.
  *