Bug 1319237 - Avoid reposition waiting if position is unchanged; r=maja_zf
When the requested window position is the same as the current position,
we should avoid the wait condition.
MozReview-Commit-ID: 3koG5BeOkFC
--- a/testing/marionette/driver.js
+++ b/testing/marionette/driver.js
@@ -1183,18 +1183,24 @@ GeckoDriver.prototype.setWindowPosition
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);
+ yield wait.until((resolve, reject) => {
+ if ((x == win.screenX && y == win.screenY) ||
+ (win.screenX != orig.screenX || win.screenY != orig.screenY)) {
+ resolve();
+ } else {
+ reject();
+ }
+ });
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.
*
--- a/testing/marionette/harness/marionette_harness/tests/unit/test_window_position.py
+++ b/testing/marionette/harness/marionette_harness/tests/unit/test_window_position.py
@@ -26,8 +26,15 @@ class TestWindowPosition(MarionetteTestC
self.marionette.set_window_position(x, y)
def test_move_to_new_position(self):
old_position = self.marionette.get_window_position()
new_position = {"x": old_position["x"] + 10, "y": old_position["y"] + 10}
self.marionette.set_window_position(new_position["x"], new_position["y"])
self.assertNotEqual(old_position["x"], new_position["x"])
self.assertNotEqual(old_position["y"], new_position["y"])
+
+ def test_move_to_existing_position(self):
+ old_position = self.marionette.get_window_position()
+ self.marionette.set_window_position(old_position["x"], old_position["y"])
+ new_position = self.marionette.get_window_position()
+ self.assertEqual(old_position["x"], new_position["x"])
+ self.assertEqual(old_position["y"], new_position["y"])