Bug 1801879: Don't cross document boundaries in nsAccUtils::GetSelectableContainer. r=eeejay,geckoview-reviewers,owlish

Trying to access a local OuterDocAccessible from the Android UI thread was causing a crash.
We shouldn't be crossing document boundaries anyway.

Differential Revision: https://phabricator.services.mozilla.com/D163067
This commit is contained in:
James Teh 2022-11-29 05:18:23 +00:00
Родитель b8327d4af3
Коммит 5508057e9f
3 изменённых файлов: 17 добавлений и 1 удалений

Просмотреть файл

@ -194,10 +194,13 @@ Accessible* nsAccUtils::GetSelectableContainer(const Accessible* aAccessible,
if (!aAccessible) return nullptr;
if (!(aState & states::SELECTABLE)) return nullptr;
MOZ_ASSERT(!aAccessible->IsDoc());
const Accessible* parent = aAccessible;
while ((parent = parent->Parent()) && !parent->IsSelect()) {
if (parent->Role() == roles::PANE) return nullptr;
if (parent->IsDoc() || parent->Role() == roles::PANE) {
return nullptr;
}
}
return const_cast<Accessible*>(parent);
}

Просмотреть файл

@ -8,5 +8,6 @@
this.getAttribute('aria-selected') == 'true' ? 'false' : 'true')">1</li>
<li role="option" aria-selected="false">2</li>
</ul>
<li id="outsideSelectable" role="option" tabindex="0">outside selectable</li>
</body>
</html>

Просмотреть файл

@ -1056,6 +1056,18 @@ class AccessibilityTest : BaseSessionTest() {
provider.performAction(nodeId, AccessibilityNodeInfo.ACTION_SELECT, null)
waitUntilSelect(false)
// Ensure that querying an option outside of a selectable container
// doesn't crash (bug 1801879).
mainSession.evaluateJS("document.getElementById('outsideSelectable').focus()")
sessionRule.waitUntilCalled(object : EventDelegate {
@AssertCalled(count = 1)
override fun onFocused(event: AccessibilityEvent) {
nodeId = getSourceId(event)
val node = createNodeInfo(nodeId)
assertThat("Focused outsideSelectable", node.text.toString(), equalTo("outside selectable"))
}
})
}
@Test fun testMutation() {