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
--- 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();