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

Don't set the STATE_SYSTEM_HOTTRACKED state in tests.

It's set whenever the mouse is over an element, which just leads
to flakiness.

BUG=454600
NOPRESUBMIT=true

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

Cr-Commit-Position: refs/heads/master@{#314382}
parent 10ef1e2a
......@@ -31,7 +31,8 @@ BrowserAccessibilityStateImpl* BrowserAccessibilityStateImpl::GetInstance() {
BrowserAccessibilityStateImpl::BrowserAccessibilityStateImpl()
: BrowserAccessibilityState(),
accessibility_mode_(AccessibilityModeOff) {
accessibility_mode_(AccessibilityModeOff),
disable_hot_tracking_(false) {
ResetAccessibilityModeValue();
#if defined(OS_WIN)
// On Windows, UpdateHistograms calls some system functions with unknown
......
......@@ -60,6 +60,18 @@ class CONTENT_EXPORT BrowserAccessibilityStateImpl
// removed.
void RemoveAccessibilityMode(AccessibilityMode mode);
// Accessibility objects can have the "hot tracked" state set when
// the mouse is hovering over them, but this makes tests flaky because
// the test behaves differently when the mouse happens to be over an
// element. This is a global switch to not use the "hot tracked" state
// in a test.
void set_disable_hot_tracking_for_testing(bool disable_hot_tracking) {
disable_hot_tracking_ = disable_hot_tracking;
}
bool disable_hot_tracking_for_testing() const {
return disable_hot_tracking_;
}
private:
friend class base::RefCountedThreadSafe<BrowserAccessibilityStateImpl>;
friend struct DefaultSingletonTraits<BrowserAccessibilityStateImpl>;
......@@ -84,6 +96,8 @@ class CONTENT_EXPORT BrowserAccessibilityStateImpl
std::vector<base::Closure> histogram_callbacks_;
bool disable_hot_tracking_;
DISALLOW_COPY_AND_ASSIGN(BrowserAccessibilityStateImpl);
};
......
......@@ -3568,8 +3568,6 @@ void BrowserAccessibilityWin::InitRoleAndState() {
ia_state |= STATE_SYSTEM_FOCUSABLE;
if (HasState(ui::AX_STATE_HASPOPUP))
ia_state |= STATE_SYSTEM_HASPOPUP;
if (HasState(ui::AX_STATE_HOVERED))
ia_state |= STATE_SYSTEM_HOTTRACKED;
if (HasState(ui::AX_STATE_INDETERMINATE))
ia_state |= STATE_SYSTEM_INDETERMINATE;
if (HasIntAttribute(ui::AX_ATTR_INVALID_STATE) &&
......@@ -3607,6 +3605,16 @@ void BrowserAccessibilityWin::InitRoleAndState() {
if (HasState(ui::AX_STATE_VISITED))
ia_state |= STATE_SYSTEM_TRAVERSED;
// Expose whether or not the mouse is over an element, but suppress
// this for tests because it can make the test results flaky depending
// on the position of the mouse.
BrowserAccessibilityStateImpl* accessibility_state =
BrowserAccessibilityStateImpl::GetInstance();
if (!accessibility_state->disable_hot_tracking_for_testing()) {
if (HasState(ui::AX_STATE_HOVERED))
ia_state |= STATE_SYSTEM_HOTTRACKED;
}
// WebKit marks everything as readonly unless it's editable text, so if it's
// not readonly, mark it as editable now. The final computation of the
// READONLY state for MSAA is below, after the switch.
......
......@@ -16,6 +16,7 @@
#include "content/browser/accessibility/accessibility_tree_formatter.h"
#include "content/browser/accessibility/browser_accessibility.h"
#include "content/browser/accessibility/browser_accessibility_manager.h"
#include "content/browser/accessibility/browser_accessibility_state_impl.h"
#include "content/browser/web_contents/web_contents_impl.h"
#include "content/public/browser/web_contents.h"
#include "content/public/common/content_paths.h"
......@@ -121,6 +122,11 @@ void DumpAccessibilityTestBase::ParseHtmlForExtraDirectives(
void DumpAccessibilityTestBase::RunTest(
const base::FilePath file_path, const char* file_dir) {
// Disable the "hot tracked" state (set when the mouse is hovering over
// an object) because it makes test output change based on the mouse position.
BrowserAccessibilityStateImpl::GetInstance()->
set_disable_hot_tracking_for_testing(true);
NavigateToURL(shell(), GURL(url::kAboutBlankURL));
// Output the test path to help anyone who encounters a failure and needs
......
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