Bug 540389 - WARNING: Bad accessible tree! [tabbrowser tab], r=davidb, marcoz, mconnor

This commit is contained in:
Alexander Surkov 2010-01-19 12:35:08 +08:00
parent 0104108380
commit b83702675c
8 changed files with 281 additions and 20 deletions

View file

@ -44,17 +44,19 @@
#include "nsIDOMXULSelectCntrlEl.h"
#include "nsIDOMXULSelectCntrlItemEl.h"
/**
* XUL Tab
*/
////////////////////////////////////////////////////////////////////////////////
// nsXULTabAccessible
////////////////////////////////////////////////////////////////////////////////
/** Constructor */
nsXULTabAccessible::nsXULTabAccessible(nsIDOMNode* aNode, nsIWeakReference* aShell):
nsLeafAccessible(aNode, aShell)
{
nsXULTabAccessible::
nsXULTabAccessible(nsIDOMNode* aNode, nsIWeakReference* aShell) :
nsAccessibleWrap(aNode, aShell)
{
}
/** Only one action available */
////////////////////////////////////////////////////////////////////////////////
// nsXULTabAccessible: nsIAccessible
NS_IMETHODIMP nsXULTabAccessible::GetNumActions(PRUint8 *_retval)
{
*_retval = 1;
@ -86,7 +88,9 @@ NS_IMETHODIMP nsXULTabAccessible::DoAction(PRUint8 index)
return NS_ERROR_INVALID_ARG;
}
/** We are a tab */
////////////////////////////////////////////////////////////////////////////////
// nsXULTabAccessible: nsAccessible
nsresult
nsXULTabAccessible::GetRoleInternal(PRUint32 *aRole)
{
@ -94,14 +98,13 @@ nsXULTabAccessible::GetRoleInternal(PRUint32 *aRole)
return NS_OK;
}
/**
* Possible states: focused, focusable, unavailable(disabled), offscreen
*/
nsresult
nsXULTabAccessible::GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState)
{
// Possible states: focused, focusable, unavailable(disabled), offscreen.
// get focus and disable status from base class
nsresult rv = nsLeafAccessible::GetStateInternal(aState, aExtraState);
nsresult rv = nsAccessibleWrap::GetStateInternal(aState, aExtraState);
NS_ENSURE_A11Y_SUCCESS(rv, rv);
// In the past, tabs have been focusable in classic theme
@ -129,11 +132,12 @@ nsXULTabAccessible::GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState)
return NS_OK;
}
// nsIAccessible
NS_IMETHODIMP
nsXULTabAccessible::GetRelationByType(PRUint32 aRelationType,
nsIAccessibleRelation **aRelation)
{
nsresult rv = nsLeafAccessible::GetRelationByType(aRelationType,
nsresult rv = nsAccessibleWrap::GetRelationByType(aRelationType,
aRelation);
NS_ENSURE_SUCCESS(rv, rv);

View file

@ -46,7 +46,7 @@
/**
* An individual tab, xul:tab element
*/
class nsXULTabAccessible : public nsLeafAccessible
class nsXULTabAccessible : public nsAccessibleWrap
{
public:
enum { eAction_Switch = 0 };

View file

@ -37,10 +37,14 @@ const ROLE_NOTHING = nsIAccessibleRole.ROLE_NOTHING;
const ROLE_OPTION = nsIAccessibleRole.ROLE_OPTION;
const ROLE_OUTLINE = nsIAccessibleRole.ROLE_OUTLINE;
const ROLE_OUTLINEITEM = nsIAccessibleRole.ROLE_OUTLINEITEM;
const ROLE_PAGETAB = nsIAccessibleRole.ROLE_PAGETAB;
const ROLE_PAGETABLIST = nsIAccessibleRole.ROLE_PAGETABLIST;
const ROLE_PANE = nsIAccessibleRole.ROLE_PANE;
const ROLE_PARAGRAPH = nsIAccessibleRole.ROLE_PARAGRAPH;
const ROLE_PARENT_MENUITEM = nsIAccessibleRole.ROLE_PARENT_MENUITEM;
const ROLE_PASSWORD_TEXT = nsIAccessibleRole.ROLE_PASSWORD_TEXT;
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_ROW = nsIAccessibleRole.ROLE_ROW;
@ -54,6 +58,7 @@ const ROLE_TABLE = nsIAccessibleRole.ROLE_TABLE;
const ROLE_TEXT_CONTAINER = nsIAccessibleRole.ROLE_TEXT_CONTAINER;
const ROLE_TEXT_LEAF = nsIAccessibleRole.ROLE_TEXT_LEAF;
const ROLE_TOGGLE_BUTTON = nsIAccessibleRole.ROLE_TOGGLE_BUTTON;
const ROLE_TOOLTIP = nsIAccessibleRole.ROLE_TOOLTIP;
const ROLE_TREE_TABLE = nsIAccessibleRole.ROLE_TREE_TABLE;
const ROLE_WHITESPACE = nsIAccessibleRole.ROLE_WHITESPACE;

View file

@ -60,6 +60,8 @@ _TEST_FILES =\
test_media.html \
test_menu.xul \
test_select.html \
test_tabbox.xul \
test_tabbrowser.xul \
test_table.html \
test_tree.xul \
test_txtcntr.html \

View file

@ -0,0 +1,94 @@
<?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 tabbox 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
function doTest()
{
//////////////////////////////////////////////////////////////////////////
// tabbox
var accTree = {
role: ROLE_PANE,
children: [
{
role: ROLE_PAGETABLIST,
children: [
{
role: ROLE_PAGETAB,
children: []
},
{
role: ROLE_PAGETAB,
children: []
}
]
},
{
role: ROLE_PROPERTYPAGE,
children: []
},
{
role: ROLE_PROPERTYPAGE,
children: []
}
]
};
testAccessibleTree("tabbox", accTree);
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=540389"
title=" WARNING: Bad accessible tree!: [tabbrowser tab] ">
Mozilla Bug 540389
</a><br/>
<p id="display"></p>
<div id="content" style="display: none">
</div>
<pre id="test">
</pre>
</body>
<vbox flex="1">
<tabbox id="tabbox">
<tabs>
<tab label="tab1"/>
<tab label="tab2"/>
</tabs>
<tabpanels>
<tabpanel/>
<tabpanel/>
</tabpanels>
</tabbox>
</vbox>
</hbox>
</window>

View file

@ -0,0 +1,144 @@
<?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="Accessible XUL tabbrowser 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
const Ci = Components.interfaces;
// Hack to make xul:tabbrowser work.
var XULBrowserWindow = {
isBusy: false,
setOverLink: function (link, b) {
}
};
var gFindBar = {
hidden: true
};
function doTest()
{
var tabBrowser = document.getElementById("tabbrowser");
var progressListener =
{
onStateChange: function onStateChange(aWebProgress,
aRequest,
aStateFlags,
aStatus)
{
if (aStateFlags & Ci.nsIWebProgressListener.STATE_STOP)
testAccTree();
}
};
tabBrowser.addProgressListener(progressListener,
Ci.nsIWebProgress.NOTIFY_STATE_WINDOW);
tabBrowser.loadTabs(["about:", "about:mozilla"], false, true);
}
function testAccTree()
{
var accTree = {
role: ROLE_PANE,
children: [
{
role: ROLE_TOOLTIP
},
{
role: ROLE_MENUPOPUP
},
{
role: ROLE_PAGETABLIST,
children: [
{
role: ROLE_PAGETAB,
children: [
{
role: ROLE_PUSHBUTTON
}
]
},
{
role: ROLE_PAGETAB,
children: [
{
role: ROLE_PUSHBUTTON
}
]
},
{
role: ROLE_PUSHBUTTON
},
{
role: ROLE_PUSHBUTTON
}
]
},
{
role: ROLE_PROPERTYPAGE
},
{
role: ROLE_PROPERTYPAGE
}
]
};
testAccessibleTree(getNode("tabbrowser").mTabBox, accTree);
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=540389"
title=" WARNING: Bad accessible tree!: [tabbrowser tab] ">
Mozilla Bug 540389
</a><br/>
<p id="display"></p>
<div id="content" style="display: none">
</div>
<pre id="test">
</pre>
</body>
<!-- Hack to make xul:tabbrowser work -->
<menubar>
<menu label="menu">
<menupopup>
<menuitem label="close window hook" id="menu_closeWindow"/>
<menuitem label="close hook" id="menu_close"/>
</menupopup>
</menu>
</menubar>
<tabbrowser type="content-primary" flex="1" id="tabbrowser"/>
</hbox>
</window>

View file

@ -3240,9 +3240,16 @@
<binding id="tabbrowser-tab" display="xul:hbox"
extends="chrome://global/content/bindings/tabbox.xml#tab">
<content closetabtext="&closeTab.label;">
<xul:image xbl:inherits="validate,src=image" class="tab-icon-image"/>
<xul:label flex="1" xbl:inherits="value=label,crop,accesskey" class="tab-text"/>
<xul:toolbarbutton anonid="close-button" tabindex="-1" class="tab-close-button"/>
<xul:image xbl:inherits="validate,src=image"
class="tab-icon-image"
role="presentation"/>
<xul:label flex="1"
xbl:inherits="value=label,crop,accesskey"
class="tab-text"
role="presentation"/>
<xul:toolbarbutton anonid="close-button"
tabindex="-1"
class="tab-close-button"/>
</content>
<implementation>

View file

@ -607,8 +607,13 @@
<content>
<xul:hbox class="tab-middle box-inherit" xbl:inherits="align,dir,pack,orient,selected" flex="1">
<xul:image class="tab-icon" xbl:inherits="validate,src=image"/>
<xul:label class="tab-text" xbl:inherits="value=label,accesskey,crop,disabled" flex="1"/>
<xul:image class="tab-icon"
xbl:inherits="validate,src=image"
role="presentation"/>
<xul:label class="tab-text"
xbl:inherits="value=label,accesskey,crop,disabled"
flex="1"
role="presentation"/>
</xul:hbox>
</content>