diff --git a/testing/marionette/client/marionette_driver/marionette.py b/testing/marionette/client/marionette_driver/marionette.py index ee1dab660683..4f5db2fffd1c 100644 --- a/testing/marionette/client/marionette_driver/marionette.py +++ b/testing/marionette/client/marionette_driver/marionette.py @@ -1466,6 +1466,8 @@ class Marionette(object): :returns: a dictionary with x and y """ + warnings.warn("get_window_position() has been deprecated, please use get_window_rect()", + DeprecationWarning) return self._send_message( "getWindowPosition", key="value" if self.protocol == 1 else None) @@ -1500,6 +1502,10 @@ class Marionette(object): "height": height, "width": width}) + @property + def window_rect(self): + return self._send_message("getWindowRect") + @property def title(self): """Current title of the active window.""" @@ -2184,6 +2190,8 @@ class Marionette(object): :returns: dictionary representation of current window width and height """ + warnings.warn("window_size property has been deprecated, please use get_window_rect()", + DeprecationWarning) return self._send_message("getWindowSize", key="value" if self.protocol == 1 else None) diff --git a/testing/marionette/driver.js b/testing/marionette/driver.js index 2a07e7e666bc..f79ef41b5679 100644 --- a/testing/marionette/driver.js +++ b/testing/marionette/driver.js @@ -1247,17 +1247,23 @@ GeckoDriver.prototype.getChromeWindowHandles = function (cmd, resp) { } /** - * Get the current window position. + * Get the current position and size of the browser window currently in focus. + * + * Will return the current browser window size in pixels. Refers to + * window outerWidth and outerHeight values, which include scroll bars, + * title bars, etc. * * @return {Object.} - * Object with |x| and |y| coordinates. + * Object with |x| and |y| coordinates, and |width| and |height| + * of browser window. */ -GeckoDriver.prototype.getWindowPosition = function (cmd, resp) { +GeckoDriver.prototype.getWindowRect = function (cmd, resp) { let win = assert.window(this.getCurrentWindow()); - return { x: win.screenX, y: win.screenY, + width: win.outerWidth, + height: win.outerHeight, }; }; @@ -2580,21 +2586,6 @@ GeckoDriver.prototype.setScreenOrientation = function (cmd, resp) { } }; -/** - * Get the size of the browser window currently in focus. - * - * Will return the current browser window size in pixels. Refers to - * window outerWidth and outerHeight values, which include scroll bars, - * title bars, etc. - */ -GeckoDriver.prototype.getWindowSize = function (cmd, resp) { - let win = assert.window(this.getCurrentWindow()); - return { - width: win.outerWidth, - height: win.outerHeight, - }; -}; - /** * Maximizes the user agent window as if the user pressed the maximise * button. @@ -3014,9 +3005,10 @@ GeckoDriver.prototype.commands = { "getCurrentChromeWindowHandle": GeckoDriver.prototype.getChromeWindowHandle, "getWindowHandles": GeckoDriver.prototype.getWindowHandles, "getChromeWindowHandles": GeckoDriver.prototype.getChromeWindowHandles, - "getWindowPosition": GeckoDriver.prototype.getWindowPosition, + "getWindowPosition": GeckoDriver.prototype.getWindowRect, // Redirecting for compatibility "setWindowPosition": GeckoDriver.prototype.setWindowRect, // Redirecting for compatibility "setWindowRect": GeckoDriver.prototype.setWindowRect, + "getWindowRect": GeckoDriver.prototype.getWindowRect, "getActiveFrame": GeckoDriver.prototype.getActiveFrame, "switchToFrame": GeckoDriver.prototype.switchToFrame, "switchToParentFrame": GeckoDriver.prototype.switchToParentFrame, @@ -3037,7 +3029,7 @@ GeckoDriver.prototype.commands = { "getActiveElement": GeckoDriver.prototype.getActiveElement, "getScreenOrientation": GeckoDriver.prototype.getScreenOrientation, "setScreenOrientation": GeckoDriver.prototype.setScreenOrientation, - "getWindowSize": GeckoDriver.prototype.getWindowSize, + "getWindowSize": GeckoDriver.prototype.getWindowRect, // Redirecting for compatibility "setWindowSize": GeckoDriver.prototype.setWindowRect, // Redirecting for compatibility "maximizeWindow": GeckoDriver.prototype.maximizeWindow, "dismissDialog": GeckoDriver.prototype.dismissDialog, diff --git a/testing/marionette/harness/marionette_harness/tests/unit/test_window_position.py b/testing/marionette/harness/marionette_harness/tests/unit/test_window_position.py index c0d130c13253..0b902c809697 100644 --- a/testing/marionette/harness/marionette_harness/tests/unit/test_window_position.py +++ b/testing/marionette/harness/marionette_harness/tests/unit/test_window_position.py @@ -35,7 +35,7 @@ class TestWindowPosition(MarionetteTestCase): x=None, y=None) def test_set_position_with_rect(self): - old_position = self.marionette.get_window_position() + old_position = self.marionette.window_rect wanted_position = {"x": old_position["x"] + 10, "y": old_position["y"] + 10} new_position = self.marionette.set_window_rect(x=wanted_position["x"], y=wanted_position["y"])