Phantomjs: getEventListeners

Created on 15 Aug 2014  路  17Comments  路  Source: ariya/phantomjs

I use PhantomJS for testing, and for one project we are testing bindings on native DOM objects.

Some of the developer tools include a way to get the event listeners:

https://developer.chrome.com/devtools/docs/commandline-api#geteventlistenersobject
https://getfirebug.com/wiki/index.php/GetEventListeners

It would be neat to have this available in PhantomJS for testing as well.

Love yall!

All 17 comments

I love this idea but it poses an interesting question: to what object do we attach the getEventListeners method? It would need to be in the client-side scope of the WebPage instances, so perhaps just to each page's window object?

Coincidentally, this would be very easy to implement by just using JavaScript to duck-punch the addEventListener and removeEventListener methods on the Element prototype as well.

+1

+1

+1

+1

We really need this feature to evaluating web pages for accessibility features

What we really want to test for accessibility is the presence or absence of particular event handlers. For example if their are mouse event handlers on a DOM node or one of its ancestors are their corresponding keyboard event handlers on the DOM node or one of its ancestors.

So initially we would just need a Boolean test to identify any event handlers of a specific type (e.g. mousedown, keypress) on an DOM node.

+1 as this is also related to an IndieUI feature that could/would/will be relevant to other web technologies as well!!

+1

+1

+1

+1

+1

Any progress on adding this feature?

+1

+1

+1

I am finding this, can it work now?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

gustavohenke picture gustavohenke  路  4Comments

mdominado picture mdominado  路  3Comments

Sayalic0 picture Sayalic0  路  5Comments

sinojelly picture sinojelly  路  3Comments

dhilipsiva picture dhilipsiva  路  4Comments