Bug 1319237 - Make GeckoDriver#setWindowPosition synchronous; r=automatedtester draft
authorAndreas Tolfsen <ato@mozilla.com>
Mon, 21 Nov 2016 23:43:35 +0100
changeset 482815 7b4b34aab5c11172e1c12ad62b8017ff0a92a566
parent 482814 88647b1c7115f15649d5029391ff21567f9d527c
child 482816 7121efa0ee5ccf4c50256744dd6b08fcc63cf0e6
push id45172
push userbmo:ato@mozilla.com
push dateMon, 13 Feb 2017 14:08:30 +0000
reviewersautomatedtester
bugs1319237
milestone54.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
@@ -31,16 +31,17 @@ Cu.import("chrome://marionette/content/e
 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/session.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";
 
@@ -1171,25 +1172,29 @@ 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) {
   assert.firefox()
 
   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.
  *