Bug 1461463 - [wdspec] Add timeout reset finalizer to session fixture.
If tests modify the timeout values those have to be reset for the
next test.
MozReview-Commit-ID: FqFwhduDR2m
--- a/testing/web-platform/tests/webdriver/tests/support/fixtures.py
+++ b/testing/web-platform/tests/webdriver/tests/support/fixtures.py
@@ -9,16 +9,20 @@ import sys
import webdriver
from tests.support.http_request import HTTPRequest
from tests.support.wait import wait
default_host = "http://127.0.0.1"
default_port = "4444"
+default_script_timeout = 30
+default_page_load_timeout = 300
+default_implicit_wait_timeout = 0
+
def ignore_exceptions(f):
def inner(*args, **kwargs):
try:
return f(*args, **kwargs)
except webdriver.error.WebDriverException as e:
print("Ignored exception %s" % e, file=sys.stderr)
inner.__name__ = f.__name__
@@ -48,16 +52,24 @@ def _dismiss_user_prompts(session):
session.alert.dismiss()
except webdriver.NoSuchAlertException:
pass
session.window_handle = current_window
@ignore_exceptions
+def _restore_timeouts(session):
+ """Restores modified timeouts to their default values"""
+ session.timeouts.implicit = default_implicit_wait_timeout
+ session.timeouts.page_load = default_page_load_timeout
+ session.timeouts.script = default_script_timeout
+
+
+@ignore_exceptions
def _restore_window_state(session):
"""Reset window to an acceptable size, bringing it out of maximized,
minimized, or fullscreened state
"""
session.window.size = (800, 600)
@@ -163,16 +175,17 @@ def session(configuration, request):
# 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_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))
+ request.addfinalizer(lambda: _restore_timeouts(_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.
This is intended for tests that are themselves testing new session creation, and the