Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(238)

Unified Diff: content/browser/accessibility/hit_testing_browsertest.cc

Issue 2748463003: Generalize the HIT_TEST accessibility action so that it can send any event. (Closed)
Patch Set: Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/browser/accessibility/hit_testing_browsertest.cc
diff --git a/content/browser/accessibility/hit_testing_browsertest.cc b/content/browser/accessibility/hit_testing_browsertest.cc
index afcb4f6eba18886556027c076c0b7402d2ac9693..2b1acd00da56363b58c1489bbe1da3cdfdde456f 100644
--- a/content/browser/accessibility/hit_testing_browsertest.cc
+++ b/content/browser/accessibility/hit_testing_browsertest.cc
@@ -23,30 +23,39 @@ class AccessibilityHitTestingBrowserTest : public ContentBrowserTest {
~AccessibilityHitTestingBrowserTest() override {}
protected:
- BrowserAccessibility* HitTestAndWaitForResult(const gfx::Point& point) {
+ BrowserAccessibility* HitTestAndWaitForResultWithEvent(
+ const gfx::Point& point,
+ ui::AXEvent event_to_fire) {
WebContentsImpl* web_contents =
static_cast<WebContentsImpl*>(shell()->web_contents());
FrameTree* frame_tree = web_contents->GetFrameTree();
BrowserAccessibilityManager* manager =
web_contents->GetRootBrowserAccessibilityManager();
- AccessibilityNotificationWaiter hover_waiter(
- shell()->web_contents(), ACCESSIBILITY_MODE_COMPLETE,
- ui::AX_EVENT_HOVER);
+ AccessibilityNotificationWaiter event_waiter(
+ shell()->web_contents(), ACCESSIBILITY_MODE_COMPLETE, event_to_fire);
for (FrameTreeNode* node : frame_tree->Nodes())
- hover_waiter.ListenToAdditionalFrame(node->current_frame_host());
- manager->HitTest(point);
- hover_waiter.WaitForNotification();
-
- RenderFrameHostImpl* target_frame = hover_waiter.event_render_frame_host();
+ event_waiter.ListenToAdditionalFrame(node->current_frame_host());
+ ui::AXActionData action_data;
+ action_data.action = ui::AX_ACTION_HIT_TEST;
+ action_data.target_point = point;
+ action_data.hit_test_event_to_fire = event_to_fire;
+ manager->delegate()->AccessibilityPerformAction(action_data);
+ event_waiter.WaitForNotification();
+
+ RenderFrameHostImpl* target_frame = event_waiter.event_render_frame_host();
BrowserAccessibilityManager* target_manager =
target_frame->browser_accessibility_manager();
- int hover_target_id = hover_waiter.event_target_id();
+ int event_target_id = event_waiter.event_target_id();
BrowserAccessibility* hovered_node =
David Tseng 2017/03/13 21:43:47 nit: hit_node
dmazzoni 2017/03/20 05:40:39 Done.
- target_manager->GetFromID(hover_target_id);
+ target_manager->GetFromID(event_target_id);
return hovered_node;
}
+ BrowserAccessibility* HitTestAndWaitForResult(const gfx::Point& point) {
+ return HitTestAndWaitForResultWithEvent(point, ui::AX_EVENT_HOVER);
+ }
+
BrowserAccessibility* CallCachingAsyncHitTest(const gfx::Point& point) {
WebContentsImpl* web_contents =
static_cast<WebContentsImpl*>(shell()->web_contents());
@@ -150,6 +159,13 @@ IN_PROC_BROWSER_TEST_F(AccessibilityHitTestingBrowserTest,
hovered_node = HitTestAndWaitForResult(gfx::Point(50, 505));
ASSERT_TRUE(hovered_node != NULL);
ASSERT_EQ(ui::AX_ROLE_DIV, hovered_node->GetRole());
+
+ // (50, 505) -> div in second iframe
+ // but with a different event
+ hovered_node =
+ HitTestAndWaitForResultWithEvent(gfx::Point(50, 505), ui::AX_EVENT_ALERT);
+ ASSERT_TRUE(hovered_node != NULL);
David Tseng 2017/03/13 21:43:47 nit: ASSERT_NE
dmazzoni 2017/03/20 05:40:39 Done.
+ ASSERT_EQ(ui::AX_ROLE_DIV, hovered_node->GetRole());
}
IN_PROC_BROWSER_TEST_F(AccessibilityHitTestingBrowserTest,

Powered by Google App Engine
This is Rietveld 408576698