Feature request: Allow to remove (maybe only temporarily?) event listeners from a node
Categories
(DevTools :: Inspector, enhancement)
Tracking
(Not tracked)
People
(Reporter: emilio, Unassigned)
Details
Thank you for helping make Firefox better. If you are reporting a defect, please complete the following:
What were you doing?
This is a feature request, but for what is worth, I was debugging gmail for bug 1582585.
What happened?
It would be useful to be able to remove event listeners from the page (maybe only temporarily?) to see if it's what is messing up / causing the bug.
This should be relatively easy, I think, since the event listener info already contains a reference to the callback, so we should be able to just call removeEventListener.
The "temporary" part may be tricky, if we aim to preserve the original event listener order (because we'd need to add / remove in the right order). But doesn't seem impossible either.
Reporter | ||
Comment 1•5 years ago
|
||
Some of the code I had to use today for this purpose, in case it's useful:
function removeAllListeners(target) {
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
for (const e of Services.els.getListenerInfoFor(target))
target.removeEventListener(e.type, e.listenerObject, e.capturing);
}
function removeAllListenersInWindow(window) {
removeAllListeners(window);
removeAllListeners(window.document);
for (const e of window.document.querySelectorAll("*")) {
removeAllListeners(e);
if (e.contentWindow)
removeAllListenersInWindow(e.contentWindow);
}
}
removeAllListenersInWindow(tabs[1].content.window)
Comment 2•5 years ago
|
||
Thanks for filing Emilio. I think this is a duplicate of bug 1492497. Honza has it on his roadmap for the future.
Description
•