Bug 1319237 - Avoid reposition waiting if position is unchanged; r=maja_zf
☠☠ backed out by 4f4dcc23d36b ☠ ☠
authorAndreas Tolfsen <ato@mozilla.com>
Thu, 02 Feb 2017 14:58:36 +0000
changeset 341017 4dc796bbcfaa497154f21abe3f501933a64392db
parent 341016 f8449c471b8fbe6518063072e0de193f06af6229
child 341018 1f7f75c57c59733835ea3168abbc22f6a8e24d62
push id86615
push userkwierso@gmail.com
push dateTue, 07 Feb 2017 01:52:08 +0000
treeherdermozilla-inbound@f0453084d86e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmaja_zf
bugs1319237
milestone54.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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
testing/marionette/driver.js
testing/marionette/harness/marionette_harness/tests/unit/test_window_position.py
--- 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"])