-
Couldn't load subscription status.
- Fork 1.4k
Closed
Description
What
Enable the Page.On's existing event system to be used as event listening for Page.WaitForRequest|Response.
Why
The current Page.WaitForResponse:
- Deviates from the existing
Page.Onevent system, which we perfected long ago: - Unnecessarily creates its own event handling system, separate from our existing one.
By using Page.On's existing event handling, we can improve the maintainability of the browser module code and simplify its implementation of Page.WaitForRequest and related functions.
How
Similar to Playwright, we plan to add two methods:
Page.addEventListenerto register an event listenerPage.removeEventListenerto remove an event listenerPage.waitForEventto listen for a page event.- Later on,
removeEventListenercan be used for implementingPage.RemoveEventListener🎉 - Later on,
waitForEventcan be used for implementingPage.WaitForEventand many others 🎉
By using these two methods, we can reuse them from Page.On, Page.WaitForResponse, Page.WaitForRequest, and so on.
Plan
- Browser: Add
Page.add|removeEventListener#5311 - Browser: Refactor pattern matcher #5314
- Add
Page.waitForEventby refactoring page event handling #5315 - Simplify page event iteration by using an iterator #5340