3 <p>Test that setRequestHeader encodes header values as latin-
1</p>
4 <pre id=result
>FAIL: script didn't run or raised an unexpected exception.
</pre>
7 testRunner
.dumpAsText();
10 document
.getElementById("result").textContent
+= msg
+ "\n";
12 document
.getElementById("result").textContent
= "";
15 req
= new XMLHttpRequest
;
16 req
.open("GET", "resources/latin1-test.cgi", false);
18 req
.setRequestHeader("CUSTOM-HEADER", "\xd5K");
20 exceptionThrown
= false;
22 req
.setRequestHeader("X-SNOWMAN", "\u2603");
24 exceptionThrown
= true;
27 log("PASSED: non-latin-1 header value throws");
29 log("FAILED: latin-1 header value accepted");
32 if (req
.responseText
.indexOf("HTTP_CUSTOM_HEADER: %D5K") >= 0)
33 log("PASSED: header bytes preserved as latin-1");
35 log("FAILED: header bytes not preserved as latin-1");
37 if (req
.getResponseHeader("Custom-Header") == "\xd5K")
38 log("PASSED: response header interpreted correctly");
40 log("FAILED: response header interpreted incorrectly");
42 // TODO(davidben): Test req.statusText too. Unfortunately, lighttpd
43 // doesn't seem to forward the HTTP status text from the CGI script's