Bug 1371781 - Allow <select> accessible children to be put back in list accessible. r=surkov

This commit is contained in:
Eitan Isaacson 2017-07-31 13:00:00 -04:00
parent 5aeb1f0c4b
commit 1911897aee
3 changed files with 47 additions and 3 deletions

View file

@ -2174,7 +2174,6 @@ DocAccessible::PutChildrenBack(nsTArray<RefPtr<Accessible> >* aChildren,
{ {
MOZ_ASSERT(aStartIdx <= aChildren->Length(), "Wrong removal index"); MOZ_ASSERT(aStartIdx <= aChildren->Length(), "Wrong removal index");
nsTArray<RefPtr<Accessible> > containers;
for (auto idx = aStartIdx; idx < aChildren->Length(); idx++) { for (auto idx = aStartIdx; idx < aChildren->Length(); idx++) {
Accessible* child = aChildren->ElementAt(idx); Accessible* child = aChildren->ElementAt(idx);
if (!child->IsInDocument()) { if (!child->IsInDocument()) {
@ -2196,11 +2195,12 @@ DocAccessible::PutChildrenBack(nsTArray<RefPtr<Accessible> >* aChildren,
// Unset relocated flag to find an insertion point for the child. // Unset relocated flag to find an insertion point for the child.
child->SetRelocated(false); child->SetRelocated(false);
nsIContent* content = child->GetContent();
int32_t idxInParent = -1; int32_t idxInParent = -1;
Accessible* origContainer = GetContainerAccessible(child->GetContent()); Accessible* origContainer = AccessibleOrTrueContainer(content->GetParentNode());
if (origContainer) { if (origContainer) {
TreeWalker walker(origContainer); TreeWalker walker(origContainer);
if (walker.Seek(child->GetContent())) { if (walker.Seek(content)) {
Accessible* prevChild = walker.Prev(); Accessible* prevChild = walker.Prev();
if (prevChild) { if (prevChild) {
idxInParent = prevChild->IndexInParent() + 1; idxInParent = prevChild->IndexInParent() + 1;

View file

@ -7,3 +7,4 @@ support-files =
!/accessible/tests/mochitest/*.js !/accessible/tests/mochitest/*.js
[browser_test_aria_owns.js] [browser_test_aria_owns.js]
[browser_test_aria_owns_select.js]

View file

@ -0,0 +1,43 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
function testChildrenIds(acc, expectedIds) {
let ids = arrayFromChildren(acc).map(child => getAccessibleDOMNodeID(child));
Assert.deepEqual(ids, expectedIds,
`Children for ${getAccessibleDOMNodeID(acc)} are wrong.`);
}
async function runTests(browser, accDoc) {
let div = findAccessibleChildByID(accDoc, "div");
let select = findAccessibleChildByID(accDoc, "select");
testChildrenIds(div, ["b"]);
testChildrenIds(select.firstChild, ["a"]);
let onReorders = waitForEvents([
[EVENT_REORDER, "div"],
[EVENT_REORDER,
evt => getAccessibleDOMNodeID(evt.accessible.parent) == "select"]
]);
await ContentTask.spawn(browser, null, async function() {
document.getElementById("div").removeAttribute("aria-owns");
});
testChildrenIds(div, []);
testChildrenIds(select.firstChild, ["a", "b"]);
}
/**
* Test caching of accessible object states
*/
addAccessibleTask(`
<div id="div" role="group" aria-owns="b"></div>
<select id="select">
<option id="a"></option>
<option id="b"></option>
</select>
`, runTests);