gecko/accessible/tests/mochitest/test_nsIAccessible_comboboxes.xul
Alexander Surkov f77c4d89e7 Bug 473765 - Intermittent test failure in bug 469985 test_events_mutation.html, r=davidb, marcoz
--HG--
rename : accessible/tests/mochitest/common.js => accessible/tests/mochitest/events.js
2009-01-25 12:42:21 +08:00

113 lines
3.5 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"?>
<?xml-stylesheet href="chrome://browser/content/browser.css"
type="text/css"?>
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
title="nsIAccessible interface for xul:menulist test.">
<script type="application/javascript"
src="chrome://mochikit/content/MochiKit/packed.js"></script>
<script type="application/javascript"
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
<script type="application/javascript"
src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js" />
<script type="application/javascript"
src="chrome://mochikit/content/a11y/accessible/common.js" />
<script type="application/javascript"
src="chrome://mochikit/content/a11y/accessible/events.js" />
<script type="application/javascript">
<![CDATA[
function openHideCombobox(aComboboxNodeOrID, aIsOpen)
{
this.invoke = function invoke()
{
synthesizeMouse(this.DOMNode, 5, 5, {});
}
this.check = function check(aEvent)
{
aEvent.QueryInterface(nsIAccessibleStateChangeEvent);
var id = this.getID();
is(aEvent.state, nsIAccessibleStates.STATE_EXPANDED,
"Wrong state change event is handled in test '" + id + "'.");
is(aEvent.isEnabled(), this.mIsOpen,
"Wrong value of state expanded in test '" + id + "'.");
}
this.getID = function getID()
{
if (this.mIsOpen)
return this.DOMNodeOrID + " open combobox";
return this.DOMNodeOrID + " close combobox";
}
this.DOMNodeOrID = aComboboxNodeOrID;
this.DOMNode = getNode(aComboboxNodeOrID);
this.mIsOpen = aIsOpen;
}
var gQueue = null;
function doTest()
{
gQueue = new eventQueue(nsIAccessibleEvent.EVENT_STATE_CHANGE);
var ID = "menulist";
gQueue.push(new openHideCombobox(ID, true));
gQueue.push(new openHideCombobox(ID, false));
// XXX: searchbar doesn't fire state change events because accessible
// parent of combobox_list accessible is pushbutton accessible.
//var searchbar = document.getElementById("searchbar");
//gQueue.push(new openHideCombobox(searchbar, true));
//gQueue.push(new openHideCombobox(searchbar, false));
gQueue.invoke(); // Will call SimpleTest.finish();
}
// This is the hack needed for searchbar work outside of browser.
function getBrowser()
{
return {
mCurrentBrowser: { engines: new Array() }
};
}
SimpleTest.waitForExplicitFinish();
addA11yLoadEvent(doTest);
]]>
</script>
<hbox style="overflow: auto;" flex="1">
<body xmlns="http://www.w3.org/1999/xhtml">
<a target="_blank"
href="https://bugzilla.mozilla.org/show_bug.cgi?id=467057"
title="xul menulist doesn't fire expand/collapse state change events">
Mozilla Bug 467057
</a>
<p id="display"></p>
<div id="content" style="display: none">
</div>
<pre id="test">
</pre>
</body>
<vbox flex="1">
<menulist id="menulist">
<menupopup>
<menuitem label="item1"/>
<menuitem label="item2"/>
<menuitem label="item3"/>
</menupopup>
</menulist>
<searchbar id="searchbar"/>
</vbox>
</hbox>
</window>