<html>
<script>
if (window.testRunner) {
    testRunner.dumpAsText();
    testRunner.dumpResourceLoadCallbacks();
    testRunner.waitUntilDone();
}

function startTest()
{
    window.setTimeout("createFrame(0);", 0);
}

var testCodes = [301, 302, 303, 307];

function createFrame(index)
{
    var h4 = document.createElement("h4");
    h4.innerHTML = testCodes[index] + " redirect";
    document.body.appendChild(h4);
    var iframe = document.createElement("iframe");
    iframe.setAttribute("testCode", testCodes[index]);
    iframe.setAttribute("id", index);
    iframe.setAttribute("name", index);
    iframe.setAttribute("height", "90px");
    document.body.appendChild(iframe);
    iframe.src="resources/redirect-methods-form.html";
    iframe.setAttribute("onload", "iframeLoaded(" + index + ");");
}

function iframeLoaded(frameID)
{
    var iframe = document.getElementById(frameID);
    if (iframe.hasAttribute("submitted")) {
        if (++frameID == testCodes.length) {
            if (window.testRunner)
                testRunner.notifyDone();
            return;
        }
        createFrame(frameID);
    } else {
        submitFormForFrame(iframe);
    }
}

function submitFormForFrame(iframe)
{
    var testInput = iframe.contentDocument.getElementById("testFormInput");
    testInput.value = iframe.getAttribute("testCode");
    var testForm = iframe.contentDocument.getElementById("testForm");
    iframe.setAttribute("submitted", "true");
    testForm.submit();
}

</script>
</head>
<body onload="startTest();">
This test checks to see what HTTP method is used to fetch the final resource in the case where the first request results in a redirect.<br>
301, 302, 303, and 307 http redirects are all tested.<br>

</body>
</html>
