Commit b85c42be authored by Andreas Tolfsen's avatar Andreas Tolfsen
Browse files

bug 1492499: marionette: make window positioning idempotent; r=whimboo

When the ChromeWindow is already in the desired x/y position,
WebDriver:SetWindowRect should act as a no-op.  This avoids a
superfluous call to ChromeWindow.moveTo.

Depends on D8416

Differential Revision: https://phabricator.services.mozilla.com/D8417

--HG--
extra : moz-landing-system : lando
parent a63546f5
Loading
Loading
Loading
Loading
+3 −14
Original line number Diff line number Diff line
@@ -1469,18 +1469,6 @@ GeckoDriver.prototype.setWindowRect = async function(cmd) {
    });
  };

  // Wait for the window position to change.
  async function windowPosition(x, y) {
    return new PollPromise((resolve, reject) => {
      if ((x == win.screenX && y == win.screenY) ||
          (win.screenX != origRect.x || win.screenY != origRect.y)) {
        resolve();
      } else {
        reject();
      }
    });
  }

  switch (WindowState.from(win.windowState)) {
    case WindowState.Fullscreen:
      await exitFullscreen(win);
@@ -1505,8 +1493,9 @@ GeckoDriver.prototype.setWindowRect = async function(cmd) {
    assert.integer(x);
    assert.integer(y);

    if (win.screenX != x || win.screenY != y) {
      win.moveTo(x, y);
    await windowPosition(x, y);
    }
  }

  return this.curBrowser.rect;