Make focus-related test cases succeed in Firefox

Firefox throws an exception if an element to be focused is not visible or not
in DOM at all. This patch fixes three test cases: two by accepting the
exception as valid, one by making sure the element is visible.

Change by Adrian Lang. Ported from https://gerrit.wikimedia.org/r/#/c/105945/
Some clean-up
Merge pull request #3 from wmde/firefoxtest

Make focus-related test cases succeed in Firefox