Bug 1470533 - [wdspec] Add global "current_session" fixture. draft
authorHenrik Skupin <mail@hskupin.info>
Mon, 25 Jun 2018 20:45:18 +0200
changeset 810802 695bd270281cd8856f9bae5bbabea314f2c27e0e
parent 810379 6e8e861540e6d8c85c73ab7b2afa1f027fb3750c
child 810803 46af939560ec893fb2d7bc8bf51ccda94c442b2f
push id114117
push userbmo:hskupin@gmail.com
push dateTue, 26 Jun 2018 15:03:37 +0000
bugs1470533
milestone63.0a1
Bug 1470533 - [wdspec] Add global "current_session" fixture. To allow sub-conftest.py files to define custom session fixtures, the currently active session as created by the global "session" or "new_session" fixtures has to be exposed as fixture too. This will allow any other custom session fixture to delete the currently active session. MozReview-Commit-ID: E6yeCd587Kv
testing/web-platform/meta/MANIFEST.json
testing/web-platform/tests/webdriver/tests/conftest.py
testing/web-platform/tests/webdriver/tests/support/fixtures.py
--- a/testing/web-platform/meta/MANIFEST.json
+++ b/testing/web-platform/meta/MANIFEST.json
@@ -618732,17 +618732,17 @@
    "8c22860607cb0f3d610888c9816bf2384e2c5445",
    "wdspec"
   ],
   "webdriver/tests/close_window/user_prompts.py": [
    "58390344e980306233cd0daedca99fd4ec855cf8",
    "wdspec"
   ],
   "webdriver/tests/conftest.py": [
-   "21143aabab3474c3786c552d22d3c79512a120c4",
+   "507edfc726b5e4b78937735e3e6969ecc1c135fe",
    "support"
   ],
   "webdriver/tests/delete_all_cookies/__init__.py": [
    "da39a3ee5e6b4b0d3255bfef95601890afd80709",
    "support"
   ],
   "webdriver/tests/delete_all_cookies/delete.py": [
    "1248b2e14b6b690b996f8bf620a6a1f33514256a",
@@ -619176,17 +619176,17 @@
    "5a31a3917a5157516c10951a3b3d5ffb43b992d9",
    "support"
   ],
   "webdriver/tests/support/asserts.py": [
    "b7424061b41d9bb1b87f147d5b29786695249d10",
    "support"
   ],
   "webdriver/tests/support/fixtures.py": [
-   "5ae91067cee6f4cf7e3c63e99aca65104bbc2fab",
+   "d06b203cf5257d1715ff5ac31f6a291c0efb522e",
    "support"
   ],
   "webdriver/tests/support/http_request.py": [
    "cb40c781fea2280b98135522def5e6a116d7b946",
    "support"
   ],
   "webdriver/tests/support/inline.py": [
    "48399821b7abca50df824e37c41829d7a4573be1",
--- a/testing/web-platform/tests/webdriver/tests/conftest.py
+++ b/testing/web-platform/tests/webdriver/tests/conftest.py
@@ -1,25 +1,29 @@
 import pytest
+
 from tests.support.fixtures import (
     add_browser_capabilites,
     add_event_listeners,
     configuration,
     create_dialog,
     create_frame,
     create_window,
+    current_session,
     http,
     new_session,
     server_config,
     session,
     url)
 
+
 pytest.fixture()(add_browser_capabilites)
 pytest.fixture()(add_event_listeners)
 pytest.fixture(scope="session")(configuration)
 pytest.fixture()(create_dialog)
 pytest.fixture()(create_frame)
 pytest.fixture()(create_window)
+pytest.fixture(scope="function")(current_session)
 pytest.fixture()(http)
 pytest.fixture(scope="function")(new_session)
 pytest.fixture()(server_config)
 pytest.fixture(scope="function")(session)
 pytest.fixture()(url)
--- a/testing/web-platform/tests/webdriver/tests/support/fixtures.py
+++ b/testing/web-platform/tests/webdriver/tests/support/fixtures.py
@@ -200,16 +200,20 @@ def session(configuration, request):
     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 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
     session created is closed at the end of the test."""
     def end():
         global _current_session
         if _current_session is not None and _current_session.session_id: