Skip to content

Commit

Permalink
Remove page on event name check
Browse files Browse the repository at this point in the history
This is safe to do so as we will no longer pass a rogue string to this
method. Only the page on event names can be passed to this function.

Unless, of course, somebody converts a string with an incorrect name to
PageOnEventName to call this function. This will easily be catched in
reviews, and nobody would do such a thing. We follow the Go idiom of
being pragmatic instead of being highly defensive. Also, this method is
used by the mapping layer, and there is already an event name check.
  • Loading branch information
inancgumus committed Oct 10, 2024
1 parent c0042e6 commit dab04d6
Showing 1 changed file with 0 additions and 7 deletions.
7 changes: 0 additions & 7 deletions common/page.go
Original file line number Diff line number Diff line change
Expand Up @@ -1113,13 +1113,6 @@ type PageOnEvent struct {
// passing in the ConsoleMessage associated with the event.
// The only accepted event value is 'console'.
func (p *Page) On(event PageOnEventName, handler func(PageOnEvent)) error {
switch event {
case EventPageConsoleAPICalled:
case EventPageMetricCalled:
default:
return fmt.Errorf("unknown page event: %q", event)
}

p.eventHandlersMu.Lock()
defer p.eventHandlersMu.Unlock()

Expand Down

0 comments on commit dab04d6

Please sign in to comment.