gecko-dev/accessible/tests/mochitest/tree/test_tabbrowser.xul

266 lines
7.5 KiB
XML

<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
<!-- Firefox tabbrowser -->
<?xml-stylesheet href="chrome://browser/content/browser.css"
type="text/css"?>
<!-- SeaMonkey tabbrowser -->
<?xml-stylesheet href="chrome://navigator/content/navigator.css"
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 tabbrowser 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" src="chrome://global/content/globalOverlay.js"/>
<script type="application/javascript">
<![CDATA[
////////////////////////////////////////////////////////////////////////////
// Test
const Ci = Components.interfaces;
// Hack to make xul:tabbrowser work.
Components.utils.import("resource://gre/modules/Services.jsm");
var handleDroppedLink = null;
var XULBrowserWindow = {
isBusy: false,
setOverLink: function (link, b) {}
};
var gFindBar = {
hidden: true
};
function doTest()
{
var tabBrowser = document.getElementById("tabbrowser");
// Load documents into tabs and wait for reorder events caused by these
// documents load before we start the test.
var docURIs = ["about:", "about:mozilla"];
var handler = {
handleEvent: function handleEvent(aEvent) {
var target = aEvent.accessible;
if (target.role == ROLE_INTERNAL_FRAME &&
target.parent.parent == getAccessible(this.tabBrowser.mTabBox.tabpanels)) {
this.reorderCnt++;
}
if (this.reorderCnt == docURIs.length) {
unregisterA11yEventListener(EVENT_REORDER, this);
testAccTree();
}
},
tabBrowser: tabBrowser,
reorderCnt: 0
};
registerA11yEventListener(EVENT_REORDER, handler);
// Test XUL and HTML documents.
tabBrowser.loadTabs(docURIs, false, true);
}
function testAccTree()
{
var tabBrowser = document.getElementById("tabbrowser");
////////////////////
// Tab bar
////////////////////
var tabsAccTree = {
// xul:tabs
role: ROLE_PAGETABLIST,
children: [
// Children depend on application (UI): see below.
]
};
// SeaMonkey and Firefox tabbrowser UIs differ.
if ("restoreTab" in tabBrowser) {
SimpleTest.ok(true, "Testing SeaMonkey tabbrowser UI.");
tabsAccTree.children.splice(0, 0,
{
// xul:toolbarbutton ("Open a new tab")
role: ROLE_PUSHBUTTON,
children: []
},
{
// xul:tab ("about:")
role: ROLE_PAGETAB,
children: []
},
{
// tab ("about:mozilla")
role: ROLE_PAGETAB,
children: []
},
{
// xul:toolbarbutton ("List all tabs")
role: ROLE_PUSHBUTTON,
children: [
{
// xul:menupopup
role: ROLE_MENUPOPUP,
children: []
}
]
},
{
// xul:toolbarbutton ("Close current tab")
role: ROLE_PUSHBUTTON,
children: []
}
);
} else {
SimpleTest.ok(true, "Testing Firefox tabbrowser UI.");
// NB: The (3) buttons are not visible, unless manually hovered,
// probably due to size reduction in this test.
tabsAccTree.children.splice(0, 0,
{
// xul:tab ("about:")
role: ROLE_PAGETAB,
children: [
{
// xul:toolbarbutton ("Close Tab")
role: ROLE_PUSHBUTTON,
children: []
}
]
},
{
// tab ("about:mozilla")
role: ROLE_PAGETAB,
children: [
{
// xul:toolbarbutton ("Close Tab")
role: ROLE_PUSHBUTTON,
children: []
}
]
},
{
// xul:toolbarbutton ("Open a new tab")
role: ROLE_PUSHBUTTON,
children: []
}
// "List all tabs" dropdown
// XXX: This child(?) is not present in this test.
// I'm not sure why (though probably expected).
);
}
testAccessibleTree(tabBrowser.tabContainer, tabsAccTree);
////////////////////
// Tab contents
////////////////////
var tabboxAccTree = {
// xul:tabpanels
role: ROLE_PANE,
children: [
{
// xul:notificationbox
role: ROLE_PROPERTYPAGE,
children: [
{
// xul:browser
role: ROLE_INTERNAL_FRAME,
children: [
{
// #document ("about:")
role: ROLE_DOCUMENT
// children: [ ... ] // Ignore document content.
}
]
}
]
},
{
// notificationbox
role: ROLE_PROPERTYPAGE,
children: [
{
// browser
role: ROLE_INTERNAL_FRAME,
children: [
{
// #document ("about:mozilla")
role: ROLE_DOCUMENT
// children: [ ... ] // Ignore document content.
}
]
}
]
}
]
};
testAccessibleTree(tabBrowser.mTabBox.tabpanels, tabboxAccTree);
SimpleTest.finish();
}
SimpleTest.waitForExplicitFinish();
addA11yLoadEvent(doTest);
]]>
</script>
<vbox 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/>
<a target="_blank"
href="https://bugzilla.mozilla.org/show_bug.cgi?id=552944"
title="No relationship between tabs and associated property page in new tabbrowser construct">
Mozilla Bug 552944
</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>
<tabs id="tabbrowser-tabs" class="tabbrowser-tabs"
tabbrowser="tabbrowser"
setfocus="false">
<tab class="tabbrowser-tab" selected="true" fadein="true"/>
</tabs>
<tabbrowser id="tabbrowser"
type="content-primary"
tabcontainer="tabbrowser-tabs"
flex="1"/>
<toolbar id="addon-bar"/>
</vbox>
</window>