Bug 560239 - no children of application accessible for open windows before accessibility was started, r=marcoz, davidb, sr=neil, a=dholbert

This commit is contained in:
Alexander Surkov 2010-04-23 12:46:37 +09:00
Родитель c5c2fd3be2
Коммит 6cd89897a1
4 изменённых файлов: 125 добавлений и 2 удалений

Просмотреть файл

@ -45,6 +45,9 @@
#include "nsAccessibilityService.h" #include "nsAccessibilityService.h"
#include "nsIComponentManager.h" #include "nsIComponentManager.h"
#include "nsIDOMDocument.h"
#include "nsIDOMWindow.h"
#include "nsIWindowMediator.h"
#include "nsServiceManagerUtils.h" #include "nsServiceManagerUtils.h"
nsApplicationAccessible::nsApplicationAccessible() : nsApplicationAccessible::nsApplicationAccessible() :
@ -258,8 +261,42 @@ nsApplicationAccessible::InvalidateChildren()
void void
nsApplicationAccessible::CacheChildren() nsApplicationAccessible::CacheChildren()
{ {
// Nothing to do. Children are keeped up to dated by Add/RemoveRootAccessible // CacheChildren is called only once for application accessible when its
// method calls. // children are requested because empty InvalidateChldren() prevents its
// repeated calls.
// Basicly children are kept updated by Add/RemoveRootAccessible method
// calls. However if there are open windows before accessibility was started
// then we need to make sure root accessibles for open windows are created so
// that all root accessible are stored in application accessible children
// array.
nsCOMPtr<nsIWindowMediator> windowMediator =
do_GetService(NS_WINDOWMEDIATOR_CONTRACTID);
nsCOMPtr<nsISimpleEnumerator> windowEnumerator;
nsresult rv = windowMediator->GetEnumerator(nsnull,
getter_AddRefs(windowEnumerator));
if (NS_FAILED(rv))
return;
PRBool hasMore = PR_FALSE;
windowEnumerator->HasMoreElements(&hasMore);
while (hasMore) {
nsCOMPtr<nsISupports> window;
windowEnumerator->GetNext(getter_AddRefs(window));
nsCOMPtr<nsIDOMWindow> DOMWindow = do_QueryInterface(window);
if (DOMWindow) {
nsCOMPtr<nsIDOMDocument> DOMDocument;
DOMWindow->GetDocument(getter_AddRefs(DOMDocument));
if (DOMDocument) {
nsCOMPtr<nsIAccessible> accessible;
GetAccService()->GetAccessibleFor(DOMDocument,
getter_AddRefs(accessible));
}
}
windowEnumerator->HasMoreElements(&hasMore);
}
} }
nsAccessible* nsAccessible*

Просмотреть файл

@ -46,6 +46,7 @@ include $(DEPTH)/config/autoconf.mk
include $(topsrcdir)/config/rules.mk include $(topsrcdir)/config/rules.mk
_TEST_FILES =\ _TEST_FILES =\
$(warning test_applicationacc.xul temporarily disabled) \
test_aria_globals.html \ test_aria_globals.html \
test_aria_imgmap.html \ test_aria_imgmap.html \
test_button.xul \ test_button.xul \
@ -70,6 +71,7 @@ _TEST_FILES =\
test_txtcntr.html \ test_txtcntr.html \
test_txtctrl.html \ test_txtctrl.html \
test_txtctrl.xul \ test_txtctrl.xul \
wnd.xul \
$(NULL) $(NULL)
libs:: $(_TEST_FILES) libs:: $(_TEST_FILES)

Просмотреть файл

@ -0,0 +1,76 @@
<?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 Application Accessible hierarchy tests">
<script type="application/javascript"
src="chrome://mochikit/content/MochiKit/packed.js" />
<script type="application/javascript"
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
<script type="application/javascript"
src="chrome://mochikit/content/a11y/accessible/common.js" />
<script type="application/javascript"
src="chrome://mochikit/content/a11y/accessible/role.js" />
<script type="application/javascript">
<![CDATA[
////////////////////////////////////////////////////////////////////////////
// Test
// Note: but 560239 can be tested if this test runs in standalone mode only.
var gURL = "chrome://mochikit/content/a11y/accessible/tree/wnd.xul"
var gWnd = window.openDialog(gURL, "wnd", "chrome,width=600,height=600");
function doTest()
{
// Application accessible should contain two root document accessibles,
// one is for browser window, another one is for open dialog window.
var accTree = {
role: ROLE_APP_ROOT,
children: [
{
role: ROLE_CHROME_WINDOW,
name: "Accessibility Chrome Test Harness - Minefield"
},
{
role: ROLE_CHROME_WINDOW,
name: "Empty Window"
}
]
};
testAccessibleTree(getApplicationAccessible(), accTree);
gWnd.close();
SimpleTest.finish()
}
SimpleTest.waitForExplicitFinish();
// We need to open dialog window before accessibility is started.
addLoadEvent(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=560239"
title="no children of application accessible for windows open before accessibility was started">
Mozilla Bug 560239
</a><br/>
<p id="display"></p>
<div id="content" style="display: none">
</div>
<pre id="test">
</pre>
</body>
</hbox>
</window>

Просмотреть файл

@ -0,0 +1,8 @@
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
title="Empty Window">
</window>