Commit f137c403 authored by dmazzoni's avatar dmazzoni Committed by Commit bot

Fix flakiness in DumpAccessibilityEvent* tests.

Logging revealed the flakiness was in ::AccessibleObjectFromWindow.
Replace that with an alternative method, and remove the logging.

BUG=440579
TBR=dtseng,ananta

Review URL: https://codereview.chromium.org/901183003

Cr-Commit-Position: refs/heads/master@{#315229}
parent b8ae4eb7
......@@ -95,6 +95,11 @@ class AccessibilityEventRecorderWin : public AccessibilityEventRecorder {
DWORD event_thread,
DWORD event_time);
// Wrapper around AccessibleObjectFromWindow because the function call
// inexplicably flakes sometimes on build/trybots.
HRESULT AccessibleObjectFromWindowWrapper(
HWND hwnd, DWORD dwId, REFIID riid, void **ppvObject);
HWINEVENTHOOK win_event_hook_handle_;
static AccessibilityEventRecorderWin* instance_;
};
......@@ -138,7 +143,6 @@ AccessibilityEventRecorderWin::AccessibilityEventRecorderWin(
GetCurrentProcessId(),
0, // Hook all threads
WINEVENT_INCONTEXT);
LOG(INFO) << "SetWinEventHook handle: " << win_event_hook_handle_;
CHECK(win_event_hook_handle_);
}
......@@ -155,18 +159,8 @@ void AccessibilityEventRecorderWin::OnWinEventHook(
LONG child_id,
DWORD event_thread,
DWORD event_time) {
// http://crbug.com/440579 TODO(dmazzoni): remove most logging in this file,
// or change to VLOG(1), once flakiness on CrWinClang testers is fixed.
LOG(INFO) << "OnWinEventHook handle=" << handle
<< " event=" << event
<< " hwnd=" << hwnd
<< " obj_id=" << obj_id
<< " child_id=" << child_id
<< " event_thread=" << event_thread
<< " event_time=" << event_time;
base::win::ScopedComPtr<IAccessible> browser_accessible;
HRESULT hr = AccessibleObjectFromWindow(
HRESULT hr = AccessibleObjectFromWindowWrapper(
hwnd,
obj_id,
IID_IAccessible,
......@@ -175,10 +169,7 @@ void AccessibilityEventRecorderWin::OnWinEventHook(
// Note: our event hook will pick up some superfluous events we
// don't care about, so it's safe to just ignore these failures.
// Same below for other HRESULT checks.
LOG(INFO) << "Ignoring result " << hr << " from AccessibleObjectFromWindow";
TCHAR name[MAX_PATH];
GetClassName(hwnd, name, _countof(name));
LOG(INFO) << "Hwnd " << hwnd << " class is " << name;
VLOG(1) << "Ignoring result " << hr << " from AccessibleObjectFromWindow";
return;
}
......@@ -186,21 +177,21 @@ void AccessibilityEventRecorderWin::OnWinEventHook(
base::win::ScopedComPtr<IDispatch> dispatch;
hr = browser_accessible->get_accChild(childid_variant, dispatch.Receive());
if (!SUCCEEDED(hr) || !dispatch) {
LOG(INFO) << "Ignoring result " << hr << " and result " << dispatch
<< " from get_accChild";
VLOG(1) << "Ignoring result " << hr << " and result " << dispatch
<< " from get_accChild";
return;
}
base::win::ScopedComPtr<IAccessible> iaccessible;
hr = dispatch.QueryInterface(iaccessible.Receive());
if (!SUCCEEDED(hr)) {
LOG(INFO) << "Ignoring result " << hr << " from QueryInterface";
VLOG(1) << "Ignoring result " << hr << " from QueryInterface";
return;
}
std::string event_str = AccessibilityEventToStringUTF8(event);
if (event_str.empty()) {
LOG(INFO) << "Ignoring event " << event;
VLOG(1) << "Ignoring event " << event;
return;
}
......@@ -244,9 +235,27 @@ void AccessibilityEventRecorderWin::OnWinEventHook(
}
}
LOG(INFO) << "Got event log: " << log;
event_logs_.push_back(log);
}
HRESULT AccessibilityEventRecorderWin::AccessibleObjectFromWindowWrapper(
HWND hwnd, DWORD dw_id, REFIID riid, void** ppv_object) {
HRESULT hr = ::AccessibleObjectFromWindow(hwnd, dw_id, riid, ppv_object);
if (SUCCEEDED(hr))
return hr;
// The above call to ::AccessibleObjectFromWindow fails for unknown
// reasons every once in a while on the bots. Work around it by grabbing
// the object directly from the BrowserAccessibilityManager.
HWND accessibility_hwnd =
manager_->delegate()->AccessibilityGetAcceleratedWidget();
if (accessibility_hwnd != hwnd)
return E_FAIL;
IAccessible* obj = manager_->GetRoot()->ToBrowserAccessibilityWin();
obj->AddRef();
*ppv_object = obj;
return S_OK;
}
} // namespace content
......@@ -124,10 +124,6 @@ bool LegacyRenderWidgetHostHWND::Init() {
CHILDID_SELF);
}
// http://crbug.com/440579 TODO(dmazzoni): remove this logging when
// flakiness is fixed.
LOG(INFO) << "LegacyRenderWidgetHostHWND::Init hwnd=" << hwnd();
return !!SUCCEEDED(hr);
}
......@@ -151,15 +147,6 @@ LRESULT LegacyRenderWidgetHostHWND::OnGetObject(UINT message,
// because it sometimes gets sign-extended incorrectly (but not always).
DWORD obj_id = static_cast<DWORD>(static_cast<DWORD_PTR>(l_param));
// http://crbug.com/440579 TODO(dmazzoni): remove this logging when
// flakiness is fixed.
LOG(INFO) << "LegacyRenderWidgetHostHWND::OnGetObject"
<< " message=" << message
<< " w_param=" << w_param
<< " l_param=" << l_param
<< " obj_id=" << obj_id
<< " host_=" << host_;
if (kIdScreenReaderHoneyPot == obj_id) {
// When an MSAA client has responded to our fake event on this id,
// enable screen reader support.
......@@ -172,18 +159,14 @@ LRESULT LegacyRenderWidgetHostHWND::OnGetObject(UINT message,
RenderWidgetHostImpl* rwhi = RenderWidgetHostImpl::From(
host_->GetRenderWidgetHost());
if (!rwhi) {
LOG(WARNING) << "No RWHI";
if (!rwhi)
return static_cast<LRESULT>(0L);
}
BrowserAccessibilityManagerWin* manager =
static_cast<BrowserAccessibilityManagerWin*>(
rwhi->GetRootBrowserAccessibilityManager());
if (!manager) {
LOG(WARNING) << "No manager";
if (!manager)
return static_cast<LRESULT>(0L);
}
base::win::ScopedComPtr<IAccessible> root(
manager->GetRoot()->ToBrowserAccessibilityWin());
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment