| 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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 #include "components/guest_view/browser/test_guest_view_manager.h" | 48 #include "components/guest_view/browser/test_guest_view_manager.h" |
| 49 #include "content/public/browser/ax_event_notification_details.h" | 49 #include "content/public/browser/ax_event_notification_details.h" |
| 50 #include "content/public/browser/gpu_data_manager.h" | 50 #include "content/public/browser/gpu_data_manager.h" |
| 51 #include "content/public/browser/interstitial_page.h" | 51 #include "content/public/browser/interstitial_page.h" |
| 52 #include "content/public/browser/interstitial_page_delegate.h" | 52 #include "content/public/browser/interstitial_page_delegate.h" |
| 53 #include "content/public/browser/notification_service.h" | 53 #include "content/public/browser/notification_service.h" |
| 54 #include "content/public/browser/render_process_host.h" | 54 #include "content/public/browser/render_process_host.h" |
| 55 #include "content/public/browser/render_widget_host.h" | 55 #include "content/public/browser/render_widget_host.h" |
| 56 #include "content/public/browser/render_widget_host_view.h" | 56 #include "content/public/browser/render_widget_host_view.h" |
| 57 #include "content/public/browser/web_contents_delegate.h" | 57 #include "content/public/browser/web_contents_delegate.h" |
| 58 #include "content/public/common/browser_plugin_guest_mode.h" | |
| 59 #include "content/public/common/child_process_host.h" | 58 #include "content/public/common/child_process_host.h" |
| 60 #include "content/public/common/content_switches.h" | 59 #include "content/public/common/content_switches.h" |
| 61 #include "content/public/test/browser_test_utils.h" | 60 #include "content/public/test/browser_test_utils.h" |
| 62 #include "content/public/test/download_test_observer.h" | 61 #include "content/public/test/download_test_observer.h" |
| 63 #include "content/public/test/fake_speech_recognition_manager.h" | 62 #include "content/public/test/fake_speech_recognition_manager.h" |
| 64 #include "content/public/test/test_renderer_host.h" | 63 #include "content/public/test/test_renderer_host.h" |
| 65 #include "extensions/browser/api/declarative/rules_registry.h" | 64 #include "extensions/browser/api/declarative/rules_registry.h" |
| 66 #include "extensions/browser/api/declarative/rules_registry_service.h" | 65 #include "extensions/browser/api/declarative/rules_registry_service.h" |
| 67 #include "extensions/browser/api/declarative/test_rules_registry.h" | 66 #include "extensions/browser/api/declarative/test_rules_registry.h" |
| 68 #include "extensions/browser/api/declarative_webrequest/webrequest_constants.h" | 67 #include "extensions/browser/api/declarative_webrequest/webrequest_constants.h" |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 210 message_loop_runner_->Run(); | 209 message_loop_runner_->Run(); |
| 211 } | 210 } |
| 212 | 211 |
| 213 private: | 212 private: |
| 214 bool terminated_; | 213 bool terminated_; |
| 215 scoped_refptr<content::MessageLoopRunner> message_loop_runner_; | 214 scoped_refptr<content::MessageLoopRunner> message_loop_runner_; |
| 216 | 215 |
| 217 DISALLOW_COPY_AND_ASSIGN(EmbedderWebContentsObserver); | 216 DISALLOW_COPY_AND_ASSIGN(EmbedderWebContentsObserver); |
| 218 }; | 217 }; |
| 219 | 218 |
| 219 bool UseCrossProcessFramesForGuests() { |
| 220 return base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 221 switches::kUseCrossProcessFramesForGuests); |
| 222 } |
| 223 |
| 220 void ExecuteScriptWaitForTitle(content::WebContents* web_contents, | 224 void ExecuteScriptWaitForTitle(content::WebContents* web_contents, |
| 221 const char* script, | 225 const char* script, |
| 222 const char* title) { | 226 const char* title) { |
| 223 base::string16 expected_title(base::ASCIIToUTF16(title)); | 227 base::string16 expected_title(base::ASCIIToUTF16(title)); |
| 224 base::string16 error_title(base::ASCIIToUTF16("error")); | 228 base::string16 error_title(base::ASCIIToUTF16("error")); |
| 225 | 229 |
| 226 content::TitleWatcher title_watcher(web_contents, expected_title); | 230 content::TitleWatcher title_watcher(web_contents, expected_title); |
| 227 title_watcher.AlsoWaitForTitle(error_title); | 231 title_watcher.AlsoWaitForTitle(error_title); |
| 228 EXPECT_TRUE(content::ExecuteScript(web_contents, script)); | 232 EXPECT_TRUE(content::ExecuteScript(web_contents, script)); |
| 229 EXPECT_EQ(expected_title, title_watcher.WaitAndGetTitle()); | 233 EXPECT_EQ(expected_title, title_watcher.WaitAndGetTitle()); |
| (...skipping 856 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1086 false); | 1090 false); |
| 1087 GetEmbedderWebContents()->GetController().Reload(false); | 1091 GetEmbedderWebContents()->GetController().Reload(false); |
| 1088 ASSERT_TRUE(launched_again_listener.WaitUntilSatisfied()); | 1092 ASSERT_TRUE(launched_again_listener.WaitUntilSatisfied()); |
| 1089 } | 1093 } |
| 1090 | 1094 |
| 1091 IN_PROC_BROWSER_TEST_P(WebViewTest, AcceptTouchEvents) { | 1095 IN_PROC_BROWSER_TEST_P(WebViewTest, AcceptTouchEvents) { |
| 1092 // This test only makes sense for non-OOPIF WebView, since with | 1096 // This test only makes sense for non-OOPIF WebView, since with |
| 1093 // UseCrossProcessFramesForGuests() events are routed directly to the | 1097 // UseCrossProcessFramesForGuests() events are routed directly to the |
| 1094 // guest, so the embedder does not need to know about the installation of | 1098 // guest, so the embedder does not need to know about the installation of |
| 1095 // touch handlers. | 1099 // touch handlers. |
| 1096 if (content::BrowserPluginGuestMode::UseCrossProcessFramesForGuests()) | 1100 if (UseCrossProcessFramesForGuests()) |
| 1097 return; | 1101 return; |
| 1098 | 1102 |
| 1099 LoadAppWithGuest("web_view/accept_touch_events"); | 1103 LoadAppWithGuest("web_view/accept_touch_events"); |
| 1100 | 1104 |
| 1101 content::RenderViewHost* embedder_rvh = | 1105 content::RenderViewHost* embedder_rvh = |
| 1102 GetEmbedderWebContents()->GetRenderViewHost(); | 1106 GetEmbedderWebContents()->GetRenderViewHost(); |
| 1103 | 1107 |
| 1104 bool embedder_has_touch_handler = | 1108 bool embedder_has_touch_handler = |
| 1105 content::RenderViewHostTester::HasTouchEventHandler(embedder_rvh); | 1109 content::RenderViewHostTester::HasTouchEventHandler(embedder_rvh); |
| 1106 EXPECT_FALSE(embedder_has_touch_handler); | 1110 EXPECT_FALSE(embedder_has_touch_handler); |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1297 "web_view/shim", | 1301 "web_view/shim", |
| 1298 NO_TEST_SERVER); | 1302 NO_TEST_SERVER); |
| 1299 } | 1303 } |
| 1300 | 1304 |
| 1301 IN_PROC_BROWSER_TEST_P(WebViewTest, Shim_TestDisplayNoneWebviewLoad) { | 1305 IN_PROC_BROWSER_TEST_P(WebViewTest, Shim_TestDisplayNoneWebviewLoad) { |
| 1302 TestHelper("testDisplayNoneWebviewLoad", "web_view/shim", NO_TEST_SERVER); | 1306 TestHelper("testDisplayNoneWebviewLoad", "web_view/shim", NO_TEST_SERVER); |
| 1303 } | 1307 } |
| 1304 | 1308 |
| 1305 IN_PROC_BROWSER_TEST_P(WebViewTest, Shim_TestDisplayNoneWebviewRemoveChild) { | 1309 IN_PROC_BROWSER_TEST_P(WebViewTest, Shim_TestDisplayNoneWebviewRemoveChild) { |
| 1306 // http://crbug.com/585652 | 1310 // http://crbug.com/585652 |
| 1307 if (content::BrowserPluginGuestMode::UseCrossProcessFramesForGuests()) | 1311 if (UseCrossProcessFramesForGuests()) |
| 1308 return; | 1312 return; |
| 1309 TestHelper("testDisplayNoneWebviewRemoveChild", | 1313 TestHelper("testDisplayNoneWebviewRemoveChild", |
| 1310 "web_view/shim", NO_TEST_SERVER); | 1314 "web_view/shim", NO_TEST_SERVER); |
| 1311 } | 1315 } |
| 1312 | 1316 |
| 1313 IN_PROC_BROWSER_TEST_P(WebViewTest, Shim_TestDisplayBlock) { | 1317 IN_PROC_BROWSER_TEST_P(WebViewTest, Shim_TestDisplayBlock) { |
| 1314 TestHelper("testDisplayBlock", "web_view/shim", NO_TEST_SERVER); | 1318 TestHelper("testDisplayBlock", "web_view/shim", NO_TEST_SERVER); |
| 1315 } | 1319 } |
| 1316 | 1320 |
| 1317 IN_PROC_BROWSER_TEST_P(WebViewTest, | 1321 IN_PROC_BROWSER_TEST_P(WebViewTest, |
| 1318 Shim_TestInlineScriptFromAccessibleResources) { | 1322 Shim_TestInlineScriptFromAccessibleResources) { |
| (...skipping 1872 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3191 } | 3195 } |
| 3192 | 3196 |
| 3193 // Ensure that focusing a WebView while it is already focused does not blur the | 3197 // Ensure that focusing a WebView while it is already focused does not blur the |
| 3194 // guest content. | 3198 // guest content. |
| 3195 IN_PROC_BROWSER_TEST_P(WebViewTest, Shim_TestFocusWhileFocused) { | 3199 IN_PROC_BROWSER_TEST_P(WebViewTest, Shim_TestFocusWhileFocused) { |
| 3196 TestHelper("testFocusWhileFocused", "web_view/shim", NO_TEST_SERVER); | 3200 TestHelper("testFocusWhileFocused", "web_view/shim", NO_TEST_SERVER); |
| 3197 } | 3201 } |
| 3198 | 3202 |
| 3199 IN_PROC_BROWSER_TEST_P(WebViewTest, NestedGuestContainerBounds) { | 3203 IN_PROC_BROWSER_TEST_P(WebViewTest, NestedGuestContainerBounds) { |
| 3200 // TODO(lfg): https://crbug.com/581898 | 3204 // TODO(lfg): https://crbug.com/581898 |
| 3201 if (content::BrowserPluginGuestMode::UseCrossProcessFramesForGuests()) | 3205 if (UseCrossProcessFramesForGuests()) |
| 3202 return; | 3206 return; |
| 3203 | 3207 |
| 3204 TestHelper("testPDFInWebview", "web_view/shim", NO_TEST_SERVER); | 3208 TestHelper("testPDFInWebview", "web_view/shim", NO_TEST_SERVER); |
| 3205 | 3209 |
| 3206 std::vector<content::WebContents*> guest_web_contents_list; | 3210 std::vector<content::WebContents*> guest_web_contents_list; |
| 3207 GetGuestViewManager()->WaitForNumGuestsCreated(2u); | 3211 GetGuestViewManager()->WaitForNumGuestsCreated(2u); |
| 3208 GetGuestViewManager()->GetGuestWebContentsList(&guest_web_contents_list); | 3212 GetGuestViewManager()->GetGuestWebContentsList(&guest_web_contents_list); |
| 3209 ASSERT_EQ(2u, guest_web_contents_list.size()); | 3213 ASSERT_EQ(2u, guest_web_contents_list.size()); |
| 3210 | 3214 |
| 3211 content::WebContents* web_view_contents = guest_web_contents_list[0]; | 3215 content::WebContents* web_view_contents = guest_web_contents_list[0]; |
| (...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3525 } | 3529 } |
| 3526 | 3530 |
| 3527 private: | 3531 private: |
| 3528 content::WebContents* web_contents_; | 3532 content::WebContents* web_contents_; |
| 3529 bool expected_focus_; | 3533 bool expected_focus_; |
| 3530 }; | 3534 }; |
| 3531 | 3535 |
| 3532 IN_PROC_BROWSER_TEST_F(WebViewGuestTouchFocusTest, | 3536 IN_PROC_BROWSER_TEST_F(WebViewGuestTouchFocusTest, |
| 3533 TouchFocusesBrowserPluginInEmbedder) { | 3537 TouchFocusesBrowserPluginInEmbedder) { |
| 3534 // This test is only relevant for non-OOPIF WebView. | 3538 // This test is only relevant for non-OOPIF WebView. |
| 3535 if (content::BrowserPluginGuestMode::UseCrossProcessFramesForGuests()) | 3539 if (UseCrossProcessFramesForGuests()) |
| 3536 return; | 3540 return; |
| 3537 | 3541 |
| 3538 LoadAppWithGuest("web_view/guest_focus_test"); | 3542 LoadAppWithGuest("web_view/guest_focus_test"); |
| 3539 | 3543 |
| 3540 // Lookup relevant information about guest and embedder. | 3544 // Lookup relevant information about guest and embedder. |
| 3541 content::WebContents* embedder_contents = GetEmbedderWebContents(); | 3545 content::WebContents* embedder_contents = GetEmbedderWebContents(); |
| 3542 | 3546 |
| 3543 std::vector<content::WebContents*> guest_web_contents_list; | 3547 std::vector<content::WebContents*> guest_web_contents_list; |
| 3544 GetGuestViewManager()->WaitForNumGuestsCreated(1u); | 3548 GetGuestViewManager()->WaitForNumGuestsCreated(1u); |
| 3545 GetGuestViewManager()->GetGuestWebContentsList(&guest_web_contents_list); | 3549 GetGuestViewManager()->GetGuestWebContentsList(&guest_web_contents_list); |
| (...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3830 gfx::Point embedder_origin = | 3834 gfx::Point embedder_origin = |
| 3831 GetEmbedderWebContents()->GetContainerBounds().origin(); | 3835 GetEmbedderWebContents()->GetContainerBounds().origin(); |
| 3832 guest_rect.Offset(-embedder_origin.x(), -embedder_origin.y()); | 3836 guest_rect.Offset(-embedder_origin.x(), -embedder_origin.y()); |
| 3833 | 3837 |
| 3834 // Generate and send synthetic touch event. | 3838 // Generate and send synthetic touch event. |
| 3835 content::SimulateTouchPressAt(GetEmbedderWebContents(), | 3839 content::SimulateTouchPressAt(GetEmbedderWebContents(), |
| 3836 guest_rect.CenterPoint()); | 3840 guest_rect.CenterPoint()); |
| 3837 EXPECT_TRUE(aura_webview->HasFocus()); | 3841 EXPECT_TRUE(aura_webview->HasFocus()); |
| 3838 } | 3842 } |
| 3839 #endif | 3843 #endif |
| OLD | NEW |