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
--- 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.
*