Created
February 2, 2012 03:26
-
-
Save neilsarkar/1721221 to your computer and use it in GitHub Desktop.
Firefox 10 Crossdomain isArray bug
This file contains hidden or 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
# /etc/hosts | |
127.0.0.1 example.com | |
127.0.0.1 api.example.com |
This file contains hidden or 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 PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> | |
<html> | |
<body> | |
<script> | |
document.domain = "example.com" | |
</script> | |
<!-- Subdomains only. Everything works as expected if we use src="/xdreceiver.html" --> | |
<iframe name="xd" src="http://api.example.com/xdreceiver.html"></iframe> | |
<script> | |
// we have to wait for the iframe to be loaded on the page | |
setTimeout( function() { | |
//both alert false | |
alert(Array.isArray(window.xd.arr)) | |
alert(Array.isArray(window.xd.JSON.parse("[]"))) | |
Array.isArray = function(obj) { | |
return Object.prototype.toString.call(obj) === "[object Array]"; | |
} | |
//both alert true | |
alert(Array.isArray(window.xd.arr)) | |
alert(Array.isArray(window.xd.JSON.parse("[]"))) | |
}, 200) | |
</script> | |
</body> | |
</html> |
This file contains hidden or 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 PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> | |
<html> | |
<head> | |
</head> | |
<body> | |
<script> | |
document.domain = "example.com" | |
window.arr = [] | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment