<!DOCTYPE html>
<html lang="en">
<title>HTMLSelectMenuElement 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">
  <selectmenu name="s0" id="selectmenu0">
    <option selected>one</option>
    <option>two</option>
    <option>three</option>
  </selectmenu>
</form>

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

<script>

test(() => {
  const form0 = document.getElementById("form0");
  const selectMenu0 = document.getElementById("selectmenu0");
  assert_equals(selectMenu0.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 HTMLSelectMenu.value is used for form submission");

test(() => {
  const form1 = document.getElementById("form1");
  const selectMenu1 = document.getElementById("selectmenu1");
  assert_equals(selectMenu1.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 HTMLSelectMenu.value is not used for form submission without name attribute");

</script>
