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