<html>
<head>
  <script src="../../../resources/js-test-pre.js"></script>
<body>
<p>Test that removing a form attribute from an input element leaves any
existing radio button group in the  document in a valid state.</p>
<div id="console"></div>
<form id="form1">
  <input type="radio" name="test" id="rb1" value="1">
  <input type="radio" name="test" id="rb2" value="2">
</form>
<input type="radio" name="test" id="rb3" form="form1" value="3" checked>
<input type="radio" name="test" id="rb4" value="4">
<input type="radio" name="test" id="rb5" value="5" checked>
<script>
  var result = document.getElementById('result');
  var form = document.forms[0];
  var rb1 = document.getElementById('rb1');
  var rb2 = document.getElementById('rb2');
  var rb3 = document.getElementById('rb3');
  var rb4 = document.getElementById('rb4');
  var rb5 = document.getElementById('rb5');

  debug('- Verify initial state')
  shouldBeFalse('rb1.checked');
  shouldBeFalse('rb2.checked');
  shouldBeTrue('rb3.checked');
  shouldBeFalse('rb4.checked');
  shouldBeTrue('rb5.checked');

  debug('');
  debug('- Remove form attr from rb3, verify that rb5 becomes unchecked state');
  rb3.removeAttribute('form');
  shouldBeFalse('rb1.checked');
  shouldBeFalse('rb2.checked');
  shouldBeTrue('rb3.checked');
  shouldBeFalse('rb4.checked');
  shouldBeFalse('rb5.checked');
</script>
</body>
</html>
