Bug 656225 - XUL listbox accessible tree doens't get updated, r=tbsaunde, bz

This commit is contained in:
Alexander Surkov 2012-03-27 16:29:51 +09:00
parent 74225dfdad
commit d7940989f5
5 changed files with 206 additions and 1 deletions

View File

@ -53,6 +53,7 @@ const ROLE_PROGRESSBAR = nsIAccessibleRole.ROLE_PROGRESSBAR;
const ROLE_PROPERTYPAGE = nsIAccessibleRole.ROLE_PROPERTYPAGE;
const ROLE_PUSHBUTTON = nsIAccessibleRole.ROLE_PUSHBUTTON;
const ROLE_RADIOBUTTON = nsIAccessibleRole.ROLE_RADIOBUTTON;
const ROLE_RICH_OPTION = nsIAccessibleRole.ROLE_RICH_OPTION;
const ROLE_ROW = nsIAccessibleRole.ROLE_ROW;
const ROLE_ROWHEADER = nsIAccessibleRole.ROLE_ROWHEADER;
const ROLE_SCROLLBAR = nsIAccessibleRole.ROLE_SCROLLBAR;

View File

@ -57,6 +57,7 @@ _TEST_FILES =\
test_imagemap.html \
test_list_editabledoc.html \
test_list.html \
test_listbox.xul \
test_menu.xul \
test_menubutton.xul \
test_recreation.html \

View File

@ -0,0 +1,180 @@
<?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="Accessible XUL listbox hierarchy 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="../events.js" />
<script type="application/javascript">
<![CDATA[
////////////////////////////////////////////////////////////////////////////
// Test
function insertListitem(aListboxID)
{
this.listboxNode = getNode(aListboxID);
this.listitemNode = document.createElement("listitem");
this.listitemNode.setAttribute("label", "item1");
this.eventSeq = [
new invokerChecker(EVENT_SHOW, this.listitemNode),
new invokerChecker(EVENT_REORDER, this.listboxNode)
];
this.invoke = function insertListitem_invoke()
{
this.listboxNode.insertBefore(this.listitemNode,
this.listboxNode.firstChild);
}
this.finalCheck = function insertListitem_finalCheck()
{
var tree =
{ LISTBOX: [
{
role: ROLE_RICH_OPTION,
name: "item1"
},
{
role: ROLE_RICH_OPTION,
name: "item2"
},
{
role: ROLE_RICH_OPTION,
name: "item3"
},
{
role: ROLE_RICH_OPTION,
name: "item4"
}
] };
testAccessibleTree(this.listboxNode, tree);
}
this.getID = function insertListitem_getID()
{
return "insert listitem ";
}
}
function removeListitem(aListboxID)
{
this.listboxNode = getNode(aListboxID);
this.listitemNode = null;
this.listitem;
function getListitem(aThisObj)
{
return aThisObj.listitem;
}
this.eventSeq = [
new invokerChecker(EVENT_HIDE, getListitem, this),
new invokerChecker(EVENT_REORDER, this.listboxNode)
];
this.invoke = function removeListitem_invoke()
{
this.listitemNode = this.listboxNode.firstChild;
this.listitem = getAccessible(this.listitemNode);
this.listboxNode.removeChild(this.listitemNode);
}
this.finalCheck = function removeListitem_finalCheck()
{
var tree =
{ LISTBOX: [
{
role: ROLE_RICH_OPTION,
name: "item2"
},
{
role: ROLE_RICH_OPTION,
name: "item3"
},
{
role: ROLE_RICH_OPTION,
name: "item4"
}
] };
testAccessibleTree(this.listboxNode, tree);
}
this.getID = function removeListitem_getID()
{
return "remove listitem ";
}
}
//gA11yEventDumpToConsole = true; // debug stuff
var gQueue = null;
function doTest()
{
var tree =
{ LISTBOX: [
{
role: ROLE_RICH_OPTION,
name: "item2"
},
{
role: ROLE_RICH_OPTION,
name: "item3"
},
{
role: ROLE_RICH_OPTION,
name: "item4"
}
] };
testAccessibleTree("listbox", tree);
gQueue = new eventQueue();
gQueue.push(new insertListitem("listbox"));
gQueue.push(new removeListitem("listbox"));
gQueue.invoke(); // Will call SimpleTest.finish()
}
SimpleTest.waitForExplicitFinish();
addA11yLoadEvent(doTest);
]]>
</script>
<hbox flex="1" style="overflow: auto;">
<body xmlns="http://www.w3.org/1999/xhtml">
<a target="_blank"
href="https://bugzilla.mozilla.org/show_bug.cgi?id=656225"
title="XUL listbox accessible tree doesn't get updated">
Mozilla Bug 656225
</a>
<br/>
<p id="display"></p>
<div id="content" style="display: none">
</div>
<pre id="test">
</pre>
</body>
<vbox flex="1">
<listbox id="listbox" rows="2">
<listitem label="item2"/>
<listitem label="item3"/>
<listitem label="item4"/>
</listbox>
</vbox>
</hbox>
</window>

View File

@ -10551,7 +10551,7 @@ nsCSSFrameConstructor::CreateListBoxContent(nsPresContext* aPresContext,
nsIFrame* newFrame = frameItems.FirstChild();
*aNewFrame = newFrame;
if (NS_SUCCEEDED(rv) && (nsnull != newFrame)) {
if (newFrame) {
// Notify the parent frame
if (aIsAppend)
rv = ((nsListBoxBodyFrame*)aParentFrame)->ListBoxAppendFrames(frameItems);
@ -10560,6 +10560,16 @@ nsCSSFrameConstructor::CreateListBoxContent(nsPresContext* aPresContext,
}
EndUpdate();
#ifdef ACCESSIBILITY
if (newFrame) {
nsAccessibilityService* accService = nsIPresShell::AccService();
if (accService) {
accService->ContentRangeInserted(mPresShell, aChild->GetParent(),
aChild, aChild->GetNextSibling());
}
}
#endif
}
return rv;

View File

@ -70,6 +70,10 @@
#include "nsChildIterator.h"
#include "nsRenderingContext.h"
#ifdef ACCESSIBILITY
#include "nsAccessibilityService.h"
#endif
/////////////// nsListScrollSmoother //////////////////
/* A mediator used to smooth out scrolling. It works by seeing if
@ -1515,6 +1519,15 @@ nsListBoxBodyFrame::RemoveChildFrame(nsBoxLayoutState &aState,
return;
}
#ifdef ACCESSIBILITY
nsAccessibilityService* accService = nsIPresShell::AccService();
if (accService) {
nsIContent* content = aFrame->GetContent();
accService->ContentRemoved(PresContext()->PresShell(), content->GetParent(),
content);
}
#endif
mFrames.RemoveFrame(aFrame);
if (mLayoutManager)
mLayoutManager->ChildrenRemoved(this, aState, aFrame);