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

Unified Diff: chrome/browser/apps/guest_view/web_view_browsertest.cc

Issue 2009283002: Fix touch accessibility events in WebViews and iframes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add cross-site iframe test too Created 4 years, 7 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: chrome/browser/apps/guest_view/web_view_browsertest.cc
diff --git a/chrome/browser/apps/guest_view/web_view_browsertest.cc b/chrome/browser/apps/guest_view/web_view_browsertest.cc
index 27c0dc031612700dbd247b2eb5eb62be44b074f6..d4a1ee4f181e841df09660eac083ae35176a1ddc 100644
--- a/chrome/browser/apps/guest_view/web_view_browsertest.cc
+++ b/chrome/browser/apps/guest_view/web_view_browsertest.cc
@@ -45,6 +45,7 @@
#include "components/guest_view/browser/guest_view_manager_delegate.h"
#include "components/guest_view/browser/guest_view_manager_factory.h"
#include "components/guest_view/browser/test_guest_view_manager.h"
+#include "content/public/browser/ax_event_notification_details.h"
#include "content/public/browser/gpu_data_manager.h"
#include "content/public/browser/interstitial_page.h"
#include "content/public/browser/interstitial_page_delegate.h"
@@ -3114,6 +3115,80 @@ IN_PROC_BROWSER_TEST_P(WebViewAccessibilityTest, FocusAccessibility) {
EXPECT_EQ("Guest button", node_data.GetStringAttribute(ui::AX_ATTR_NAME));
}
+class WebContentsAccessibilityEventWatcher
+ : public content::WebContentsObserver {
+ public:
+ WebContentsAccessibilityEventWatcher(
+ content::WebContents* web_contents,
+ ui::AXEvent event)
+ : content::WebContentsObserver(web_contents),
+ event_(event),
+ count_(0) {}
+ ~WebContentsAccessibilityEventWatcher() override {}
+
+ void Wait() {
+ if (count_ == 0) {
+ loop_runner_ = new content::MessageLoopRunner();
+ loop_runner_->Run();
+ }
+ }
+
+ void AccessibilityEventReceived(
+ const std::vector<content::AXEventNotificationDetails>& details_vector)
+ override {
+ for (auto& details : details_vector) {
+ if (details.event_type == event_ && details.update.nodes.size() > 0) {
+ count_++;
+ node_data_ = details.update.nodes[0];
+ loop_runner_->Quit();
+ }
+ }
+ }
+
+ size_t count() const { return count_; }
+
+ const ui::AXNodeData& node_data() const { return node_data_; }
+
+ private:
+ scoped_refptr<content::MessageLoopRunner> loop_runner_;
+ ui::AXEvent event_;
+ ui::AXNodeData node_data_;
+ size_t count_;
+};
+
+IN_PROC_BROWSER_TEST_P(WebViewAccessibilityTest, TouchAccessibility) {
+ LoadAppWithGuest("web_view/touch_accessibility");
+ content::WebContents* web_contents = GetFirstAppWindowWebContents();
+ content::EnableAccessibilityForWebContents(web_contents);
+ content::WebContents* guest_web_contents = GetGuestWebContents();
+ content::EnableAccessibilityForWebContents(guest_web_contents);
+
+ // Listen for accessibility events on both WebContents.
+ WebContentsAccessibilityEventWatcher main_event_watcher(
+ web_contents, ui::AX_EVENT_HOVER);
+ WebContentsAccessibilityEventWatcher guest_event_watcher(
+ guest_web_contents, ui::AX_EVENT_HOVER);
+
+ // Send an accessibility touch event to the main WebContents, but
+ // positioned on top of the button inside the inner WebView.
+ blink::WebMouseEvent accessibility_touch_event;
+ accessibility_touch_event.type = blink::WebInputEvent::MouseMove;
+ accessibility_touch_event.x = 95;
+ accessibility_touch_event.y = 55;
+ accessibility_touch_event.modifiers =
+ blink::WebInputEvent::IsTouchAccessibility;
+ web_contents->GetRenderViewHost()->GetWidget()->ForwardMouseEvent(
+ accessibility_touch_event);
+
+ // Ensure that we got just a single hover event on the guest WebContents,
+ // and that it was fired on a button.
+ guest_event_watcher.Wait();
+ ui::AXNodeData hit_node = guest_event_watcher.node_data();
+ EXPECT_EQ(1U, guest_event_watcher.count());
+ EXPECT_EQ(ui::AX_ROLE_BUTTON, hit_node.role);
+ EXPECT_EQ(0U, main_event_watcher.count());
+}
+
class WebViewGuestScrollTest
: public WebViewTestBase,
public testing::WithParamInterface<testing::tuple<bool, bool>> {

Powered by Google App Engine
This is Rietveld 408576698