Polymer / tools

Polymer Tools Monorepo
BSD 3-Clause "New" or "Revised" License
430 stars 200 forks source link

Firefox force focus on window #3016

Open valdrinkoshi opened 8 years ago

valdrinkoshi commented 8 years ago

Focus related tests fail on Firefox 44 because the focus moves away from the Firefox window.

Example 1

test('document has focus', function() {
  assert.isTrue(document.hasFocus(), 'document has focus');
});

Example 2 https://github.com/PolymerElements/paper-dialog-behavior/blob/master/test/paper-dialog-behavior.html#L269

valdrinkoshi commented 8 years ago

cc @azakus

valdrinkoshi commented 8 years ago

In my case, doing window.top.focus() solves the issue (tests are run into an <iframe>)

valdrinkoshi commented 8 years ago

cc/ @justinfagnani

justinfagnani commented 8 years ago

I wonder where the right place to fix this is. If we want to make sure that a browser has focus before a test, that needs to happen per test. WCT might not have the right hook into the tests for that. Would a utility function that prepares a focus test suffice?

justinfagnani commented 8 years ago

@valdrinkoshi what's the latest on the focus woes?

valdrinkoshi commented 8 years ago

@justinfagnani no news on this issue. I think a better and more reliable technique for focus related tests is to check for who causes focus to change, instead of checking the consequences of changing focus. In other words, is better to observe if node.focus() gets called (e.g. with a spy), rather than check its consequences (e.g. check the value of document.activeElement).

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.