gecko/accessible/tests/mochitest/events/test_focus.html

154 lines
4.2 KiB
HTML

<html>
<head>
<title>Accessible focus testing</title>
<link rel="stylesheet" type="text/css"
href="chrome://mochikit/content/tests/SimpleTest/test.css" />
<script type="application/javascript"
src="chrome://mochikit/content/MochiKit/packed.js"></script>
<script type="application/javascript"
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript"
src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
<script type="application/javascript"
src="../common.js"></script>
<script type="application/javascript"
src="../events.js"></script>
<script type="application/javascript">
function openCloseDialog(aID)
{
this.DOMNode = getNode(aID);
this.invoke = function openCloseDialog_invoke()
{
var wnd = window.open("focus.html");
wnd.close();
}
this.getID = function openCloseDialog_getID()
{
return "Open close dialog on " + prettyName(aID);
}
}
function focusElmWhileSubdocIsFocused(aID)
{
this.DOMNode = getNode(aID);
this.invoke = function focusElmWhileSubdocIsFocused_invoke()
{
this.DOMNode.focus();
}
this.eventSeq = [
new invokerChecker(EVENT_FOCUS, this.DOMNode)
];
this.unexpectedEventSeq = [
new invokerChecker(EVENT_FOCUS, this.DOMNode.ownerDocument)
];
this.getID = function focusElmWhileSubdocIsFocused_getID()
{
return "Focus element while subdocument is focused " + prettyName(aID);
}
}
function showNFocusAlertDialog()
{
this.ID = "alertdialog";
this.DOMNode = getNode(this.ID);
this.invoke = function showNFocusAlertDialog_invoke()
{
document.getElementById(this.ID).style.display = 'block';
document.getElementById(this.ID).focus();
}
this.eventSeq = [
new invokerChecker(EVENT_SHOW, this.DOMNode),
new invokerChecker(EVENT_FOCUS, this.DOMNode)
];
this.getID = function showNFocusAlertDialog_getID()
{
return "Show and focus alert dialog " + prettyName(this.ID);
}
}
/**
* Do tests.
*/
//gA11yEventDumpID = "eventdump"; // debug stuff
var gQueue = null;
function doTests()
{
gQueue = new eventQueue(EVENT_FOCUS);
gQueue.push(new synthFocus("editablearea"));
gQueue.push(new synthFocus("textbox"));
gQueue.push(new synthFocus("button"));
gQueue.push(new openCloseDialog("button"));
var frameNode = getNode("editabledoc");
gQueue.push(new synthFocusOnFrame(frameNode));
gQueue.push(new openCloseDialog(frameNode.contentDocument));
gQueue.push(new focusElmWhileSubdocIsFocused("button"));
gQueue.push(new showNFocusAlertDialog());
gQueue.invoke(); // Will call SimpleTest.finish();
}
SimpleTest.waitForExplicitFinish();
addA11yLoadEvent(doTests);
</script>
</head>
<body>
<a target="_blank"
href="https://bugzilla.mozilla.org/show_bug.cgi?id=551679"
title="focus is not fired for focused document when switching between windows">
Mozilla Bug 551679
</a>
<a target="_blank"
href="https://bugzilla.mozilla.org/show_bug.cgi?id=352220"
title=" Inconsistent focus events when returning to a document frame">
Mozilla Bug 352220
</a>
<a target="_blank"
href="https://bugzilla.mozilla.org/show_bug.cgi?id=580464"
title="Accessible focus incorrect after JS focus() but correct after switching apps or using menu bar">
Mozilla Bug 580464
</a>
<p id="display"></p>
<div id="content" style="display: none"></div>
<pre id="test">
</pre>
<div id="editablearea" contentEditable="true">editable area</div>
<input id="textbox">
<button id="button">button</button>
<iframe id="editabledoc" src="focus.html"></iframe>
<div id="alertdialog" style="display: none" tabindex="-1" role="alertdialog" aria-labelledby="title2" aria-describedby="desc2">
<div id="title2">Blah blah</div>
<div id="desc2">Woof woof woof.</div>
<button>Close</button>
</div>
<div id="eventdump"></div>
</body>
</html>