Bug 1319237 - Avoid reposition waiting if position is unchanged. r=maja_zf, a=test-only
authorAndreas Tolfsen <ato@mozilla.com>
Thu, 02 Feb 2017 14:58:36 +0000
changeset 376224 3df0618b87a35c823e6b1e973991ac4dffd7e5e2
parent 376223 7310c81675f4e2127f1231c1367c95a7ae012d7d
child 376225 7b41cdbb9c97c4e41bb88ef1495e84b478b79131
push id6996
push userjlorenzo@mozilla.com
push dateMon, 06 Mar 2017 20:48:21 +0000
treeherdermozilla-beta@d89512dab048 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmaja_zf, test-only
bugs1319237
milestone53.0a2
Bug 1319237 - Avoid reposition waiting if position is unchanged. r=maja_zf, a=test-only 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"])