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 039a331eafa71efa0e1b3dac131aeb9b0f3b68c4..29991195ae5673a7bf5e89ea5243000d9671637e 100644 |
--- a/content/browser/site_per_process_browsertest.cc |
+++ b/content/browser/site_per_process_browsertest.cc |
@@ -602,9 +602,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()); |
@@ -618,8 +616,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()); |
} |
@@ -652,8 +649,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 = |
@@ -700,8 +696,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()); |
@@ -768,9 +763,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); |
@@ -796,8 +789,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()); |
@@ -849,9 +841,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); |
@@ -867,8 +857,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()); |
@@ -911,9 +900,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); |
@@ -944,9 +931,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()); |
@@ -1003,9 +988,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()); |
@@ -1067,9 +1050,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()); |
@@ -1136,9 +1117,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()); |
@@ -1244,9 +1223,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()); |
@@ -1295,9 +1272,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()); |
@@ -1382,9 +1357,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. |
{ |
@@ -1438,9 +1411,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(); |
@@ -1542,9 +1513,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( |
@@ -1611,9 +1580,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" |
@@ -1688,9 +1655,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. |
@@ -1776,9 +1741,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( |
@@ -1850,9 +1813,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" |
@@ -1913,9 +1874,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. |
@@ -2158,9 +2117,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()); |
@@ -2306,9 +2263,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( |
@@ -2379,9 +2334,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( |
@@ -2471,9 +2424,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" |
@@ -2562,9 +2513,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()); |
@@ -2662,9 +2611,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()); |
@@ -2786,9 +2733,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()); |
@@ -2860,9 +2805,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()); |
@@ -2941,9 +2884,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( |
@@ -3022,9 +2963,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()); |
@@ -3055,9 +2994,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. |
@@ -3114,9 +3051,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( |
@@ -3167,9 +3102,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()); |
@@ -3203,9 +3136,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. |
@@ -3239,9 +3170,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); |
@@ -3286,9 +3215,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. |
@@ -3311,9 +3238,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()); |
@@ -3359,9 +3284,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()); |
@@ -3470,9 +3393,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); |
@@ -3547,9 +3468,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()); |
@@ -3608,9 +3527,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")); |
@@ -3676,9 +3593,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")); |
@@ -3729,9 +3644,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")); |
@@ -3789,9 +3702,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 |
@@ -3864,9 +3775,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( |
@@ -3913,9 +3822,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" |
@@ -3980,9 +3887,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( |
@@ -4069,9 +3974,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(); |
RenderFrameDeletedObserver deleted_observer(rfh); |
@@ -4132,9 +4035,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" |
@@ -4194,9 +4095,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" |
@@ -4273,9 +4172,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" |
@@ -4341,9 +4238,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" |
@@ -4480,9 +4375,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(), |
@@ -4501,9 +4394,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 |
@@ -4546,9 +4438,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( |
@@ -4567,7 +4458,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); |
@@ -4603,9 +4494,7 @@ 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(); |
+ FrameTreeNode* root = web_contents()->GetFrameTree()->root(); |
ASSERT_EQ(1U, root->child_count()); |
GURL frame_url( |
@@ -4739,9 +4628,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( |
@@ -4761,10 +4649,10 @@ 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(); |
+ contents->GetInputEventRouter(); |
EXPECT_TRUE(router->gesture_target_queue_.empty()); |
EXPECT_EQ(nullptr, router->gesture_target_); |
@@ -4828,9 +4716,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")); |
@@ -4849,9 +4736,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( |
@@ -4994,9 +4881,7 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, MAYBE_CreateContextMenuTest) { |
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); |
@@ -5029,8 +4914,7 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, MAYBE_CreateContextMenuTest) { |
shell()->web_contents()->SetDelegate(&context_menu_delegate); |
RenderWidgetHostInputEventRouter* router = |
- static_cast<WebContentsImpl*>(shell()->web_contents()) |
- ->GetInputEventRouter(); |
+ web_contents()->GetInputEventRouter(); |
// Target right-click event to child frame. |
blink::WebMouseEvent click_event; |
@@ -5232,10 +5116,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()); |
@@ -5309,12 +5190,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()); |
@@ -5334,10 +5214,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; |
@@ -5359,7 +5239,7 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, ParentDetachRemoteChild) { |
// 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), |
+ contents->GetFrameTree()->root()->child_at(0), |
embedded_test_server()->GetURL("d.com", "/title3.html")); |
watcher.Wait(); |
EXPECT_TRUE(watcher.did_exit_normally()); |
@@ -5374,9 +5254,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()); |
@@ -5414,9 +5292,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( |
@@ -5470,9 +5346,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( |
@@ -5522,9 +5396,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(), |
@@ -5593,9 +5465,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. |
@@ -5664,9 +5534,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()); |
@@ -5692,9 +5560,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) |
@@ -5733,9 +5599,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); |
@@ -5751,9 +5615,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(); |
@@ -5775,6 +5637,145 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, CrossSiteIframeDisplayNone) { |
observer->Wait(); |
} |
+// 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. |
+ 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 |
+ 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); |
+} |
+ |
// Test that a cross-origin iframe can be blocked by X-Frame-Options and CSP |
// frame-ancestors. |
IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, |
@@ -5783,9 +5784,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(), |
@@ -5853,9 +5852,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", |