Bug 1388036 - Clean up fullscreen state after wdspec test. r?automatedtester draft
authorAndreas Tolfsen <ato@sny.no>
Mon, 07 Aug 2017 14:00:24 +0100
changeset 646595 82f8b0fe1cce3f9cdc92739b45dd038fd5ea4b77
parent 646594 ccea4e5b1e423c72a69762858c45568545b53944
child 646596 26dd123c2faabae61a06d1489257b2bbc5fd010b
push id74184
push userbmo:ato@sny.no
push dateTue, 15 Aug 2017 14:46:44 +0000
reviewersautomatedtester
bugs1388036
milestone57.0a1
Bug 1388036 - Clean up fullscreen state after wdspec test. r?automatedtester This ensures the window is not fullscreen after the test is finished. MozReview-Commit-ID: GRCevDLlkRk
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
@@ -46,16 +46,23 @@ def _restore_normal_window_state(session
     if state == "maximized":
         session.window.maximize()
     elif state == "minimized":
         session.window.minimize()
     elif state == "fullscreen":
         session.window.fullscreen()
 
 
+def _exit_fullscreen(session):
+    """If the window is in fullscreen state, exit fullscreen."""
+    if session.window.fullscreened:
+        session.window.fullscreen()
+    assert not session.window.fullscreened
+
+
 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
 
     for window in _windows(session, exclude=[current_window]):
         session.window_handle = window
@@ -150,16 +157,17 @@ def session(configuration, request):
             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_windows(_current_session))
     request.addfinalizer(lambda: _dismiss_user_prompts(_current_session))
+    request.addfinalizer(lambda: _exit_fullscreen(_current_session))
     request.addfinalizer(lambda: _ensure_valid_window(_current_session))
 
     return _current_session
 
 
 def new_session(configuration, request):
     """Return a factory function that will attempt to start a session with a given body.