<!DOCTYPE html>
<html>
<body>
<script src="../../../../resources/js-test-pre.js"></script>
<script>
description("Test that we can send textarea data containing null characters.");

function runTest()
{
    // We can't use testSendingFormData because PHP escapes
    // null bytes on Windows.
    var xhr = new XMLHttpRequest();
    xhr.open('POST', 'http://127.0.0.1:8000/xmlhttprequest/resources/post-echo.cgi', false);
    var formData = new FormData();
    formData.append('textarea', 'hello\u0000world');
    xhr.send(formData);
    if (xhr.readyState !== 4 || xhr.status !== 200) {
        testFailed('xhr.readyState = ' + xhr.readyState + ', xhr.status = ' + xhr.status);
        return;
    }
    if (xhr.response.indexOf('name="textarea"\r\n\r\nhello\u0000world') >= 0) {
        testPassed('the string containing a null byte is echoed correctly.');
    } else {
        testFailed('the string containing a null byte is not echoed correctly.');
    }
}

if (window.eventSender) {
    runTest();
} else {
    testFailed("This test is not interactive, please run in a testing environment.");
}

</script>
<script src="../../../../resources/js-test-post.js"></script>
</body>
</html>
