2008-11-04 Anders Carlsson <andersca@apple.com>
[webkit/qt.git] / LayoutTests / fast / dom / xmlhttprequest-html-response-encoding.html
blob4c6c92d3d076dbd0c3f66bc9b170b0870ea9904b
1 <html>
2 <head>
3 <title>Test XmlHttpRequest response encoding handling</title>
4 </head>
5 <body>
6 <p>Test for <a href="http://bugs.webkit.org/show_bug.cgi?id=14288">bug 14288</a>:
7 XMLHttpRequest doesn't use a correct content type for file:// URLs.</p>
8 <script>
10 if (window.layoutTestController)
11 layoutTestController.dumpAsText();
13 var console_messages = document.createElement("ol");
14 document.body.appendChild(console_messages);
16 var asyncStep = 1;
18 function log(message)
20 var item = document.createElement("li");
21 item.appendChild(document.createTextNode(message));
22 console_messages.appendChild(item);
25 function get(url, async)
27 if (window.XMLHttpRequest) {
28 req = new XMLHttpRequest();
29 } else {
30 try {
31 req = new ActiveXObject("Msxml2.XMLHTTP");
32 } catch (ex) {
33 req = new ActiveXObject("Microsoft.XMLHTTP");
37 if (async)
38 req.onreadystatechange = processStateChange;
40 req.open('GET', url, async);
41 req.send(null);
43 return req;
46 function processStateChange(){
47 if (req.readyState == 4)
48 log("Async: HTML, charset determined by a META: " + req.responseText.replace(/\s/g, "").replace(/.*<body>(.*)<\/body>.*/, "$1"));
51 try {
52 req = get('resources/1251.html', false);
53 log("HTML, charset determined by a META: " + req.responseText.replace(/\s/g, "").replace(/.*<body>(.*)<\/body>.*/, "$1"));
54 } catch (ex) {
55 log("Exception: " + ex.description);
58 get('resources/1251.html', true);
60 </script>
61 </body>
62 </html>