From 8ae1f394a660f775d892b19c78919228a4cd7cf9 Mon Sep 17 00:00:00 2001 From: James Graham Date: Fri, 7 Apr 2017 15:56:33 +0100 Subject: [PATCH] Bug 1363982 - Clean up fixtures for session creation in wdspec, a=testonly [Cherry-picked from wpt] This introduces two fixtures for creating a multi-test session and a longlived session. For performance it is important that we don't ordinarily create a new session for each test, but it's also important that specific tests are able to create new sessions with arbitary capabilities. MozReview-Commit-ID: DNZCgmkrwvn --- .../web-platform/tests/webdriver/conftest.py | 5 +- .../tests/webdriver/support/fixtures.py | 107 ++++++++++++------ 2 files changed, 76 insertions(+), 36 deletions(-) diff --git a/testing/web-platform/tests/webdriver/conftest.py b/testing/web-platform/tests/webdriver/conftest.py index 6dbcfea203e6..77118f0bbd56 100644 --- a/testing/web-platform/tests/webdriver/conftest.py +++ b/testing/web-platform/tests/webdriver/conftest.py @@ -1,12 +1,13 @@ import pytest from support.fixtures import ( - create_frame, create_session, create_window, http, server_config, session, + configuration, create_frame, create_window, http, new_session, server_config, session, url) +pytest.fixture(scope="session")(configuration) pytest.fixture()(create_frame) -pytest.fixture()(create_session) pytest.fixture()(create_window) pytest.fixture()(http) +pytest.fixture(scope="function")(new_session) pytest.fixture()(server_config) pytest.fixture(scope="function")(session) pytest.fixture()(url) diff --git a/testing/web-platform/tests/webdriver/support/fixtures.py b/testing/web-platform/tests/webdriver/support/fixtures.py index 91b93757cbcd..1d64d1a394f6 100644 --- a/testing/web-platform/tests/webdriver/support/fixtures.py +++ b/testing/web-platform/tests/webdriver/support/fixtures.py @@ -31,6 +31,7 @@ def _dismiss_user_prompts(session): session.window_handle = current_window + def _restore_windows(session): """Closes superfluous windows opened by the test without ending the session implicitly by closing the last window. @@ -44,6 +45,7 @@ def _restore_windows(session): session.window_handle = current_window + def _switch_to_top_level_browsing_context(session): """If the current browsing context selected by WebDriver is a `` or an `