Bug 1388365 - Add client.Window#state and #rect. r?whimboo draft
authorAndreas Tolfsen <ato@sny.no>
Tue, 08 Aug 2017 14:59:09 +0100
changeset 642716 5b069b674c29368eead868fa3f5ca70df1275f67
parent 642715 f195c5b537e23ae3ff71831d7d4bfcbd40d4148c
child 642717 6fc2ca2f0ca5327d075283458c9ef18e22e23e35
push id72846
push userbmo:ato@sny.no
push dateTue, 08 Aug 2017 17:43:46 +0000
reviewerswhimboo
bugs1388365
milestone57.0a1
Bug 1388365 - Add client.Window#state and #rect. r?whimboo Introduces two new APIs on client.Window in the WPT WebDriver client: client.Window#state and client.Window#rect. The latter is used to reduce raw calls amongst client.Window's shorthands to GET window/rect. MozReview-Commit-ID: Kf4P2q93QaL
testing/web-platform/tests/tools/webdriver/webdriver/client.py
--- a/testing/web-platform/tests/tools/webdriver/webdriver/client.py
+++ b/testing/web-platform/tests/tools/webdriver/webdriver/client.py
@@ -234,40 +234,50 @@ class Actions(object):
 
 
 class Window(object):
     def __init__(self, session):
         self.session = session
 
     @property
     @command
+    def rect(self):
+        return self.session.send_session_command("GET", "window/rect")
+
+    @property
+    @command
     def size(self):
-        resp = self.session.send_session_command("GET", "window/rect")
-        return (resp["width"], resp["height"])
+        rect = self.rect
+        return (rect["width"], rect["height"])
 
     @size.setter
     @command
     def size(self, data):
         width, height = data
         body = {"width": width, "height": height}
         self.session.send_session_command("POST", "window/rect", body)
 
     @property
     @command
     def position(self):
-        resp = self.session.send_session_command("GET", "window/rect")
-        return (resp["x"], resp["y"])
+        rect = self.rect
+        return (rect["x"], rect["y"])
 
     @position.setter
     @command
     def position(self, data):
         data = x, y
         body = {"x": x, "y": y}
         self.session.send_session_command("POST", "window/rect", body)
 
+    @property
+    @command
+    def state(self):
+        return self.rect["state"]
+
     @command
     def maximize(self):
         return self.session.send_session_command("POST", "window/maximize")
 
 
 class Find(object):
     def __init__(self, session):
         self.session = session