3 <meta http-equiv=
"content-type" content=
"text/html;charset=utf-8">
5 <p>Test for
<a href=
"http://bugs.webkit.org/show_bug.cgi?id=34653">bug
34653</a>:
6 XMLHttpRequest should force to send content-type as charset equals UTF-
8.
</p>
7 <div id=result1
>FAIL: script didn't run to completion.
</div>
8 <div id=result2
>FAIL: script didn't run to completion.
</div>
9 <div id=result3
>FAIL: script didn't run to completion.
</div>
10 <div id=result4
>FAIL: script didn't run to completion.
</div>
14 // Test when content-type is not set.
15 req
= new XMLHttpRequest
;
16 req
.open("POST", "print-content-type.cgi", false);
20 document
.getElementById("result1").firstChild
.data
= "Test1 (setRequestHeader was not called):";
21 if (req
.responseText
== "application/xml\n")
22 document
.getElementById("result1").firstChild
.data
+= " SUCCESS";
24 document
.getElementById("result1").firstChild
.data
+= " FAILURE: '" + req
.responseText
+ "'";
28 // Test when content-type is set without charset.
29 req
= new XMLHttpRequest
;
30 req
.open("POST", "print-content-type.cgi", false);
32 req
.setRequestHeader("Content-Type", "application/xml");
35 document
.getElementById("result2").firstChild
.data
= "Test2 (setRequestHeader was called without a charset):";
36 if (req
.responseText
== "application/xml\n")
37 document
.getElementById("result2").firstChild
.data
+= " SUCCESS";
39 document
.getElementById("result2").firstChild
.data
+= " FAILURE: '" + req
.responseText
+ "'";
43 // Test when content-type is set with non-UTF-8 charset.
44 req
= new XMLHttpRequest
;
45 req
.open("POST", "print-content-type.cgi", false);
47 req
.setRequestHeader("Content-Type", "application/xml; charset=KOI8-R");
50 document
.getElementById("result3").firstChild
.data
= "Test3 (setRequestHeader was called with a non-UTF8 charset):";
51 if (req
.responseText
== "application/xml; charset=UTF-8\n")
52 document
.getElementById("result3").firstChild
.data
+= " SUCCESS";
54 document
.getElementById("result3").firstChild
.data
+= " FAILURE: '" + req
.responseText
+ "'";
58 // Test when content-type is set with multiple charsets and other attributes.
59 req
= new XMLHttpRequest
;
60 req
.open("POST", "print-content-type.cgi", false);
62 req
.setRequestHeader("Content-Type", "application/xml; charset=KOI8-R; charset=UTF-8; charset=iso-8859-1; KOI8-R");
65 document
.getElementById("result4").firstChild
.data
= "Test4 (setRequestHeader was called with multiple charsets and other attributes):";
66 if (req
.responseText
== "application/xml; charset=UTF-8; charset=UTF-8; charset=UTF-8; KOI8-R\n")
67 document
.getElementById("result4").firstChild
.data
+= " SUCCESS";
69 document
.getElementById("result4").firstChild
.data
+= " FAILURE: '" + req
.responseText
+ "'";
72 if (window
.testRunner
)
73 testRunner
.dumpAsText();