Source code

Revision control

Copy as Markdown

Other Tools

Test Info:

<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
type="text/css"?>
title="Context menu focus testing">
<script type="application/javascript"
src="../common.js" />
<script type="application/javascript"
src="../role.js" />
<script type="application/javascript"
src="../states.js" />
<script type="application/javascript"
src="../promisified-events.js" />
<script type="application/javascript">
//gA11yEventDumpID = "eventdump"; // debug stuff
//gA11yEventDumpToConsole = true; // debug stuff
let winLowerThanVista = navigator.platform.indexOf("Win") == 0;
if (winLowerThanVista) {
let version = Services.sysinfo.getProperty("version");
version = parseFloat(version);
winLowerThanVista = !(version >= 6.0);
}
async function doTests() {
// bug 746183 - Whole file times out on OS X
if (MAC || winLowerThanVista) {
todo(false, "Reenable on mac after fixing bug 746183!");
SimpleTest.finish();
return;
}
// Test focus events.
let focused = waitForEvent(EVENT_FOCUS, "button");
getNode("button").focus();
await focused;
let menuPopupStart = waitForEvent(EVENT_MENUPOPUP_START, "contextmenu");
let popupShown = new Promise(r =>
getNode("contextmenu").addEventListener("popupshown", r, { once: true })
);
synthesizeMouse(getNode("button"), 1, 1, {
button: 0,
type: "contextmenu",
});
await menuPopupStart;
await popupShown;
focused = waitForEvent(EVENT_FOCUS, "item1");
synthesizeKey("VK_DOWN", {});
await focused;
focused = waitForEvent(EVENT_FOCUS, "button");
synthesizeKey("VK_ESCAPE", {});
await focused;
menuPopupStart = waitForEvent(EVENT_MENUPOPUP_START, "contextmenu");
synthesizeMouse(getNode("button"), 1, 1, {
button: 0,
type: "contextmenu",
});
await menuPopupStart;
focused = waitForEvent(EVENT_FOCUS, "item1");
synthesizeKey("VK_DOWN", {});
await focused;
focused = waitForEvent(EVENT_FOCUS, "item2");
synthesizeKey("VK_DOWN", {});
await focused;
focused = waitForEvent(EVENT_FOCUS, "item2.1");
synthesizeKey("VK_RIGHT", {});
await focused;
if (WIN) {
todo(false, "synthEscapeKey for item2.1 and item2 disabled due to bug 691580");
} else {
focused = waitForEvent(EVENT_FOCUS, "item2");
synthesizeKey("VK_ESCAPE", {});
await focused;
focused = waitForEvent(EVENT_FOCUS, "button");
synthesizeKey("VK_ESCAPE", {});
await focused;
}
SimpleTest.finish();
}
SimpleTest.waitForExplicitFinish();
addA11yLoadEvent(doTests);
</script>
<hbox flex="1" style="overflow: auto;">
<a target="_blank"
title="Rework accessible focus handling">
Mozilla Bug 673958
</a>
<p id="display"></p>
<div id="content" style="display: none"></div>
<pre id="test">
</pre>
</body>
<vbox flex="1">
<button id="button" context="contextmenu" label="button"/>
<menupopup id="contextmenu">
<menuitem id="item1" label="item1"/>
<menu id="item2" label="item2">
<menupopup>
<menuitem id="item2.1" label="item2.1"/>
</menupopup>
</menu>
</menupopup>
<vbox id="eventdump"/>
</vbox>
</hbox>
</window>