1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/toolkit/content/tests/chrome/test_radio.xul Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,66 @@ 1.4 +<?xml version="1.0"?> 1.5 +<?xml-stylesheet href="chrome://global/skin" type="text/css"?> 1.6 +<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?> 1.7 +<!-- 1.8 + XUL Widget Test for radio buttons 1.9 + --> 1.10 +<window title="Radio Buttons" width="500" height="600" 1.11 + onload="setTimeout(test_radio, 0);" 1.12 + xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> 1.13 + <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> 1.14 + <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script> 1.15 + <script type="application/javascript" src="xul_selectcontrol.js"/> 1.16 + 1.17 +<radiogroup id="radiogroup"/> 1.18 + 1.19 +<radiogroup id="radiogroup-initwithvalue" value="two"> 1.20 + <radio label="One" value="one"/> 1.21 + <radio label="Two" value="two"/> 1.22 + <radio label="Three" value="three"/> 1.23 +</radiogroup> 1.24 +<radiogroup id="radiogroup-initwithselected" value="two"> 1.25 + <radio id="one" label="One" value="one" accesskey="o"/> 1.26 + <radio id="two" label="Two" value="two" accesskey="t"/> 1.27 + <radio label="Three" value="three" selected="true"/> 1.28 +</radiogroup> 1.29 + 1.30 + <!-- test results are displayed in the html:body --> 1.31 + <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/> 1.32 + 1.33 + <!-- test code goes here --> 1.34 + <script type="application/javascript"><![CDATA[ 1.35 + 1.36 +SimpleTest.waitForExplicitFinish(); 1.37 + 1.38 +function test_radio() 1.39 +{ 1.40 + var element = document.getElementById("radiogroup"); 1.41 + test_nsIDOMXULSelectControlElement(element, "radio", null); 1.42 + test_nsIDOMXULSelectControlElement_UI(element, null); 1.43 + 1.44 + window.blur(); 1.45 + 1.46 + var accessKeyDetails = (navigator.platform.indexOf("Mac") >= 0) ? 1.47 + { altKey : true, ctrlKey : true } : 1.48 + { altKey : true, shiftKey: true }; 1.49 + synthesizeKey("t", accessKeyDetails); 1.50 + 1.51 + var radiogroup = $("radiogroup-initwithselected"); 1.52 + is(document.activeElement, radiogroup, "accesskey focuses radiogroup"); 1.53 + is(radiogroup.selectedItem, $("two"), "accesskey selects radio"); 1.54 + 1.55 + $("radiogroup-initwithvalue").focus(); 1.56 + 1.57 + $("one").disabled = true; 1.58 + synthesizeKey("o", accessKeyDetails); 1.59 + 1.60 + is(document.activeElement, $("radiogroup-initwithvalue"), "accesskey on disabled radio doesn't focus"); 1.61 + is(radiogroup.selectedItem, $("two"), "accesskey on disabled radio doesn't change selection"); 1.62 + 1.63 + SimpleTest.finish(); 1.64 +} 1.65 + 1.66 +]]> 1.67 +</script> 1.68 + 1.69 +</window>