Bug 1597043: RootAccessible::ProcessDOMEvent: Return early if AsXULMultiSelectControl() on a XUL tree element fails. r=MarcoZ
authorJames Teh <jteh@mozilla.com>
Mon, 18 Nov 2019 05:42:28 +0000
changeset 502374 cbe5a080a2ada0308ff3a8eae088ddd44b79af6d
parent 502373 cbe50feba8e1ce4deb5b9dac66bd6feb4970b34f
child 502375 eb5f05b67d5684795a3043d90ef99cc9f17c504a
child 502500 f78494c785f1b3264b1a17376d01520e1072ba7b
push id114172
push userdluca@mozilla.com
push dateTue, 19 Nov 2019 11:31:10 +0000
treeherdermozilla-inbound@b5c5ba07d3db [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersMarcoZ
bugs1597043
milestone72.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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
accessible/generic/RootAccessible.cpp
--- a/accessible/generic/RootAccessible.cpp
+++ b/accessible/generic/RootAccessible.cpp
@@ -343,16 +343,25 @@ void RootAccessible::ProcessDOMEvent(Eve
   nsINode* targetNode = accessible->GetNode();
   if (treeItemAcc && eventType.EqualsLiteral("select")) {
     // XXX: We shouldn't be based on DOM select event which doesn't provide us
     // any context info. We should integrate into nsTreeSelection instead.
     // If multiselect tree, we should fire selectionadd or selection removed
     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")) {
         // XXX: We need to fire EVENT_SELECTION_ADD and EVENT_SELECTION_REMOVE
         // for each tree item. Perhaps each tree item will need to cache its
         // selection state and fire an event after a DOM "select" event when
         // that state changes. XULTreeAccessible::UpdateTreeSelection();
         nsEventShell::FireEvent(nsIAccessibleEvent::EVENT_SELECTION_WITHIN,