Bug 1461463 - [wdspec] Add timeout reset finalizer to session fixture. r=ato
authorHenrik Skupin <mail@hskupin.info>
Thu, 17 May 2018 09:17:28 +0200
changeset 420249 f4261bd006df39cd7034764cad48320306dc84fc
parent 420248 abd4d105082af9649e2b6c452d9be30d94256015
child 420250 fe8aa70475dde011b190f1c5c7df5e56814b1cde
push id64569
push userhskupin@mozilla.com
push dateTue, 29 May 2018 15:49:19 +0000
treeherderautoland@fe8aa70475dd [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersato
bugs1461463
milestone62.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1461463 - [wdspec] Add timeout reset finalizer to session fixture. r=ato If tests modify the timeout values those have to be reset for the next test. MozReview-Commit-ID: FqFwhduDR2m
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
@@ -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