Bug 1391691 - Restore window state using Set Window Rect. r?automatedtester draft
authorAndreas Tolfsen <ato@sny.no>
Fri, 18 Aug 2017 18:33:06 +0100
changeset 649134 a3285532c82c76aa7b1925bd48087430d027482e
parent 649133 eb1c27d7d0319a13051966a512fd7a42b39c7e03
child 649135 26928da53ea896adcf7f62f58240bb1027c2f8b1
push id74962
push userbmo:ato@sny.no
push dateFri, 18 Aug 2017 17:50:50 +0000
reviewersautomatedtester
bugs1391691
milestone57.0a1
Bug 1391691 - Restore window state using Set Window Rect. r?automatedtester Because the Maximize Window, Minimize Window, and Fullscreen Window commands are now idempotent we will want to use the Set Window Rect to bring them back to the normal window state. MozReview-Commit-ID: BxtAJizfti6
testing/web-platform/tests/webdriver/tests/support/fixtures.py
--- a/testing/web-platform/tests/webdriver/tests/support/fixtures.py
+++ b/testing/web-platform/tests/webdriver/tests/support/fixtures.py
@@ -32,28 +32,23 @@ def _dismiss_user_prompts(session):
         try:
             session.alert.dismiss()
         except webdriver.NoSuchAlertException:
             pass
 
     session.window_handle = current_window
 
 
-def _restore_normal_window_state(session):
+def _restore_window_state(session):
     """If the window is maximized, minimized, or fullscreened it will
     be returned to normal state.
 
     """
-    state = session.window.state
-    if state == "maximized":
-        session.window.maximize()
-    elif state == "minimized":
-        session.window.minimize()
-    elif state == "fullscreen":
-        session.window.fullscreen()
+    if session.window.state in ("maximized", "minimized", "fullscreen"):
+        session.window.size = (800, 600)
 
 
 def _restore_windows(session):
     """Closes superfluous windows opened by the test without ending
     the session implicitly by closing the last window.
     """
     current_window = session.window_handle
 
@@ -147,17 +142,17 @@ def session(configuration, request):
         _current_session.start()
     except webdriver.errors.SessionNotCreatedException:
         if not _current_session.session_id:
             raise
 
     # finalisers are popped off a stack,
     # making their ordering reverse
     request.addfinalizer(lambda: _switch_to_top_level_browsing_context(_current_session))
-    request.addfinalizer(lambda: _restore_normal_window_state(_current_session))
+    request.addfinalizer(lambda: _restore_window_state(_current_session))
     request.addfinalizer(lambda: _restore_windows(_current_session))
     request.addfinalizer(lambda: _dismiss_user_prompts(_current_session))
     request.addfinalizer(lambda: _ensure_valid_window(_current_session))
 
     return _current_session
 
 
 def new_session(configuration, request):