Skip to content
Snippets Groups Projects
Commit 1911897a authored by Eitan Isaacson's avatar Eitan Isaacson
Browse files

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

parent 5aeb1f0c
No related branches found
No related tags found
No related merge requests found
...@@ -2174,7 +2174,6 @@ DocAccessible::PutChildrenBack(nsTArray<RefPtr<Accessible> >* aChildren, ...@@ -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, ...@@ -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;
......
...@@ -7,3 +7,4 @@ support-files = ...@@ -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]
/* 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);
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment