check if window is defined before accessing props

otherwise mocha tests fail (they do not recognise the window object)