Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / http / tests / xmlhttprequest / xmlhttprequest-latin1.html
blob3530f8a7c162dcc10c7d3135d678e804b6200e20
1 <html>
2 <body>
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>
5 <script>
6 if (window.testRunner)
7 testRunner.dumpAsText();
9 function log(msg) {
10 document.getElementById("result").textContent += msg + "\n";
12 document.getElementById("result").textContent = "";
14 try {
15 req = new XMLHttpRequest;
16 req.open("GET", "resources/latin1-test.cgi", false);
18 req.setRequestHeader("CUSTOM-HEADER", "\xd5K");
20 exceptionThrown = false;
21 try {
22 req.setRequestHeader("X-SNOWMAN", "\u2603");
23 } catch(e) {
24 exceptionThrown = true;
26 if (exceptionThrown)
27 log("PASSED: non-latin-1 header value throws");
28 else
29 log("FAILED: latin-1 header value accepted");
31 req.send("");
32 if (req.responseText.indexOf("HTTP_CUSTOM_HEADER: %D5K") >= 0)
33 log("PASSED: header bytes preserved as latin-1");
34 else
35 log("FAILED: header bytes not preserved as latin-1");
37 if (req.getResponseHeader("Custom-Header") == "\xd5K")
38 log("PASSED: response header interpreted correctly");
39 else
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
44 // status header.
45 } catch (ex) {
46 log("FAILED: " + ex);
48 </script>
49 </body>
50 </html>