blob: e2d0ecf4dc39065805b4233f2cd89e63cf712af1 [file] [log] [blame]
<html>
<head>
<title>Test XmlHttpRequest response encoding handling</title>
</head>
<body>
<p>Test for <a href="http://bugs.webkit.org/show_bug.cgi?id=14288">bug 14288</a>:
XMLHttpRequest doesn't use a correct content type for file:// URLs.</p>
<script>
if (window.testRunner) {
testRunner.dumpAsText();
testRunner.waitUntilDone();
}
var console_messages = document.createElement("ol");
document.body.appendChild(console_messages);
var asyncStep = 1;
function log(message)
{
var item = document.createElement("li");
item.appendChild(document.createTextNode(message));
console_messages.appendChild(item);
}
function get(url, async)
{
if (window.XMLHttpRequest) {
req = new XMLHttpRequest();
} else {
try {
req = new ActiveXObject("Msxml2.XMLHTTP");
} catch (ex) {
req = new ActiveXObject("Microsoft.XMLHTTP");
}
}
if (async)
req.onreadystatechange = processStateChange;
req.open('GET', url, async);
req.send(null);
return req;
}
function processStateChange(){
if (req.readyState == 4) {
log("Async: HTML, charset determined by a META: " + req.responseText.replace(/\s/g, "").replace(/.*<body>(.*)<\/body>.*/, "$1"));
if (window.testRunner)
testRunner.notifyDone();
}
}
try {
req = get('resources/1251.html', false);
log("HTML, charset determined by a META: " + req.responseText.replace(/\s/g, "").replace(/.*<body>(.*)<\/body>.*/, "$1"));
} catch (ex) {
log("Exception: " + ex.description);
}
get('resources/1251.html', true);
</script>
</body>
</html>