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

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: Disable cross-site test temporarily Created 4 years, 6 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
« no previous file with comments | « no previous file | chrome/test/data/extensions/platform_apps/web_view/touch_accessibility/main.html » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 3047 matching lines...) Expand 10 before | Expand all | Expand 10 after
3105 content::WaitForAccessibilityFocusChange(); 3106 content::WaitForAccessibilityFocusChange();
3106 } 3107 }
3107 3108
3108 // Ensure that we hit the button inside the guest frame labeled 3109 // Ensure that we hit the button inside the guest frame labeled
3109 // "Guest button". 3110 // "Guest button".
3110 ui::AXNodeData node_data = 3111 ui::AXNodeData node_data =
3111 content::GetFocusedAccessibilityNodeInfo(web_contents); 3112 content::GetFocusedAccessibilityNodeInfo(web_contents);
3112 EXPECT_EQ("Guest button", node_data.GetStringAttribute(ui::AX_ATTR_NAME)); 3113 EXPECT_EQ("Guest button", node_data.GetStringAttribute(ui::AX_ATTR_NAME));
3113 } 3114 }
3114 3115
3116 class WebContentsAccessibilityEventWatcher
3117 : public content::WebContentsObserver {
3118 public:
3119 WebContentsAccessibilityEventWatcher(
3120 content::WebContents* web_contents,
3121 ui::AXEvent event)
3122 : content::WebContentsObserver(web_contents),
3123 event_(event),
3124 count_(0) {}
3125 ~WebContentsAccessibilityEventWatcher() override {}
3126
3127 void Wait() {
3128 if (count_ == 0) {
3129 loop_runner_ = new content::MessageLoopRunner();
3130 loop_runner_->Run();
3131 }
3132 }
3133
3134 void AccessibilityEventReceived(
3135 const std::vector<content::AXEventNotificationDetails>& details_vector)
3136 override {
3137 for (auto& details : details_vector) {
3138 if (details.event_type == event_ && details.update.nodes.size() > 0) {
3139 count_++;
3140 node_data_ = details.update.nodes[0];
3141 loop_runner_->Quit();
3142 }
3143 }
3144 }
3145
3146 size_t count() const { return count_; }
3147
3148 const ui::AXNodeData& node_data() const { return node_data_; }
3149
3150 private:
3151 scoped_refptr<content::MessageLoopRunner> loop_runner_;
3152 ui::AXEvent event_;
3153 ui::AXNodeData node_data_;
3154 size_t count_;
3155 };
3156
3157 IN_PROC_BROWSER_TEST_P(WebViewAccessibilityTest, TouchAccessibility) {
3158 LoadAppWithGuest("web_view/touch_accessibility");
3159 content::WebContents* web_contents = GetFirstAppWindowWebContents();
3160 content::EnableAccessibilityForWebContents(web_contents);
3161 content::WebContents* guest_web_contents = GetGuestWebContents();
3162 content::EnableAccessibilityForWebContents(guest_web_contents);
3163
3164 // Listen for accessibility events on both WebContents.
3165 WebContentsAccessibilityEventWatcher main_event_watcher(
3166 web_contents, ui::AX_EVENT_HOVER);
3167 WebContentsAccessibilityEventWatcher guest_event_watcher(
3168 guest_web_contents, ui::AX_EVENT_HOVER);
3169
3170 // Send an accessibility touch event to the main WebContents, but
3171 // positioned on top of the button inside the inner WebView.
3172 blink::WebMouseEvent accessibility_touch_event;
3173 accessibility_touch_event.type = blink::WebInputEvent::MouseMove;
3174 accessibility_touch_event.x = 95;
3175 accessibility_touch_event.y = 55;
3176 accessibility_touch_event.modifiers =
3177 blink::WebInputEvent::IsTouchAccessibility;
3178 web_contents->GetRenderViewHost()->GetWidget()->ForwardMouseEvent(
3179 accessibility_touch_event);
3180
3181 // Ensure that we got just a single hover event on the guest WebContents,
3182 // and that it was fired on a button.
3183 guest_event_watcher.Wait();
3184 ui::AXNodeData hit_node = guest_event_watcher.node_data();
3185 EXPECT_EQ(1U, guest_event_watcher.count());
3186 EXPECT_EQ(ui::AX_ROLE_BUTTON, hit_node.role);
3187 EXPECT_EQ(0U, main_event_watcher.count());
3188 }
3189
3115 class WebViewGuestScrollTest 3190 class WebViewGuestScrollTest
3116 : public WebViewTestBase, 3191 : public WebViewTestBase,
3117 public testing::WithParamInterface<testing::tuple<bool, bool>> { 3192 public testing::WithParamInterface<testing::tuple<bool, bool>> {
3118 protected: 3193 protected:
3119 WebViewGuestScrollTest() {} 3194 WebViewGuestScrollTest() {}
3120 ~WebViewGuestScrollTest() {} 3195 ~WebViewGuestScrollTest() {}
3121 3196
3122 void SetUpCommandLine(base::CommandLine* command_line) override { 3197 void SetUpCommandLine(base::CommandLine* command_line) override {
3123 WebViewTestBase::SetUpCommandLine(command_line); 3198 WebViewTestBase::SetUpCommandLine(command_line);
3124 3199
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after
3428 gfx::Point embedder_origin = 3503 gfx::Point embedder_origin =
3429 GetEmbedderWebContents()->GetContainerBounds().origin(); 3504 GetEmbedderWebContents()->GetContainerBounds().origin();
3430 guest_rect.Offset(-embedder_origin.x(), -embedder_origin.y()); 3505 guest_rect.Offset(-embedder_origin.x(), -embedder_origin.y());
3431 3506
3432 // Generate and send synthetic touch event. 3507 // Generate and send synthetic touch event.
3433 content::SimulateTouchPressAt(GetEmbedderWebContents(), 3508 content::SimulateTouchPressAt(GetEmbedderWebContents(),
3434 guest_rect.CenterPoint()); 3509 guest_rect.CenterPoint());
3435 EXPECT_TRUE(aura_webview->HasFocus()); 3510 EXPECT_TRUE(aura_webview->HasFocus());
3436 } 3511 }
3437 #endif 3512 #endif
OLDNEW
« no previous file with comments | « no previous file | chrome/test/data/extensions/platform_apps/web_view/touch_accessibility/main.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698