Reviewed by Darin Adler.
[WebKit-https.git] / LayoutTests / http / tests / xmlhttprequest / encode-request-url-2.html
1 <head><meta charset="iso-8859-1"></head>
2 <body>
3 <p>Test how URLs are encoded.</p>
4 <ol id=result></ol>
5 <script>
6     function log(message)
7     {
8         var item = document.createElement("li");
9         item.appendChild(document.createTextNode(message));
10         document.getElementById("result").appendChild(item);
11     }
12
13     if (window.layoutTestController) {
14         layoutTestController.waitUntilDone();
15         layoutTestController.dumpAsText();
16     }
17
18     <!-- Firefox 3 encodes query part of XMLHttpRequest requests as UTF-8, but WebKit doesn't special case these. -->
19     var req = new XMLHttpRequest;
20     req.open("GET", "/xmlhttprequest/resources/print-query.cgi?Zürich", false);
21     req.send();
22     log("abs-path: " + (req.responseText == "Z%FCrich" ? "PASS" : "FAIL (" + req.responseText + ")"));
23
24     req.open("GET", "resources/print-query.cgi?Zürich", false);
25     req.send();
26     log("rel-path: " + (req.responseText == "Z%FCrich" ? "PASS" : "FAIL (" + req.responseText + ")"));
27
28     req.open("GET", document.URL.replace(/encode-request-url-2\.html/, "") + "resources/print-query.cgi?Zürich", false);
29     req.send();
30     log("absolute: " + (req.responseText == "Z%FCrich" ? "PASS" : "FAIL (" + req.responseText + ")"));
31
32     var framesLoaded = 0;
33     function frameLoaded()
34     {
35         ++framesLoaded;
36         if (framesLoaded == 2) {
37             log("Frame, abs-path: " + (frames[0].document.documentElement.textContent == "Z%FCrich" ? "PASS" : "FAIL (" + frames[0].document.documentElement.textContent + ")"));
38             log("Frame, rel-path: " + (frames[1].document.documentElement.textContent == "Z%FCrich" ? "PASS" : "FAIL (" + frames[0].document.documentElement.textContent + ")"));
39
40             if (window.layoutTestController)
41                 layoutTestController.notifyDone();
42         }
43     }
44 </script>
45 <iframe src="/xmlhttprequest/resources/print-query.cgi?Zürich" onload="frameLoaded()"></iframe>
46 <iframe src="resources/print-query.cgi?Zürich" onload="frameLoaded()"></iframe>
47 </body>