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

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).