Fix IE restricted property check

This commit is contained in:
Matt Lott 2014-09-24 15:46:46 -07:00
parent 53ddf0159d
commit db525a8073

View file

@ -65,19 +65,19 @@ self.console = console;
self.importScripts('/javascripts/lodash.js', '/javascripts/world.js', '/javascripts/aether.js');
// TODO: setting these in a loop in IE11 throws an error
Object.defineProperty(self, XMLHttpRequest, {
get: function() { throw new Error("Access to XMLHttpRequest is forbidden."); },
configurable: false
});
Object.defineProperty(self, importScripts, {
get: function() { throw new Error("Access to importScripts is forbidden."); },
configurable: false
});
Object.defineProperty(self, Worker, {
get: function() { throw new Error("Access to Worker is forbidden."); },
configurable: false
});
var restricted = ["XMLHttpRequest", "Worker"];
if (!self.navigator || !(self.navigator.userAgent.indexOf('MSIE') > 0) &&
!self.navigator.userAgent.match(/Trident.*rv\:11\./)) {
// Can't restrict 'importScripts' in IE11, skip for all IE versions
restricted.push("importScripts");
}
for(var i = 0; i < restricted.length; ++i) {
// We could do way more from this: http://stackoverflow.com/questions/10653809/making-webworkers-a-safe-environment
Object.defineProperty(self, restricted[i], {
get: function() { throw new Error("Access to that global property is forbidden."); },
configurable: false
});
}
self.transferableSupported = function transferableSupported() {
if (typeof self._transferableSupported !== 'undefined') return self._transferableSupported;