-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Open
Open
Copy link
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.On
event 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.addEventListener
to register an event listenerPage.removeEventListener
to remove an event listenerPage.waitForEvent
to listen for a page event.- Later on,
removeEventListener
can be used for implementingPage.RemoveEventListener
🎉 - Later on,
waitForEvent
can be used for implementingPage.WaitForEvent
and many others 🎉
By using these two methods, we can reuse them from Page.On
, Page.WaitForResponse
, Page.WaitForRequest
, and so on.
Plan
- Add
Page.add|removeEventListener
#5311 - Refactor pattern matcher #5314
- Add
Page.waitForEvent
by refactoring page event handling #5315 - Use the existing event system to listen for responses and requests
- Consolidate all request handling methods (e.g.,
onRequest
)