diff --git a/es6-shim.js b/es6-shim.js index 1fce5dde..80b2df18 100644 --- a/es6-shim.js +++ b/es6-shim.js @@ -144,7 +144,15 @@ }()); /*jshint evil: true */ - var getGlobal = new Function('return this;'); + var getGlobal = function () { + // the only reliable means to get the global object is + // `Function('return this')()` + // However, this causes CSP violations in Chrome apps. + if (typeof self !== 'undefined') { return self; } + if (typeof window !== 'undefined') { return window; } + if (typeof global !== 'undefined') { return global; } + throw new Error('unable to locate global object'); + }; /*jshint evil: false */ var globals = getGlobal();