-
Notifications
You must be signed in to change notification settings - Fork 6.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
chore(focus-classes): fix failing tests when browser is blurred #2935
chore(focus-classes): fix failing tests when browser is blurred #2935
Conversation
8014fe9
to
09d14cf
Compare
09d14cf
to
6deb9db
Compare
On Saucelabs, browsers will run simultaneously and therefore can't focus all browser windows at the same time. This is problematic when testing focus states. Chrome and Firefoxonly fire FocusEvents when the window is focused. This issue also appears locally. Fixes angular#2903.
6deb9db
to
c9f45cf
Compare
Are we not able to set the focusmanager.testmode pref? Are you sure this is a problem in chrome too? My tests seem to consistently pass in chrome |
Not really. Chrome does not have such a flag and setting it for Firefox in Saucelabs doesn't seem to be possible. Kristiyan and I have the same problems locally (when not focused). Also IE11 seems to have similar problems on Saucelabs. I think that this approach is be the most reliable one. |
// On Saucelabs, browsers will run simultaneously and therefore can't focus all browser windows | ||
// at the same time. This is problematic when testing focus states. Chrome and Firefox | ||
// only fire FocusEvents when the window is focused. This issue also appears locally. | ||
let _nativeButtonFocus = buttonElement.focus.bind(buttonElement); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you extract this into a separate method e.g. fixFocus(el: Element)
? also both this and dispatchFocusEvent
would be good things to put in a separate test utilities directory
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. I called it patchElementFocus
- also added a comment, so we can move all helpers to a global utility file as in #2902
What version of Chrome are you running @mmalerba? I think 56 started aggresively throttling background tabs, which might be what's causing the issue here. |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
On Saucelabs, browsers will run simultaneously and therefore can't focus all browser windows at the same time.
This is problematic when testing focus states. Chrome and Firefoxonly fire FocusEvents when the window is focused. This issue also appears locally.
Also while investigating the
karma-test-shim.js
file looked very ugly, so I refactored it a bit (ES6 not allowed)Fixes #2903.