From 22fbfdd4bb268cb2846468a3cf561c9d5f696cbd Mon Sep 17 00:00:00 2001 From: Nikolay Vitkov <34244704+Lightning00Blade@users.noreply.github.com> Date: Tue, 12 Mar 2024 22:30:14 +0000 Subject: [PATCH] Bug 1882759 [wpt PR 44856] - [wdspec] Remove uses of navigation with `wait=none`, a=testonly Automatic update from web-platform-tests [wdspec] Remove uses of navigation with `wait=none` (#44856) * [WebDriverBiDi] Remove uses of navigation with `wait=none` * chore: fix for ff -- wpt-commits: 1cfa5b134e8be1403c1e9b678b9251f95b8e2b23 wpt-pr: 44856 --- .../network/add_intercept/phase_auth_required.py | 19 ++++++------- .../bidi/network/auth_required/auth_required.py | 24 ++++++++++------- .../bidi/network/auth_required/unsubscribe.py | 31 ++++++++++++---------- .../network/response_started/response_started.py | 12 +++++---- 4 files changed, 48 insertions(+), 38 deletions(-) diff --git a/testing/web-platform/tests/webdriver/tests/bidi/network/add_intercept/phase_auth_required.py b/testing/web-platform/tests/webdriver/tests/bidi/network/add_intercept/phase_auth_required.py index dd322a23405e..0df3e9e86afd 100644 --- a/testing/web-platform/tests/webdriver/tests/bidi/network/add_intercept/phase_auth_required.py +++ b/testing/web-platform/tests/webdriver/tests/bidi/network/add_intercept/phase_auth_required.py @@ -1,9 +1,6 @@ import pytest -from .. import ( - assert_before_request_sent_event, - assert_response_event, -) +import asyncio from .. import ( assert_before_request_sent_event, @@ -26,7 +23,14 @@ async def test_basic_authentication( url, setup_network_test, add_intercept, + fetch, ): + await bidi_session.browsing_context.navigate( + context=new_tab["context"], + url=url(PAGE_EMPTY_TEXT), + wait="complete", + ) + network_events = await setup_network_test( events=[ BEFORE_REQUEST_SENT_EVENT, @@ -49,11 +53,8 @@ async def test_basic_authentication( assert isinstance(intercept, str) on_auth_required = wait_for_event(AUTH_REQUIRED_EVENT) - await bidi_session.browsing_context.navigate( - context=new_tab["context"], - url=auth_url, - wait="none", - ) + # The fetch should fails as there is no authentication + asyncio.ensure_future(fetch(url=auth_url, context=new_tab)) await wait_for_future_safe(on_auth_required) expected_request = {"method": "GET", "url": auth_url} diff --git a/testing/web-platform/tests/webdriver/tests/bidi/network/auth_required/auth_required.py b/testing/web-platform/tests/webdriver/tests/bidi/network/auth_required/auth_required.py index 9a24946cde9c..4f5c836280dc 100644 --- a/testing/web-platform/tests/webdriver/tests/bidi/network/auth_required/auth_required.py +++ b/testing/web-platform/tests/webdriver/tests/bidi/network/auth_required/auth_required.py @@ -1,12 +1,20 @@ import pytest +import asyncio + from .. import assert_response_event, AUTH_REQUIRED_EVENT, PAGE_EMPTY_HTML @pytest.mark.asyncio async def test_subscribe_status( - bidi_session, new_tab, subscribe_events, wait_for_event, wait_for_future_safe, url + bidi_session, new_tab, subscribe_events, wait_for_event, wait_for_future_safe, url, fetch ): + await bidi_session.browsing_context.navigate( + context=new_tab["context"], + url=url(PAGE_EMPTY_HTML), + wait="complete", + ) + await subscribe_events(events=[AUTH_REQUIRED_EVENT]) # Track all received network.authRequired events in the events array. @@ -15,7 +23,8 @@ async def test_subscribe_status( async def on_event(method, data): events.append(data) - remove_listener = bidi_session.add_event_listener(AUTH_REQUIRED_EVENT, on_event) + remove_listener = bidi_session.add_event_listener( + AUTH_REQUIRED_EVENT, on_event) auth_url = url( "/webdriver/tests/support/http_handlers/authentication.py?realm=testrealm" @@ -23,13 +32,7 @@ async def test_subscribe_status( on_auth_required = wait_for_event(AUTH_REQUIRED_EVENT) - # navigate using wait="none" as other wait conditions would hang because of - # the authentication prompt. - await bidi_session.browsing_context.navigate( - context=new_tab["context"], - url=auth_url, - wait="none", - ) + asyncio.ensure_future(fetch(url=auth_url, context=new_tab)) await wait_for_future_safe(on_auth_required) @@ -63,7 +66,8 @@ async def test_no_authentication( async def on_event(method, data): events.append(data) - remove_listener = bidi_session.add_event_listener(AUTH_REQUIRED_EVENT, on_event) + remove_listener = bidi_session.add_event_listener( + AUTH_REQUIRED_EVENT, on_event) # Navigate to a page which should not trigger any authentication. await bidi_session.browsing_context.navigate( diff --git a/testing/web-platform/tests/webdriver/tests/bidi/network/auth_required/unsubscribe.py b/testing/web-platform/tests/webdriver/tests/bidi/network/auth_required/unsubscribe.py index cf818fee6f5a..0bbf8df26673 100644 --- a/testing/web-platform/tests/webdriver/tests/bidi/network/auth_required/unsubscribe.py +++ b/testing/web-platform/tests/webdriver/tests/bidi/network/auth_required/unsubscribe.py @@ -1,15 +1,22 @@ -import asyncio - import pytest -pytestmark = pytest.mark.asyncio +import asyncio + +from webdriver.bidi.modules.script import ScriptEvaluateResultException from .. import AUTH_REQUIRED_EVENT, PAGE_EMPTY_HTML +pytestmark = pytest.mark.asyncio # This test can be moved back to `auth_required.py` when all implementations # support handing of HTTP auth prompt. -async def test_unsubscribe(bidi_session, new_tab, url): +async def test_unsubscribe(bidi_session, new_tab, url, fetch): + await bidi_session.browsing_context.navigate( + context=new_tab["context"], + url=url(PAGE_EMPTY_HTML), + wait="complete", + ) + await bidi_session.session.subscribe(events=[AUTH_REQUIRED_EVENT]) await bidi_session.session.unsubscribe(events=[AUTH_REQUIRED_EVENT]) @@ -19,17 +26,13 @@ async def test_unsubscribe(bidi_session, new_tab, url): async def on_event(method, data): events.append(data) - remove_listener = bidi_session.add_event_listener(AUTH_REQUIRED_EVENT, on_event) + remove_listener = bidi_session.add_event_listener( + AUTH_REQUIRED_EVENT, on_event) + + asyncio.ensure_future(fetch(url=url( + "/webdriver/tests/support/http_handlers/authentication.py?realm=testrealm" + ), context=new_tab)) - # Navigate to authentication.py again and check no event is received. - await bidi_session.browsing_context.navigate( - context=new_tab["context"], - url=url( - "/webdriver/tests/support/http_handlers/authentication.py?realm=testrealm" - ), - wait="none", - ) - await asyncio.sleep(0.5) assert len(events) == 0 remove_listener() diff --git a/testing/web-platform/tests/webdriver/tests/bidi/network/response_started/response_started.py b/testing/web-platform/tests/webdriver/tests/bidi/network/response_started/response_started.py index dec743e17555..fb99073fb338 100644 --- a/testing/web-platform/tests/webdriver/tests/bidi/network/response_started/response_started.py +++ b/testing/web-platform/tests/webdriver/tests/bidi/network/response_started/response_started.py @@ -245,6 +245,11 @@ async def test_response_mime_type_file( async def test_www_authenticate( bidi_session, url, fetch, new_tab, wait_for_event, wait_for_future_safe, setup_network_test ): + await bidi_session.browsing_context.navigate( + context=new_tab["context"], + url=url(PAGE_EMPTY_HTML), + wait="complete", + ) auth_url = url( "/webdriver/tests/support/http_handlers/authentication.py?realm=testrealm" ) @@ -253,11 +258,8 @@ async def test_www_authenticate( events = network_events[RESPONSE_STARTED_EVENT] on_response_started = wait_for_event(RESPONSE_STARTED_EVENT) - await bidi_session.browsing_context.navigate( - context=new_tab["context"], - url=auth_url, - wait="none", - ) + + asyncio.ensure_future(fetch(url=auth_url, context=new_tab)) await wait_for_future_safe(on_response_started) -- 2.11.4.GIT