Commit 4a959e9
refactor: fix flaky focus origin tests (#5454)
Fixes failures in the `FocusOriginMonitor` tests on IE, if the browser is in focus. The issue comes from the fact that IE will trigger the `focus` handlers asynchronously, whereas other browsers are synchronous. Here's an example log:
```
IE 11.0.0 (Windows 10 0.0.0) LOG: 'dispatching events'
IE 11.0.0 (Windows 10 0.0.0) LOG: 'making assertions'
IE 11.0.0 (Windows 10 0.0.0) LOG: 'focus event fired'
-----------------------------------------------------------
Chrome 59.0.3071 (Windows 10 0.0.0) LOG: 'dispatching events'
Chrome 59.0.3071 (Windows 10 0.0.0) LOG: 'focus event fired'
Chrome 59.0.3071 (Windows 10 0.0.0) LOG: 'making assertions'
```
The issue only happens when the browser is focused, because the `patchElementFocus` function will override the native `focus` method with a synchronous one only if the browser is **not** focused. These changes make it so the native event is always overwritten, in order to make the tests a little more predictable. Also switches all the tests from `async` to `fakeAsync` to avoid using `setTimeout` in tests.1 parent b00f838 commit 4a959e9
1 file changed
+174
-265
lines changed
0 commit comments