Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / http / tests / xmlhttprequest / cookies.html
blob879a4d89b911d9312dc3c2a5e21ba8971ff5de4a
1 <html>
2 <body>
3 <p>Tests for <a href="http://bugs.webkit.org/show_bug.cgi?id=3420">bug 3420</a>:
4 XMLHttpRequest does not handle set-cookie headers.</p>
5 <div id="result">FAIL: test script didn't run.</div>
7 <script>
8 function clearCookies()
10 req = new XMLHttpRequest;
11 req.open("POST", "resources/get-set-cookie.cgi?clear=1", false);
12 req.send("");
14 function getAndSetCookies()
16 req = new XMLHttpRequest;
17 req.open("POST", "resources/get-set-cookie.cgi", false);
18 req.send("");
19 return req.responseText;
21 function setResult(result)
23 document.getElementById("result").firstChild.data = result;
26 if (window.testRunner)
27 testRunner.dumpAsText();
28 try {
29 clearCookies();
30 var response = getAndSetCookies();
31 if (response && response.match(/.*WK-test=1.*/)) {
32 setResult("FAIL: The cookie still present after clear. clearCookies() failed. Must be a bug in the test!");
33 } else {
34 var response = getAndSetCookies();
35 if (response.match(/.*WK-test-secure=1.*/))
36 setResult("FAIL: a secure cookie was sent via HTTP");
37 else if (response.match(/.*WK-test=1.*/))
38 setResult("SUCCESS");
39 else
40 setResult("FAIL: the cookie was not set");
42 } catch (ex) {
43 setResult(ex);
44 } finally {
45 clearCookies();
47 </script>
48 <body>
49 </html>