2008-09-16 07:38:48 -07:00
|
|
|
<html>
|
|
|
|
|
|
|
|
<head>
|
|
|
|
<title>Accessible caret move events 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>
|
2009-01-24 20:42:21 -08:00
|
|
|
<script type="application/javascript"
|
|
|
|
src="chrome://mochikit/content/a11y/accessible/events.js"></script>
|
2008-09-16 07:38:48 -07:00
|
|
|
|
|
|
|
<script type="application/javascript">
|
2008-12-16 02:14:20 -08:00
|
|
|
/**
|
2009-10-06 00:50:47 -07:00
|
|
|
* Generic checker.
|
2008-12-16 02:14:20 -08:00
|
|
|
*/
|
2009-10-06 00:50:47 -07:00
|
|
|
function checker(aCaretOffset)
|
2008-09-16 07:38:48 -07:00
|
|
|
{
|
2009-10-06 00:50:47 -07:00
|
|
|
this.check = function checker_check(aEvent)
|
2008-09-16 07:38:48 -07:00
|
|
|
{
|
2008-12-16 02:14:20 -08:00
|
|
|
is(aEvent.QueryInterface(nsIAccessibleCaretMoveEvent).caretOffset,
|
2009-10-06 00:50:47 -07:00
|
|
|
aCaretOffset,
|
|
|
|
"Wrong caret offset for " + prettyName(aEvent.target));
|
2008-09-16 07:38:48 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-12-16 02:14:20 -08:00
|
|
|
/**
|
2009-10-06 00:50:47 -07:00
|
|
|
* Click checker.
|
2008-12-16 02:14:20 -08:00
|
|
|
*/
|
2009-10-06 00:50:47 -07:00
|
|
|
function clickChecker(aCaretOffset, aExtraNodeOrID, aExtraCaretOffset)
|
2008-09-16 07:38:48 -07:00
|
|
|
{
|
2009-10-06 00:50:47 -07:00
|
|
|
this.__proto__ = new checker(aCaretOffset);
|
2008-12-16 02:14:20 -08:00
|
|
|
|
|
|
|
this.extraNode = getNode(aExtraNodeOrID);
|
|
|
|
|
2009-10-06 00:50:47 -07:00
|
|
|
this.check = function clickChecker_check(aEvent)
|
2008-09-16 07:38:48 -07:00
|
|
|
{
|
2008-12-16 02:14:20 -08:00
|
|
|
this.__proto__.check(aEvent);
|
|
|
|
|
|
|
|
if (this.extraNode) {
|
|
|
|
var acc = getAccessible(this.extraNode, [nsIAccessibleText]);
|
2009-10-06 00:50:47 -07:00
|
|
|
is(acc.caretOffset, aExtraCaretOffset,
|
2008-12-16 02:14:20 -08:00
|
|
|
"Wrong caret offset for " + aExtraNodeOrID);
|
|
|
|
}
|
2008-09-16 07:38:48 -07:00
|
|
|
}
|
2008-12-16 02:14:20 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Do tests.
|
|
|
|
*/
|
|
|
|
var gQueue = null;
|
2008-09-16 07:38:48 -07:00
|
|
|
|
2009-09-09 02:03:14 -07:00
|
|
|
// gA11yEventDumpID = "eventdump"; // debug stuff
|
|
|
|
|
2008-12-16 02:14:20 -08:00
|
|
|
function testCaretOffset(aAccOrElmOrID, aCaretOffset)
|
2008-09-16 07:38:48 -07:00
|
|
|
{
|
2008-12-16 02:14:20 -08:00
|
|
|
var acc = getAccessible(aAccOrElmOrID, [nsIAccessibleText]);
|
|
|
|
is(acc.caretOffset, aCaretOffset,
|
|
|
|
"Wrong caret offset for " + aAccOrElmOrID);
|
2008-09-16 07:38:48 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
function doTests()
|
|
|
|
{
|
2009-09-23 09:21:38 -07:00
|
|
|
todo(false, "enable commented tests Bug 510128 is fixed");
|
|
|
|
// test no focused accessibles
|
|
|
|
//testCaretOffset("textbox", -1);
|
|
|
|
//testCaretOffset("textarea", -1);
|
|
|
|
testCaretOffset("p", -1);
|
2008-12-16 02:14:20 -08:00
|
|
|
|
|
|
|
// test caret move events and caret offsets
|
2010-01-20 03:16:32 -08:00
|
|
|
gQueue = new eventQueue(EVENT_TEXT_CARET_MOVED);
|
2008-12-16 02:14:20 -08:00
|
|
|
|
|
|
|
var id = "textbox";
|
2009-10-06 00:50:47 -07:00
|
|
|
gQueue.push(new synthFocus(id, new checker(5)));
|
|
|
|
gQueue.push(new synthSelectAll(id, new checker(5)));
|
|
|
|
gQueue.push(new synthClick(id, new checker(0)));
|
|
|
|
gQueue.push(new synthRightKey(id, new checker(1)));
|
2008-09-16 07:38:48 -07:00
|
|
|
|
2008-12-16 02:14:20 -08:00
|
|
|
id = "textarea";
|
2009-10-06 00:50:47 -07:00
|
|
|
gQueue.push(new synthClick(id, new checker(0)));
|
|
|
|
gQueue.push(new synthRightKey(id, new checker(1)));
|
|
|
|
gQueue.push(new synthDownKey(id, new checker(12)));
|
2008-09-16 07:38:48 -07:00
|
|
|
|
2008-12-16 02:14:20 -08:00
|
|
|
id = "p";
|
2009-10-06 00:50:47 -07:00
|
|
|
gQueue.push(new synthClick(id, new checker(0)));
|
|
|
|
gQueue.push(new synthRightKey(id, new checker(1)));
|
|
|
|
gQueue.push(new synthDownKey(id, new checker(6)));
|
2008-09-16 07:38:48 -07:00
|
|
|
|
2009-10-06 00:50:47 -07:00
|
|
|
gQueue.push(new synthClick("p1_in_div",
|
|
|
|
new clickChecker(0, "p2_in_div", -1)));
|
2008-09-16 07:38:48 -07:00
|
|
|
|
2009-10-06 00:50:47 -07:00
|
|
|
gQueue.push(new synthShiftTab("p", new checker(0)));
|
|
|
|
gQueue.push(new synthShiftTab("textarea", new checker(12)));
|
|
|
|
gQueue.push(new synthTab("p", new checker(0)));
|
2008-09-16 07:38:48 -07:00
|
|
|
|
2008-12-16 02:14:20 -08:00
|
|
|
gQueue.invoke(); // Will call SimpleTest.finish();
|
2008-09-16 07:38:48 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
SimpleTest.waitForExplicitFinish();
|
2009-09-23 07:21:47 -07:00
|
|
|
addA11yLoadEvent(doTests);
|
2008-09-16 07:38:48 -07:00
|
|
|
</script>
|
|
|
|
</head>
|
|
|
|
|
|
|
|
<body>
|
|
|
|
|
|
|
|
<a target="_blank"
|
|
|
|
href="https://bugzilla.mozilla.org/show_bug.cgi?id=454377"
|
|
|
|
title="Accessible caret move events testing">
|
|
|
|
Mozilla Bug 454377
|
|
|
|
</a>
|
|
|
|
<p id="display"></p>
|
|
|
|
<div id="content" style="display: none"></div>
|
|
|
|
<pre id="test">
|
|
|
|
</pre>
|
|
|
|
|
|
|
|
<input id="textbox" value="hello"/>
|
|
|
|
<textarea id="textarea">text<br>text</textarea>
|
|
|
|
<p id="p" contentEditable="true"><span>text</span><br/>text</p>
|
2008-12-16 02:14:20 -08:00
|
|
|
<div id="div" contentEditable="true"><p id="p1_in_div">text</p><p id="p2_in_div">text</p></div>
|
2008-09-16 07:38:48 -07:00
|
|
|
|
2009-09-09 02:03:14 -07:00
|
|
|
<div id="eventdump"></div>
|
2008-09-16 07:38:48 -07:00
|
|
|
</body>
|
|
|
|
</html>
|