зеркало из https://github.com/mozilla/pjs.git
Bug 454377 - caret move event is fired for parent of html:textarea when textarea is tabed, r=aaronlev, marcoz
This commit is contained in:
Родитель
e3b8d64d4e
Коммит
a6d122cd24
|
@ -247,8 +247,17 @@ nsCaretAccessible::NormalSelectionChanged(nsIDOMDocument *aDoc,
|
|||
return NS_OK; // Don't fire caret moves until doc loaded
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDOMNode> nodeWithCaret = focusNode;
|
||||
// Get focused node.
|
||||
nsCOMPtr<nsIContent> focusContainer(do_QueryInterface(focusNode));
|
||||
if (focusContainer && focusContainer->IsNodeOfType(nsINode::eELEMENT)) {
|
||||
PRInt32 focusOffset = 0;
|
||||
aSel->GetFocusOffset(&focusOffset);
|
||||
|
||||
nsCOMPtr<nsIContent> focusContent = focusContainer->GetChildAt(focusOffset);
|
||||
focusNode = do_QueryInterface(focusContent);
|
||||
}
|
||||
|
||||
// Get relevant accessible for the focused node.
|
||||
nsCOMPtr<nsIAccessibleText> textAcc;
|
||||
while (focusNode) {
|
||||
// Make sure to get the correct starting node for selection events inside XBL content trees
|
||||
|
@ -307,6 +316,16 @@ nsCaretAccessible::SpellcheckSelectionChanged(nsIDOMDocument *aDoc,
|
|||
if (!targetNode)
|
||||
return NS_OK;
|
||||
|
||||
// Get focused node.
|
||||
nsCOMPtr<nsIContent> focusContainer(do_QueryInterface(targetNode));
|
||||
if (focusContainer && focusContainer->IsNodeOfType(nsINode::eELEMENT)) {
|
||||
PRInt32 focusOffset = 0;
|
||||
aSel->GetFocusOffset(&focusOffset);
|
||||
|
||||
nsCOMPtr<nsIContent> focusContent = focusContainer->GetChildAt(focusOffset);
|
||||
targetNode = do_QueryInterface(focusContent);
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIAccessibleDocument> docAccessible =
|
||||
nsAccessNode::GetDocAccessibleFor(targetNode);
|
||||
NS_ENSURE_STATE(docAccessible);
|
||||
|
|
|
@ -59,6 +59,7 @@ _TEST_FILES =\
|
|||
test_bug368835.xul \
|
||||
test_bug420863.html \
|
||||
test_cssattrs.html \
|
||||
test_events_caretmove.html \
|
||||
test_groupattrs.xul \
|
||||
$(warning test_table_indexes.html temporarily disabled) \
|
||||
test_nsIAccessible_actions.html \
|
||||
|
|
|
@ -1,28 +1,16 @@
|
|||
const nsIAccessibleRetrieval = Components.interfaces.nsIAccessibleRetrieval;
|
||||
|
||||
// Mapping needed state flags for easier handling.
|
||||
const state_focusable =
|
||||
Components.interfaces.nsIAccessibleStates.STATE_FOCUSABLE;
|
||||
const state_focused =
|
||||
Components.interfaces.nsIAccessibleStates.STATE_FOCUSED;
|
||||
const state_readonly =
|
||||
Components.interfaces.nsIAccessibleStates.STATE_READONLY;
|
||||
const state_focusable = nsIAccessibleStates.STATE_FOCUSABLE;
|
||||
const state_focused = nsIAccessibleStates.STATE_FOCUSED;
|
||||
const state_readonly = nsIAccessibleStates.STATE_READONLY;
|
||||
|
||||
const ext_state_multi_line =
|
||||
Components.interfaces.nsIAccessibleStates.EXT_STATE_MULTI_LINE;
|
||||
const ext_state_editable =
|
||||
Components.interfaces.nsIAccessibleStates.EXT_STATE_EDITABLE;
|
||||
const ext_state_required =
|
||||
Components.interfaces.nsIAccessibleStates.STATE_REQUIRED;
|
||||
const ext_state_invalid =
|
||||
Components.interfaces.nsIAccessibleStates.STATE_INVALID;
|
||||
const ext_state_multi_line = nsIAccessibleStates.EXT_STATE_MULTI_LINE;
|
||||
const ext_state_editable = nsIAccessibleStates.EXT_STATE_EDITABLE;
|
||||
const ext_state_required = nsIAccessibleStates.STATE_REQUIRED;
|
||||
const ext_state_invalid = nsIAccessibleStates.STATE_INVALID;
|
||||
|
||||
// Mapping needed final roles
|
||||
const role_entry = Components.interfaces.nsIAccessibleRole.ROLE_ENTRY;
|
||||
const role_password_text =
|
||||
Components.interfaces.nsIAccessibleRole.ROLE_PASSWORD_TEXT;
|
||||
|
||||
var gAccRetrieval = null;
|
||||
const role_entry = nsIAccessibleRole.ROLE_ENTRY;
|
||||
const role_password_text = nsIAccessibleRole.ROLE_PASSWORD_TEXT;
|
||||
|
||||
function testValue(aID, aAcc, aValue, aRole)
|
||||
{
|
||||
|
|
|
@ -0,0 +1,130 @@
|
|||
<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>
|
||||
|
||||
<script type="application/javascript">
|
||||
function synthMouseTest(aNode)
|
||||
{
|
||||
this.node = aNode;
|
||||
this.testFunc = function testFunc()
|
||||
{
|
||||
synthesizeMouse(this.node, 1, 1, {});
|
||||
}
|
||||
}
|
||||
|
||||
function synthKeyTest(aNode, aKey)
|
||||
{
|
||||
this.node = aNode;
|
||||
this.testFunc = function testFunc()
|
||||
{
|
||||
synthesizeKey(aKey, {});
|
||||
}
|
||||
}
|
||||
|
||||
function synthTabTest(aNode, aBackTab)
|
||||
{
|
||||
this.node = aNode;
|
||||
this.testFunc = function testFunc()
|
||||
{
|
||||
synthesizeKey("VK_TAB", {shiftKey: aBackTab});
|
||||
}
|
||||
}
|
||||
|
||||
var gTestsArray = [];
|
||||
var gTestIdx = -1;
|
||||
|
||||
var gCaretMoveHandler =
|
||||
{
|
||||
handleEvent: function handleEvent(aEvent)
|
||||
{
|
||||
if (aEvent.DOMNode == gTestsArray[gTestIdx].node)
|
||||
gTestsArray[gTestIdx].wasCaught = true;
|
||||
}
|
||||
};
|
||||
|
||||
function doTest()
|
||||
{
|
||||
window.setTimeout(
|
||||
function()
|
||||
{
|
||||
if (gTestIdx == gTestsArray.length - 1) {
|
||||
|
||||
unregisterA11yEventListener(nsIAccessibleEvent.EVENT_TEXT_CARET_MOVED,
|
||||
gCaretMoveHandler);
|
||||
|
||||
for (var idx = 0; idx < gTestsArray.length; idx++)
|
||||
ok(gTestsArray[idx].wasCaught, "test " + idx + " failed");
|
||||
|
||||
SimpleTest.finish();
|
||||
return;
|
||||
}
|
||||
|
||||
gTestsArray[++gTestIdx].testFunc();
|
||||
doTest();
|
||||
},
|
||||
100
|
||||
);
|
||||
}
|
||||
|
||||
function doTests()
|
||||
{
|
||||
var textbox = document.getElementById("textbox");
|
||||
gTestsArray.push(new synthMouseTest(textbox));
|
||||
gTestsArray.push(new synthKeyTest(textbox, "VK_RIGHT"));
|
||||
|
||||
var textarea = document.getElementById("textarea");
|
||||
gTestsArray.push(new synthMouseTest(textarea));
|
||||
gTestsArray.push(new synthKeyTest(textarea, "VK_RIGHT"));
|
||||
gTestsArray.push(new synthKeyTest(textarea, "VK_DOWN"));
|
||||
|
||||
var p = document.getElementById("p");
|
||||
gTestsArray.push(new synthMouseTest(p));
|
||||
gTestsArray.push(new synthKeyTest(p, "VK_RIGHT"));
|
||||
gTestsArray.push(new synthKeyTest(p, "VK_DOWN"));
|
||||
|
||||
gTestsArray.push(new synthTabTest(textarea, true));
|
||||
gTestsArray.push(new synthTabTest(p));
|
||||
|
||||
registerA11yEventListener(nsIAccessibleEvent.EVENT_TEXT_CARET_MOVED,
|
||||
gCaretMoveHandler);
|
||||
|
||||
doTest();
|
||||
}
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
addLoadEvent(doTests);
|
||||
</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>
|
||||
|
||||
</body>
|
||||
</html>
|
|
@ -7,17 +7,19 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=442648
|
|||
<title>nsIAccessible textboxes chrome tests</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/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/a11y/accessible/testTextboxes.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/testTextboxes.js"></script>
|
||||
|
||||
<script type="application/javascript">
|
||||
function doTest()
|
||||
{
|
||||
gAccRetrieval = Components.classes["@mozilla.org/accessibleRetrieval;1"].
|
||||
getService(nsIAccessibleRetrieval);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// normal textbox without content and with no proper label
|
||||
testThis("unlabelled_Textbox", // ID
|
||||
|
|
|
@ -12,15 +12,14 @@
|
|||
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
|
||||
|
||||
<script type="application/javascript"
|
||||
src="chrome://mochikit/content/a11y/accessible/testTextboxes.js"></script>
|
||||
src="chrome://mochikit/content/a11y/accessible/common.js" />
|
||||
<script type="application/javascript"
|
||||
src="chrome://mochikit/content/a11y/accessible/testTextboxes.js" />
|
||||
|
||||
<script type="application/javascript">
|
||||
<![CDATA[
|
||||
function doTest()
|
||||
{
|
||||
gAccRetrieval = Components.classes["@mozilla.org/accessibleRetrieval;1"].
|
||||
getService(nsIAccessibleRetrieval);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// normal textbox without content and with no proper label
|
||||
testThis("unlabelled_Textbox", // ID
|
||||
|
|
Загрузка…
Ссылка в новой задаче