summaryrefslogtreecommitdiffstats
path: root/dom/html/test/forms/test_radio_in_label.html
blob: 1676c9819babb5ec29446a6251a6f2e14b0677af (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
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=229925
-->
<head>
  <title>Test for Bug 229925</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=229925">Mozilla Bug 229925</a>
<p id="display"></p>
<form>
  <label>
    <span id="s1">LABEL</span>
    <input type="radio" name="rdo" value="1" id="r1" onmousedown="document.body.appendChild(document.createTextNode('down'));">
    <input type="radio" name="rdo" value="2" id="r2" checked="checked">
  </label>
</form>
<script class="testbody" type="text/javascript">

/** Test for Bug 229925 **/
SimpleTest.waitForExplicitFinish();
var r1 = document.getElementById("r1");
var r2 = document.getElementById("r2");
var s1 = document.getElementById("s1");
SpecialPowers.pushPrefEnv({"set":[["snav.enabled", false]]}, startTest);
function startTest() {
  r1.click();
  ok(r1.checked,
     "The first radio input element should be checked by clicking the element");
  r2.click();
  ok(r2.checked,
     "The second radio input element should be checked by clicking the element");
  s1.click();
  ok(r1.checked,
     "The first radio input element should be checked by clicking other element");

  r1.focus();
  synthesizeKey("VK_LEFT", {});
  ok(r2.checked,
     "The second radio input element should be checked by key");
  synthesizeKey("VK_LEFT", {});
  ok(r1.checked,
     "The first radio input element should be checked by key");
  SimpleTest.finish();
}
</script>
</pre>
</body>
</html>