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

118 lines
3.1 KiB
HTML
Raw Normal View History

<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="chrome://mochikit/content/a11y/accessible/common.js"></script>
<script type="application/javascript"
src="chrome://mochikit/content/a11y/accessible/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);
}
}
/**
* 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.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>
<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="eventdump"></div>
</body>
</html>