<form id="form">
<input id="file" multiple type="file" name="file">
</form>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script type="text/javascript">
promise_test((t) => {
eventSender.beginDragWithFiles(
['resources/UTF8.txt', 'resources/UTF8-2.txt']);
eventSender.mouseMoveTo(10, 10);
eventSender.mouseUp();
var form = document.getElementById('form');
var formData = new FormData(form);
var request = new Request('/', {
method: 'POST',
body: formData
});
return request.text().then(text => {
assert_true(text.search('WebKitFormBoundary') > 0,
'the boundary is contained');
assert_true(text.search('Hello') > 0, 'UTF8.txt is contained');
assert_true(text.search('Wonderful') > 0, 'UTF8-2.txt is contained');
});
}, "Reading a text from form files.");
promise_test((t) => {
eventSender.beginDragWithFiles(['resources/UTF8.txt']);
eventSender.mouseMoveTo(10, 10);
eventSender.mouseUp();
var file = document.getElementById('file');
var formData = new FormData();
formData.append('file', file.files[0]);
assert_equals(file.files[0].size, 5, 'file size');
var request = new Request('/', {
method: 'POST',
body: formData
});
return request.text().then(text => {
assert_true(text.search('WebKitFormBoundary') > 0,
'the boundary is contained');
assert_true(text.search('Hello') > 0, 'UTF8.txt is contained');
assert_true(text.search('Wonderful') < 0, 'UTF8-2.txt is not contained');
});
}, "Reading a text from a generated form data.");
</script>