| 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 44 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 45 #include "chrome/test/base/ui_test_utils.h" | 45 #include "chrome/test/base/ui_test_utils.h" |
| 46 #include "components/content_settings/core/browser/host_content_settings_map.h" | 46 #include "components/content_settings/core/browser/host_content_settings_map.h" |
| 47 #include "components/guest_view/browser/guest_view_manager.h" | 47 #include "components/guest_view/browser/guest_view_manager.h" |
| 48 #include "components/guest_view/browser/guest_view_manager_delegate.h" | 48 #include "components/guest_view/browser/guest_view_manager_delegate.h" |
| 49 #include "components/guest_view/browser/guest_view_manager_factory.h" | 49 #include "components/guest_view/browser/guest_view_manager_factory.h" |
| 50 #include "components/guest_view/browser/test_guest_view_manager.h" | 50 #include "components/guest_view/browser/test_guest_view_manager.h" |
| 51 #include "content/public/browser/ax_event_notification_details.h" | 51 #include "content/public/browser/ax_event_notification_details.h" |
| 52 #include "content/public/browser/gpu_data_manager.h" | 52 #include "content/public/browser/gpu_data_manager.h" |
| 53 #include "content/public/browser/interstitial_page.h" | 53 #include "content/public/browser/interstitial_page.h" |
| 54 #include "content/public/browser/interstitial_page_delegate.h" | |
| 55 #include "content/public/browser/notification_service.h" | 54 #include "content/public/browser/notification_service.h" |
| 56 #include "content/public/browser/render_process_host.h" | 55 #include "content/public/browser/render_process_host.h" |
| 57 #include "content/public/browser/render_widget_host.h" | 56 #include "content/public/browser/render_widget_host.h" |
| 58 #include "content/public/browser/render_widget_host_view.h" | 57 #include "content/public/browser/render_widget_host_view.h" |
| 59 #include "content/public/browser/web_contents_delegate.h" | 58 #include "content/public/browser/web_contents_delegate.h" |
| 60 #include "content/public/common/child_process_host.h" | 59 #include "content/public/common/child_process_host.h" |
| 61 #include "content/public/common/content_features.h" | 60 #include "content/public/common/content_features.h" |
| 62 #include "content/public/common/content_switches.h" | 61 #include "content/public/common/content_switches.h" |
| 63 #include "content/public/test/browser_test_utils.h" | 62 #include "content/public/test/browser_test_utils.h" |
| 64 #include "content/public/test/download_test_observer.h" | 63 #include "content/public/test/download_test_observer.h" |
| 65 #include "content/public/test/fake_speech_recognition_manager.h" | 64 #include "content/public/test/fake_speech_recognition_manager.h" |
| 66 #include "content/public/test/test_navigation_observer.h" | 65 #include "content/public/test/test_navigation_observer.h" |
| 67 #include "content/public/test/test_renderer_host.h" | 66 #include "content/public/test/test_renderer_host.h" |
| 68 #include "content/public/test/test_utils.h" | 67 #include "content/public/test/test_utils.h" |
| 69 #include "extensions/browser/api/declarative/rules_registry.h" | 68 #include "extensions/browser/api/declarative/rules_registry.h" |
| 70 #include "extensions/browser/api/declarative/rules_registry_service.h" | 69 #include "extensions/browser/api/declarative/rules_registry_service.h" |
| 71 #include "extensions/browser/api/declarative/test_rules_registry.h" | 70 #include "extensions/browser/api/declarative/test_rules_registry.h" |
| 72 #include "extensions/browser/api/declarative_webrequest/webrequest_constants.h" | 71 #include "extensions/browser/api/declarative_webrequest/webrequest_constants.h" |
| 73 #include "extensions/browser/api/extensions_api_client.h" | 72 #include "extensions/browser/api/extensions_api_client.h" |
| 74 #include "extensions/browser/app_window/native_app_window.h" | 73 #include "extensions/browser/app_window/native_app_window.h" |
| 75 #include "extensions/browser/guest_view/web_view/web_view_guest.h" | 74 #include "extensions/browser/guest_view/web_view/web_view_guest.h" |
| 76 #include "extensions/common/extension.h" | 75 #include "extensions/common/extension.h" |
| 77 #include "extensions/common/extensions_client.h" | 76 #include "extensions/common/extensions_client.h" |
| 78 #include "extensions/test/extension_test_message_listener.h" | 77 #include "extensions/test/extension_test_message_listener.h" |
| 79 #include "media/base/media_switches.h" | 78 #include "media/base/media_switches.h" |
| 80 #include "net/test/embedded_test_server/embedded_test_server.h" | 79 #include "net/test/embedded_test_server/embedded_test_server.h" |
| 81 #include "net/test/embedded_test_server/http_request.h" | 80 #include "net/test/embedded_test_server/http_request.h" |
| 82 #include "net/test/embedded_test_server/http_response.h" | 81 #include "net/test/embedded_test_server/http_response.h" |
| 83 #include "ppapi/features/features.h" | 82 #include "ppapi/features/features.h" |
| 83 #include "third_party/WebKit/public/platform/WebMouseEvent.h" |
| 84 #include "ui/aura/env.h" | 84 #include "ui/aura/env.h" |
| 85 #include "ui/aura/window.h" | 85 #include "ui/aura/window.h" |
| 86 #include "ui/compositor/compositor.h" | 86 #include "ui/compositor/compositor.h" |
| 87 #include "ui/compositor/compositor_observer.h" | 87 #include "ui/compositor/compositor_observer.h" |
| 88 #include "ui/display/display_switches.h" | 88 #include "ui/display/display_switches.h" |
| 89 #include "ui/events/gesture_detection/gesture_configuration.h" | 89 #include "ui/events/gesture_detection/gesture_configuration.h" |
| 90 #include "ui/gl/gl_switches.h" | 90 #include "ui/gl/gl_switches.h" |
| 91 #include "ui/views/view.h" | 91 #include "ui/views/view.h" |
| 92 #include "ui/views/widget/widget.h" | 92 #include "ui/views/widget/widget.h" |
| 93 | 93 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 117 using ui::MenuModel; | 117 using ui::MenuModel; |
| 118 | 118 |
| 119 namespace { | 119 namespace { |
| 120 const char kEmptyResponsePath[] = "/close-socket"; | 120 const char kEmptyResponsePath[] = "/close-socket"; |
| 121 const char kRedirectResponsePath[] = "/server-redirect"; | 121 const char kRedirectResponsePath[] = "/server-redirect"; |
| 122 const char kUserAgentRedirectResponsePath[] = "/detect-user-agent"; | 122 const char kUserAgentRedirectResponsePath[] = "/detect-user-agent"; |
| 123 const char kCacheResponsePath[] = "/cache-control-response"; | 123 const char kCacheResponsePath[] = "/cache-control-response"; |
| 124 const char kRedirectResponseFullPath[] = | 124 const char kRedirectResponseFullPath[] = |
| 125 "/extensions/platform_apps/web_view/shim/guest_redirect.html"; | 125 "/extensions/platform_apps/web_view/shim/guest_redirect.html"; |
| 126 | 126 |
| 127 class TestInterstitialPageDelegate : public content::InterstitialPageDelegate { | |
| 128 public: | |
| 129 TestInterstitialPageDelegate() { | |
| 130 } | |
| 131 ~TestInterstitialPageDelegate() override {} | |
| 132 std::string GetHTMLContents() override { return std::string(); } | |
| 133 }; | |
| 134 | |
| 135 class WebContentsHiddenObserver : public content::WebContentsObserver { | 127 class WebContentsHiddenObserver : public content::WebContentsObserver { |
| 136 public: | 128 public: |
| 137 WebContentsHiddenObserver(content::WebContents* web_contents, | 129 WebContentsHiddenObserver(content::WebContents* web_contents, |
| 138 const base::Closure& hidden_callback) | 130 const base::Closure& hidden_callback) |
| 139 : WebContentsObserver(web_contents), | 131 : WebContentsObserver(web_contents), |
| 140 hidden_callback_(hidden_callback), | 132 hidden_callback_(hidden_callback), |
| 141 hidden_observed_(false) { | 133 hidden_observed_(false) { |
| 142 } | 134 } |
| 143 | 135 |
| 144 // WebContentsObserver. | 136 // WebContentsObserver. |
| (...skipping 539 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 684 content::Source<content::NavigationController> source = | 676 content::Source<content::NavigationController> source = |
| 685 guest_observer.source(); | 677 guest_observer.source(); |
| 686 EXPECT_TRUE(source->GetWebContents()->GetRenderProcessHost()-> | 678 EXPECT_TRUE(source->GetWebContents()->GetRenderProcessHost()-> |
| 687 IsForGuestsOnly()); | 679 IsForGuestsOnly()); |
| 688 | 680 |
| 689 content::WebContents* guest_web_contents = source->GetWebContents(); | 681 content::WebContents* guest_web_contents = source->GetWebContents(); |
| 690 return guest_web_contents; | 682 return guest_web_contents; |
| 691 } | 683 } |
| 692 | 684 |
| 693 // Helper to load interstitial page in a <webview>. | 685 // Helper to load interstitial page in a <webview>. |
| 694 void InterstitialTeardownTestHelper() { | 686 void InterstitialTestHelper() { |
| 695 // Start a HTTPS server so we can load an interstitial page inside guest. | 687 // Start a HTTPS server so we can load an interstitial page inside guest. |
| 696 net::EmbeddedTestServer https_server(net::EmbeddedTestServer::TYPE_HTTPS); | 688 net::EmbeddedTestServer https_server(net::EmbeddedTestServer::TYPE_HTTPS); |
| 697 https_server.SetSSLConfig(net::EmbeddedTestServer::CERT_MISMATCHED_NAME); | 689 https_server.SetSSLConfig(net::EmbeddedTestServer::CERT_MISMATCHED_NAME); |
| 698 https_server.ServeFilesFromSourceDirectory("chrome/test/data"); | 690 https_server.ServeFilesFromSourceDirectory("chrome/test/data"); |
| 699 ASSERT_TRUE(https_server.Start()); | 691 ASSERT_TRUE(https_server.Start()); |
| 700 | 692 |
| 701 net::HostPortPair host_and_port = https_server.host_port_pair(); | 693 net::HostPortPair host_and_port = https_server.host_port_pair(); |
| 702 | 694 |
| 703 LoadAndLaunchPlatformApp("web_view/interstitial_teardown", | 695 LoadAndLaunchPlatformApp("web_view/interstitial_teardown", |
| 704 "EmbedderLoaded"); | 696 "EmbedderLoaded"); |
| (...skipping 985 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1690 "web_view/shim", | 1682 "web_view/shim", |
| 1691 NO_TEST_SERVER); | 1683 NO_TEST_SERVER); |
| 1692 } | 1684 } |
| 1693 | 1685 |
| 1694 IN_PROC_BROWSER_TEST_P(WebViewSizeTest, Shim_TestResizeWebviewResizesContent) { | 1686 IN_PROC_BROWSER_TEST_P(WebViewSizeTest, Shim_TestResizeWebviewResizesContent) { |
| 1695 TestHelper("testResizeWebviewResizesContent", | 1687 TestHelper("testResizeWebviewResizesContent", |
| 1696 "web_view/shim", | 1688 "web_view/shim", |
| 1697 NO_TEST_SERVER); | 1689 NO_TEST_SERVER); |
| 1698 } | 1690 } |
| 1699 | 1691 |
| 1692 // Test makes sure that interstitial pages renders in <webview>. |
| 1693 IN_PROC_BROWSER_TEST_P(WebViewTest, InterstitialPage) { |
| 1694 // This test tests that a inner WebContents' InterstitialPage is properly |
| 1695 // connected to an outer WebContents through a CrossProcessFrameConnector, it |
| 1696 // doesn't make sense for BrowserPlugin based guests. |
| 1697 if (!base::FeatureList::IsEnabled(::features::kGuestViewCrossProcessFrames)) |
| 1698 return; |
| 1699 |
| 1700 InterstitialTestHelper(); |
| 1701 |
| 1702 content::WebContents* guest_web_contents = |
| 1703 GetGuestViewManager()->WaitForSingleGuestCreated(); |
| 1704 |
| 1705 EXPECT_TRUE(guest_web_contents->ShowingInterstitialPage()); |
| 1706 EXPECT_TRUE(guest_web_contents->GetInterstitialPage() |
| 1707 ->GetMainFrame() |
| 1708 ->GetView() |
| 1709 ->IsShowing()); |
| 1710 EXPECT_TRUE(content::IsInnerInterstitialPageConnected( |
| 1711 guest_web_contents->GetInterstitialPage())); |
| 1712 } |
| 1713 |
| 1714 // Test makes sure that interstitial pages are registered in the |
| 1715 // RenderWidgetHostInputEventRouter when inside a <webview>. |
| 1716 IN_PROC_BROWSER_TEST_P(WebViewTest, InterstitialPageRouteEvents) { |
| 1717 // This test tests that a inner WebContents' InterstitialPage is properly |
| 1718 // connected to an outer WebContents through a CrossProcessFrameConnector, it |
| 1719 // doesn't make sense for BrowserPlugin based guests. |
| 1720 if (!base::FeatureList::IsEnabled(::features::kGuestViewCrossProcessFrames)) |
| 1721 return; |
| 1722 |
| 1723 InterstitialTestHelper(); |
| 1724 |
| 1725 content::WebContents* outer_web_contents = GetFirstAppWindowWebContents(); |
| 1726 content::WebContents* guest_web_contents = |
| 1727 GetGuestViewManager()->WaitForSingleGuestCreated(); |
| 1728 content::InterstitialPage* interstitial_page = |
| 1729 guest_web_contents->GetInterstitialPage(); |
| 1730 |
| 1731 std::vector<content::RenderWidgetHostView*> hosts = |
| 1732 content::GetInputEventRouterRenderWidgetHostViews(outer_web_contents); |
| 1733 EXPECT_TRUE(std::find(hosts.begin(), hosts.end(), |
| 1734 interstitial_page->GetMainFrame()->GetView()) != |
| 1735 hosts.end()); |
| 1736 } |
| 1737 |
| 1738 // Test makes sure that interstitial pages will receive input events and can be |
| 1739 // focused. |
| 1740 IN_PROC_BROWSER_TEST_P(WebViewTest, InterstitialPageFocusedWidget) { |
| 1741 // This test tests that a inner WebContents' InterstitialPage is properly |
| 1742 // connected to an outer WebContents through a CrossProcessFrameConnector, it |
| 1743 // doesn't make sense for BrowserPlugin based guests. |
| 1744 if (!base::FeatureList::IsEnabled(::features::kGuestViewCrossProcessFrames)) |
| 1745 return; |
| 1746 |
| 1747 InterstitialTestHelper(); |
| 1748 |
| 1749 content::WebContents* outer_web_contents = GetFirstAppWindowWebContents(); |
| 1750 content::WebContents* guest_web_contents = |
| 1751 GetGuestViewManager()->WaitForSingleGuestCreated(); |
| 1752 content::InterstitialPage* interstitial_page = |
| 1753 guest_web_contents->GetInterstitialPage(); |
| 1754 content::RenderFrameHost* interstitial_main_frame = |
| 1755 interstitial_page->GetMainFrame(); |
| 1756 content::RenderWidgetHost* interstitial_widget = |
| 1757 interstitial_main_frame->GetRenderViewHost()->GetWidget(); |
| 1758 |
| 1759 content::WaitForChildFrameSurfaceReady(interstitial_main_frame); |
| 1760 |
| 1761 EXPECT_NE(interstitial_widget, |
| 1762 content::GetFocusedRenderWidgetHost(guest_web_contents)); |
| 1763 EXPECT_NE(interstitial_widget, |
| 1764 content::GetFocusedRenderWidgetHost(outer_web_contents)); |
| 1765 |
| 1766 // Send mouse down. |
| 1767 blink::WebMouseEvent event; |
| 1768 event.button = blink::WebPointerProperties::Button::kLeft; |
| 1769 event.SetType(blink::WebInputEvent::kMouseDown); |
| 1770 event.SetPositionInWidget(10, 10); |
| 1771 content::RouteMouseEvent(outer_web_contents, &event); |
| 1772 |
| 1773 // Wait a frame. |
| 1774 content::MainThreadFrameObserver observer(interstitial_widget); |
| 1775 observer.Wait(); |
| 1776 |
| 1777 // Send mouse up. |
| 1778 event.SetType(blink::WebInputEvent::kMouseUp); |
| 1779 event.SetPositionInWidget(10, 10); |
| 1780 content::RouteMouseEvent(outer_web_contents, &event); |
| 1781 |
| 1782 // Wait another frame. |
| 1783 observer.Wait(); |
| 1784 |
| 1785 EXPECT_EQ(interstitial_widget, |
| 1786 content::GetFocusedRenderWidgetHost(guest_web_contents)); |
| 1787 EXPECT_EQ(interstitial_widget, |
| 1788 content::GetFocusedRenderWidgetHost(outer_web_contents)); |
| 1789 } |
| 1790 |
| 1700 // This test makes sure the browser process does not crash if app is closed | 1791 // This test makes sure the browser process does not crash if app is closed |
| 1701 // while an interstitial page is being shown in guest. | 1792 // while an interstitial page is being shown in guest. |
| 1702 IN_PROC_BROWSER_TEST_P(WebViewTest, InterstitialTeardown) { | 1793 IN_PROC_BROWSER_TEST_P(WebViewTest, InterstitialTeardown) { |
| 1703 InterstitialTeardownTestHelper(); | 1794 InterstitialTestHelper(); |
| 1704 | 1795 |
| 1705 // Now close the app while interstitial page being shown in guest. | 1796 // Now close the app while interstitial page being shown in guest. |
| 1706 extensions::AppWindow* window = GetFirstAppWindow(); | 1797 extensions::AppWindow* window = GetFirstAppWindow(); |
| 1707 window->GetBaseWindow()->Close(); | 1798 window->GetBaseWindow()->Close(); |
| 1708 } | 1799 } |
| 1709 | 1800 |
| 1710 // This test makes sure the browser process does not crash if browser is shut | 1801 // This test makes sure the browser process does not crash if browser is shut |
| 1711 // down while an interstitial page is being shown in guest. | 1802 // down while an interstitial page is being shown in guest. |
| 1712 // Flaky. http://crbug.com/627962. | 1803 // Flaky. http://crbug.com/627962. |
| 1713 IN_PROC_BROWSER_TEST_P(WebViewTest, | 1804 IN_PROC_BROWSER_TEST_P(WebViewTest, |
| 1714 DISABLED_InterstitialTeardownOnBrowserShutdown) { | 1805 DISABLED_InterstitialTeardownOnBrowserShutdown) { |
| 1715 InterstitialTeardownTestHelper(); | 1806 InterstitialTestHelper(); |
| 1716 | 1807 |
| 1717 // Now close the app while interstitial page being shown in guest. | 1808 // Now close the app while interstitial page being shown in guest. |
| 1718 extensions::AppWindow* window = GetFirstAppWindow(); | 1809 extensions::AppWindow* window = GetFirstAppWindow(); |
| 1719 window->GetBaseWindow()->Close(); | 1810 window->GetBaseWindow()->Close(); |
| 1720 | 1811 |
| 1721 // InterstitialPage is not destroyed immediately, so the | 1812 // InterstitialPage is not destroyed immediately, so the |
| 1722 // RenderWidgetHostViewGuest for it is still there, closing all | 1813 // RenderWidgetHostViewGuest for it is still there, closing all |
| 1723 // renderer processes will cause the RWHVGuest's RenderProcessGone() | 1814 // renderer processes will cause the RWHVGuest's RenderProcessGone() |
| 1724 // shutdown path to be exercised. | 1815 // shutdown path to be exercised. |
| 1725 chrome::CloseAllBrowsers(); | 1816 chrome::CloseAllBrowsers(); |
| (...skipping 2302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4028 ClosingChromeSignInShouldNotCrash) { | 4119 ClosingChromeSignInShouldNotCrash) { |
| 4029 GURL signin_url{"chrome://chrome-signin"}; | 4120 GURL signin_url{"chrome://chrome-signin"}; |
| 4030 | 4121 |
| 4031 AddTabAtIndex(0, signin_url, ui::PAGE_TRANSITION_TYPED); | 4122 AddTabAtIndex(0, signin_url, ui::PAGE_TRANSITION_TYPED); |
| 4032 AddTabAtIndex(1, signin_url, ui::PAGE_TRANSITION_TYPED); | 4123 AddTabAtIndex(1, signin_url, ui::PAGE_TRANSITION_TYPED); |
| 4033 WaitForWebViewInDom(); | 4124 WaitForWebViewInDom(); |
| 4034 | 4125 |
| 4035 chrome::CloseTab(browser()); | 4126 chrome::CloseTab(browser()); |
| 4036 } | 4127 } |
| 4037 #endif | 4128 #endif |
| OLD | NEW |