Open Bug 2019950 Opened 8 days ago Updated 5 days ago

fetch keepalive requests ignore offline network conditions

Categories

(Remote Protocol :: WebDriver BiDi, defect, P2)

defect
Points:
2

Tracking

(Not tracked)

ASSIGNED

People

(Reporter: hbenl, Assigned: jdescottes)

References

(Blocks 1 open bug)

Details

(Whiteboard: [webdriver:m19])

This Playwright test fails because a fetch with keepalive: true succeeds in offline mode.
I was able to reproduce the issue with this test:

@pytest_asyncio.fixture
async def get_can_fetch2(bidi_session, url):
    async def get_can_fetch2(context):
        try:
            await bidi_session.script.call_function(
                function_declaration="(url)=>fetch(url, { cache: 'no-store', keepalive: true })",
                arguments=[{
                    "type": "string",
                    "value": url("/common/dummy.json")
                }],
                target=ContextTarget(context["context"]),
                await_promise=True,
            )
            return True
        except ScriptEvaluateResultException:
            return False

    return get_can_fetch2

async def test_fetch_keepalive(bidi_session, top_context, url, get_can_fetch2):
    # Navigate away from about:blank to allow fetch requests.
    await bidi_session.browsing_context.navigate(
        context=top_context["context"],
        url=url("/common/blank.html"),
        wait="complete")

    assert await get_can_fetch2(top_context)
    await bidi_session.emulation.set_network_conditions(
        network_conditions=OFFLINE_NETWORK_CONDITIONS,
        contexts=[top_context["context"]])
    assert not await get_can_fetch2(top_context)
    await bidi_session.emulation.set_network_conditions(
        network_conditions=None,
        contexts=[top_context["context"]])
    assert await get_can_fetch2(top_context)

The test passes when I remove the keepalive: true option.

Assignee: nobody → jdescottes
Severity: -- → S3
Points: --- → 2
Priority: -- → P2
Whiteboard: [webdriver:m19]
Status: NEW → ASSIGNED
You need to log in before you can comment on or make changes to this bug.