Skip to content

Simplify Page.On event handling system for Request and Response handling #5310

@inancgumus

Description

@inancgumus

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 listener
  • Page.removeEventListener to remove an event listener
  • Page.waitForEvent to listen for a page event.
  • Later on, removeEventListener can be used for implementing Page.RemoveEventListener 🎉
  • Later on, waitForEvent can be used for implementing Page.WaitForEvent and many others 🎉

By using these two methods, we can reuse them from Page.On, Page.WaitForResponse, Page.WaitForRequest, and so on.

Plan

Related

Metadata

Metadata

Assignees

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions