blob: 311f3e06244c3c799a59449a955d8155255914d0 [file] [log] [blame]
<html>
<body>
<p>Tests for <a href="https://bugs.webkit.org/show_bug.cgi?id=3812"> bug 3812</a> -
GET and POST should not be the only HTTP methods implemented in XMLHttpRequest.</p>
<script>
if (window.testRunner) {
testRunner.dumpAsText();
testRunner.waitUntilDone();
}
var console_messages = document.createElement("ol");
document.body.appendChild(console_messages);
function log(message)
{
var item = document.createElement("li");
item.appendChild(document.createTextNode(message));
console_messages.appendChild(item);
}
// async
var asyncStep = 1;
req = new XMLHttpRequest;
req.onreadystatechange = processStateChange;
req.open("GET", "methods.cgi", true);
req.send("");
function processStateChange() {
if (req.readyState == 4){
if (req.status == 200){
if (asyncStep == 1) {
asyncStep = 2;
log('GET(""): ' + req.getResponseHeader("REQMETHOD") + "(" + req.getResponseHeader("REQLENGTH") + " bytes), Content-Type: " + req.getResponseHeader("REQTYPE"));
req.open("GET", "methods.cgi", true);
req.send(null);
} else if (asyncStep == 2) {
asyncStep = 3;
log('GET(null): ' + req.getResponseHeader("REQMETHOD") + "(" + req.getResponseHeader("REQLENGTH") + " bytes), Content-Type: " + req.getResponseHeader("REQTYPE"));
req.open("GET", "methods.cgi", true);
req.send("123");
} else if (asyncStep == 3) {
asyncStep = 4;
log('GET("123"): ' + req.getResponseHeader("REQMETHOD") + "(" + req.getResponseHeader("REQLENGTH") + " bytes), Content-Type: " + req.getResponseHeader("REQTYPE"));
req.open("POST", "methods.cgi", true);
req.send("");
} else if (asyncStep == 4) {
asyncStep = 5;
log('POST(""): ' + req.getResponseHeader("REQMETHOD") + "(" + req.getResponseHeader("REQLENGTH") + " bytes), Content-Type: " + req.getResponseHeader("REQTYPE"));
req.open("POST", "methods.cgi", true);
req.send(null);
} else if (asyncStep == 5) {
asyncStep = 6;
log('POST(null): ' + req.getResponseHeader("REQMETHOD") + "(" + req.getResponseHeader("REQLENGTH") + " bytes), Content-Type: " + req.getResponseHeader("REQTYPE"));
req.open("POST", "methods.cgi", true);
req.send("123");
} else if (asyncStep == 6) {
asyncStep = 7;
log('POST("123"): ' + req.getResponseHeader("REQMETHOD") + "(" + req.getResponseHeader("REQLENGTH") + " bytes), Content-Type: " + req.getResponseHeader("REQTYPE"));
req.open("PUT", "methods.cgi", true);
req.send("");
} else if (asyncStep == 7) {
asyncStep = 8;
log('PUT(""): ' + req.getResponseHeader("REQMETHOD") + "(" + req.getResponseHeader("REQLENGTH") + " bytes), Content-Type: " + req.getResponseHeader("REQTYPE"));
req.open("PUT", "methods.cgi", true);
req.send(null);
} else if (asyncStep == 8) {
asyncStep = 9;
log('PUT(null): ' + req.getResponseHeader("REQMETHOD") + "(" + req.getResponseHeader("REQLENGTH") + " bytes), Content-Type: " + req.getResponseHeader("REQTYPE"));
req.open("PUT", "methods.cgi", true);
req.send("123");
} else if (asyncStep == 9) {
asyncStep = 10;
log('PUT("123"): ' + req.getResponseHeader("REQMETHOD") + "(" + req.getResponseHeader("REQLENGTH") + " bytes), Content-Type: " + req.getResponseHeader("REQTYPE"));
req.open("DELETE", "methods.cgi", true);
req.send("");
} else if (asyncStep == 10) {
asyncStep = 11;
log('DELETE(""): ' + req.getResponseHeader("REQMETHOD") + "(" + req.getResponseHeader("REQLENGTH") + " bytes), Content-Type: " + req.getResponseHeader("REQTYPE"));
req.open("DELETE", "methods.cgi", true);
req.send(null);
} else if (asyncStep == 11) {
asyncStep = 12;
log('DELETE(null): ' + req.getResponseHeader("REQMETHOD") + "(" + req.getResponseHeader("REQLENGTH") + " bytes), Content-Type: " + req.getResponseHeader("REQTYPE"));
req.open("DELETE", "methods.cgi", true);
req.send("123");
} else if (asyncStep == 12) {
asyncStep = 13;
log('DELETE("123"): ' + req.getResponseHeader("REQMETHOD") + "(" + req.getResponseHeader("REQLENGTH") + " bytes), Content-Type: " + req.getResponseHeader("REQTYPE"));
req.open("HEAD", "methods.cgi", true);
req.send("");
} else if (asyncStep == 13) {
asyncStep = 14;
log('HEAD(""): ' + req.getResponseHeader("REQMETHOD") + "(" + req.getResponseHeader("REQLENGTH") + " bytes), Content-Type: " + req.getResponseHeader("REQTYPE"));
req.open("HEAD", "methods.cgi", true);
req.send(null);
} else if (asyncStep == 14) {
asyncStep = 15;
log('HEAD(null): ' + req.getResponseHeader("REQMETHOD") + "(" + req.getResponseHeader("REQLENGTH") + " bytes), Content-Type: " + req.getResponseHeader("REQTYPE"));
req.open("HEAD", "methods.cgi", true);
req.send("123");
} else if (asyncStep == 15) {
asyncStep = 16;
log('HEAD("123"): ' + req.getResponseHeader("REQMETHOD") + "(" + req.getResponseHeader("REQLENGTH") + " bytes), Content-Type: " + req.getResponseHeader("REQTYPE"));
req.open("WKFOOBAR", "methods.cgi", true);
req.send("");
} else if (asyncStep == 16) {
asyncStep = 17;
log('WKFOOBAR(""): ' + req.getResponseHeader("REQMETHOD") + "(" + req.getResponseHeader("REQLENGTH") + " bytes), Content-Type: " + req.getResponseHeader("REQTYPE"));
req.open("WKFOOBAR", "methods.cgi", true);
req.send(null);
} else if (asyncStep == 17) {
asyncStep = 18;
log('WKFOOBAR(null): ' + req.getResponseHeader("REQMETHOD") + "(" + req.getResponseHeader("REQLENGTH") + " bytes), Content-Type: " + req.getResponseHeader("REQTYPE"));
req.open("WKFOOBAR", "methods.cgi", true);
req.send("123");
} else if (asyncStep == 18) {
asyncStep = 19;
log('WKFOOBAR("123"): ' + req.getResponseHeader("REQMETHOD") + "(" + req.getResponseHeader("REQLENGTH") + " bytes), Content-Type: " + req.getResponseHeader("REQTYPE"));
req.open("SEARCH", "methods.cgi", true);
req.send("");
} else if (asyncStep == 19) {
asyncStep = 20;
log('SEARCH(""): ' + req.getResponseHeader("REQMETHOD") + "(" + req.getResponseHeader("REQLENGTH") + " bytes), Content-Type: " + req.getResponseHeader("REQTYPE"));
req.open("SEARCH", "methods.cgi", true);
req.send(null);
} else if (asyncStep == 20) {
asyncStep = 21;
log('SEARCH(null): ' + req.getResponseHeader("REQMETHOD") + "(" + req.getResponseHeader("REQLENGTH") + " bytes), Content-Type: " + req.getResponseHeader("REQTYPE"));
req.open("SEARCH", "methods.cgi", true);
req.send("123");
} else if (asyncStep == 21) {
log('SEARCH("123"): ' + req.getResponseHeader("REQMETHOD") + "(" + req.getResponseHeader("REQLENGTH") + " bytes), Content-Type: " + req.getResponseHeader("REQTYPE"));
if (window.testRunner)
testRunner.notifyDone();
}
} else {
log("Error loading URL: status " + req.status);
}
}
}
</script>
</body>
</html>