<!DOCTYPE html>
<html>
<script src="../../../resources/ui-helper.js"></script>
<body>
<form method="GET" action="get-file-upload.html" enctype="application/x-www-form-urlencoded">
  <input type="file" name="file" id="file">
  <input type="hidden" name="submitted" value="true">
</form>
<pre id='console'></pre>

<script>
function log(message)
{
    document.getElementById('console').appendChild(document.createTextNode(message + "\n"));
}

function startOrVerify()
{
    var query = window.location.search;
    if (query.indexOf('submitted=true') != -1) {
        // Verify the result
        if (query.indexOf('file=') != -1)
            log('PASS: ' + query);
        else
            log('FAIL: ' + query);
        testRunner.notifyDone();
    } else {
        // Start the test
        testRunner.setOpenPanelFiles(['get-file-upload.html']);
        document.getElementById('file').addEventListener('change', function() {
            document.forms[0].submit();
        });

        var inputElement = document.getElementById("file");
        var centerX = inputElement.offsetLeft + inputElement.offsetWidth / 2;
        var centerY = inputElement.offsetTop + inputElement.offsetHeight / 2;
        UIHelper.activateAt(centerX, centerY);
    }
}

if (window.eventSender) {
    testRunner.dumpAsText();
    testRunner.waitUntilDone();
    window.onload = startOrVerify;
}
</script>
</body>
</html>
