gecko/accessible/tests/mochitest/test_text_caret.html

98 lines
2.4 KiB
HTML

<html>
<head>
<title>Text accessible caret testing</title>
<link rel="stylesheet" type="text/css"
href="chrome://mochikit/content/tests/SimpleTest/test.css" />
<script type="application/javascript"
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript"
src="common.js"></script>
<script type="application/javascript"
src="events.js"></script>
<script type="application/javascript">
/**
* Checkers.
*/
function caretMovedChecker(aID, aOffset)
{
this.__proto__ = new invokerChecker(EVENT_TEXT_CARET_MOVED, aID);
this.check = function caretMovedChecker_check(aEvent)
{
is(aEvent.QueryInterface(nsIAccessibleCaretMoveEvent).caretOffset,
aOffset,
"Wrong caret offset for " + prettyName(aEvent.target));
}
}
/**
* Invokers.
*/
function setCaretOffsetInvoker(aID, aOffset)
{
this.target = getAccessible(aID, [nsIAccessibleText]);
this.invoke = function setCaretOffsetInvoker_invoke()
{
this.target.caretOffset = aOffset;
}
this.getID = function setCaretOffsetInvoker_getID()
{
return "nsIAccessibleText::caretOffset test";
}
this.eventSeq = [
new invokerChecker(EVENT_FOCUS, this.target),
new caretMovedChecker(this.target, aOffset)
];
}
/**
* Do tests.
*/
var gQueue = null;
// gA11yEventDumpID = "eventdump"; // debug stuff
function doTests()
{
// test caret move events and caret offsets
gQueue = new eventQueue();
gQueue.push(new setCaretOffsetInvoker("textbox", 1));
gQueue.push(new setCaretOffsetInvoker("link", 1));
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=524115"
title="HyperText accessible should get focus when the caret is positioned inside of it, text is changed or copied into clipboard by ATs">
Mozilla Bug 524115
</a>
<p id="display"></p>
<div id="content" style="display: none"></div>
<pre id="test">
</pre>
<input id="textbox" value="hello"/>
<a id="link" href="about:">about mozilla</a>
<div id="eventdump"></div>
</body>
</html>