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

Side by Side 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 unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <queue> 5 #include <queue>
6 #include <set> 6 #include <set>
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/callback_helpers.h" 9 #include "base/callback_helpers.h"
10 #include "base/files/file_util.h" 10 #include "base/files/file_util.h"
(...skipping 27 matching lines...) Expand all
38 #include "chrome/browser/task_management/task_manager_browsertest_util.h" 38 #include "chrome/browser/task_management/task_manager_browsertest_util.h"
39 #include "chrome/browser/ui/browser.h" 39 #include "chrome/browser/ui/browser.h"
40 #include "chrome/browser/ui/browser_dialogs.h" 40 #include "chrome/browser/ui/browser_dialogs.h"
41 #include "chrome/browser/ui/tabs/tab_strip_model.h" 41 #include "chrome/browser/ui/tabs/tab_strip_model.h"
42 #include "chrome/test/base/ui_test_utils.h" 42 #include "chrome/test/base/ui_test_utils.h"
43 #include "components/content_settings/core/browser/host_content_settings_map.h" 43 #include "components/content_settings/core/browser/host_content_settings_map.h"
44 #include "components/guest_view/browser/guest_view_manager.h" 44 #include "components/guest_view/browser/guest_view_manager.h"
45 #include "components/guest_view/browser/guest_view_manager_delegate.h" 45 #include "components/guest_view/browser/guest_view_manager_delegate.h"
46 #include "components/guest_view/browser/guest_view_manager_factory.h" 46 #include "components/guest_view/browser/guest_view_manager_factory.h"
47 #include "components/guest_view/browser/test_guest_view_manager.h" 47 #include "components/guest_view/browser/test_guest_view_manager.h"
48 #include "content/public/browser/ax_event_notification_details.h"
48 #include "content/public/browser/gpu_data_manager.h" 49 #include "content/public/browser/gpu_data_manager.h"
49 #include "content/public/browser/interstitial_page.h" 50 #include "content/public/browser/interstitial_page.h"
50 #include "content/public/browser/interstitial_page_delegate.h" 51 #include "content/public/browser/interstitial_page_delegate.h"
51 #include "content/public/browser/notification_service.h" 52 #include "content/public/browser/notification_service.h"
52 #include "content/public/browser/render_process_host.h" 53 #include "content/public/browser/render_process_host.h"
53 #include "content/public/browser/render_widget_host.h" 54 #include "content/public/browser/render_widget_host.h"
54 #include "content/public/browser/render_widget_host_view.h" 55 #include "content/public/browser/render_widget_host_view.h"
55 #include "content/public/browser/web_contents_delegate.h" 56 #include "content/public/browser/web_contents_delegate.h"
56 #include "content/public/common/browser_plugin_guest_mode.h" 57 #include "content/public/common/browser_plugin_guest_mode.h"
57 #include "content/public/common/child_process_host.h" 58 #include "content/public/common/child_process_host.h"
(...skipping 3049 matching lines...) Expand 10 before | Expand all | Expand 10 after
3107 content::WaitForAccessibilityFocusChange(); 3108 content::WaitForAccessibilityFocusChange();
3108 } 3109 }
3109 3110
3110 // Ensure that we hit the button inside the guest frame labeled 3111 // Ensure that we hit the button inside the guest frame labeled
3111 // "Guest button". 3112 // "Guest button".
3112 ui::AXNodeData node_data = 3113 ui::AXNodeData node_data =
3113 content::GetFocusedAccessibilityNodeInfo(web_contents); 3114 content::GetFocusedAccessibilityNodeInfo(web_contents);
3114 EXPECT_EQ("Guest button", node_data.GetStringAttribute(ui::AX_ATTR_NAME)); 3115 EXPECT_EQ("Guest button", node_data.GetStringAttribute(ui::AX_ATTR_NAME));
3115 } 3116 }
3116 3117
3118 class WebContentsAccessibilityEventWatcher
3119 : public content::WebContentsObserver {
3120 public:
3121 WebContentsAccessibilityEventWatcher(
3122 content::WebContents* web_contents,
3123 ui::AXEvent event)
3124 : content::WebContentsObserver(web_contents),
3125 event_(event),
3126 count_(0) {}
3127 ~WebContentsAccessibilityEventWatcher() override {}
3128
3129 void Wait() {
3130 if (count_ == 0) {
3131 loop_runner_ = new content::MessageLoopRunner();
3132 loop_runner_->Run();
3133 }
3134 }
3135
3136 void AccessibilityEventReceived(
3137 const std::vector<content::AXEventNotificationDetails>& details_vector)
3138 override {
3139 for (auto& details : details_vector) {
3140 if (details.event_type == event_ && details.update.nodes.size() > 0) {
3141 count_++;
3142 node_data_ = details.update.nodes[0];
3143 loop_runner_->Quit();
3144 }
3145 }
3146 }
3147
3148 size_t count() const { return count_; }
3149
3150 const ui::AXNodeData& node_data() const { return node_data_; }
3151
3152 private:
3153 scoped_refptr<content::MessageLoopRunner> loop_runner_;
3154 ui::AXEvent event_;
3155 ui::AXNodeData node_data_;
3156 size_t count_;
3157 };
3158
3159 IN_PROC_BROWSER_TEST_P(WebViewAccessibilityTest, TouchAccessibility) {
3160 LoadAppWithGuest("web_view/touch_accessibility");
3161 content::WebContents* web_contents = GetFirstAppWindowWebContents();
3162 content::EnableAccessibilityForWebContents(web_contents);
3163 content::WebContents* guest_web_contents = GetGuestWebContents();
3164 content::EnableAccessibilityForWebContents(guest_web_contents);
3165
3166 // Listen for accessibility events on both WebContents.
3167 WebContentsAccessibilityEventWatcher main_event_watcher(
3168 web_contents, ui::AX_EVENT_HOVER);
3169 WebContentsAccessibilityEventWatcher guest_event_watcher(
3170 guest_web_contents, ui::AX_EVENT_HOVER);
3171
3172 // Send an accessibility touch event to the main WebContents, but
3173 // positioned on top of the button inside the inner WebView.
3174 blink::WebMouseEvent accessibility_touch_event;
3175 accessibility_touch_event.type = blink::WebInputEvent::MouseMove;
3176 accessibility_touch_event.x = 95;
3177 accessibility_touch_event.y = 55;
3178 accessibility_touch_event.modifiers =
3179 blink::WebInputEvent::IsTouchAccessibility;
3180 web_contents->GetRenderViewHost()->GetWidget()->ForwardMouseEvent(
3181 accessibility_touch_event);
3182
3183 // Ensure that we got just a single hover event on the guest WebContents,
3184 // and that it was fired on a button.
3185 guest_event_watcher.Wait();
3186 ui::AXNodeData hit_node = guest_event_watcher.node_data();
3187 EXPECT_EQ(1U, guest_event_watcher.count());
3188 EXPECT_EQ(ui::AX_ROLE_BUTTON, hit_node.role);
3189 EXPECT_EQ(0U, main_event_watcher.count());
3190 }
3191
3117 class WebViewGuestScrollTest 3192 class WebViewGuestScrollTest
3118 : public WebViewTestBase, 3193 : public WebViewTestBase,
3119 public testing::WithParamInterface<testing::tuple<bool, bool>> { 3194 public testing::WithParamInterface<testing::tuple<bool, bool>> {
3120 protected: 3195 protected:
3121 WebViewGuestScrollTest() {} 3196 WebViewGuestScrollTest() {}
3122 ~WebViewGuestScrollTest() {} 3197 ~WebViewGuestScrollTest() {}
3123 3198
3124 void SetUpCommandLine(base::CommandLine* command_line) override { 3199 void SetUpCommandLine(base::CommandLine* command_line) override {
3125 WebViewTestBase::SetUpCommandLine(command_line); 3200 WebViewTestBase::SetUpCommandLine(command_line);
3126 3201
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after
3430 gfx::Point embedder_origin = 3505 gfx::Point embedder_origin =
3431 GetEmbedderWebContents()->GetContainerBounds().origin(); 3506 GetEmbedderWebContents()->GetContainerBounds().origin();
3432 guest_rect.Offset(-embedder_origin.x(), -embedder_origin.y()); 3507 guest_rect.Offset(-embedder_origin.x(), -embedder_origin.y());
3433 3508
3434 // Generate and send synthetic touch event. 3509 // Generate and send synthetic touch event.
3435 content::SimulateTouchPressAt(GetEmbedderWebContents(), 3510 content::SimulateTouchPressAt(GetEmbedderWebContents(),
3436 guest_rect.CenterPoint()); 3511 guest_rect.CenterPoint());
3437 EXPECT_TRUE(aura_webview->HasFocus()); 3512 EXPECT_TRUE(aura_webview->HasFocus());
3438 } 3513 }
3439 #endif 3514 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698