summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/html/semantics/forms/form-submission-0/submit-file.sub.html
blob: aab60ba9491b9d28d32d2f51e991e299be9e7796 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
<!DOCTYPE html>
<meta charset="utf-8">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<body>
<iframe id=testframe name=testframe></iframe>
<form id=testform method=post action="//{{domains[www1]}}:{{location[port]}}/html/semantics/forms/form-submission-0/resources/file-submission.py" target=testframe enctype="multipart/form-data">
<input name=testinput id=testinput type=file>
</form>
<script>
async_test(t => {
  const dataTransfer = new DataTransfer();
  dataTransfer.items.add(new File(["foobar"], "name"));
  assert_equals(1, dataTransfer.files.length);

  testinput.files = dataTransfer.files;
  testform.submit();

  onmessage = t.step_func(e => {
    if (e.source !== testframe) return;
    assert_equals(e.data, "foobar");
    t.done();
  });
}, 'Posting a File');
</script>