summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/html/semantics/forms/the-selectlist-element/selectlist-form-submission.tentative.html
blob: 4b5e4970287b4df5bfd0c516f0e116fe68ddd77d (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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<!DOCTYPE html>
<html lang="en">
<title>HTMLSelectListElement Test: form submission</title>
<link rel="author" title="Ionel Popescu" href="mailto:iopopesc@microsoft.com">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>

<form id="form0">
  <selectlist name="s0" id="selectlist0">
    <option selected>one</option>
    <option>two</option>
    <option>three</option>
  </selectlist>
</form>

<form id="form1">
  <input type="text" name="i1" value="test">
  <selectlist id="selectlist1">
    <option selected>one</option>
    <option>two</option>
    <option>three</option>
  </selectlist>
</form>

<script>

test(() => {
  const form0 = document.getElementById("form0");
  const selectList0 = document.getElementById("selectlist0");
  assert_equals(selectList0.value, "one");

  const formData = new FormData(form0);
  let entries = 0;
  for (let entry of formData.entries()) {
    assert_equals(entry[0], "s0");
    assert_equals(entry[1], "one");
    entries++;
  }
  assert_equals(entries, 1);
}, "Test that HTMLSelectList.value is used for form submission");

test(() => {
  const form1 = document.getElementById("form1");
  const selectList1 = document.getElementById("selectlist1");
  assert_equals(selectList1.value, "one");

  const formData = new FormData(form1);
  let entries = 0;
  for (let entry of formData.entries()) {
    assert_equals(entry[0], "i1");
    assert_equals(entry[1], "test");
    entries++;
  }
  assert_equals(entries, 1);
}, "Test that HTMLSelectList.value is not used for form submission without name attribute");

</script>