gecko/accessible/tests/mochitest/test_textboxes.xul

251 lines
9.6 KiB
XML

<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
type="text/css"?>
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
title="nsIAccessible XUL textboxes chrome tests">
<script type="application/javascript"
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
<script type="application/javascript"
src="common.js" />
<script type="application/javascript"
src="role.js" />
<script type="application/javascript"
src="states.js" />
<script type="application/javascript"
src="testTextboxes.js" />
<script type="application/javascript">
<![CDATA[
function doTest()
{
//////////////////////////////////////////////////////////////////////////
// normal textbox without content and with no proper label
testThis("unlabelled_Textbox", // ID
null, // name
"", // value
"", // description
ROLE_ENTRY, // role
(STATE_FOCUSABLE), // state
(EXT_STATE_EDITABLE), // extState
(STATE_READONLY), // absentState
1, // numActions
"activate", // ActionName
"Activate"); // ActionDescription
//////////////////////////////////////////////////////////////////////////
// normal textbox without content and with a proper label
testThis("labelled_textbox", // ID
"Second textbox:", // name
"", // value
"", // description
ROLE_ENTRY, // role
(STATE_FOCUSABLE), // state
(EXT_STATE_EDITABLE), // extState
(STATE_READONLY), // absentState
1, // numActions
"activate", // ActionName
"Activate"); // ActionDescription
//////////////////////////////////////////////////////////////////////////
// normal textbox with content and with a proper label
testThis("prefilled_textbox", // ID
"Textbox with predefined value:", // name
"I have some text", // value
"", // description
ROLE_ENTRY, // role
(STATE_FOCUSABLE), // state
(EXT_STATE_EDITABLE), // extState
(STATE_READONLY), // absentState
1, // numActions
"activate", // ActionName
"Activate"); // ActionDescription
//////////////////////////////////////////////////////////////////////////
// password textbox with a proper label
testThis("password_textbox", // ID
"Enter some password here:", // name
"", // value
"", // description
ROLE_PASSWORD_TEXT, // role
(STATE_FOCUSABLE), // state
(EXT_STATE_EDITABLE), // extState
(STATE_READONLY), // absentState
1, // numActions
"activate", // ActionName
"Activate"); // ActionDescription
//////////////////////////////////////////////////////////////////////////
// textarea without content and label
testThis("unlabelled_Textarea", // ID
null, // name
"", // value
"", // description
ROLE_ENTRY, // role
(STATE_FOCUSABLE), // state
(EXT_STATE_EDITABLE | EXT_STATE_MULTI_LINE), // extState
(STATE_READONLY), // absentState
1, // numActions
"activate", // ActionName
"Activate"); // ActionDescription
//////////////////////////////////////////////////////////////////////////
// textarea without content and with proper label
testThis("labelled_textarea", // ID
"Labelled textarea:", // name
"", // value
"", // description
ROLE_ENTRY, // role
(STATE_FOCUSABLE), // state
(EXT_STATE_EDITABLE | EXT_STATE_MULTI_LINE), // extState
(STATE_READONLY), // absentState
1, // numActions
"activate", // ActionName
"Activate"); // ActionDescription
//////////////////////////////////////////////////////////////////////////
// textarea with content and with proper label
testThis("prefilled_textarea", // ID
"Pre-filled textarea:", // name
"I also have some text.", // value
"", // description
ROLE_ENTRY, // role
(STATE_FOCUSABLE), // state
(EXT_STATE_EDITABLE | EXT_STATE_MULTI_LINE), // extState
(STATE_READONLY), // absentState
1, // numActions
"activate", // ActionName
"Activate"); // ActionDescription
//////////////////////////////////////////////////////////////////////////
// readonly textbox with content and with proper label
testThis("readonly_textbox", // ID
"The following is a read-only textbox:", // name
"You cannot change me.", // value
"", // description
ROLE_ENTRY, // role
(STATE_FOCUSABLE | STATE_READONLY), // state
(0), // extState
(0), // absentState
1, // numActions
"activate", // ActionName
"Activate"); // ActionDescription
//////////////////////////////////////////////////////////////////////////
// readonly textarea with content and with proper label
testThis("readonly_textarea", // ID
"This textarea is readonly, too:", // name
"You cannot change me, either.", // value
"", // description
ROLE_ENTRY, // role
(STATE_FOCUSABLE | STATE_READONLY), // state
(EXT_STATE_MULTI_LINE), // extState
(0), // absentState
1, // numActions
"activate", // ActionName
"Activate"); // ActionDescription
//////////////////////////////////////////////////////////////////////////
// Search textbox without search button, searches as you type and filters
// a separate control.
testThis("search-box", // ID
"Search History:", // name
"", // value
"", // description
ROLE_ENTRY, // role
(STATE_FOCUSABLE), // state
(EXT_STATE_SUPPORTS_AUTOCOMPLETION), // extState
(0), // absentState
1, // numActions
"activate", // ActionName
"Activate"); // ActionDescription
//////////////////////////////////////////////////////////////////////////
// Search textbox with search button, does not support autoCompletion.
testThis("searchfield", // ID
"Search all add-ons", // name
"", // value
"", // description
ROLE_ENTRY, // role
(STATE_FOCUSABLE), // state
(0), // extState
(0), // absentState
1, // numActions
"activate", // ActionName
"Activate"); // ActionDescription
testStates("searchfield", 0, 0, 0, EXT_STATE_SUPPORTS_AUTOCOMPLETION);
SimpleTest.finish();
}
SimpleTest.waitForExplicitFinish();
addA11yLoadEvent(doTest);
]]>
</script>
<body xmlns="http://www.w3.org/1999/xhtml">
<a target="_blank"
href="https://bugzilla.mozilla.org/show_bug.cgi?id=442648">
Mozilla Bug 442648
</a>
<p id="display"></p>
<div id="content" style="display: none"></div>
<pre id="test">
</pre>
</body>
<vbox>
<hbox>
<label value="Text before input without labelling it:"/>
<textbox id="unlabelled_Textbox" size="50"/>
</hbox>
<hbox>
<label control="labelled_textbox">Second textbox:</label>
<textbox id="labelled_textbox"/>
</hbox>
<hbox>
<label control="prefilled_textbox">Textbox with predefined value:</label>
<textbox id="prefilled_textbox" value="I have some text" size="80"/>
</hbox>
<hbox>
<label control="password_textbox">Enter some password here:</label>
<textbox type="password" id="password_textbox"/>
</hbox>
<vbox>
<label value="Textarea without label:"/>
<textbox multiline="true" id="unlabelled_Textarea" cols="80" rows="5"/>
</vbox>
<vbox>
<label control="labelled_textarea">Labelled textarea:</label>
<textbox multiline="true" id="labelled_textarea" cols="80" rows="5"/>
</vbox>
<vbox>
<label control="prefilled_textarea">Pre-filled textarea:</label>
<textbox multiline="true" id="prefilled_textarea" cols="80" rows="5"
value="I also have some text."/>
</vbox>
<hbox>
<label control="readonly_textbox">The following is a read-only textbox:</label>
<textbox readonly="true" id="readonly_textbox"
value="You cannot change me."/>
</hbox>
<vbox>
<label control="readonly_textarea">This textarea is readonly, too:</label>
<textbox multiline="true" id="readonly_textarea" readonly="true" cols="80"
rows="5" value="You cannot change me, either."/>
</vbox>
<hbox>
<label value="Search History:" accesskey="S"
control="search-box"/>
<textbox id="search-box" flex="1" type="search"
results="historyTree"/>
</hbox>
<textbox id="searchfield" placeholder="Search all add-ons"
type="search" searchbutton="true"/>
</vbox>
</window>