OLD | NEW |
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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 #include "ui/base/l10n/l10n_util.h" | 80 #include "ui/base/l10n/l10n_util.h" |
81 #include "ui/compositor/compositor.h" | 81 #include "ui/compositor/compositor.h" |
82 #include "ui/compositor/compositor_observer.h" | 82 #include "ui/compositor/compositor_observer.h" |
83 #include "ui/display/display_switches.h" | 83 #include "ui/display/display_switches.h" |
84 #include "ui/events/event_switches.h" | 84 #include "ui/events/event_switches.h" |
85 #include "ui/events/gesture_detection/gesture_configuration.h" | 85 #include "ui/events/gesture_detection/gesture_configuration.h" |
86 #include "ui/gl/gl_switches.h" | 86 #include "ui/gl/gl_switches.h" |
87 #include "ui/views/view.h" | 87 #include "ui/views/view.h" |
88 #include "ui/views/widget/widget.h" | 88 #include "ui/views/widget/widget.h" |
89 | 89 |
| 90 #if defined (USE_AURA) |
| 91 #include "content/common/view_messages.h" |
| 92 #include "content/public/browser/browser_message_filter.h" |
| 93 #include "ipc/ipc_message_macros.h" |
| 94 #endif |
| 95 |
90 #if defined(ENABLE_PLUGINS) | 96 #if defined(ENABLE_PLUGINS) |
91 #include "content/public/browser/plugin_service.h" | 97 #include "content/public/browser/plugin_service.h" |
92 #include "content/public/common/webplugininfo.h" | 98 #include "content/public/common/webplugininfo.h" |
93 #include "content/public/test/ppapi_test_utils.h" | 99 #include "content/public/test/ppapi_test_utils.h" |
94 #endif | 100 #endif |
95 | 101 |
96 #if defined(OS_CHROMEOS) | 102 #if defined(OS_CHROMEOS) |
97 #include "ash/common/accessibility_types.h" | 103 #include "ash/common/accessibility_types.h" |
98 #include "chrome/browser/chromeos/accessibility/accessibility_manager.h" | 104 #include "chrome/browser/chromeos/accessibility/accessibility_manager.h" |
99 #include "chrome/browser/chromeos/accessibility/speech_monitor.h" | 105 #include "chrome/browser/chromeos/accessibility/speech_monitor.h" |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 if (std::string(current->GetClassName()).find("WebView") != | 245 if (std::string(current->GetClassName()).find("WebView") != |
240 std::string::npos) { | 246 std::string::npos) { |
241 return current; | 247 return current; |
242 } | 248 } |
243 | 249 |
244 for (int i = 0; i < current->child_count(); ++i) | 250 for (int i = 0; i < current->child_count(); ++i) |
245 queue.push(current->child_at(i)); | 251 queue.push(current->child_at(i)); |
246 } | 252 } |
247 return nullptr; | 253 return nullptr; |
248 } | 254 } |
| 255 |
| 256 // Waits for widget shown/closed. |
| 257 class WidgetUpdatedWaiter : public content::BrowserMessageFilter { |
| 258 public: |
| 259 explicit WidgetUpdatedWaiter(content::WebContents* web_contents) |
| 260 : content::BrowserMessageFilter(ViewMsgStart) { |
| 261 web_contents->GetRenderProcessHost()->AddFilter(this); |
| 262 } |
| 263 |
| 264 bool OnMessageReceived(const IPC::Message& message) override { |
| 265 IPC_BEGIN_MESSAGE_MAP(WidgetUpdatedWaiter, message) |
| 266 IPC_MESSAGE_HANDLER(ViewHostMsg_ShowWidget, OnShowWidget) |
| 267 IPC_MESSAGE_HANDLER(ViewHostMsg_Close, OnCloseWidget) |
| 268 IPC_END_MESSAGE_MAP() |
| 269 return false; |
| 270 } |
| 271 |
| 272 void Wait() { |
| 273 message_loop_runner_ = new content::MessageLoopRunner; |
| 274 message_loop_runner_->Run(); |
| 275 base::RunLoop().RunUntilIdle(); |
| 276 } |
| 277 |
| 278 private: |
| 279 ~WidgetUpdatedWaiter() override {} |
| 280 |
| 281 void OnShowWidget(int route_id, const gfx::Rect& initial_rect) { |
| 282 content::BrowserThread::PostTask( |
| 283 content::BrowserThread::UI, FROM_HERE, |
| 284 base::Bind(&WidgetUpdatedWaiter::OnWidgetUpdatedOnUI, this)); |
| 285 } |
| 286 void OnCloseWidget() { |
| 287 content::BrowserThread::PostTask( |
| 288 content::BrowserThread::UI, FROM_HERE, |
| 289 base::Bind(&WidgetUpdatedWaiter::OnWidgetUpdatedOnUI, this)); |
| 290 } |
| 291 |
| 292 void OnWidgetUpdatedOnUI() { |
| 293 message_loop_runner_->Quit(); |
| 294 } |
| 295 |
| 296 scoped_refptr<content::MessageLoopRunner> message_loop_runner_; |
| 297 |
| 298 DISALLOW_COPY_AND_ASSIGN(WidgetUpdatedWaiter); |
| 299 }; |
249 #endif | 300 #endif |
250 | 301 |
251 } // namespace | 302 } // namespace |
252 | 303 |
253 // This class intercepts media access request from the embedder. The request | 304 // This class intercepts media access request from the embedder. The request |
254 // should be triggered only if the embedder API (from tests) allows the request | 305 // should be triggered only if the embedder API (from tests) allows the request |
255 // in Javascript. | 306 // in Javascript. |
256 // We do not issue the actual media request; the fact that the request reached | 307 // We do not issue the actual media request; the fact that the request reached |
257 // embedder's WebContents is good enough for our tests. This is also to make | 308 // embedder's WebContents is good enough for our tests. This is also to make |
258 // the test run successfully on trybots. | 309 // the test run successfully on trybots. |
(...skipping 861 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1120 | 1171 |
1121 // Tests that addListener call succeeds on webview's WebRequest API events. | 1172 // Tests that addListener call succeeds on webview's WebRequest API events. |
1122 IN_PROC_BROWSER_TEST_P(WebViewTest, Shim_TestWebRequestAPIAddListener) { | 1173 IN_PROC_BROWSER_TEST_P(WebViewTest, Shim_TestWebRequestAPIAddListener) { |
1123 TestHelper("testWebRequestAPIAddListener", "web_view/shim", NO_TEST_SERVER); | 1174 TestHelper("testWebRequestAPIAddListener", "web_view/shim", NO_TEST_SERVER); |
1124 } | 1175 } |
1125 | 1176 |
1126 IN_PROC_BROWSER_TEST_P(WebViewTest, Shim_TestWebRequestAPIErrorOccurred) { | 1177 IN_PROC_BROWSER_TEST_P(WebViewTest, Shim_TestWebRequestAPIErrorOccurred) { |
1127 TestHelper("testWebRequestAPIErrorOccurred", "web_view/shim", NO_TEST_SERVER); | 1178 TestHelper("testWebRequestAPIErrorOccurred", "web_view/shim", NO_TEST_SERVER); |
1128 } | 1179 } |
1129 | 1180 |
| 1181 #if defined(USE_AURA) |
| 1182 // Test validates that select tag can be shown and hidden in webview safely |
| 1183 // using quick touch. |
| 1184 IN_PROC_BROWSER_TEST_P(WebViewTest, SelectShowHide) { |
| 1185 LoadAppWithGuest("web_view/select"); |
| 1186 |
| 1187 content::WebContents* embedder_contents = GetFirstAppWindowWebContents(); |
| 1188 ASSERT_TRUE(embedder_contents); |
| 1189 |
| 1190 std::vector<content::WebContents*> guest_contents_list; |
| 1191 GetGuestViewManager()->GetGuestWebContentsList(&guest_contents_list); |
| 1192 ASSERT_EQ(1u, guest_contents_list.size()); |
| 1193 content::WebContents* guest_contents = guest_contents_list[0]; |
| 1194 |
| 1195 const gfx::Rect embedder_rect = embedder_contents->GetContainerBounds(); |
| 1196 const gfx::Rect guest_rect = guest_contents->GetContainerBounds(); |
| 1197 const gfx::Point click_point(guest_rect.x() - embedder_rect.x() + 10, |
| 1198 guest_rect.y() - embedder_rect.y() + 10); |
| 1199 |
| 1200 scoped_refptr<WidgetUpdatedWaiter> widget_updated_waiter = |
| 1201 new WidgetUpdatedWaiter(guest_contents); |
| 1202 |
| 1203 for (int i = 0; i < 10; ++i) { |
| 1204 // Important, pass mouse click to embedder in order to transfer focus. |
| 1205 content::SimulateMouseClickAt( |
| 1206 embedder_contents, 0, blink::WebMouseEvent::ButtonLeft, click_point); |
| 1207 widget_updated_waiter->Wait(); |
| 1208 } |
| 1209 } |
| 1210 #endif |
| 1211 |
1130 // http://crbug.com/315920 | 1212 // http://crbug.com/315920 |
1131 #if defined(GOOGLE_CHROME_BUILD) && (defined(OS_WIN) || defined(OS_LINUX)) | 1213 #if defined(GOOGLE_CHROME_BUILD) && (defined(OS_WIN) || defined(OS_LINUX)) |
1132 #define MAYBE_Shim_TestChromeExtensionURL DISABLED_Shim_TestChromeExtensionURL | 1214 #define MAYBE_Shim_TestChromeExtensionURL DISABLED_Shim_TestChromeExtensionURL |
1133 #else | 1215 #else |
1134 #define MAYBE_Shim_TestChromeExtensionURL Shim_TestChromeExtensionURL | 1216 #define MAYBE_Shim_TestChromeExtensionURL Shim_TestChromeExtensionURL |
1135 #endif | 1217 #endif |
1136 IN_PROC_BROWSER_TEST_P(WebViewTest, MAYBE_Shim_TestChromeExtensionURL) { | 1218 IN_PROC_BROWSER_TEST_P(WebViewTest, MAYBE_Shim_TestChromeExtensionURL) { |
1137 TestHelper("testChromeExtensionURL", "web_view/shim", NO_TEST_SERVER); | 1219 TestHelper("testChromeExtensionURL", "web_view/shim", NO_TEST_SERVER); |
1138 } | 1220 } |
1139 | 1221 |
(...skipping 2536 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3676 gfx::Point embedder_origin = | 3758 gfx::Point embedder_origin = |
3677 GetEmbedderWebContents()->GetContainerBounds().origin(); | 3759 GetEmbedderWebContents()->GetContainerBounds().origin(); |
3678 guest_rect.Offset(-embedder_origin.x(), -embedder_origin.y()); | 3760 guest_rect.Offset(-embedder_origin.x(), -embedder_origin.y()); |
3679 | 3761 |
3680 // Generate and send synthetic touch event. | 3762 // Generate and send synthetic touch event. |
3681 content::SimulateTouchPressAt(GetEmbedderWebContents(), | 3763 content::SimulateTouchPressAt(GetEmbedderWebContents(), |
3682 guest_rect.CenterPoint()); | 3764 guest_rect.CenterPoint()); |
3683 EXPECT_TRUE(aura_webview->HasFocus()); | 3765 EXPECT_TRUE(aura_webview->HasFocus()); |
3684 } | 3766 } |
3685 #endif | 3767 #endif |
OLD | NEW |