blob: ad287789c0f8a38922fc95d860e1e497a7e69365 [file] [log] [blame]
<html>
<head>
<title>Check exception thrown by getAllResponseHeaders </title>
</head>
<body>
<p>Test page for the <a href="http://bugs.webkit.org/show_bug.cgi?id=15356">bug 15356</a> : getResponseHeader and getAllResponseHeaders do not throw exceptions</p>
<script type="text/javascript">
if (window.layoutTestController)
layoutTestController.dumpAsText();
function log (msg) {
document.body.appendChild(document.createTextNode(msg));
document.body.appendChild(document.createElement("br"));
}
var xhr;
if (window.XMLHttpRequest) {
xhr = new XMLHttpRequest();
} else {
try {
xhr = new ActiveXObject("Msxml2.XMLHTTP");
} catch (ex) {
xhr = new ActiveXObject("Microsoft.XMLHTTP");
}
}
xhr.onreadystatechange = function() {
var rState = this.readyState;
// We expect an INVALID_STATE_ERR exception for readyState = 1 or 2
// and no exception for readyState = 3 or 4
try {
var header = this.getAllResponseHeaders();
if (rState == 1 || rState == 2) {
log("FAILED ( header :" + header + ")" + rState);
} else {
log("PASSED " + rState);
}
} catch (e) {
if (rState == 1 || rState == 2) {
log("PASSED (" + e.message +" ) " + rState);
} else {
log("FAILED (EXCEPTION THROWN " + e.message + " ) " + rState);
}
}
}
// Test for readyState = 0
try {
var header = xhr.getAllResponseHeaders();
log("FAILED ( header :" + header + ")" + xhr.readyState);
} catch (e) {
log("PASSED (" + e.message +" ) " + xhr.readyState);
}
xhr.open("GET","resources/1251.html", true);
xhr.send(null);
</script>
</body>
</html>