Skip to content

Conversation

crisbeto
Copy link
Member

@crisbeto crisbeto commented Jul 1, 2017

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 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.

@crisbeto crisbeto added the in progress This issue is currently in progress label Jul 1, 2017
@crisbeto crisbeto self-assigned this Jul 1, 2017
@googlebot googlebot added the cla: yes PR author has agreed to Google's Contributor License Agreement label Jul 1, 2017
@crisbeto crisbeto added pr: merge safe and removed in progress This issue is currently in progress labels Jul 1, 2017
@crisbeto crisbeto assigned jelbourn and unassigned crisbeto Jul 1, 2017
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.
@crisbeto crisbeto force-pushed the focus-origin-ie-failures branch from aa792b6 to afdb9b7 Compare July 1, 2017 12:30
@crisbeto crisbeto changed the title build: fix flaky focus origin tests refactor: fix flaky focus origin tests Jul 1, 2017
Copy link
Member

@jelbourn jelbourn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@jelbourn jelbourn added pr: lgtm action: merge The PR is ready for merge by the caretaker and removed pr: needs review labels Jul 5, 2017
@mmalerba mmalerba merged commit 4a959e9 into angular:master Jul 5, 2017
amcdnl pushed a commit to amcdnl/material2 that referenced this pull request Jul 8, 2017
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.
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 6, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

action: merge The PR is ready for merge by the caretaker cla: yes PR author has agreed to Google's Contributor License Agreement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants