Chromium Code Reviews| Index: content/browser/site_per_process_browsertest.cc |
| diff --git a/content/browser/site_per_process_browsertest.cc b/content/browser/site_per_process_browsertest.cc |
| index 30381e2f13cdade5a085c90d8ca6dc13d1512968..ea5570a18c2dbe99d4efb55806537048785c94c4 100644 |
| --- a/content/browser/site_per_process_browsertest.cc |
| +++ b/content/browser/site_per_process_browsertest.cc |
| @@ -31,7 +31,6 @@ |
| #include "content/browser/renderer_host/render_view_host_impl.h" |
| #include "content/browser/renderer_host/render_widget_host_input_event_router.h" |
| #include "content/browser/renderer_host/render_widget_host_view_aura.h" |
| -#include "content/browser/web_contents/web_contents_impl.h" |
| #include "content/common/frame_messages.h" |
| #include "content/common/input/synthetic_tap_gesture_params.h" |
| #include "content/common/view_messages.h" |
| @@ -47,7 +46,6 @@ |
| #include "content/public/test/content_browser_test_utils.h" |
| #include "content/public/test/test_navigation_observer.h" |
| #include "content/public/test/test_utils.h" |
| -#include "content/shell/browser/shell.h" |
| #include "content/test/content_browser_test_utils_internal.h" |
| #include "content/test/test_frame_navigation_observer.h" |
| #include "ipc/ipc_security_test_util.h" |
| @@ -632,9 +630,7 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, CrossSiteIframe) { |
| NavigateToURL(shell(), main_url); |
| // It is safe to obtain the root frame tree node here, as it doesn't change. |
| - FrameTreeNode* root = |
| - static_cast<WebContentsImpl*>(shell()->web_contents())-> |
| - GetFrameTree()->root(); |
| + FrameTreeNode* root = web_contents()->GetFrameTree()->root(); |
| TestNavigationObserver observer(shell()->web_contents()); |
| @@ -648,8 +644,7 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, CrossSiteIframe) { |
| // There should be only one RenderWidgetHost when there are no |
| // cross-process iframes. |
| std::set<RenderWidgetHostView*> views_set = |
| - static_cast<WebContentsImpl*>(shell()->web_contents()) |
| - ->GetRenderWidgetHostViewsInTree(); |
| + web_contents()->GetRenderWidgetHostViewsInTree(); |
| EXPECT_EQ(1U, views_set.size()); |
| } |
| @@ -682,8 +677,7 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, CrossSiteIframe) { |
| // There should be now two RenderWidgetHosts, one for each process |
| // rendering a frame. |
| std::set<RenderWidgetHostView*> views_set = |
| - static_cast<WebContentsImpl*>(shell()->web_contents()) |
| - ->GetRenderWidgetHostViewsInTree(); |
| + web_contents()->GetRenderWidgetHostViewsInTree(); |
| EXPECT_EQ(2U, views_set.size()); |
| } |
| RenderFrameProxyHost* proxy_to_parent = |
| @@ -730,8 +724,7 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, CrossSiteIframe) { |
| EXPECT_NE(rph, child->current_frame_host()->GetProcess()); |
| { |
| std::set<RenderWidgetHostView*> views_set = |
| - static_cast<WebContentsImpl*>(shell()->web_contents()) |
| - ->GetRenderWidgetHostViewsInTree(); |
| + web_contents()->GetRenderWidgetHostViewsInTree(); |
| EXPECT_EQ(2U, views_set.size()); |
| } |
| EXPECT_EQ(proxy_to_parent, child->render_manager()->GetProxyToParent()); |
| @@ -798,9 +791,7 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, |
| NavigateToURL(shell(), main_url); |
| // It is safe to obtain the root frame tree node here, as it doesn't change. |
| - FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) |
| - ->GetFrameTree() |
| - ->root(); |
| + FrameTreeNode* root = web_contents()->GetFrameTree()->root(); |
| ASSERT_EQ(1U, root->child_count()); |
| FrameTreeNode* parent_iframe_node = root->child_at(0); |
| @@ -826,8 +817,7 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, |
| nested_iframe_node->current_frame_host()->GetRenderWidgetHost()); |
| RenderWidgetHostInputEventRouter* router = |
| - static_cast<WebContentsImpl*>(shell()->web_contents()) |
| - ->GetInputEventRouter(); |
| + web_contents()->GetInputEventRouter(); |
| RenderWidgetHostViewBase* root_view = static_cast<RenderWidgetHostViewBase*>( |
| root->current_frame_host()->GetRenderWidgetHost()->GetView()); |
| @@ -879,9 +869,7 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, |
| NavigateToURL(shell(), main_url); |
| // It is safe to obtain the root frame tree node here, as it doesn't change. |
| - FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) |
| - ->GetFrameTree() |
| - ->root(); |
| + FrameTreeNode* root = web_contents()->GetFrameTree()->root(); |
| ASSERT_EQ(1U, root->child_count()); |
| FrameTreeNode* child_node = root->child_at(0); |
| @@ -897,8 +885,7 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, |
| child_node->current_frame_host()->GetRenderWidgetHost()); |
| RenderWidgetHostInputEventRouter* router = |
| - static_cast<WebContentsImpl*>(shell()->web_contents()) |
| - ->GetInputEventRouter(); |
| + web_contents()->GetInputEventRouter(); |
| RenderWidgetHostViewBase* root_view = static_cast<RenderWidgetHostViewBase*>( |
| root->current_frame_host()->GetRenderWidgetHost()->GetView()); |
| @@ -941,9 +928,7 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, |
| NavigateToURL(shell(), main_url); |
| // It is safe to obtain the root frame tree node here, as it doesn't change. |
| - FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) |
| - ->GetFrameTree() |
| - ->root(); |
| + FrameTreeNode* root = web_contents()->GetFrameTree()->root(); |
| ASSERT_EQ(1U, root->child_count()); |
| FrameTreeNode* child_node = root->child_at(0); |
| @@ -974,9 +959,7 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, CleanupCrossSiteIframe) { |
| NavigateToURL(shell(), main_url); |
| // It is safe to obtain the root frame tree node here, as it doesn't change. |
| - FrameTreeNode* root = |
| - static_cast<WebContentsImpl*>(shell()->web_contents())-> |
| - GetFrameTree()->root(); |
| + FrameTreeNode* root = web_contents()->GetFrameTree()->root(); |
| TestNavigationObserver observer(shell()->web_contents()); |
| @@ -1033,9 +1016,7 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, RestrictFrameDetach) { |
| NavigateToURL(shell(), main_url); |
| // It is safe to obtain the root frame tree node here, as it doesn't change. |
| - FrameTreeNode* root = |
| - static_cast<WebContentsImpl*>(shell()->web_contents())-> |
| - GetFrameTree()->root(); |
| + FrameTreeNode* root = web_contents()->GetFrameTree()->root(); |
| TestNavigationObserver observer(shell()->web_contents()); |
| @@ -1097,9 +1078,7 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, NavigateRemoteFrame) { |
| NavigateToURL(shell(), main_url); |
| // It is safe to obtain the root frame tree node here, as it doesn't change. |
| - FrameTreeNode* root = |
| - static_cast<WebContentsImpl*>(shell()->web_contents())-> |
| - GetFrameTree()->root(); |
| + FrameTreeNode* root = web_contents()->GetFrameTree()->root(); |
| TestNavigationObserver observer(shell()->web_contents()); |
| @@ -1166,9 +1145,7 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, |
| NavigateToURL(shell(), main_url); |
| // It is safe to obtain the root frame tree node here, as it doesn't change. |
| - FrameTreeNode* root = |
| - static_cast<WebContentsImpl*>(shell()->web_contents())-> |
| - GetFrameTree()->root(); |
| + FrameTreeNode* root = web_contents()->GetFrameTree()->root(); |
| TestNavigationObserver observer(shell()->web_contents()); |
| @@ -1274,9 +1251,7 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, |
| NavigateToURL(shell(), main_url); |
| // It is safe to obtain the root frame tree node here, as it doesn't change. |
| - FrameTreeNode* root = |
| - static_cast<WebContentsImpl*>(shell()->web_contents())-> |
| - GetFrameTree()->root(); |
| + FrameTreeNode* root = web_contents()->GetFrameTree()->root(); |
| TestNavigationObserver observer(shell()->web_contents()); |
| ASSERT_EQ(2U, root->child_count()); |
| @@ -1325,9 +1300,7 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, |
| NavigateToURL(shell(), main_url); |
| // It is safe to obtain the root frame tree node here, as it doesn't change. |
| - FrameTreeNode* root = |
| - static_cast<WebContentsImpl*>(shell()->web_contents())-> |
| - GetFrameTree()->root(); |
| + FrameTreeNode* root = web_contents()->GetFrameTree()->root(); |
| TestNavigationObserver observer(shell()->web_contents()); |
| ASSERT_EQ(2U, root->child_count()); |
| @@ -1412,9 +1385,7 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, NavigateRemoteAfterError) { |
| NavigateToURL(shell(), main_url); |
| // It is safe to obtain the root frame tree node here, as it doesn't change. |
| - FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) |
| - ->GetFrameTree() |
| - ->root(); |
| + FrameTreeNode* root = web_contents()->GetFrameTree()->root(); |
| // Load same-site page into iframe. |
| { |
| @@ -1468,9 +1439,7 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, ProcessTransferAfterError) { |
| EXPECT_TRUE(NavigateToURL(shell(), main_url)); |
| // It is safe to obtain the root frame tree node here, as it doesn't change. |
| - FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) |
| - ->GetFrameTree() |
| - ->root(); |
| + FrameTreeNode* root = web_contents()->GetFrameTree()->root(); |
| FrameTreeNode* child = root->child_at(0); |
| GURL url_a = child->current_url(); |
| @@ -1572,9 +1541,7 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, |
| NavigateToURL(shell(), main_url); |
| // It is safe to obtain the root frame tree node here, as it doesn't change. |
| - FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) |
| - ->GetFrameTree() |
| - ->root(); |
| + FrameTreeNode* root = web_contents()->GetFrameTree()->root(); |
| TestNavigationObserver observer(shell()->web_contents()); |
| EXPECT_EQ( |
| @@ -1637,9 +1604,7 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, |
| EXPECT_TRUE(NavigateToURL(shell(), main_url)); |
| // It is safe to obtain the root frame tree node here, as it doesn't change. |
| - FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) |
| - ->GetFrameTree() |
| - ->root(); |
| + FrameTreeNode* root = web_contents()->GetFrameTree()->root(); |
| EXPECT_EQ( |
| " Site A ------------ proxies for B\n" |
| @@ -1714,9 +1679,7 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, |
| EXPECT_TRUE(NavigateToURL(shell(), main_url)); |
| // It is safe to obtain the root frame tree node here, as it doesn't change. |
| - FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) |
| - ->GetFrameTree() |
| - ->root(); |
| + FrameTreeNode* root = web_contents()->GetFrameTree()->root(); |
| SiteInstance* site_instance_a = root->current_frame_host()->GetSiteInstance(); |
| // Open a popup and navigate it cross-process to b.com. |
| @@ -1802,9 +1765,7 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, |
| NavigateToURL(shell(), main_url); |
| // It is safe to obtain the root frame tree node here, as it doesn't change. |
| - FrameTreeNode* root = |
| - static_cast<WebContentsImpl*>(shell()->web_contents())-> |
| - GetFrameTree()->root(); |
| + FrameTreeNode* root = web_contents()->GetFrameTree()->root(); |
| ASSERT_EQ(2U, root->child_count()); |
| GURL site_b_url( |
| @@ -1876,9 +1837,7 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, CrashSubframe) { |
| NavigateToURL(shell(), main_url); |
| // Check the subframe process. |
| - FrameTreeNode* root = |
| - static_cast<WebContentsImpl*>(shell()->web_contents())-> |
| - GetFrameTree()->root(); |
| + FrameTreeNode* root = web_contents()->GetFrameTree()->root(); |
| EXPECT_EQ( |
| " Site A ------------ proxies for B\n" |
| " +--Site B ------- proxies for A\n" |
| @@ -1939,9 +1898,7 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, CreateProxiesForNewFrames) { |
| EXPECT_TRUE(NavigateToURL(shell(), main_url)); |
| // It is safe to obtain the root frame tree node here, as it doesn't change. |
| - FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) |
| - ->GetFrameTree() |
| - ->root(); |
| + FrameTreeNode* root = web_contents()->GetFrameTree()->root(); |
| ASSERT_EQ(1U, root->child_count()); |
| // Make sure the frame starts out at the correct cross-site URL. |
| @@ -2184,9 +2141,7 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, |
| NavigateToURL(shell(), main_url); |
| // It is safe to obtain the root frame tree node here, as it doesn't change. |
| - FrameTreeNode* root = |
| - static_cast<WebContentsImpl*>(shell()->web_contents())-> |
| - GetFrameTree()->root(); |
| + FrameTreeNode* root = web_contents()->GetFrameTree()->root(); |
| EXPECT_TRUE(root->child_at(1) != NULL); |
| EXPECT_EQ(2U, root->child_at(1)->child_count()); |
| @@ -2332,9 +2287,7 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, |
| NavigateToURL(shell(), main_url); |
| // It is safe to obtain the root frame tree node here, as it doesn't change. |
| - FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) |
| - ->GetFrameTree() |
| - ->root(); |
| + FrameTreeNode* root = web_contents()->GetFrameTree()->root(); |
| ASSERT_EQ(1u, root->child_count()); |
| EXPECT_EQ( |
| @@ -2400,9 +2353,7 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, |
| NavigateToURL(shell(), main_url); |
| // It is safe to obtain the root frame tree node here, as it doesn't change. |
| - FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) |
| - ->GetFrameTree() |
| - ->root(); |
| + FrameTreeNode* root = web_contents()->GetFrameTree()->root(); |
| ASSERT_EQ(1u, root->child_count()); |
| EXPECT_EQ( |
| @@ -2489,9 +2440,7 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, OriginReplication) { |
| EXPECT_TRUE(NavigateToURL(shell(), main_url)); |
| // It is safe to obtain the root frame tree node here, as it doesn't change. |
| - FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) |
| - ->GetFrameTree() |
| - ->root(); |
| + FrameTreeNode* root = web_contents()->GetFrameTree()->root(); |
| EXPECT_EQ( |
| " Site A ------------ proxies for B C\n" |
| @@ -2580,9 +2529,7 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, SandboxFlagsReplication) { |
| EXPECT_TRUE(NavigateToURL(shell(), main_url)); |
| // It is safe to obtain the root frame tree node here, as it doesn't change. |
| - FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) |
| - ->GetFrameTree() |
| - ->root(); |
| + FrameTreeNode* root = web_contents()->GetFrameTree()->root(); |
| TestNavigationObserver observer(shell()->web_contents()); |
| @@ -2680,9 +2627,7 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, DynamicSandboxFlags) { |
| EXPECT_TRUE(NavigateToURL(shell(), main_url)); |
| // It is safe to obtain the root frame tree node here, as it doesn't change. |
| - FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) |
| - ->GetFrameTree() |
| - ->root(); |
| + FrameTreeNode* root = web_contents()->GetFrameTree()->root(); |
| TestNavigationObserver observer(shell()->web_contents()); |
| ASSERT_EQ(2U, root->child_count()); |
| @@ -2804,9 +2749,7 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, |
| EXPECT_TRUE(NavigateToURL(shell(), main_url)); |
| // It is safe to obtain the root frame tree node here, as it doesn't change. |
| - FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) |
| - ->GetFrameTree() |
| - ->root(); |
| + FrameTreeNode* root = web_contents()->GetFrameTree()->root(); |
| TestNavigationObserver observer(shell()->web_contents()); |
| ASSERT_EQ(2U, root->child_count()); |
| @@ -2874,9 +2817,7 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, |
| EXPECT_TRUE(NavigateToURL(shell(), main_url)); |
| // It is safe to obtain the root frame tree node here, as it doesn't change. |
| - FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) |
| - ->GetFrameTree() |
| - ->root(); |
| + FrameTreeNode* root = web_contents()->GetFrameTree()->root(); |
| TestNavigationObserver observer(shell()->web_contents()); |
| ASSERT_EQ(1U, root->child_count()); |
| @@ -2955,9 +2896,7 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, |
| EXPECT_TRUE(NavigateToURL(shell(), main_url)); |
| // It is safe to obtain the root frame tree node here, as it doesn't change. |
| - FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) |
| - ->GetFrameTree() |
| - ->root(); |
| + FrameTreeNode* root = web_contents()->GetFrameTree()->root(); |
| TestNavigationObserver observer(shell()->web_contents()); |
| EXPECT_EQ( |
| @@ -3036,9 +2975,7 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, WindowNameReplication) { |
| EXPECT_TRUE(NavigateToURL(shell(), main_url)); |
| // It is safe to obtain the root frame tree node here, as it doesn't change. |
| - FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) |
| - ->GetFrameTree() |
| - ->root(); |
| + FrameTreeNode* root = web_contents()->GetFrameTree()->root(); |
| TestNavigationObserver observer(shell()->web_contents()); |
| @@ -3069,9 +3006,7 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, DynamicWindowName) { |
| EXPECT_TRUE(NavigateToURL(shell(), main_url)); |
| // It is safe to obtain the root frame tree node here, as it doesn't change. |
| - FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) |
| - ->GetFrameTree() |
| - ->root(); |
| + FrameTreeNode* root = web_contents()->GetFrameTree()->root(); |
| TestNavigationObserver observer(shell()->web_contents()); |
| // Load cross-site page into iframe. |
| @@ -3128,9 +3063,7 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, OriginUpdatesReachProxies) { |
| EXPECT_TRUE(NavigateToURL(shell(), main_url)); |
| // It is safe to obtain the root frame tree node here, as it doesn't change. |
| - FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) |
| - ->GetFrameTree() |
| - ->root(); |
| + FrameTreeNode* root = web_contents()->GetFrameTree()->root(); |
| TestNavigationObserver observer(shell()->web_contents()); |
| EXPECT_EQ( |
| @@ -3181,9 +3114,7 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, CrossSiteDidStopLoading) { |
| NavigateToURL(shell(), main_url); |
| // It is safe to obtain the root frame tree node here, as it doesn't change. |
| - FrameTreeNode* root = |
| - static_cast<WebContentsImpl*>(shell()->web_contents())-> |
| - GetFrameTree()->root(); |
| + FrameTreeNode* root = web_contents()->GetFrameTree()->root(); |
| TestNavigationObserver observer(shell()->web_contents()); |
| @@ -3217,9 +3148,7 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, |
| NavigateToURL(shell(), main_url); |
| // It is safe to obtain the root frame tree node here, as it doesn't change. |
| - FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) |
| - ->GetFrameTree() |
| - ->root(); |
| + FrameTreeNode* root = web_contents()->GetFrameTree()->root(); |
| TestNavigationObserver observer(shell()->web_contents()); |
| // Make sure the first frame is out of process. |
| @@ -3253,9 +3182,7 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, |
| NavigateToURL(shell(), main_url); |
| // It is safe to obtain the root frame tree node here, as it doesn't change. |
| - FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) |
| - ->GetFrameTree() |
| - ->root(); |
| + FrameTreeNode* root = web_contents()->GetFrameTree()->root(); |
| FrameTreeNode* node2 = root->child_at(0); |
| FrameTreeNode* node3 = root->child_at(1); |
| @@ -3300,9 +3227,7 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, LoadEventForwarding) { |
| } |
| // It is safe to obtain the root frame tree node here, as it doesn't change. |
| - FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) |
| - ->GetFrameTree() |
| - ->root(); |
| + FrameTreeNode* root = web_contents()->GetFrameTree()->root(); |
| // Load another cross-site page into the iframe and check that the load event |
| // is fired. |
| @@ -3325,9 +3250,7 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, SubframePostMessage) { |
| EXPECT_TRUE(NavigateToURL(shell(), main_url)); |
| // It is safe to obtain the root frame tree node here, as it doesn't change. |
| - FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) |
| - ->GetFrameTree() |
| - ->root(); |
| + FrameTreeNode* root = web_contents()->GetFrameTree()->root(); |
| ASSERT_EQ(2U, root->child_count()); |
| @@ -3373,9 +3296,7 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, |
| EXPECT_TRUE(NavigateToURL(shell(), main_url)); |
| // It is safe to obtain the root frame tree node here, as it doesn't change. |
| - FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) |
| - ->GetFrameTree() |
| - ->root(); |
| + FrameTreeNode* root = web_contents()->GetFrameTree()->root(); |
| ASSERT_EQ(2U, root->child_count()); |
| @@ -3484,9 +3405,7 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, IndexedFrameAccess) { |
| EXPECT_TRUE(NavigateToURL(shell(), main_url)); |
| // It is safe to obtain the root frame tree node here, as it doesn't change. |
| - FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) |
| - ->GetFrameTree() |
| - ->root(); |
| + FrameTreeNode* root = web_contents()->GetFrameTree()->root(); |
| ASSERT_EQ(3U, root->child_count()); |
| FrameTreeNode* child0 = root->child_at(0); |
| FrameTreeNode* child1 = root->child_at(1); |
| @@ -3556,9 +3475,7 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, RFPHDestruction) { |
| NavigateToURL(shell(), main_url); |
| // It is safe to obtain the root frame tree node here, as it doesn't change. |
| - FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) |
| - ->GetFrameTree() |
| - ->root(); |
| + FrameTreeNode* root = web_contents()->GetFrameTree()->root(); |
| TestNavigationObserver observer(shell()->web_contents()); |
| @@ -3617,9 +3534,7 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, OpenPopupWithRemoteParent) { |
| NavigateToURL(shell(), main_url); |
| // It is safe to obtain the root frame tree node here, as it doesn't change. |
| - FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) |
| - ->GetFrameTree() |
| - ->root(); |
| + FrameTreeNode* root = web_contents()->GetFrameTree()->root(); |
| // Navigate first child cross-site. |
| GURL frame_url(embedded_test_server()->GetURL("b.com", "/title1.html")); |
| @@ -3721,9 +3636,7 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, |
| NavigateToURL(shell(), main_url); |
| // It is safe to obtain the root frame tree node here, as it doesn't change. |
| - FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) |
| - ->GetFrameTree() |
| - ->root(); |
| + FrameTreeNode* root = web_contents()->GetFrameTree()->root(); |
| // Navigate first child cross-site. |
| GURL frame_url(embedded_test_server()->GetURL("b.com", "/title1.html")); |
| @@ -3774,9 +3687,7 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, |
| NavigateToURL(shell(), main_url); |
| // It is safe to obtain the root frame tree node here, as it doesn't change. |
| - FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) |
| - ->GetFrameTree() |
| - ->root(); |
| + FrameTreeNode* root = web_contents()->GetFrameTree()->root(); |
| // Open a same-site popup from the main frame. |
| GURL a_com_url(embedded_test_server()->GetURL("a.com", "/title3.html")); |
| @@ -3834,9 +3745,7 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, UpdateSubframeOpener) { |
| "foo.com", "/frame_tree/page_with_two_frames.html"); |
| EXPECT_TRUE(NavigateToURL(shell(), main_url)); |
| - FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) |
| - ->GetFrameTree() |
| - ->root(); |
| + FrameTreeNode* root = web_contents()->GetFrameTree()->root(); |
| EXPECT_EQ(2U, root->child_count()); |
| // From the top frame, open a popup and navigate it to a cross-site page with |
| @@ -3909,9 +3818,7 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, |
| GURL main_url = embedded_test_server()->GetURL("a.com", "/post_message.html"); |
| EXPECT_TRUE(NavigateToURL(shell(), main_url)); |
| - FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) |
| - ->GetFrameTree() |
| - ->root(); |
| + FrameTreeNode* root = web_contents()->GetFrameTree()->root(); |
| // Open a popup with a cross-site page that has a subframe. |
| GURL popup_url(embedded_test_server()->GetURL( |
| @@ -3956,9 +3863,7 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, NavigateSubframeWithOpener) { |
| "foo.com", "/frame_tree/page_with_two_frames.html")); |
| EXPECT_TRUE(NavigateToURL(shell(), main_url)); |
| - FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) |
| - ->GetFrameTree() |
| - ->root(); |
| + FrameTreeNode* root = web_contents()->GetFrameTree()->root(); |
| EXPECT_EQ( |
| " Site A ------------ proxies for B\n" |
| " |--Site B ------- proxies for A\n" |
| @@ -4023,9 +3928,7 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, |
| embedded_test_server()->GetURL("foo.com", "/post_message.html")); |
| EXPECT_TRUE(NavigateToURL(shell(), main_url)); |
| - FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) |
| - ->GetFrameTree() |
| - ->root(); |
| + FrameTreeNode* root = web_contents()->GetFrameTree()->root(); |
| // Open a popup with a cross-site page that has two subframes. |
| GURL popup_url(embedded_test_server()->GetURL( |
| @@ -4110,9 +4013,7 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, |
| GURL a_url(embedded_test_server()->GetURL("a.com", "/title1.html")); |
| NavigateToURL(shell(), a_url); |
| - FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) |
| - ->GetFrameTree() |
| - ->root(); |
| + FrameTreeNode* root = web_contents()->GetFrameTree()->root(); |
| RenderFrameHostImpl* rfh = root->current_frame_host(); |
| RenderViewHostImpl* rvh = rfh->render_view_host(); |
| int rvh_routing_id = rvh->GetRoutingID(); |
| @@ -4176,9 +4077,7 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, |
| GURL main_url(embedded_test_server()->GetURL("a.com", "/title1.html")); |
| EXPECT_TRUE(NavigateToURL(shell(), main_url)); |
| - FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) |
| - ->GetFrameTree() |
| - ->root(); |
| + FrameTreeNode* root = web_contents()->GetFrameTree()->root(); |
| RenderViewHostImpl* rvh_a = root->current_frame_host()->render_view_host(); |
| int rvh_a_routing_id = rvh_a->GetRoutingID(); |
| @@ -4209,9 +4108,7 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, |
| embedded_test_server()->GetURL("a.com", "/page_with_input_field.html")); |
| EXPECT_TRUE(NavigateToURL(shell(), main_url)); |
| - FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) |
| - ->GetFrameTree() |
| - ->root(); |
| + FrameTreeNode* root = web_contents()->GetFrameTree()->root(); |
| EXPECT_EQ( |
| " Site A ------------ proxies for B\n" |
| @@ -4271,9 +4168,7 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, DocumentActiveElement) { |
| "a.com", "/cross_site_iframe_factory.html?a(b(c))")); |
| EXPECT_TRUE(NavigateToURL(shell(), main_url)); |
| - FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) |
| - ->GetFrameTree() |
| - ->root(); |
| + FrameTreeNode* root = web_contents()->GetFrameTree()->root(); |
| EXPECT_EQ( |
| " Site A ------------ proxies for B C\n" |
| @@ -4350,9 +4245,7 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, DISABLED_DocumentHasFocus) { |
| "a.com", "/cross_site_iframe_factory.html?a(b(c),d)")); |
| EXPECT_TRUE(NavigateToURL(shell(), main_url)); |
| - FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) |
| - ->GetFrameTree() |
| - ->root(); |
| + FrameTreeNode* root = web_contents()->GetFrameTree()->root(); |
| EXPECT_EQ( |
| " Site A ------------ proxies for B C D\n" |
| @@ -4418,9 +4311,7 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, SubframeWindowFocus) { |
| "a.com", "/cross_site_iframe_factory.html?a(b,c)")); |
| EXPECT_TRUE(NavigateToURL(shell(), main_url)); |
| - FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) |
| - ->GetFrameTree() |
| - ->root(); |
| + FrameTreeNode* root = web_contents()->GetFrameTree()->root(); |
| EXPECT_EQ( |
| " Site A ------------ proxies for B C\n" |
| @@ -4557,9 +4448,7 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, |
| "/frame_tree/page_with_positioned_frame.html")); |
| EXPECT_TRUE(NavigateToURL(shell(), main_url)); |
| - FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) |
| - ->GetFrameTree() |
| - ->root(); |
| + FrameTreeNode* root = web_contents()->GetFrameTree()->root(); |
| FrameTreeNode* child_node = root->child_at(0); |
| EXPECT_NE(shell()->web_contents()->GetSiteInstance(), |
| @@ -4578,9 +4467,8 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, |
| root->child_at(0)->current_frame_host()->GetRenderWidgetHost(); |
| RenderWidgetHostViewBase* root_view = static_cast<RenderWidgetHostViewBase*>( |
| root->current_frame_host()->GetRenderWidgetHost()->GetView()); |
| - static_cast<WebContentsImpl*>(shell()->web_contents()) |
| - ->GetInputEventRouter() |
| - ->RouteMouseEvent(root_view, &mouse_event); |
| + web_contents()->GetInputEventRouter()->RouteMouseEvent(root_view, |
| + &mouse_event); |
| // CursorMessageFilter::Wait() implicitly tests whether we receive a |
| // ViewHostMsg_SetCursor message from the renderer process, because it does |
| @@ -4623,9 +4511,8 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, |
| "/frame_tree/page_with_positioned_nested_frames.html")); |
| EXPECT_TRUE(NavigateToURL(shell(), main_url)); |
| - WebContentsImpl* web_contents = |
| - static_cast<WebContentsImpl*>(shell()->web_contents()); |
| - FrameTreeNode* root = web_contents->GetFrameTree()->root(); |
| + WebContentsImpl* contents = web_contents(); |
| + FrameTreeNode* root = contents->GetFrameTree()->root(); |
| ASSERT_EQ(1U, root->child_count()); |
| GURL frame_url( |
| @@ -4643,7 +4530,7 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, |
| // Simulate touch event to sub-frame. |
| gfx::Point child_center(150, 150); |
| auto rwhv = static_cast<RenderWidgetHostViewAura*>( |
| - web_contents->GetRenderWidgetHostView()); |
| + contents->GetRenderWidgetHostView()); |
| ui::TouchEvent touch_event(ui::ET_TOUCH_PRESSED, child_center, 0, 0, |
| ui::EventTimeForNow(), 30.f, 30.f, 0.f, 0.f); |
| rwhv->OnTouchEvent(&touch_event); |
| @@ -4679,9 +4566,8 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, |
| "/frame_tree/page_with_positioned_nested_frames.html")); |
| EXPECT_TRUE(NavigateToURL(shell(), main_url)); |
| - WebContentsImpl* web_contents = |
| - static_cast<WebContentsImpl*>(shell()->web_contents()); |
| - FrameTreeNode* root = web_contents->GetFrameTree()->root(); |
| + WebContentsImpl* contents = web_contents(); |
| + FrameTreeNode* root = contents->GetFrameTree()->root(); |
| ASSERT_EQ(1U, root->child_count()); |
| GURL frame_url( |
| @@ -4814,9 +4700,8 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, |
| "/frame_tree/page_with_positioned_nested_frames.html")); |
| EXPECT_TRUE(NavigateToURL(shell(), main_url)); |
| - WebContentsImpl* web_contents = |
| - static_cast<WebContentsImpl*>(shell()->web_contents()); |
| - FrameTreeNode* root = web_contents->GetFrameTree()->root(); |
| + WebContentsImpl* contents = web_contents(); |
| + FrameTreeNode* root = contents->GetFrameTree()->root(); |
| ASSERT_EQ(1U, root->child_count()); |
| GURL frame_url( |
| @@ -4835,10 +4720,9 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, |
| // All touches & gestures are sent to the main frame's view, and should be |
| // routed appropriately from there. |
| auto rwhv_parent = static_cast<RenderWidgetHostViewBase*>( |
| - web_contents->GetRenderWidgetHostView()); |
| + contents->GetRenderWidgetHostView()); |
| - RenderWidgetHostInputEventRouter* router = |
| - web_contents->GetInputEventRouter(); |
| + RenderWidgetHostInputEventRouter* router = contents->GetInputEventRouter(); |
| EXPECT_TRUE(router->gesture_target_queue_.empty()); |
| EXPECT_EQ(nullptr, router->gesture_target_); |
| @@ -4902,9 +4786,8 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, |
| "a.com", "/frame_tree/page_with_one_frame.html")); |
| EXPECT_TRUE(NavigateToURL(shell(), main_url)); |
| - WebContentsImpl* web_contents = |
| - static_cast<WebContentsImpl*>(shell()->web_contents()); |
| - FrameTreeNode* root = web_contents->GetFrameTree()->root(); |
| + WebContentsImpl* contents = web_contents(); |
| + FrameTreeNode* root = contents->GetFrameTree()->root(); |
| GURL frame_url( |
| embedded_test_server()->GetURL("b.com", "/page_with_input_field.html")); |
| @@ -4922,9 +4805,9 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, |
| EXPECT_EQ(root->child_at(0), root->frame_tree()->GetFocusedFrame()); |
| // Generate a few keyboard events and route them to currently focused frame. |
| - SimulateKeyPress(web_contents, ui::VKEY_F, false, false, false, false); |
| - SimulateKeyPress(web_contents, ui::VKEY_O, false, false, false, false); |
| - SimulateKeyPress(web_contents, ui::VKEY_O, false, false, false, false); |
| + SimulateKeyPress(contents, ui::VKEY_F, false, false, false, false); |
| + SimulateKeyPress(contents, ui::VKEY_O, false, false, false, false); |
| + SimulateKeyPress(contents, ui::VKEY_O, false, false, false, false); |
| // Verify that the input field in the subframe received the keystrokes. |
| EXPECT_TRUE(ExecuteScriptAndExtractString( |
| @@ -5052,30 +4935,25 @@ class ContextMenuObserverDelegate : public WebContentsDelegate { |
| DISALLOW_COPY_AND_ASSIGN(ContextMenuObserverDelegate); |
| }; |
| -// Test that a mouse right-click to an out-of-process iframe causes a context |
| -// menu to be generated with the correct screen position. |
| -#if defined(OS_ANDROID) |
| -// Browser process hit testing is not implemented on Android. |
| -// https://crbug.com/491334 |
| -#define MAYBE_CreateContextMenuTest DISABLED_CreateContextMenuTest |
| -#else |
| -#define MAYBE_CreateContextMenuTest CreateContextMenuTest |
| -#endif |
| -IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, MAYBE_CreateContextMenuTest) { |
| - GURL main_url(embedded_test_server()->GetURL( |
| +// Helper function to run the CreateContextMenuTest in either normal |
|
Charlie Reis
2016/04/01 21:24:09
Why is this in your CL? This seems unrelated. Is
EhsanK
2016/04/02 03:14:02
I guess it is. Sorry about that. I reverted the re
|
| +// or high DPI mode. |
| +void CreateContextMenuTestHelper( |
| + Shell* shell, |
| + net::test_server::EmbeddedTestServer* embedded_test_server) { |
| + GURL main_url(embedded_test_server->GetURL( |
| "/frame_tree/page_with_positioned_frame.html")); |
| - NavigateToURL(shell(), main_url); |
| + EXPECT_TRUE(NavigateToURL(shell, main_url)); |
| // It is safe to obtain the root frame tree node here, as it doesn't change. |
| - FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) |
| + FrameTreeNode* root = static_cast<WebContentsImpl*>(shell->web_contents()) |
| ->GetFrameTree() |
| ->root(); |
| ASSERT_EQ(1U, root->child_count()); |
| FrameTreeNode* child_node = root->child_at(0); |
| - GURL site_url(embedded_test_server()->GetURL("baz.com", "/title1.html")); |
| + GURL site_url(embedded_test_server->GetURL("baz.com", "/title1.html")); |
| EXPECT_EQ(site_url, child_node->current_url()); |
| - EXPECT_NE(shell()->web_contents()->GetSiteInstance(), |
| + EXPECT_NE(shell->web_contents()->GetSiteInstance(), |
| child_node->current_frame_host()->GetSiteInstance()); |
| RenderWidgetHostViewBase* root_view = static_cast<RenderWidgetHostViewBase*>( |
| @@ -5086,38 +4964,33 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, MAYBE_CreateContextMenuTest) { |
| // Ensure that the child process renderer is ready to have input events |
| // routed to it. This happens when the browser process has received |
| // updated compositor surfaces from both renderer processes. |
| - gfx::Point point(75, 75); |
| - gfx::Point transformed_point; |
| - while (root_view->SurfaceIdNamespaceAtPoint(nullptr, point, |
| - &transformed_point) != |
| - rwhv_child->GetSurfaceIdNamespace()) { |
| - base::RunLoop run_loop; |
| - base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
| - FROM_HERE, run_loop.QuitClosure(), TestTimeouts::tiny_timeout()); |
| - run_loop.Run(); |
| - } |
| + SurfaceHitTestReadyNotifier notifier( |
| + static_cast<RenderWidgetHostViewChildFrame*>(rwhv_child)); |
| + notifier.WaitForSurfaceReady(); |
| // A WebContentsDelegate to listen for the ShowContextMenu message. |
| ContextMenuObserverDelegate context_menu_delegate; |
| - shell()->web_contents()->SetDelegate(&context_menu_delegate); |
| + shell->web_contents()->SetDelegate(&context_menu_delegate); |
| RenderWidgetHostInputEventRouter* router = |
| - static_cast<WebContentsImpl*>(shell()->web_contents()) |
| + static_cast<WebContentsImpl*>(shell->web_contents()) |
| ->GetInputEventRouter(); |
| + gfx::Point point(75, 75); |
| + |
| // Target right-click event to child frame. |
| blink::WebMouseEvent click_event; |
| click_event.type = blink::WebInputEvent::MouseDown; |
| click_event.button = blink::WebPointerProperties::ButtonRight; |
| - click_event.x = 75; |
| - click_event.y = 75; |
| + click_event.x = point.x(); |
| + click_event.y = point.y(); |
| click_event.clickCount = 1; |
| router->RouteMouseEvent(root_view, &click_event); |
| // We also need a MouseUp event, needed by Windows. |
| click_event.type = blink::WebInputEvent::MouseUp; |
| - click_event.x = 75; |
| - click_event.y = 75; |
| + click_event.x = point.x(); |
| + click_event.y = point.y(); |
| router->RouteMouseEvent(root_view, &click_event); |
| context_menu_delegate.Wait(); |
| @@ -5128,6 +5001,35 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, MAYBE_CreateContextMenuTest) { |
| EXPECT_EQ(point.y(), params.y); |
| } |
| +// Test that a mouse right-click to an out-of-process iframe causes a context |
| +// menu to be generated with the correct screen position. |
| +#if defined(OS_ANDROID) |
| +// Browser process hit testing is not implemented on Android. |
| +// https://crbug.com/491334 |
| +#define MAYBE_CreateContextMenuTest DISABLED_CreateContextMenuTest |
| +#else |
| +#define MAYBE_CreateContextMenuTest CreateContextMenuTest |
| +#endif |
| +IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, MAYBE_CreateContextMenuTest) { |
| + CreateContextMenuTestHelper(shell(), embedded_test_server()); |
| +} |
| + |
| +// Test that a mouse right-click to an out-of-process iframe causes a context |
| +// menu to be generated with the correct screen position on a screen with |
| +// non-default scale factor. |
| +#if defined(OS_ANDROID) || defined(OS_WIN) |
| +// Browser process hit testing is not implemented on Android. |
| +// https://crbug.com/491334 |
| +// Windows is disabled because of https://crbug.com/545547. |
| +#define MAYBE_HighDPICreateContextMenuTest DISABLED_HighDPICreateContextMenuTest |
| +#else |
| +#define MAYBE_HighDPICreateContextMenuTest HighDPICreateContextMenuTest |
| +#endif |
| +IN_PROC_BROWSER_TEST_F(SitePerProcessHighDPIBrowserTest, |
| + MAYBE_HighDPICreateContextMenuTest) { |
| + CreateContextMenuTestHelper(shell(), embedded_test_server()); |
| +} |
| + |
| class ShowWidgetMessageFilter : public content::BrowserMessageFilter { |
| public: |
| ShowWidgetMessageFilter() |
| @@ -5206,16 +5108,14 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, MAYBE_PopupMenuTest) { |
| embedded_test_server()->GetURL("/cross_site_iframe_factory.html?a(a)")); |
| NavigateToURL(shell(), main_url); |
| - FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) |
| - ->GetFrameTree() |
| - ->root(); |
| + FrameTreeNode* root = web_contents()->GetFrameTree()->root(); |
| #if !defined(OS_MACOSX) |
| // Unused variable on Mac. |
| RenderWidgetHostViewBase* rwhv_root = static_cast<RenderWidgetHostViewBase*>( |
| root->current_frame_host()->GetRenderWidgetHost()->GetView()); |
| #endif |
| - static_cast<WebContentsImpl*>(shell()->web_contents())->SendScreenRects(); |
| + web_contents()->SendScreenRects(); |
| content::TestNavigationObserver navigation_observer(shell()->web_contents()); |
| FrameTreeNode* child_node = root->child_at(0); |
| @@ -5276,16 +5176,14 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, MAYBE_NestedPopupMenuTest) { |
| "/cross_site_iframe_factory.html?a(b(c))")); |
| NavigateToURL(shell(), main_url); |
| - FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) |
| - ->GetFrameTree() |
| - ->root(); |
| + FrameTreeNode* root = web_contents()->GetFrameTree()->root(); |
| #if !defined(OS_MACOSX) |
| // Undefined variable on Mac. |
| RenderWidgetHostViewBase* rwhv_root = static_cast<RenderWidgetHostViewBase*>( |
| root->current_frame_host()->GetRenderWidgetHost()->GetView()); |
| #endif |
| - static_cast<WebContentsImpl*>(shell()->web_contents())->SendScreenRects(); |
| + web_contents()->SendScreenRects(); |
| // For clarity, we are labeling the frame tree nodes as: |
| // - root_node |
| @@ -5562,10 +5460,7 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, |
| NavigateToURL(shell(), main_url); |
| // Capture the FrameTreeNode this test will be navigating. |
| - FrameTreeNode* node = static_cast<WebContentsImpl*>(shell()->web_contents()) |
| - ->GetFrameTree() |
| - ->root() |
| - ->child_at(0); |
| + FrameTreeNode* node = web_contents()->GetFrameTree()->root()->child_at(0); |
| EXPECT_TRUE(node); |
| EXPECT_NE(node->current_frame_host()->GetSiteInstance(), |
| node->parent()->current_frame_host()->GetSiteInstance()); |
| @@ -5639,12 +5534,11 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, ParentDetachRemoteChild) { |
| "a.com", "/cross_site_iframe_factory.html?a(b,b)")); |
| NavigateToURL(shell(), main_url); |
| - WebContentsImpl* web_contents = |
| - static_cast<WebContentsImpl*>(shell()->web_contents()); |
| - EXPECT_EQ(2U, web_contents->GetFrameTree()->root()->child_count()); |
| + WebContentsImpl* contents = web_contents(); |
| + EXPECT_EQ(2U, contents->GetFrameTree()->root()->child_count()); |
| // Capture the FrameTreeNode this test will be navigating. |
| - FrameTreeNode* node = web_contents->GetFrameTree()->root()->child_at(0); |
| + FrameTreeNode* node = contents->GetFrameTree()->root()->child_at(0); |
| EXPECT_TRUE(node); |
| EXPECT_NE(node->current_frame_host()->GetSiteInstance(), |
| node->parent()->current_frame_host()->GetSiteInstance()); |
| @@ -5664,10 +5558,10 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, ParentDetachRemoteChild) { |
| // Have the parent frame remove the child frame from its DOM. This should |
| // result in the child RenderFrame being deleted in the remote process. |
| - EXPECT_TRUE(ExecuteScript(web_contents, |
| + EXPECT_TRUE(ExecuteScript(contents, |
| "document.body.removeChild(" |
| "document.querySelectorAll('iframe')[0])")); |
| - EXPECT_EQ(1U, web_contents->GetFrameTree()->root()->child_count()); |
| + EXPECT_EQ(1U, contents->GetFrameTree()->root()->child_count()); |
| { |
| FrameMsg_NewFrame_Params params; |
| @@ -5688,9 +5582,8 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, ParentDetachRemoteChild) { |
| // RenderFrame will be properly created and there will be no crash. |
| // Therefore, navigate the remaining subframe to completely different site, |
| // which will cause the original process to exit cleanly. |
| - NavigateFrameToURL( |
| - web_contents->GetFrameTree()->root()->child_at(0), |
| - embedded_test_server()->GetURL("d.com", "/title3.html")); |
| + NavigateFrameToURL(contents->GetFrameTree()->root()->child_at(0), |
| + embedded_test_server()->GetURL("d.com", "/title3.html")); |
| watcher.Wait(); |
| EXPECT_TRUE(watcher.did_exit_normally()); |
| } |
| @@ -5704,9 +5597,7 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, VisibilityChanged) { |
| GURL cross_site_url = |
| embedded_test_server()->GetURL("oopif.com", "/title1.html"); |
| - FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) |
| - ->GetFrameTree() |
| - ->root(); |
| + FrameTreeNode* root = web_contents()->GetFrameTree()->root(); |
| TestNavigationObserver observer(shell()->web_contents()); |
| @@ -5744,9 +5635,7 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, SandboxFlagsInheritance) { |
| NavigateToURL(shell(), main_url); |
| // It is safe to obtain the root frame tree node here, as it doesn't change. |
| - FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) |
| - ->GetFrameTree() |
| - ->root(); |
| + FrameTreeNode* root = web_contents()->GetFrameTree()->root(); |
| // Set sandbox flags for child frame. |
| EXPECT_TRUE(ExecuteScript( |
| @@ -5799,9 +5688,7 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, |
| NavigateToURL(shell(), main_url); |
| // It is safe to obtain the root frame tree node here, as it doesn't change. |
| - FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) |
| - ->GetFrameTree() |
| - ->root(); |
| + FrameTreeNode* root = web_contents()->GetFrameTree()->root(); |
| // Set sandbox flags for child frame. |
| EXPECT_TRUE(ExecuteScript( |
| @@ -5851,9 +5738,7 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, |
| EXPECT_TRUE(NavigateToURL(shell(), main_url)); |
| // It is safe to obtain the root frame tree node here, as it doesn't change. |
| - FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) |
| - ->GetFrameTree() |
| - ->root(); |
| + FrameTreeNode* root = web_contents()->GetFrameTree()->root(); |
| // Set sandbox flags for child frame. |
| EXPECT_TRUE(ExecuteScript(root->current_frame_host(), |
| @@ -5922,9 +5807,7 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, |
| EXPECT_TRUE(NavigateToURL(shell(), main_url)); |
| // It is safe to obtain the root frame tree node here, as it doesn't change. |
| - FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) |
| - ->GetFrameTree() |
| - ->root(); |
| + FrameTreeNode* root = web_contents()->GetFrameTree()->root(); |
| // Set sandbox flags for child frame, specifying that popups opened from it |
| // should not be sandboxed. |
| @@ -5993,9 +5876,7 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessIgnoreCertErrorsBrowserTest, |
| // When the subframe navigates, the WebContents should still be marked |
| // as having displayed insecure content. |
| GURL navigate_url(https_server.GetURL("/title1.html")); |
| - FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) |
| - ->GetFrameTree() |
| - ->root(); |
| + FrameTreeNode* root = web_contents()->GetFrameTree()->root(); |
| NavigateFrameToURL(root->child_at(0), navigate_url); |
| EXPECT_TRUE(shell()->web_contents()->DisplayedInsecureContent()); |
| @@ -6021,9 +5902,7 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessIgnoreCertErrorsBrowserTest, |
| EXPECT_TRUE(NavigateToURL(shell(), iframe_url_with_strict_blocking)); |
| EXPECT_FALSE(shell()->web_contents()->DisplayedInsecureContent()); |
| - FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) |
| - ->GetFrameTree() |
| - ->root(); |
| + FrameTreeNode* root = web_contents()->GetFrameTree()->root(); |
| EXPECT_TRUE(root->current_replication_state() |
| .should_enforce_strict_mixed_content_checking); |
| EXPECT_TRUE(root->child_at(0) |
| @@ -6062,9 +5941,7 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessIgnoreCertErrorsBrowserTest, |
| GURL iframe_url( |
| https_server.GetURL("/mixed-content/basic-active-in-iframe.html")); |
| EXPECT_TRUE(NavigateToURL(shell(), iframe_url)); |
| - FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) |
| - ->GetFrameTree() |
| - ->root(); |
| + FrameTreeNode* root = web_contents()->GetFrameTree()->root(); |
| ASSERT_EQ(1U, root->child_count()); |
| FrameTreeNode* mixed_child = root->child_at(0)->child_at(0); |
| ASSERT_TRUE(mixed_child); |
| @@ -6080,9 +5957,7 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, CrossSiteIframeDisplayNone) { |
| "a.com", "/cross_site_iframe_factory.html?a(b)")); |
| NavigateToURL(shell(), main_url); |
| - FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) |
| - ->GetFrameTree() |
| - ->root(); |
| + FrameTreeNode* root = web_contents()->GetFrameTree()->root(); |
| RenderWidgetHost* root_render_widget_host = |
| root->current_frame_host()->GetRenderWidgetHost(); |
| @@ -6112,9 +5987,7 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, |
| "a.com", "/cross_site_iframe_factory.html?a(a)")); |
| NavigateToURL(shell(), main_url); |
| - FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) |
| - ->GetFrameTree() |
| - ->root(); |
| + FrameTreeNode* root = web_contents()->GetFrameTree()->root(); |
| // Add a load event handler for the iframe element. |
| EXPECT_TRUE(ExecuteScript(shell()->web_contents(), |
| @@ -6182,9 +6055,7 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, ScreenCoordinates) { |
| "a.com", "/cross_site_iframe_factory.html?a(b)")); |
| NavigateToURL(shell(), main_url); |
| - FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) |
| - ->GetFrameTree() |
| - ->root(); |
| + FrameTreeNode* root = web_contents()->GetFrameTree()->root(); |
| FrameTreeNode* child = root->child_at(0); |
| const char* properties[] = {"screenX", "screenY", "outerWidth", |
| @@ -6268,8 +6139,7 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, |
| "a.com", "/cross_site_iframe_factory.html?a(b)")); |
| EXPECT_TRUE(NavigateToURL(shell(), main_url)); |
| - WebContentsImpl* contents = |
| - static_cast<WebContentsImpl*>(shell()->web_contents()); |
| + WebContentsImpl* contents = web_contents(); |
| FrameTreeNode* root = contents->GetFrameTree()->root(); |
| EXPECT_EQ(1U, root->child_count()); |
| @@ -6298,4 +6168,217 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, |
| EXPECT_FALSE(rvh->is_swapped_out_); |
| } |
| +// This class will sniff incoming IPC for ViewHostMsg_TextInputStateChanged. |
| +class TextInputStateChangedMessageFilter : public BrowserMessageFilter { |
| + public: |
| + explicit TextInputStateChangedMessageFilter( |
| + RenderWidgetHostImpl* render_widget_host) |
| + : BrowserMessageFilter(ViewMsgStart), text_input_state_changed_(false) { |
| + if (!render_widget_host || !render_widget_host->GetProcess()) |
| + text_input_state_changed_ = true; |
| + old_state = *render_widget_host->GetView()->text_input_state(); |
| + render_widget_host->GetProcess()->AddFilter(this); |
| + } |
| + |
| + void WaitUntilTextInputStateChanges() { |
| + if (!text_input_state_changed_) { |
| + message_loop_runner_ = new MessageLoopRunner; |
| + message_loop_runner_->Run(); |
| + } |
| + } |
| + |
| + private: |
| + ~TextInputStateChangedMessageFilter() override {} |
| + |
| + bool OnMessageReceived(const IPC::Message& msg) override { |
| + IPC_BEGIN_MESSAGE_MAP(TextInputStateChangedMessageFilter, msg) |
| + IPC_MESSAGE_HANDLER(ViewHostMsg_TextInputStateChanged, |
| + OnTextInputStateChangedMessageReceived) |
| + IPC_END_MESSAGE_MAP() |
| + return false; |
| + } |
| + |
| + void OnTextInputStateChangedMessageReceived(const TextInputState& new_state) { |
| + if (new_state.type != old_state.type || new_state.mode != old_state.mode || |
| + new_state.value != old_state.value) { |
| + text_input_state_changed_ = true; |
| + if (message_loop_runner_) |
| + BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
| + message_loop_runner_->QuitClosure()); |
| + } |
| + } |
| + |
| + bool text_input_state_changed_; |
| + scoped_refptr<MessageLoopRunner> message_loop_runner_; |
| + TextInputState old_state; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(TextInputStateChangedMessageFilter); |
| +}; |
| + |
| +// Verify that when moving the focus between different frames, the WebContents |
| +// properly keeps track of the text input state. |
| +// The test loads a page with one input field, two out of process frames, and a |
| +// second input field positioned after the last <iframe>. Then a sequence of TAB |
| +// inputs are faked to navigate focus in between the different <input> elements. |
| +// After each change, we check with the RWHV of the frame as well as the |
| +// WebContents to make sure the text input state is as expected. |
| +IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, TextInputStateChanged) { |
| + GURL main_page_url(embedded_test_server()->GetURL( |
| + "a.com", "/textinput/page_with_input_iframeX2_input.html")); |
| + NavigateToURL(shell(), main_page_url); |
| + |
| + WebContents* contents = shell()->web_contents(); |
| + |
| + FrameTreeNode* root = web_contents()->GetFrameTree()->root(); |
| + |
| + FrameTreeNode* child_b = root->child_at(0); |
| + GURL child_b_url(embedded_test_server()->GetURL( |
| + "b.com", "/textinput/page_with_input.html")); |
| + NavigateFrameToURL(child_b, child_b_url); |
| + EXPECT_TRUE(WaitForRenderFrameReady(child_b->current_frame_host())); |
| + |
| + FrameTreeNode* child_c = root->child_at(1); |
| + GURL child_c_url(embedded_test_server()->GetURL( |
| + "c.com", "/textinput/page_with_input.html")); |
| + NavigateFrameToURL(child_c, child_c_url); |
| + EXPECT_TRUE(WaitForRenderFrameReady(child_c->current_frame_host())); |
| + |
| + RenderWidgetHostImpl* root_rwh = |
| + root->current_frame_host()->GetRenderWidgetHost(); |
| + RenderWidgetHostViewBase* root_rwhv = root_rwh->GetView(); |
| + |
| + RenderWidgetHostImpl* child_b_rwh = |
| + child_b->current_frame_host()->GetRenderWidgetHost(); |
| + RenderWidgetHostViewBase* child_b_rwhv = child_b_rwh->GetView(); |
| + |
| + RenderWidgetHostImpl* child_c_rwh = |
| + child_c->current_frame_host()->GetRenderWidgetHost(); |
| + RenderWidgetHostViewBase* child_c_rwhv = child_c_rwh->GetView(); |
| + |
| + // Change the text value in <input> field of either frame so that we can |
| + // later track the changes. |
| + EXPECT_TRUE( |
| + ExecuteScript(child_b->current_frame_host(), |
| + "document.querySelector('input').value = 'second';")); |
| + EXPECT_TRUE( |
| + ExecuteScript(child_c->current_frame_host(), |
| + "document.querySelector('input').value = 'third';")); |
| + |
| + // Verfy the input type is none in the begning. |
|
Charlie Reis
2016/04/01 21:24:10
nit: beginning
EhsanK
2016/04/02 03:14:02
Done. Thanks!
|
| + EXPECT_EQ(ui::TEXT_INPUT_TYPE_NONE, root_rwhv->text_input_state()->type); |
| + |
| + // A helper function to send a tab key to the frame and wait for a state |
| + // changed message. |
| + auto press_tab_and_wait_for_text_input_state_change = |
| + [contents](RenderWidgetHostImpl* rwh) { |
| + scoped_refptr<TextInputStateChangedMessageFilter> filter = |
| + new TextInputStateChangedMessageFilter(rwh); |
| + SimulateKeyPress(contents, ui::VKEY_TAB, false, false, false, false); |
| + filter->WaitUntilTextInputStateChanges(); |
| + }; |
| + |
| + // Send focus to the first input field |
|
Charlie Reis
2016/04/01 21:24:09
nit: End with period.
EhsanK
2016/04/02 03:14:02
Done. Thanks!
|
| + press_tab_and_wait_for_text_input_state_change(root_rwh); |
| + EXPECT_EQ(ui::TEXT_INPUT_TYPE_TEXT, root_rwhv->text_input_state()->type); |
| + EXPECT_EQ("first", root_rwhv->text_input_state()->value); |
| + |
| + // Verify the top-level state is changed. |
| + EXPECT_EQ("first", web_contents()->GetTextInputState().value); |
| + |
| + // Send focus to the input field in frame b. |
| + press_tab_and_wait_for_text_input_state_change(child_b_rwh); |
| + EXPECT_EQ(ui::TEXT_INPUT_TYPE_TEXT, child_b_rwhv->text_input_state()->type); |
| + EXPECT_EQ("second", child_b_rwhv->text_input_state()->value); |
| + |
| + EXPECT_EQ("second", web_contents()->GetTextInputState().value); |
| + |
| + // Send focus to the input field in frame c. |
| + press_tab_and_wait_for_text_input_state_change(child_c_rwh); |
| + EXPECT_EQ(ui::TEXT_INPUT_TYPE_TEXT, child_c_rwhv->text_input_state()->type); |
| + EXPECT_EQ("third", child_c_rwhv->text_input_state()->value); |
| + |
| + EXPECT_EQ("third", web_contents()->GetTextInputState().value); |
| + |
| + // Send focus to the last input field in top frame. |
| + press_tab_and_wait_for_text_input_state_change(root_rwh); |
| + EXPECT_EQ(ui::TEXT_INPUT_TYPE_TEXT, root_rwhv->text_input_state()->type); |
| + EXPECT_EQ("fourth", root_rwhv->text_input_state()->value); |
| + |
| + EXPECT_EQ("fourth", web_contents()->GetTextInputState().value); |
| +} |
| + |
| +IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, |
| + TextInputStateChangesAfterRendererCrashes) { |
| + GURL main_url( |
| + embedded_test_server()->GetURL("a.com", "/page_with_iframe.html")); |
| + NavigateToURL(shell(), main_url); |
| + WebContentsImpl* contents = web_contents(); |
| + |
| + FrameTreeNode* root = contents->GetFrameTree()->root(); |
| + |
| + FrameTreeNode* child = root->child_at(0); |
| + GURL child_url(embedded_test_server()->GetURL( |
| + "b.com", "/textinput/page_with_input.html")); |
| + NavigateFrameToURL(child, child_url); |
| + EXPECT_TRUE(WaitForRenderFrameReady(child->current_frame_host())); |
| + |
| + // Verify that the text input state is initially none. |
| + EXPECT_EQ(ui::TEXT_INPUT_TYPE_NONE, contents->GetTextInputState().type); |
| + |
| + auto press_tab_and_wait_for_state_change = |
| + [contents](RenderWidgetHostImpl* rwh) { |
| + scoped_refptr<TextInputStateChangedMessageFilter> filter = |
| + new TextInputStateChangedMessageFilter(rwh); |
| + SimulateKeyPress(contents, ui::VKEY_TAB, false, false, false, false); |
| + filter->WaitUntilTextInputStateChanges(); |
| + }; |
| + |
| + auto crash_renderer_and_wait_for_input_state_none = [contents]( |
| + RenderProcessHost* host) { |
| + RenderProcessHostWatcher crash_observer( |
| + host, RenderProcessHostWatcher::WATCH_FOR_PROCESS_EXIT); |
| + host->Shutdown(0, false); |
| + crash_observer.Wait(); |
| + |
| + // We need to wait until the actual text input state update occurs. |
| + while (contents->GetTextInputState().type != ui::TEXT_INPUT_TYPE_NONE) { |
| + scoped_refptr<MessageLoopRunner> loop_runner_ = new MessageLoopRunner(); |
| + BrowserThread::PostDelayedTask(BrowserThread::UI, FROM_HERE, |
| + loop_runner_->QuitClosure(), |
| + base::TimeDelta::FromMilliseconds(0LL)); |
| + loop_runner_->Run(); |
| + } |
| + }; |
| + |
| + // Press a tab key to focus the <input> and verify that the top level |
| + // WebContents sees it. |
| + RenderWidgetHostImpl* child_rwh = |
| + child->current_frame_host()->GetRenderWidgetHost(); |
| + press_tab_and_wait_for_state_change(child_rwh); |
| + EXPECT_EQ(ui::TEXT_INPUT_TYPE_TEXT, contents->GetTextInputState().type); |
| + |
| + // Crash the renderer and wait until WebContentsImpl has updates the |
| + // state. |
| + RenderProcessHost* child_process = child_rwh->GetProcess(); |
| + crash_renderer_and_wait_for_input_state_none(child_process); |
| + |
| + // Now repeat the same test for the top level RWHV. |
| + // First remove the <iframe> and append an <input> |
| + EXPECT_TRUE(ExecuteScript(contents, |
| + "var f = document.querySelector('iframe'); " |
| + "f.parentNode.removeChild(f);")); |
| + EXPECT_TRUE(ExecuteScript( |
| + contents, "document.body.appendChild(document.createElement('input'));")); |
| + |
| + // Press tab to focus the <input> and observe the state change. |
| + RenderWidgetHostImpl* root_rwh = |
| + root->current_frame_host()->GetRenderWidgetHost(); |
| + press_tab_and_wait_for_state_change(root_rwh); |
| + EXPECT_EQ(ui::TEXT_INPUT_TYPE_TEXT, contents->GetTextInputState().type); |
| + |
| + // Crash the tab renderer and observer the input state going back to none. |
| + RenderProcessHost* host_process = root_rwh->GetProcess(); |
| + crash_renderer_and_wait_for_input_state_none(host_process); |
| +} |
| + |
| } // namespace content |