Bug 1424505: Don't try to retrieve the accessible focus from remote documents on Windows 7. r?eeejay draft
authorJames Teh <jteh@mozilla.com>
Tue, 01 May 2018 15:48:43 +1000
changeset 790075 2c8c50bbe9823975f2a3d62ac3a06fbaf7781015
parent 790006 7ef8450810693ab08e79ab0d4702de6f479e678c
push id108417
push userbmo:jteh@mozilla.com
push dateTue, 01 May 2018 05:57:35 +0000
reviewerseeejay
bugs1424505, 1421144
milestone61.0a1
Bug 1424505: Don't try to retrieve the accessible focus from remote documents on Windows 7. r?eeejay Bug 1421144 fixed IAccessible::accFocus to work when focus is within a remote document. Unfortunately, this causes mysterious intermittent crashes when called from a UIA client in Windows 7. Ideally, we'd deal with the actual cause of the crashes, but they seem to be deep in Windows RPC code and all attempts at tracking this down have failed. Clients don't seem to need this too often anyway (and it's a minor annoyance if it doesn't work when they do). MozReview-Commit-ID: IxvbBGJ2wxA
accessible/windows/msaa/RootAccessibleWrap.cpp
--- a/accessible/windows/msaa/RootAccessibleWrap.cpp
+++ b/accessible/windows/msaa/RootAccessibleWrap.cpp
@@ -1,16 +1,17 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* 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/. */
 
 #include "RootAccessibleWrap.h"
 
 #include "Compatibility.h"
+#include "mozilla/WindowsVersion.h"
 #include "nsCoreUtils.h"
 #include "nsWinUtils.h"
 
 using namespace mozilla::a11y;
 
 ////////////////////////////////////////////////////////////////////////////////
 // Constructor/destructor
 
@@ -150,18 +151,21 @@ RootAccessibleWrap::accNavigate(
   return S_OK;
 }
 
 STDMETHODIMP
 RootAccessibleWrap::get_accFocus(
       /* [retval][out] */ VARIANT __RPC_FAR *pvarChild)
 {
   HRESULT hr = DocAccessibleWrap::get_accFocus(pvarChild);
-  if (FAILED(hr) || pvarChild->vt != VT_EMPTY) {
-    // We got a definite result (either failure or an accessible).
+  if (FAILED(hr) || pvarChild->vt != VT_EMPTY || !IsWin8OrLater()) {
+    // 1. We got a definite result (either failure or an accessible); or
+    // 2. This is Windows 7, where we don't want to retrieve the focus from a
+    // remote document because this causes mysterious intermittent crashes
+    // when we're called by UIA clients; see bug 1424505.
     return hr;
   }
 
   // The base implementation reported no focus.
   // Focus might be in a remote document.
   // (The base implementation can't handle this.)
   // Get the document in the active tab.
   ProxyAccessible* docProxy = GetPrimaryRemoteTopLevelContentDoc();