toolkit/content/tests/chrome/test_radio.xul

branch
TOR_BUG_3246
changeset 7
129ffea94266
equal deleted inserted replaced
-1:000000000000 0:62eecde867fc
1 <?xml version="1.0"?>
2 <?xml-stylesheet href="chrome://global/skin" type="text/css"?>
3 <?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
4 <!--
5 XUL Widget Test for radio buttons
6 -->
7 <window title="Radio Buttons" width="500" height="600"
8 onload="setTimeout(test_radio, 0);"
9 xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
10 <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
11 <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
12 <script type="application/javascript" src="xul_selectcontrol.js"/>
13
14 <radiogroup id="radiogroup"/>
15
16 <radiogroup id="radiogroup-initwithvalue" value="two">
17 <radio label="One" value="one"/>
18 <radio label="Two" value="two"/>
19 <radio label="Three" value="three"/>
20 </radiogroup>
21 <radiogroup id="radiogroup-initwithselected" value="two">
22 <radio id="one" label="One" value="one" accesskey="o"/>
23 <radio id="two" label="Two" value="two" accesskey="t"/>
24 <radio label="Three" value="three" selected="true"/>
25 </radiogroup>
26
27 <!-- test results are displayed in the html:body -->
28 <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
29
30 <!-- test code goes here -->
31 <script type="application/javascript"><![CDATA[
32
33 SimpleTest.waitForExplicitFinish();
34
35 function test_radio()
36 {
37 var element = document.getElementById("radiogroup");
38 test_nsIDOMXULSelectControlElement(element, "radio", null);
39 test_nsIDOMXULSelectControlElement_UI(element, null);
40
41 window.blur();
42
43 var accessKeyDetails = (navigator.platform.indexOf("Mac") >= 0) ?
44 { altKey : true, ctrlKey : true } :
45 { altKey : true, shiftKey: true };
46 synthesizeKey("t", accessKeyDetails);
47
48 var radiogroup = $("radiogroup-initwithselected");
49 is(document.activeElement, radiogroup, "accesskey focuses radiogroup");
50 is(radiogroup.selectedItem, $("two"), "accesskey selects radio");
51
52 $("radiogroup-initwithvalue").focus();
53
54 $("one").disabled = true;
55 synthesizeKey("o", accessKeyDetails);
56
57 is(document.activeElement, $("radiogroup-initwithvalue"), "accesskey on disabled radio doesn't focus");
58 is(radiogroup.selectedItem, $("two"), "accesskey on disabled radio doesn't change selection");
59
60 SimpleTest.finish();
61 }
62
63 ]]>
64 </script>
65
66 </window>

mercurial