Open Bug 2018154 Opened 15 days ago Updated 12 days ago

Missing "script.realmDestroyed" event for worker after cross-process navigation in playwright test

Categories

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

defect
Points:
2

Tracking

(Not tracked)

People

(Reporter: hbenl, Unassigned)

References

(Blocks 1 open bug)

Details

(Whiteboard: [webdriver:m19] )

This Playwright test fails because it doesn't receive the expected script.realmDestroyed event for a worker in a cross-process navigation. When I run it with DEBUG=pw:protocol I can see that Firefox doesn't send this event for the worker. The corresponding test for in-process navigations passes.
I couldn't reproduce the issue in a wdspec test yet, this is how I tried to mimick the Playwright test's behavior as closely as possible:

async def test_dedicated_worker_cross_process_navigation(
    bidi_session,
    subscribe_events,
    create_user_context,
    server_config,
):
    user_context = await create_user_context()
    context = await bidi_session.browsing_context.create(
        type_hint="window", user_context=user_context
    )

    await subscribe_events(events=[REALM_CREATED_EVENT, REALM_DESTROYED_EVENT])

    created_events = []
    destroyed_events = []

    async def on_realm_created_event(method, data):
        if data["type"] == "dedicated-worker":
            created_events.append(data)

    async def on_realm_destroyed_event(method, data):
        if len(created_events) > 0 and data["realm"] == created_events[0]["realm"]:
            destroyed_events.append(data)

    bidi_session.add_event_listener(REALM_CREATED_EVENT, on_realm_created_event)
    bidi_session.add_event_listener(REALM_DESTROYED_EVENT, on_realm_destroyed_event)

    port = server_config["ports"]["http"][0]
    await bidi_session.browsing_context.navigate(
        url=f"http://localhost:{port}/webdriver/tests/bidi/browsing_context/support/empty.html",
        context=context["context"],
        wait="complete"
    )

    await bidi_session.script.call_function(
        function_declaration="arg => eval(arg)()",
        arguments=[{"type": "string", "value": """() => new Worker(URL.createObjectURL(new Blob(["console.log(1)"], {type: "application/javascript"})))"""}],
        target={"context": context["context"]},
        await_promise=True,
        user_activation=True,
    )

    await wait_for_bidi_events(bidi_session, created_events, 1)

    await bidi_session.browsing_context.navigate(
        url=f"http://127.0.0.1:{port}/webdriver/tests/bidi/browsing_context/support/empty.html",
        context=context["context"],
        wait="complete"
    )

    await wait_for_bidi_events(bidi_session, destroyed_events, 1)
Points: --- → 2
Priority: -- → P3
Whiteboard: [webdriver:m19]
Summary: no realmDestroyed event for worker after cross-process navigation in playwright test → Missing "script.realmDestroyed" event for worker after cross-process navigation in playwright test
You need to log in before you can comment on or make changes to this bug.