<html>
<body>
<p>Tests for <a href="https://bugs.webkit.org/show_bug.cgi?id=8099"> bug 8099</a> - 
XMLHttpRequest lowercase post requests broken.</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);
    }

    // sync
    req = new XMLHttpRequest;
    req.open("get", "methods.cgi", false);
    req.send("");
    log('get(""): ' + req.getResponseHeader("REQMETHOD") + "(" + req.getResponseHeader("REQLENGTH") + " bytes), Content-Type: " + req.getResponseHeader("REQTYPE"));

    req.open("post", "methods.cgi", false);
    req.send("");
    log('post(""): ' + req.getResponseHeader("REQMETHOD") + "(" + req.getResponseHeader("REQLENGTH") + " bytes), Content-Type: " + req.getResponseHeader("REQTYPE"));

    req.open("DoIt", "methods.cgi", false);
    req.send("");
    log('DoIt(""): ' + req.getResponseHeader("REQMETHOD") + "(" + req.getResponseHeader("REQLENGTH") + " bytes), Content-Type: " + req.getResponseHeader("REQTYPE"));

    // async
    var asyncStep = 1;

    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 = new XMLHttpRequest();
            req.onreadystatechange = processStateChange;
            req.open("post", "methods.cgi", true);
            req.send("");
          } else if (asyncStep == 2) {
            asyncStep = 3;
            log('post(""): ' + req.getResponseHeader("REQMETHOD") + "(" + req.getResponseHeader("REQLENGTH") + " bytes), Content-Type: " + req.getResponseHeader("REQTYPE"));
            req = new XMLHttpRequest();
            req.onreadystatechange = processStateChange;
            req.open("DoIt", "methods.cgi", true);
            req.send("");
          } else if (asyncStep == 3) {
            log('DoIt(""): ' + req.getResponseHeader("REQMETHOD") + "(" + req.getResponseHeader("REQLENGTH") + " bytes), Content-Type: " + req.getResponseHeader("REQTYPE"));
            if (window.testRunner)
              testRunner.notifyDone();
          }
        }
      }
    }

</script>
</body>
</html>
