1import pytest 2 3from tests.support.asserts import assert_error, assert_success 4 5 6def get_window_handle(session): 7 return session.transport.send( 8 "GET", "session/{session_id}/window".format(**vars(session))) 9 10 11def test_no_top_browsing_context(session, closed_window): 12 response = get_window_handle(session) 13 assert_error(response, "no such window") 14 15 16def test_no_browsing_context(session, closed_frame): 17 response = get_window_handle(session) 18 assert_success(response, session.window_handle) 19 20 21def test_basic(session): 22 response = get_window_handle(session) 23 assert_success(response, session.window_handle) 24 25 26# Capability needed as long as no valid certificate is available: 27# https://github.com/web-platform-tests/wpt/issues/28847 28@pytest.mark.capabilities({"acceptInsecureCerts": True}) 29def test_navigation_with_coop_headers(session, url): 30 base_path = ("/webdriver/tests/support/html/subframe.html" + 31 "?pipe=header(Cross-Origin-Opener-Policy,same-origin") 32 33 session.url = url(base_path, protocol="https") 34 response = get_window_handle(session) 35 first_handle = assert_success(response) 36 37 # navigating to another domain with COOP headers will force a process change 38 # in most browsers 39 session.url = url(base_path, protocol="https", domain="alt") 40 response = get_window_handle(session) 41 second_handle = assert_success(response) 42 43 assert first_handle == second_handle 44