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

--HG--
extra : rebase_source : 028ad911ad387aa2b16051666c064e7d618fcbe4
This commit is contained in:
Andreas Tolfsen 2017-02-02 14:58:36 +00:00
Родитель 67b13af80f
Коммит 23828a2bad
2 изменённых файлов: 15 добавлений и 2 удалений

Просмотреть файл

@ -1188,8 +1188,14 @@ GeckoDriver.prototype.setWindowPosition = function* (cmd, resp) {
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;
};

Просмотреть файл

@ -31,3 +31,10 @@ class TestWindowPosition(MarionetteTestCase):
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"])