| <html> |
| <body> |
| <p>Tests for <a href="http://bugs.webkit.org/show_bug.cgi?id=3420">bug 3420</a>: |
| XMLHttpRequest does not handle set-cookie headers.</p> |
| <div id="result">FAIL: test script didn't run.</div> |
| |
| <script> |
| function clearCookies() |
| { |
| req = new XMLHttpRequest; |
| req.open("POST", "resources/get-set-cookie.cgi?clear=1", false); |
| req.send(""); |
| } |
| function getAndSetCookies() |
| { |
| req = new XMLHttpRequest; |
| req.open("POST", "resources/get-set-cookie.cgi", false); |
| req.send(""); |
| return req.responseText; |
| } |
| function setResult(result) |
| { |
| document.getElementById("result").firstChild.data = result; |
| } |
| |
| if (window.testRunner) |
| testRunner.dumpAsText(); |
| try { |
| clearCookies(); |
| var response = getAndSetCookies(); |
| if (response && response.match(/.*WK-test=1.*/)) { |
| setResult("FAIL: The cookie still present after clear. clearCookies() failed. Must be a bug in the test!"); |
| } else { |
| var response = getAndSetCookies(); |
| if (response.match(/.*WK-test-secure=1.*/)) |
| setResult("FAIL: a secure cookie was sent via HTTP"); |
| else if (response.match(/.*WK-test=1.*/)) |
| setResult("SUCCESS"); |
| else |
| setResult("FAIL: the cookie was not set"); |
| } |
| } catch (ex) { |
| setResult(ex); |
| } finally { |
| clearCookies(); |
| } |
| </script> |
| <body> |
| </html> |