Last active
June 3, 2023 11:48
-
-
Save oogatta/7208821 to your computer and use it in GitHub Desktop.
Strange behavior of the IE11 on compat-mode. A function wrapping 'typeof' mis-detect an ActiveXObject.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<script src="test.js"></script> | |
</head> | |
<body> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
location /ie11-emulateie7/ { | |
alias /home/oogatta/ie11/; | |
add_header 'X-UA-Compatible' 'IE=EmulateIE7'; | |
expires epoch; | |
add_header Cache-Control private; | |
add_header Cache-Control must-revalidate; | |
add_header Cache-Control no-store; | |
add_header Pragma no-cache; | |
} | |
location /ie11-emulateie8/ { | |
alias /home/oogatta/ie11/; | |
add_header 'X-UA-Compatible' 'IE=EmulateIE8'; | |
expires epoch; | |
add_header Cache-Control private; | |
add_header Cache-Control must-revalidate; | |
add_header Cache-Control no-store; | |
add_header Pragma no-cache; | |
} | |
location /ie11-emulateie9/ { | |
alias /home/oogatta/ie11/; | |
add_header 'X-UA-Compatible' 'IE=EmulateIE9'; | |
expires epoch; | |
add_header Cache-Control private; | |
add_header Cache-Control must-revalidate; | |
add_header Cache-Control no-store; | |
add_header Pragma no-cache; | |
} | |
location /ie11-emulateie10/ { | |
alias /home/oogatta/ie11/; | |
add_header 'X-UA-Compatible' 'IE=EmulateIE10'; | |
expires epoch; | |
add_header Cache-Control private; | |
add_header Cache-Control must-revalidate; | |
add_header Cache-Control no-store; | |
add_header Pragma no-cache; | |
} | |
location /ie11-edge/ { | |
alias /home/oogatta/ie11/; | |
add_header 'X-UA-Compatible' 'IE=edge'; | |
expires epoch; | |
add_header Cache-Control private; | |
add_header Cache-Control must-revalidate; | |
add_header Cache-Control no-store; | |
add_header Pragma no-cache; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var isFunction = function(object) { | |
// only with 'typeof' | |
return typeof object == 'function'; | |
}; | |
// run in one thread. piled up karma | |
var result = ''; | |
for ( var i=1; i<12; i++ ) { // the number varies. I'm not sure why. It might be the defference between 32bit and 64bit, or among zones, or something | |
result += isFunction() + '\n'; | |
} | |
// then check in another thread, bang. | |
setTimeout(function(){ | |
var dom = document.getElementsByTagName('body')[0]; | |
alert(isFunction(dom)); // true!, ActiveXObject | |
alert(result); // all false | |
alert(isFunction(XMLHttpRequest)); // true, another ActiveXObject | |
// NOTICE: the type of XMLHttpRequest is 'function' on standard-mode, 'object' on emulateIE7 & emulateIE8 mode | |
alert(isFunction({})); // false, pure JS Object | |
},0); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment