Test for undefined in focus method

In current Chromium the focus method gets sometimes called with this set to window. Thus an exception is thrown, which is disturbing during debugging.

```
Uncaught TypeError: Cannot read property 'ownerDocument' of undefined 
```

This PR tests for undefined.