gecko-dev/layout/reftests/xul/accesskey.xul
Brian Grinstead db663b11af Bug 1508446 - Require that [accesskey] gets set on <xul:label> to enable formatting without referencing a binding parent;r=paolo
Previously, if the accesskey attribute was missing then the label would reach up
to binding parent to find it's accesskey. In practice, bindings already do
[xbl:inherits=accesskey] to send it down to the label anyway.

The problem with this is that for controls without accesskeys, the attribute doesn't get set,
so the label will access the control from JS. This is fine for XBL, since typically
the label XBL will construct at the same time as the control, but when migrating
to Custom Elements, the label gets connected even when the control is hidden.

Differential Revision: https://phabricator.services.mozilla.com/D12355

--HG--
extra : moz-landing-system : lando
2019-02-26 16:41:47 +00:00

44 lines
1.5 KiB
XML

<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
<!-- This test checks that access keys are rendered properly, both when set with the
accesskey attribute in the markup and updated via script later.
-->
<window class="reftest-wait" onload="changeKeys()"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script>
<![CDATA[
var keys = ['L', 'l', 'b', 'x', 'l'];
function changeKeys()
{
var box = document.getElementById('d');
for (var b = 0; b < 5; b++)
box.childNodes[b * 2].accessKey = keys[b];
document.documentElement.className='';
}
]]>
</script>
<hbox align="start">
<label control="b1" accesskey="L">Label1</label><textbox id="b1" size="2"/>
<label control="b2" accesskey="l">Label2</label><textbox id="b2" size="2"/>
<label control="b3" accesskey="b">Label3</label><textbox id="b3" size="2"/>
<label control="b4" accesskey="x">Label4</label><textbox id="b4" size="2"/>
<label control="b5" accesskey="l" maxwidth="50">Quite a long label. Hopefully it will wrap</label><textbox id="b5" size="2"/>
</hbox>
<hbox id="d" align="start">
<label control="d1" accesskey="z">Label1</label><textbox id="d1" size="2"/>
<label control="d2">Label2</label><textbox id="d2" size="2"/>
<label control="d3" accesskey="t">Label3</label><textbox id="d3" size="2"/>
<label control="d4" accesskey="b">Label4</label><textbox id="d4" size="2"/>
<label control="d5" accesskey="l" maxwidth="50">Quite a long label. Hopefully it will wrap</label><textbox id="d5" size="2"/>
</hbox>
</window>