check if typeof window is not undefined before accessing window props

even though the pack is for browsers, it is sometimes desirable to run
mocha tests. if you reference window before checking that it is
defined,  mocha tests will immediately fail, even if you are not using
this module (it’s enough that you include it).