<!DOCTYPE html>
<meta charset="utf-8">
<title>HTMLLegendElement Test: form</title>
<link rel="author" title="Intel" href="http://www.intel.com/">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>

<div id="log"></div>

<div style="display:none">
  <form id="testform">
    <legend id="testlegend">radio</legend>
  </form>
</div>

<div style="display:none">
  <form id="testformWithFieldSet">
    <fieldset>
    <legend id="legendWithFieldSet">radio</legend>
    </fieldset>
  </form>
</div>
<script>
test(function () {
  var legendEle = document.getElementById("legendWithFieldSet");
  assert_not_equals(legendEle.form, null);
  assert_equals(legendEle.form, document.getElementById("testformWithFieldSet"));
}, "Check if legend.form returns its parent when it's inside a fieldset");
test(function () {
  var legendEle = document.getElementById("testlegend");
  assert_equals(legendEle.form, null);
}, "Check if legend.form return null when legend has no fieldset element as its parent");
</script>
