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() { ...@@ -31,7 +31,8 @@ BrowserAccessibilityStateImpl* BrowserAccessibilityStateImpl::GetInstance() {
BrowserAccessibilityStateImpl::BrowserAccessibilityStateImpl() BrowserAccessibilityStateImpl::BrowserAccessibilityStateImpl()
: BrowserAccessibilityState(), : BrowserAccessibilityState(),
accessibility_mode_(AccessibilityModeOff) { accessibility_mode_(AccessibilityModeOff),
disable_hot_tracking_(false) {
ResetAccessibilityModeValue(); ResetAccessibilityModeValue();
#if defined(OS_WIN) #if defined(OS_WIN)
// On Windows, UpdateHistograms calls some system functions with unknown // On Windows, UpdateHistograms calls some system functions with unknown
......
...@@ -60,6 +60,18 @@ class CONTENT_EXPORT BrowserAccessibilityStateImpl ...@@ -60,6 +60,18 @@ class CONTENT_EXPORT BrowserAccessibilityStateImpl
// removed. // removed.
void RemoveAccessibilityMode(AccessibilityMode mode); 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: private:
friend class base::RefCountedThreadSafe<BrowserAccessibilityStateImpl>; friend class base::RefCountedThreadSafe<BrowserAccessibilityStateImpl>;
friend struct DefaultSingletonTraits<BrowserAccessibilityStateImpl>; friend struct DefaultSingletonTraits<BrowserAccessibilityStateImpl>;
...@@ -84,6 +96,8 @@ class CONTENT_EXPORT BrowserAccessibilityStateImpl ...@@ -84,6 +96,8 @@ class CONTENT_EXPORT BrowserAccessibilityStateImpl
std::vector<base::Closure> histogram_callbacks_; std::vector<base::Closure> histogram_callbacks_;
bool disable_hot_tracking_;
DISALLOW_COPY_AND_ASSIGN(BrowserAccessibilityStateImpl); DISALLOW_COPY_AND_ASSIGN(BrowserAccessibilityStateImpl);
}; };
......
...@@ -3568,8 +3568,6 @@ void BrowserAccessibilityWin::InitRoleAndState() { ...@@ -3568,8 +3568,6 @@ void BrowserAccessibilityWin::InitRoleAndState() {
ia_state |= STATE_SYSTEM_FOCUSABLE; ia_state |= STATE_SYSTEM_FOCUSABLE;
if (HasState(ui::AX_STATE_HASPOPUP)) if (HasState(ui::AX_STATE_HASPOPUP))
ia_state |= STATE_SYSTEM_HASPOPUP; ia_state |= STATE_SYSTEM_HASPOPUP;
if (HasState(ui::AX_STATE_HOVERED))
ia_state |= STATE_SYSTEM_HOTTRACKED;
if (HasState(ui::AX_STATE_INDETERMINATE)) if (HasState(ui::AX_STATE_INDETERMINATE))
ia_state |= STATE_SYSTEM_INDETERMINATE; ia_state |= STATE_SYSTEM_INDETERMINATE;
if (HasIntAttribute(ui::AX_ATTR_INVALID_STATE) && if (HasIntAttribute(ui::AX_ATTR_INVALID_STATE) &&
...@@ -3607,6 +3605,16 @@ void BrowserAccessibilityWin::InitRoleAndState() { ...@@ -3607,6 +3605,16 @@ void BrowserAccessibilityWin::InitRoleAndState() {
if (HasState(ui::AX_STATE_VISITED)) if (HasState(ui::AX_STATE_VISITED))
ia_state |= STATE_SYSTEM_TRAVERSED; 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 // 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 // not readonly, mark it as editable now. The final computation of the
// READONLY state for MSAA is below, after the switch. // READONLY state for MSAA is below, after the switch.
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
#include "content/browser/accessibility/accessibility_tree_formatter.h" #include "content/browser/accessibility/accessibility_tree_formatter.h"
#include "content/browser/accessibility/browser_accessibility.h" #include "content/browser/accessibility/browser_accessibility.h"
#include "content/browser/accessibility/browser_accessibility_manager.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/browser/web_contents/web_contents_impl.h"
#include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents.h"
#include "content/public/common/content_paths.h" #include "content/public/common/content_paths.h"
...@@ -121,6 +122,11 @@ void DumpAccessibilityTestBase::ParseHtmlForExtraDirectives( ...@@ -121,6 +122,11 @@ void DumpAccessibilityTestBase::ParseHtmlForExtraDirectives(
void DumpAccessibilityTestBase::RunTest( void DumpAccessibilityTestBase::RunTest(
const base::FilePath file_path, const char* file_dir) { 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)); NavigateToURL(shell(), GURL(url::kAboutBlankURL));
// Output the test path to help anyone who encounters a failure and needs // 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