check if window is defined before accessing props

otherwise mocha tests fail (they do not recognise the window object)
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).
Merge pull request #7 from StreamRail/master

check existence of window before referencing it to allow mocha tests to pass