Commit 4095a353 authored by Kevin Babbitt's avatar Kevin Babbitt Committed by Commit Bot

Reland "Parameterize existing accessibility hit-testing tests"

This is a reland of 50fbc87a

The CL got reverted due to flakiness on Win7. From the logs it appears
that the flakes were caused by test content sometimes extending beyond
window bounds, resulting in incorrect hit test results.

To address this issue, existing tests have been rewritten to use smaller
content. I ran the rewritten tests 100x on a Win7 VM and saw 0 failures.

Several cleanups were made along the way:

- Update comments and code to reflect the fact that
BrowserAccessibilityManager.HitTest takes a point in frame coordinates.

- Increase device scale factor in scaled tests from 1.25 back to 2.

- AccessibilityHitTestingBrowserTest.HitTestingInIframes: This test was
almost identical to AccessibilityHitTestingZoomBrowserTest.HitTest, with
the addition of testing with a different event. Combined the two into a
single test: AccessibilityHitTestingBrowserTest.HitTest.

- AccessibilityHitTestingCrossProcessBrowserTest.*: these two tests were
also nearly identical. Combined into a single test which validates both
the frame tree and the scrolling case with the same content.

- AccessibilityHitTestingBrowserTest.*WithPinchZoom: these tests were
not actually exercising accessibility hit testing paths - they were
generating input events which got sent directly to Blink. Replaced these
with tests that exercise accessibility hit test paths in the presence of
pinch zoom.

Original change's description:
> Parameterize existing accessibility hit-testing tests
>
> https://crrev.com/c/2117330 added tests for cross-platform
> accessibility hit testing code using parameterized combinations of
> simulated device scale factor and use-zoom-for-dsf on or off. This CL
> expands the parameterization to other existing hit-testing tests.
>
> To fix issues running these tests on cast_shell_linux I also made two
> changes to the tests themselves:
> - Reduce the scale factor from 2 to 1.25
> - Relocate one test point to be within the screen size
>
> Bug: 1007488
> Change-Id: I715270064365458ac9ec69f3c3ac81a674d2718c
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2135017
> Commit-Queue: Kevin Babbitt <kbabbitt@microsoft.com>
> Reviewed-by: Dominic Mazzoni <dmazzoni@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#756884}

