diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:13:33 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:13:33 +0000 |
commit | 086c044dc34dfc0f74fbe41f4ecb402b2cd34884 (patch) | |
tree | a4f824bd33cb075dd5aa3eb5a0a94af221bbe83a /testing/web-platform/tests/webdriver/tests/bidi/network/response_started | |
parent | Adding debian version 124.0.1-1. (diff) | |
download | firefox-086c044dc34dfc0f74fbe41f4ecb402b2cd34884.tar.xz firefox-086c044dc34dfc0f74fbe41f4ecb402b2cd34884.zip |
Merging upstream version 125.0.1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/webdriver/tests/bidi/network/response_started')
2 files changed, 81 insertions, 5 deletions
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 dec743e175..fb99073fb3 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) diff --git a/testing/web-platform/tests/webdriver/tests/bidi/network/response_started/response_started_cached.py b/testing/web-platform/tests/webdriver/tests/bidi/network/response_started/response_started_cached.py index 2776950b0e..2c747f135a 100644 --- a/testing/web-platform/tests/webdriver/tests/bidi/network/response_started/response_started_cached.py +++ b/testing/web-platform/tests/webdriver/tests/bidi/network/response_started/response_started_cached.py @@ -21,6 +21,7 @@ async def test_cached( ) events = network_events[RESPONSE_STARTED_EVENT] + # `nocache` is not used in cached.py, it is here to avoid the browser cache. cached_url = url( f"/webdriver/tests/support/http_handlers/cached.py?status=200&nocache={random.random()}" ) @@ -78,6 +79,7 @@ async def test_cached_redirect( events = network_events[RESPONSE_STARTED_EVENT] text_url = url(PAGE_EMPTY_TEXT) + # `nocache` is not used in cached.py, it is here to avoid the browser cache. cached_url = url( f"/webdriver/tests/support/http_handlers/cached.py?status=301&location={text_url}&nocache={random.random()}" ) @@ -156,6 +158,7 @@ async def test_cached_revalidate( ) events = network_events[RESPONSE_STARTED_EVENT] + # `nocache` is not used in cached.py, it is here to avoid the browser cache. revalidate_url = url( f"/webdriver/tests/support/http_handlers/must-revalidate.py?nocache={random.random()}" ) @@ -197,3 +200,74 @@ async def test_cached_revalidate( expected_request=expected_request, expected_response=expected_response, ) + + +@pytest.mark.asyncio +async def test_page_with_cached_resource( + bidi_session, + url, + inline, + setup_network_test, + top_context, +): + network_events = await setup_network_test( + events=[ + RESPONSE_STARTED_EVENT, + ] + ) + events = network_events[RESPONSE_STARTED_EVENT] + + # Build a page with a stylesheet resource which will be read from http cache + # on the next reload. + # `nocache` is not used in cached.py, it is here to avoid the browser cache. + cached_css_url = url( + f"/webdriver/tests/support/http_handlers/cached.py?status=200&contenttype=text/css&nocache={random.random()}" + ) + page_with_cached_css = inline( + f""" + <head><link rel="stylesheet" type="text/css" href="{cached_css_url}"></head> + <body>test page with cached stylesheet</body> + """, + ) + + await bidi_session.browsing_context.navigate( + context=top_context["context"], + url=page_with_cached_css, + wait="complete", + ) + + # Expect two events, one for the page, one for the stylesheet. + wait = AsyncPoll(bidi_session, timeout=2) + await wait.until(lambda _: len(events) >= 2) + assert len(events) == 2 + + assert_response_event( + events[0], + expected_request={"method": "GET", "url": page_with_cached_css}, + expected_response={"url": page_with_cached_css, "fromCache": False}, + ) + assert_response_event( + events[1], + expected_request={"method": "GET", "url": cached_css_url}, + expected_response={"url": cached_css_url, "fromCache": False}, + ) + + # Reload the page. + await bidi_session.browsing_context.reload(context=top_context["context"]) + + # Expect two additional events after reload, for the page and the stylesheet. + wait = AsyncPoll(bidi_session, timeout=2) + await wait.until(lambda _: len(events) >= 4) + assert len(events) == 4 + + assert_response_event( + events[2], + expected_request={"method": "GET", "url": page_with_cached_css}, + expected_response={"url": page_with_cached_css, "fromCache": False}, + ) + + assert_response_event( + events[3], + expected_request={"method": "GET", "url": cached_css_url}, + expected_response={"url": cached_css_url, "fromCache": True}, + ) |