-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Firing tab event on window does not change the document.activeElement #2102
Comments
Firing events does not change focus, as you can see: https://jsbin.com/qiresuzisi/edit?html,console,output Please actually test the code in browsers next time. |
Hmm sorry about that. What I was trying to convey is keyboard tabbing; when the user presses the tab event on their keyboard it moves between multiple tabbable dim elements. I’m looking for something similar to PhantomJS’s Page.sendEvent When sending the tab to the page, PhantomJS does tab to the next event because it interprets the event as a user event. Is there a similar function that can be called in jsdom? |
You can use element.focus() |
This maybe a better example: Click in the first input box and keep hitting the tab key, you'll see when it reaches the end, it goes back to beginning. The idea is if the three input elements were in a dialog or some other layered context, it makes no sense for the user's to exit that layer. Now I could fire the event directly on the last element but the goal here is an integration test, not a unit test. If I wanted to unit test this and mock out the user interaction side of it, I would be using Mocha, not Karma + JSDom. The method to do this in Phantom for your reference is the following
The tab event created "is sent to the web page as if it comes as part of user interaction.". Is there a way to create events and send them to JSDom as if they were user interactions? |
No, there are no user actions in jsdom. |
PhantomJS it is! Thanks! |
Basic info:
Minimal reproduction case
How does similar code behave in browsers?
Focus changes between the two input elements in a rotating manner as multiple tabs are pressed
The text was updated successfully, but these errors were encountered: