content/html/content/test/forms/test_input_radio_radiogroup.html
author Giovanni Sferro <agi.novanta@gmail.com>
Mon, 06 Oct 2014 21:51:00 -0400
changeset 209160 9e7dff9e44045775d6e852d4d249346dc2290aa9
parent 180482 c9ef39ad6e7089faae1cbffb22b8b4885ac7e626
permissions -rw-r--r--
Bug 1059030 - Do not crash when an element has the same @id as a @name of a radiogroup. r=bz

<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=343444
-->
<head>
  <title>Test for Bug 343444</title>
  <script type="text/javascript" src="/MochiKit/MochiKit.js"></script>
  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
  <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=343444">Mozilla Bug 343444</a>
<p id="display"></p>
<form>
  <fieldset id="testradio">
    <input type="radio" name="testradio" id="start"></input>
    <input type="text"  name="testradio"></input>
    <input type="text"  name="testradio"></input>
    <input type="radio" name="testradio"></input>
    <input type="text"  name="testradio"></input>
    <input type="radio" name="testradio"></input>
    <input type="text"  name="testradio"></input>
    <input type="radio" name="testradio"></input>
    <input type="radio" name="testradio"></input>
    <input type="text"  name="testradio"></input>
  </fieldset>

  <fieldset>
    <input type="radio" name="testtwo" id="start2"></input>
    <input type="radio" name="testtwo"></input>
    <input type="radio" name="error" id="testtwo"></input>
    <input type="radio" name="testtwo" id="end"></input>
  </fieldset>

  <fieldset>
    <input type="radio" name="testthree" id="start3"></input>
    <input type="radio" name="errorthree" id="testthree"></input>
  </fieldset>
</form>
<script class="testbody" type="text/javascript">
/** Test for Bug 343444 **/
document.getElementById("start").focus();
var count=0;
while (count < 2) {
  sendKey("DOWN");
  is(document.activeElement.type, "radio", "radioGroup should ignore non-radio input fields");
  if (document.activeElement.id == "start") {
    count++;
  }
}

document.getElementById("start2").focus();
count = 0;
while (count < 3) {
  is(document.activeElement.name, "testtwo",
     "radioGroup should only contain elements with the same @name")
  sendKey("DOWN");
  count++;
}

document.getElementById("start3").focus();
sendKey("DOWN");
is(document.activeElement.name, "testthree", "we don't have an infinite-loop");
</script>
</pre>
</body>
</html>