Bug 1347589: Implement Marionette Get Window Rect. r=ato

Brings the getWindowPosition and getWindowSize calls into
one call. This aligns Marionette with the W3C WebDriver call
`Get Window Rect`.

MozReview-Commit-ID: ItWI6YpCJkx

--HG--
extra : rebase_source : c08daa9ba0a31a2f2082a7d460619e817180bf22
This commit is contained in:
David Burns 2017-03-24 13:54:37 +00:00
Родитель 54c2a05c8d
Коммит acf4662f21
3 изменённых файлов: 22 добавлений и 22 удалений

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

@ -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)

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

@ -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.<string, number>}
* 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,

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

@ -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"])