2010-02-21 00:50:50 +00:00
|
|
|
<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"
|
2010-09-01 22:09:56 +00:00
|
|
|
src="common.js"></script>
|
2010-02-21 00:50:50 +00:00
|
|
|
<script type="application/javascript"
|
2010-09-01 22:09:56 +00:00
|
|
|
src="events.js"></script>
|
2010-02-21 00:50:50 +00:00
|
|
|
|
|
|
|
<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.
|
|
|
|
*/
|
2011-10-16 03:38:19 +00:00
|
|
|
function setCaretOffsetInvoker(aID, aOffset, aFocusableContainerID)
|
2010-02-21 00:50:50 +00:00
|
|
|
{
|
|
|
|
this.target = getAccessible(aID, [nsIAccessibleText]);
|
2011-10-16 03:38:19 +00:00
|
|
|
this.focus = aFocusableContainerID ?
|
|
|
|
getAccessible(aFocusableContainerID) : this.target;
|
2010-02-21 00:50:50 +00:00
|
|
|
|
|
|
|
this.invoke = function setCaretOffsetInvoker_invoke()
|
|
|
|
{
|
|
|
|
this.target.caretOffset = aOffset;
|
|
|
|
}
|
|
|
|
|
|
|
|
this.getID = function setCaretOffsetInvoker_getID()
|
|
|
|
{
|
2011-10-16 03:38:19 +00:00
|
|
|
return "Set caretOffset on " + prettyName(aID) + " at " + aOffset;
|
2010-02-21 00:50:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
this.eventSeq = [
|
2011-10-16 03:38:19 +00:00
|
|
|
new caretMovedChecker(this.target, aOffset),
|
|
|
|
new asyncInvokerChecker(EVENT_FOCUS, this.focus)
|
2010-02-21 00:50:50 +00:00
|
|
|
];
|
|
|
|
}
|
|
|
|
|
2011-10-16 03:38:19 +00:00
|
|
|
/**
|
|
|
|
* Turn on/off the caret browsing mode.
|
|
|
|
*/
|
|
|
|
function turnCaretBrowsing(aIsOn)
|
|
|
|
{
|
|
|
|
var prefs = Components.classes["@mozilla.org/preferences-service;1"].
|
|
|
|
getService(Components.interfaces.nsIPrefBranch);
|
|
|
|
prefs.setBoolPref("accessibility.browsewithcaret", aIsOn);
|
|
|
|
}
|
|
|
|
|
2010-02-21 00:50:50 +00:00
|
|
|
/**
|
|
|
|
* Do tests.
|
|
|
|
*/
|
|
|
|
var gQueue = null;
|
|
|
|
|
2011-10-16 03:38:19 +00:00
|
|
|
//gA11yEventDumpID = "eventdump"; // debug stuff
|
|
|
|
//gA11yEventDumpToConsole = true;
|
2010-02-21 00:50:50 +00:00
|
|
|
|
|
|
|
function doTests()
|
|
|
|
{
|
2011-10-16 03:38:19 +00:00
|
|
|
turnCaretBrowsing(true);
|
|
|
|
|
2010-02-21 00:50:50 +00:00
|
|
|
// test caret move events and caret offsets
|
|
|
|
gQueue = new eventQueue();
|
|
|
|
|
|
|
|
gQueue.push(new setCaretOffsetInvoker("textbox", 1));
|
|
|
|
gQueue.push(new setCaretOffsetInvoker("link", 1));
|
2011-10-16 03:38:19 +00:00
|
|
|
gQueue.push(new setCaretOffsetInvoker("heading", 1, document));
|
|
|
|
gQueue.onFinish = function()
|
|
|
|
{
|
|
|
|
turnCaretBrowsing(false);
|
|
|
|
}
|
2010-02-21 00:50:50 +00:00
|
|
|
|
|
|
|
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>
|
2011-10-16 03:38:19 +00:00
|
|
|
<a target="_blank"
|
|
|
|
href="https://bugzilla.mozilla.org/show_bug.cgi?id=546068"
|
|
|
|
title="Position is not being updated when atk_text_set_caret_offset is used">
|
|
|
|
Mozilla Bug 546068
|
|
|
|
</a>
|
2010-02-21 00:50:50 +00:00
|
|
|
<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>
|
2011-10-16 03:38:19 +00:00
|
|
|
<h5 id="heading">heading</h5>
|
2010-02-21 00:50:50 +00:00
|
|
|
|
|
|
|
<div id="eventdump"></div>
|
|
|
|
</body>
|
|
|
|
</html>
|