Wish: enable / disable event listeners easily

NEW
Unassigned

Status

DevTools
Debugger
3 years ago
a month ago

People

(Reporter: hallvors, Unassigned)

Tracking

(Depends on: 1 bug)

35 Branch

Firefox Tracking Flags

(Not tracked)

Details

(Reporter)

Description

3 years ago
Debugging event-based threads is hard because there are usually many event listeners attached, and many events being fired. Even if you tell the debugger to only break on, say, "keydown" the page may have 10 different keydown listeners and it's time-consuming to isolate the one that causes a problem.

If there was a simple way to disable a specific listener, it would help.

(Note: I imagine this is a somewhat non-trivial feature, especially if we want to make it persist across reloads. I don't think it needs to persist. We already have a UI for listing event listeners, so a way to enable/disable them from there would be perfect.)
To do this we would first need some platform work so I have logged bug 1238999 to add disableEventListener() and enableEventListener() to the event listener service.
(In reply to Michael Ratcliffe [:miker] [:mratcliffe] from comment #2)
> To do this we would first need some platform work so I have logged bug
> 1238999 to add disableEventListener() and enableEventListener() to the event
> listener service.

You could use the Debugger API to set a hidden (to the user) breakpoint on the first bytecode of the listener, and when the breakpoint hits force an early return rather than executing the body.

This would not require any additional platform work and builds on the debugging primitives we already use.

Updated

a month ago
Product: Firefox → DevTools
You need to log in before you can comment on or make changes to this bug.