-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
fix: check for activeElement before calling blur() on it #11214
Conversation
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.
Stupid mistake on my side, sorry about that.
But I don't understand why doesn't this appear in https://travis-ci.org/zurb/foundation-sites/jobs/372717914 ? I can reproduce it locally with index.html
.
@@ -27,7 +27,7 @@ describe('Accordion', function() { | |||
|
|||
afterEach(function() { | |||
plugin.destroy(); | |||
document.activeElement.blur(); | |||
if(document.activeElement)document.activeElement.blur(); |
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.
if(document.activeElement)document.activeElement.blur();
// ^
// no space ?
I still guess that the tests on Browserstack run slower than on real devices. |
Prefix depends on the type of change, not where it is. Here, it should be |
test/javascript/util/keyboard.js
Outdated
@@ -20,7 +20,7 @@ describe('Keyboard util', function() { | |||
}; | |||
|
|||
afterEach(function() { | |||
document.activeElement.blur(); | |||
if(document.activeElement)document.activeElement.blur(); |
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.
if(document.activeElement)document.activeElement.blur();
// ^
// no space ?
You can rebase this change with the previous commit I guess. The PR is clear enough. And use style: ...
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.
29d21c8 tests: always call blur() for asynchronous calls
Why "asynchronous calls". I see nothing asynchronous in test/javascript/components/dropdownMenu.js.
Also even if .focus()
is called asynchronously, we wait for the test to finish before calling .blur()
in afterEach
.
So this line is not the issue.
|
||
setTimeout(function() { | ||
$(window).trigger('resize'); | ||
}, 20); |
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.
This break the purpose of the test itself. calls reflow on viewport size change once
means that with multiple resize
, _reflow
is called only once within a given delay (10ms by default for MutationObserver debounce). We cannot test this behavior without triggering resize
once.
So we actually broke these test before with switching to delays over 10ms. We should triggers several resize
in 10ms and expect reflow to be called once.
Also, this should not be in this PR.
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.
Right. But not fixing this in this PR will produce a failing Travis build.
What do you recommend because of this issue with reflow and the timing issues on the Travis containers?
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.
Right. But not fixing this in this PR will produce a failing Travis build.
Are you sure ? Tests runs after tests: always call blur() for asynchronous calls
. Do we need both commits for tests to runs ?
I would recommend to actually test what we want to test and expect it to fail if the component does not work properly: trigger resize
several times in 10ms and check after that if _reflow
was called once.
This shoud work. If it doesn't, Interchange has a bug. I'll take a look at this later.
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.
I'll take a look at this later.
This would be really helpful, thanks.
The testsuite tells differently but ok. How would you solve this here? Not sure if we can solve these issues related to timing functions when the browser / VM is too slow. |
Will do this tomorrow |
So the bug with the previous Interchange tests came from the browser not able to respect the setTimeout delays, which lead to big differences between several timeout running in parrallel. If the difference is bigger than the |
Well, in general setTimeout is never exact when it comes to timing as it is often longer than what is set as timeout. So what is the correct solution in your opinion? Keep in mind that the VM might be slower and timeouts may trigger later. |
I have a working solution. I'll open a PR specific to it because it require a bug fix in |
Which PRs? You linked just one? I thought these replace mine? |
Sorry, see #11259 and its required fix #11258. They only partially replace this PR as they only fix the Interchange test issue. The Like "As soon as a Git branch is public, active and used, its commit history must be kept intact". |
Closed in favor of #11260 |
Description
Currently the tests throw errors in IE11 on Windows 10 because there might be some race conditions or differences in the browser behaviors as document.activeElement is not always defined.
Motivation and Context
Fixes the unit tests in IE11 on Windows 10.
Types of changes
functionality to change)
Checklist (all required):
develop
orsupport/*
).