tizen beta release
[framework/web/webkit-efl.git] / LayoutTests / fast / xmlhttprequest / xmlhttprequest-html-response-encoding.html
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>
9
10     if (window.layoutTestController) {
11         layoutTestController.dumpAsText();
12         layoutTestController.waitUntilDone();
13     }
14
15     var console_messages = document.createElement("ol");
16     document.body.appendChild(console_messages);
17     
18     var asyncStep = 1;
19     
20     function log(message)
21     {
22         var item = document.createElement("li");
23         item.appendChild(document.createTextNode(message));
24         console_messages.appendChild(item);
25     }
26     
27     function get(url, async)
28     {
29         if (window.XMLHttpRequest) {
30             req = new XMLHttpRequest();
31         } else {
32             try {
33                 req = new ActiveXObject("Msxml2.XMLHTTP");
34             } catch (ex) {
35                 req = new ActiveXObject("Microsoft.XMLHTTP");
36             }
37         }
38         
39         if (async)
40             req.onreadystatechange = processStateChange;
41         
42         req.open('GET', url, async);
43         req.send(null);
44         
45         return req;
46     }
47
48     function processStateChange(){
49         if (req.readyState == 4) {
50             log("Async: HTML, charset determined by a META: " + req.responseText.replace(/\s/g, "").replace(/.*<body>(.*)<\/body>.*/, "$1"));
51             if (window.layoutTestController)
52                 layoutTestController.notifyDone();
53         }
54     }
55
56     try {
57         req =  get('resources/1251.html', false);
58         log("HTML, charset determined by a META: " + req.responseText.replace(/\s/g, "").replace(/.*<body>(.*)<\/body>.*/, "$1"));
59     } catch (ex) {
60         log("Exception: " + ex.description);
61     }
62
63     get('resources/1251.html', true);
64     
65 </script>
66 </body>
67 </html>