mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2025-03-27 21:31:16 -04:00
Fix IE restricted property check
This commit is contained in:
parent
53ddf0159d
commit
db525a8073
1 changed files with 13 additions and 13 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Reference in a new issue