check if window is defined before accessing window props

If you do not check that "window" exists, then a mocha test referencing this JS will fail immediately, claiming that "window" is undefined (even though the js-binarypack module is not used - the mere presence of the window.someProperty makes mocha angry).