Closed Bug 1878842 Opened 4 months ago Closed 3 months ago

[wdspec] Add BiDi fixture to wait for N events

Categories

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

task
Points:
3

Tracking

(Not tracked)

RESOLVED WONTFIX

People

(Reporter: jdescottes, Assigned: jdescottes)

References

()

Details

(Whiteboard: [webdriver:m10])

Attachments

(4 obsolete files)

Many BiDi wdspec tests locally build arrays of events, eg:

    events = []

    async def on_event(method, data):
        events.append(data)

    remove_listener = bidi_session.add_event_listener(CONTEXT_CREATED_EVENT, on_event)
    await subscribe_events([CONTEXT_CREATED_EVENT])

    await bidi_session.browsing_context.navigate(
        context=top_context["context"], url=test_page_multiple_frames, wait="complete"
    )

    wait = AsyncPoll(
        bidi_session, message="Didn't receive context created events for frames"
    )
    await wait.until(lambda _: len(events) >= 2)
    assert len(events) == 2

With a fixture to wait for several events we could reduce the boilerplate to something like

    await subscribe_events([CONTEXT_CREATED_EVENT])
    wait_for_events = wait_for_n_events(CONTEXT_CREATED_EVENT, 2)

    await bidi_session.browsing_context.navigate(
        context=top_context["context"], url=test_page_multiple_frames, wait="complete"
    )

    events = await wait_for_events()
    assert len(events) == 2

I assume we would still have to pass a minimum amount of events to wait for into wait_for_events(). Also do we need an escape hatch via a timeout in case we do not see the expected amount of events? Right now we don't have that and as such test modules would run into a timeout.

Using await would blocks the loop forever, so we can never have more than one listener for the same event.

Assignee: nobody → jdescottes
Status: NEW → ASSIGNED
Points: --- → 3
Priority: -- → P3
Whiteboard: [webdriver:backlog]
Whiteboard: [webdriver:backlog] → [webdriver:m10]

The work and discussion will happen upstream https://github.com/web-platform-tests/wpt/issues/44702

Status: ASSIGNED → RESOLVED
Closed: 3 months ago
Resolution: --- → WONTFIX
Attachment #9378533 - Attachment is obsolete: true
Attachment #9378530 - Attachment is obsolete: true
Attachment #9378527 - Attachment is obsolete: true
Attachment #9378526 - Attachment is obsolete: true
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: