Source code

Revision control

Copy as Markdown

Other Tools

Test Info:

<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
type="text/css"?>
title="Accessible XUL button hierarchy tests">
<script type="application/javascript"
src="../common.js" />
<script type="application/javascript"
src="../role.js" />
<script type="application/javascript"
src="../name.js" />
<script type="application/javascript">
<![CDATA[
////////////////////////////////////////////////////////////////////////////
// Test
function doTest()
{
//////////////////////////////////////////////////////////////////////////
// button
var accTree = {
role: ROLE_PUSHBUTTON,
name: "hello",
children: [
{
role: ROLE_LABEL,
children: [ { role: ROLE_STATICTEXT, name: "hello" } ]
}
]
};
testAccessibleTree("button1", accTree);
//////////////////////////////////////////////////////////////////////////
// toolbarbutton
accTree = {
role: ROLE_PUSHBUTTON,
name: "hello",
children: [
{
role: ROLE_LABEL,
children: [ { role: ROLE_STATICTEXT, name: "hello" } ]
}
]
};
testAccessibleTree("button2", accTree);
//////////////////////////////////////////////////////////////////////////
// toolbarbutton with type="checkbox"
accTree = {
role: ROLE_TOGGLE_BUTTON,
name: "hello",
children: [
{
role: ROLE_LABEL,
children: [ { role: ROLE_STATICTEXT, name: "hello" } ]
}
]
};
testAccessibleTree("button3", accTree);
//////////////////////////////////////////////////////////////////////////
// toolbarbutton with ::after content on its label
accTree = {
role: ROLE_PUSHBUTTON,
name: "hello (Ctrl+B)",
children: [
{
role: ROLE_LABEL,
children: [
{ role: ROLE_STATICTEXT, name: "hello" },
{ role: ROLE_STATICTEXT, name: " (Ctrl+B)" }
]
}
]
};
testAccessibleTree("button4", accTree);
//////////////////////////////////////////////////////////////////////////
// button with ::after content on the button itself
accTree = {
role: ROLE_PUSHBUTTON,
name: "hello (Ctrl+B)",
children: [
{
role: ROLE_LABEL,
children: [ { role: ROLE_STATICTEXT, name: "hello" } ]
},
{ role: ROLE_STATICTEXT, name: "(Ctrl+B)" }
]
};
testAccessibleTree("button5", accTree);
//////////////////////////////////////////////////////////////////////////
// toolbarbutton whose label is hidden by CSS
accTree = {
role: ROLE_PUSHBUTTON,
name: "hello",
children: [ ]
};
testAccessibleTree("button6", accTree);
//////////////////////////////////////////////////////////////////////////
// menu button: the popup shouldn't contribute to the name
testName("button7", "hello");
//////////////////////////////////////////////////////////////////////////
// button with an access key that isn't in the label, which is appended to
// the visible label if menu access keys are enabled
testName(
"button8",
Services.prefs.getIntPref("ui.key.menuAccessKey") ? "hello (Z)" : "hello"
);
//////////////////////////////////////////////////////////////////////////
// button with an access key that is in the label, which is underlined
testName("button9", "hello");
//////////////////////////////////////////////////////////////////////////
// toolbarbutton with an empty label and a tooltip
testName("button10", "Foo");
SimpleTest.finish()
}
SimpleTest.waitForExplicitFinish();
addA11yLoadEvent(doTest);
]]>
</script>
<hbox flex="1" style="overflow: auto;">
<a target="_blank"
title="Ensure accessible children for toolbarbutton types 'menu'">
Mozilla Bug 249292
</a><br/>
<p id="display"></p>
<div id="content" style="display: none">
</div>
<pre id="test">
</pre>
</body>
<vbox flex="1">
<button id="button1" label="hello"/>
<toolbarbutton id="button2" label="hello"/>
<toolbarbutton id="button3" type="checkbox" label="hello"/>
<html:style>
#button4 > .toolbarbutton-text::after,
#button5::after {
content: " (Ctrl+B)";
}
</html:style>
<toolbarbutton id="button4" label="hello"/>
<button id="button5" label="hello"/>
<toolbar mode="icons">
<toolbarbutton id="button6" label="hello"/>
</toolbar>
<button id="button7" type="menu" label="hello">
<menupopup>
<menuitem label="item"/>
</menupopup>
</button>
<button id="button8" label="hello" accesskey="z"/>
<button id="button9" label="hello" accesskey="e"/>
<toolbarbutton id="button10" label="" tooltiptext="Foo"/>
</vbox>
</hbox>
</window>