Bug: 1007488, 1069850
Change-Id: I01fcb7d2b7f6a764ccd76da3e97778dfc184960e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2140198
Commit-Queue: Kevin Babbitt <kbabbitt@microsoft.com>
Reviewed-by: default avatarDominic Mazzoni <dmazzoni@chromium.org>
Cr-Commit-Position: refs/heads/master@{#758545}
parent 03a85d57
...@@ -876,13 +876,13 @@ void BrowserAccessibilityManager::ClearAccessibilityFocus( ...@@ -876,13 +876,13 @@ void BrowserAccessibilityManager::ClearAccessibilityFocus(
delegate_->AccessibilityPerformAction(action_data); delegate_->AccessibilityPerformAction(action_data);
} }
void BrowserAccessibilityManager::HitTest(const gfx::Point& page_point) const { void BrowserAccessibilityManager::HitTest(const gfx::Point& frame_point) const {
if (!delegate_) if (!delegate_)
return; return;
ui::AXActionData action_data; ui::AXActionData action_data;
action_data.action = ax::mojom::Action::kHitTest; action_data.action = ax::mojom::Action::kHitTest;
action_data.target_point = page_point; action_data.target_point = frame_point;
action_data.hit_test_event_to_fire = ax::mojom::Event::kHover; action_data.hit_test_event_to_fire = ax::mojom::Event::kHover;
delegate_->AccessibilityPerformAction(action_data); delegate_->AccessibilityPerformAction(action_data);
} }
...@@ -1479,6 +1479,7 @@ BrowserAccessibility* BrowserAccessibilityManager::CachingAsyncHitTest( ...@@ -1479,6 +1479,7 @@ BrowserAccessibility* BrowserAccessibilityManager::CachingAsyncHitTest(
if (delegate_) { if (delegate_) {
// This triggers an asynchronous request to compute the true object that's // This triggers an asynchronous request to compute the true object that's
// under the point. // under the point.
// TODO(crbug.com/2140198): this should take page scale factor into account
HitTest(blink_screen_point - screen_view_bounds.OffsetFromOrigin()); HitTest(blink_screen_point - screen_view_bounds.OffsetFromOrigin());
// Unfortunately we still have to return an answer synchronously because // Unfortunately we still have to return an answer synchronously because
......
...@@ -235,9 +235,11 @@ class CONTENT_EXPORT BrowserAccessibilityManager : public ui::AXTreeObserver, ...@@ -235,9 +235,11 @@ class CONTENT_EXPORT BrowserAccessibilityManager : public ui::AXTreeObserver,
void DoDefaultAction(const BrowserAccessibility& node); void DoDefaultAction(const BrowserAccessibility& node);
void GetImageData(const BrowserAccessibility& node, void GetImageData(const BrowserAccessibility& node,
const gfx::Size& max_size); const gfx::Size& max_size);
// See third_party/blink/renderer/core/layout/hit_test_location.h for // Per third_party/blink/renderer/core/layout/hit_test_location.h, Blink
// information on hit test coordinates expected by Blink. // expects hit test points in page coordinates. However, WebAXObject::HitTest
void HitTest(const gfx::Point& page_point) const; // applies the visual viewport offset, so we want to pass that function a
// point in frame coordinates.
void HitTest(const gfx::Point& frame_point) const;
void Increment(const BrowserAccessibility& node); void Increment(const BrowserAccessibility& node);
void LoadInlineTextBoxes(const BrowserAccessibility& node); void LoadInlineTextBoxes(const BrowserAccessibility& node);
void ScrollToMakeVisible( void ScrollToMakeVisible(
......
<!DOCTYPE html>
<html>
<body style="margin: 0; padding: 0;">
<div style="width: 300px; height: 100px;">
<button style="margin: 25px; border: 0; width: 250px; height: 50px">
Ordinary Button
</button>
</div>
</body>
</html>
<!DOCTYPE html>
<html>
<body style="margin: 0; padding: 0;">
<div style="width: 300px; height: 100px;">
<button style="margin: 25px; border: 0; width: 250px; height: 50px">
Unscrolled Button
</button>
</div>
<script>
window.scrollTo(150, 50);
document.querySelector('button').textContent = 'Scrolled Button';
</script>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<style>
body {
overflow: hidden;
}
iframe {
border: 0;
margin: 0;
padding: 0;
overflow: hidden;
}
div {
width: 300px;
height: 150px;
}
</style>
</head>
<body style="margin: 0; padding: 0;">
<div>
<button style="margin: 25px; border: 0; width: 250px; height: 50px">
Button A
</button>
</div>
<div style="width: 300px; height: 400px">
<iframe id="frame_a" style="width: 300px; height: 400px;"
scrolling="no"></iframe>
</div>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<style>
body {
overflow: hidden;
}
iframe {
border: 0;
margin: 0;
padding: 0;
overflow: hidden;
}
div {
width: 300px;
height: 150px;
}
</style>
</head>
<body style="margin: 0; padding: 0;">
<div>
<button style="margin: 25px; border: 0; width: 250px; height: 50px">
Button B
</button>
</div>
<div>
<iframe id="frame_b" style="width: 300px; height: 300px;"
scrolling="no"></iframe>
</div>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<style>
body {
overflow: hidden;
}
iframe {
border: 0;
margin: 0;
padding: 0;
overflow: hidden;
}
div {
width: 300px;
height: 150px;
}
div.placeholder {
height: 300px;
color: Red;
}
</style>
</head>
<body style="margin: 0; padding: 0;" bgcolor=Green>
<div class="placeholder">Placeholder 1</div>
<div>
<button style="margin: 25px; border: 0; width: 250px; height: 50px">
Button B
</button>
</div>
<div class="placeholder">Placeholder 2</div>
<div>
<iframe id="frame_b" style="width: 300px; height: 300px;"
scrolling="no"></iframe>
</div>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<style>
body {
overflow: hidden;
}
iframe {
border: 0;
margin: 0;
padding: 0;
overflow: hidden;
}
div {
width: 300px;
height: 150px;
}
</style>
</head>
<body style="margin: 0; padding: 0;">
<div>
<button style="margin: 25px; border: 0; width: 250px; height: 50px">
Button C
</button>
</div>
</body>
</html>
<!DOCTYPE html>
<div style="width: 5px; height: 5px; background: lightgray; display: inline-block; margin: 10px" aria-label="rectA"></div>
<div style="width: 5px; height: 5px; background: lightgray; display: inline-block; margin: 10px" aria-label="rectB"></div>
<div style="width: 5px; height: 5px; background: lightgray; display: inline-block; margin: 10px" aria-label="rectC"></div>
<div style="width: 5px; height: 5px; background: lightgray; display: inline-block; margin: 10px" aria-label="rectD"></div>
<div style="width: 5px; height: 5px; background: lightgray; display: inline-block; margin: 10px" aria-label="rectE"></div>
<div style="height: 80px"></div>
<div style="width: 5px; height: 5px; background: lightgray; display: inline-block; margin: 10px" aria-label="rectF"></div>
<div style="width: 5px; height: 5px; background: lightgray; display: inline-block; margin: 10px" aria-label="rectG"></div>
<div style="width: 5px; height: 5px; background: lightgray; display: inline-block; margin: 10px" aria-label="rectH"></div>
<div style="width: 5px; height: 5px; background: lightgray; display: inline-block; margin: 10px" aria-label="rectI"></div>
<div style="width: 5px; height: 5px; background: lightgray; display: inline-block; margin: 10px" aria-label="rectJ"></div>
<!DOCTYPE html> <!DOCTYPE html>
<html>
<head>
<style> <style>
body { .curtain {
overflow: hidden; position: fixed;
} left: 0px;
iframe { top: 0px;
border: 0; right: 0px;
margin: 0; bottom: 0px;
padding: 0; width: 100%;
overflow: hidden; height: 100%;
} z-index: -1;
div { background-color: #048;
width: 300px; }
height: 150px;
}
.curtain {
position: fixed;
left: 0px;
top: 0px;
right: 0px;
bottom: 0px;
width: 100%;
height: 100%;
z-index: -1;
background-color: #eef;
}
</style> </style>
</head>
<body style="margin: 0; padding: 0;">
<!-- Confound naive hit testing by appearing to cover the whole screen, <!-- Confound naive hit testing by appearing to cover the whole screen,
while actually having a negative z-index. --> while actually having a negative z-index. -->
<div role="group" class="curtain"> <div role="group" class="curtain">
<div role="group" class="curtain"> <div role="group" class="curtain">
</div> </div>
</div> </div>
<div> <div>
<button style="margin: 25px; border: 0; width: 250px; height: 50px"> <div style="width: 5px; height: 5px; background: lightgray; display: inline-block; margin: 10px" aria-label="rect1"></div>
Button <div style="width: 5px; height: 5px; background: lightgray; display: inline-block; margin: 10px" aria-label="rect2"></div>
</button> <div style="width: 5px; height: 5px; background: lightgray; display: inline-block; margin: 10px" aria-label="rect3"></div>
<div style="width: 5px; height: 5px; background: lightgray; display: inline-block; margin: 10px" aria-label="rect4"></div>
<div style="width: 5px; height: 5px; background: lightgray; display: inline-block; margin: 10px" aria-label="rect5"></div>
</div> </div>
<iframe src="simple_rectangles_iframe.html" style="width: 200px; height: 50px; margin: 20px"></iframe>
<div>
<button style="margin: 25px; border: 0; width: 250px; height: 50px">
Button
</button>
</div>
<div>
<iframe id="frame1" style="width: 300px; height: 100px;"
scrolling="no" src="button.html"></iframe>
</div>
<div>
<iframe id="frame2" style="width: 150px; height: 50px;"
scrolling="no" src="button_scrolled.html"></iframe>
</div>
<!-- Confound naive hit testing by appearing to cover the whole screen --> <!-- Confound naive hit testing by appearing to cover the whole screen -->
<div role="group" class="curtain"> <div role="group" class="curtain">
<div role="group" class="curtain"> <div role="group" class="curtain">
</div> </div>
</div> </div>
</body>
</html>
<!DOCTYPE html>
<div>
<div style="width: 20px; height: 20px; background: lightgray; display: inline-block; margin: 10px" aria-label="rect1">1</div>
<div style="width: 20px; height: 20px; background: lightgray; display: inline-block; margin: 10px" aria-label="rect2">2</div>
<div style="width: 20px; height: 20px; background: lightgray; display: inline-block; margin: 10px" aria-label="rect3">3</div>
<div style="width: 20px; height: 20px; background: lightgray; display: inline-block; margin: 10px" aria-label="rect4">4</div>
<div style="width: 20px; height: 20px; background: lightgray; display: inline-block; margin: 10px" aria-label="rect5">5</div>
</div>
<iframe src="text_ranges_iframe.html" style="width: 300px; height: 60px; margin: 20px"></iframe>
<!DOCTYPE html>
<div style="width: 20px; height: 20px; background: lightgray; display: inline-block; margin: 10px" aria-label="rectA">A</div>
<div style="width: 20px; height: 20px; background: lightgray; display: inline-block; margin: 10px" aria-label="rectB">B</div>
<div style="width: 20px; height: 20px; background: lightgray; display: inline-block; margin: 10px" aria-label="rectC">C</div>
<div style="width: 20px; height: 20px; background: lightgray; display: inline-block; margin: 10px" aria-label="rectD">D</div>
<div style="width: 20px; height: 20px; background: lightgray; display: inline-block; margin: 10px" aria-label="rectE">E</div>
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