Bug 1597043: RootAccessible::ProcessDOMEvent: Return early if AsXULMultiSelectControl() on a XUL tree element fails. r=MarcoZ

This really shouldn't be possible.
All XUL trees should have nsIDOMXULMultiSelectControlElement, and the tree is focused at this point, so it shouldn't be dying.
Nevertheless, this sometimes happens in the wild and was causing crashes.

Differential Revision: https://phabricator.services.mozilla.com/D53373

--HG--
extra : moz-landing-system : lando
This commit is contained in:
James Teh 2019-11-18 05:42:28 +00:00
parent 2ed860b51f
commit 135e99b607

View File

@ -348,6 +348,15 @@ void RootAccessible::ProcessDOMEvent(Event* aDOMEvent, nsINode* aTarget) {
if (FocusMgr()->HasDOMFocus(targetNode)) {
nsCOMPtr<nsIDOMXULMultiSelectControlElement> multiSel =
targetNode->AsElement()->AsXULMultiSelectControl();
if (!multiSel) {
// This shouldn't be possible. All XUL trees should have
// nsIDOMXULMultiSelectControlElement, and the tree is focused, so it
// shouldn't be dying. Nevertheless, this sometimes happens in the wild
// (bug 1597043).
MOZ_ASSERT_UNREACHABLE(
"XUL tree doesn't have nsIDOMXULMultiSelectControlElement");
return;
}
nsAutoString selType;
multiSel->GetSelType(selType);
if (selType.IsEmpty() || !selType.EqualsLiteral("single")) {