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..3d893f2b34f9953dbfe1f8af14ae935d59150d19 100644 |
--- a/content/browser/site_per_process_browsertest.cc |
+++ b/content/browser/site_per_process_browsertest.cc |
@@ -563,6 +563,9 @@ void SitePerProcessBrowserTest::SetUpOnMainThread() { |
SetupCrossSiteRedirector(embedded_test_server()); |
} |
+WebContentsImpl* SitePerProcessBrowserTest::GetWebContents() { |
+ return static_cast<WebContentsImpl*>(shell()->web_contents()); |
+} |
// |
// SitePerProcessHighDPIBrowserTest |
// |
@@ -602,9 +605,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 = GetWebContents()->GetFrameTree()->root(); |
TestNavigationObserver observer(shell()->web_contents()); |
@@ -618,8 +619,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(); |
+ GetWebContents()->GetRenderWidgetHostViewsInTree(); |
EXPECT_EQ(1U, views_set.size()); |
} |
@@ -652,8 +652,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(); |
+ GetWebContents()->GetRenderWidgetHostViewsInTree(); |
EXPECT_EQ(2U, views_set.size()); |
} |
RenderFrameProxyHost* proxy_to_parent = |
@@ -700,8 +699,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(); |
+ GetWebContents()->GetRenderWidgetHostViewsInTree(); |
EXPECT_EQ(2U, views_set.size()); |
} |
EXPECT_EQ(proxy_to_parent, child->render_manager()->GetProxyToParent()); |
@@ -768,9 +766,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 = GetWebContents()->GetFrameTree()->root(); |
ASSERT_EQ(1U, root->child_count()); |
FrameTreeNode* parent_iframe_node = root->child_at(0); |
@@ -796,8 +792,7 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, |
nested_iframe_node->current_frame_host()->GetRenderWidgetHost()); |
RenderWidgetHostInputEventRouter* router = |
- static_cast<WebContentsImpl*>(shell()->web_contents()) |
- ->GetInputEventRouter(); |
+ GetWebContents()->GetInputEventRouter(); |
RenderWidgetHostViewBase* root_view = static_cast<RenderWidgetHostViewBase*>( |
root->current_frame_host()->GetRenderWidgetHost()->GetView()); |
@@ -849,9 +844,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 = GetWebContents()->GetFrameTree()->root(); |
ASSERT_EQ(1U, root->child_count()); |
FrameTreeNode* child_node = root->child_at(0); |
@@ -867,8 +860,7 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, |
child_node->current_frame_host()->GetRenderWidgetHost()); |
RenderWidgetHostInputEventRouter* router = |
- static_cast<WebContentsImpl*>(shell()->web_contents()) |
- ->GetInputEventRouter(); |
+ GetWebContents()->GetInputEventRouter(); |
RenderWidgetHostViewBase* root_view = static_cast<RenderWidgetHostViewBase*>( |
root->current_frame_host()->GetRenderWidgetHost()->GetView()); |
@@ -911,9 +903,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 = GetWebContents()->GetFrameTree()->root(); |
ASSERT_EQ(1U, root->child_count()); |
FrameTreeNode* child_node = root->child_at(0); |
@@ -944,9 +934,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 = GetWebContents()->GetFrameTree()->root(); |
TestNavigationObserver observer(shell()->web_contents()); |
@@ -1003,9 +991,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 = GetWebContents()->GetFrameTree()->root(); |
TestNavigationObserver observer(shell()->web_contents()); |
@@ -1067,9 +1053,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 = GetWebContents()->GetFrameTree()->root(); |
TestNavigationObserver observer(shell()->web_contents()); |
@@ -1136,9 +1120,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 = GetWebContents()->GetFrameTree()->root(); |
TestNavigationObserver observer(shell()->web_contents()); |
@@ -1244,9 +1226,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 = GetWebContents()->GetFrameTree()->root(); |
TestNavigationObserver observer(shell()->web_contents()); |
ASSERT_EQ(2U, root->child_count()); |
@@ -1295,9 +1275,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 = GetWebContents()->GetFrameTree()->root(); |
TestNavigationObserver observer(shell()->web_contents()); |
ASSERT_EQ(2U, root->child_count()); |
@@ -1382,9 +1360,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 = GetWebContents()->GetFrameTree()->root(); |
// Load same-site page into iframe. |
{ |
@@ -1438,9 +1414,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 = GetWebContents()->GetFrameTree()->root(); |
FrameTreeNode* child = root->child_at(0); |
GURL url_a = child->current_url(); |
@@ -1542,9 +1516,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 = GetWebContents()->GetFrameTree()->root(); |
TestNavigationObserver observer(shell()->web_contents()); |
EXPECT_EQ( |
@@ -1611,9 +1583,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 = GetWebContents()->GetFrameTree()->root(); |
EXPECT_EQ( |
" Site A ------------ proxies for B\n" |
@@ -1688,9 +1658,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 = GetWebContents()->GetFrameTree()->root(); |
SiteInstance* site_instance_a = root->current_frame_host()->GetSiteInstance(); |
// Open a popup and navigate it cross-process to b.com. |
@@ -1776,9 +1744,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 = GetWebContents()->GetFrameTree()->root(); |
ASSERT_EQ(2U, root->child_count()); |
GURL site_b_url( |
@@ -1850,9 +1816,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 = GetWebContents()->GetFrameTree()->root(); |
EXPECT_EQ( |
" Site A ------------ proxies for B\n" |
" +--Site B ------- proxies for A\n" |
@@ -1913,9 +1877,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 = GetWebContents()->GetFrameTree()->root(); |
ASSERT_EQ(1U, root->child_count()); |
// Make sure the frame starts out at the correct cross-site URL. |
@@ -2158,9 +2120,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 = GetWebContents()->GetFrameTree()->root(); |
EXPECT_TRUE(root->child_at(1) != NULL); |
EXPECT_EQ(2U, root->child_at(1)->child_count()); |
@@ -2306,9 +2266,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 = GetWebContents()->GetFrameTree()->root(); |
ASSERT_EQ(1u, root->child_count()); |
EXPECT_EQ( |
@@ -2379,9 +2337,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 = GetWebContents()->GetFrameTree()->root(); |
ASSERT_EQ(1u, root->child_count()); |
EXPECT_EQ( |
@@ -2471,9 +2427,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 = GetWebContents()->GetFrameTree()->root(); |
EXPECT_EQ( |
" Site A ------------ proxies for B C\n" |
@@ -2562,9 +2516,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 = GetWebContents()->GetFrameTree()->root(); |
TestNavigationObserver observer(shell()->web_contents()); |
@@ -2662,9 +2614,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 = GetWebContents()->GetFrameTree()->root(); |
TestNavigationObserver observer(shell()->web_contents()); |
ASSERT_EQ(2U, root->child_count()); |
@@ -2786,9 +2736,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 = GetWebContents()->GetFrameTree()->root(); |
TestNavigationObserver observer(shell()->web_contents()); |
ASSERT_EQ(2U, root->child_count()); |
@@ -2860,9 +2808,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 = GetWebContents()->GetFrameTree()->root(); |
TestNavigationObserver observer(shell()->web_contents()); |
ASSERT_EQ(1U, root->child_count()); |
@@ -2941,9 +2887,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 = GetWebContents()->GetFrameTree()->root(); |
TestNavigationObserver observer(shell()->web_contents()); |
EXPECT_EQ( |
@@ -3022,9 +2966,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 = GetWebContents()->GetFrameTree()->root(); |
TestNavigationObserver observer(shell()->web_contents()); |
@@ -3055,9 +2997,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 = GetWebContents()->GetFrameTree()->root(); |
TestNavigationObserver observer(shell()->web_contents()); |
// Load cross-site page into iframe. |
@@ -3114,9 +3054,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 = GetWebContents()->GetFrameTree()->root(); |
TestNavigationObserver observer(shell()->web_contents()); |
EXPECT_EQ( |
@@ -3167,9 +3105,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 = GetWebContents()->GetFrameTree()->root(); |
TestNavigationObserver observer(shell()->web_contents()); |
@@ -3203,9 +3139,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 = GetWebContents()->GetFrameTree()->root(); |
TestNavigationObserver observer(shell()->web_contents()); |
// Make sure the first frame is out of process. |
@@ -3239,9 +3173,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 = GetWebContents()->GetFrameTree()->root(); |
FrameTreeNode* node2 = root->child_at(0); |
FrameTreeNode* node3 = root->child_at(1); |
@@ -3286,9 +3218,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 = GetWebContents()->GetFrameTree()->root(); |
// Load another cross-site page into the iframe and check that the load event |
// is fired. |
@@ -3311,9 +3241,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 = GetWebContents()->GetFrameTree()->root(); |
ASSERT_EQ(2U, root->child_count()); |
@@ -3359,9 +3287,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 = GetWebContents()->GetFrameTree()->root(); |
ASSERT_EQ(2U, root->child_count()); |
@@ -3470,9 +3396,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 = GetWebContents()->GetFrameTree()->root(); |
ASSERT_EQ(3U, root->child_count()); |
FrameTreeNode* child0 = root->child_at(0); |
FrameTreeNode* child1 = root->child_at(1); |
@@ -3547,9 +3471,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 = GetWebContents()->GetFrameTree()->root(); |
TestNavigationObserver observer(shell()->web_contents()); |
@@ -3608,9 +3530,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 = GetWebContents()->GetFrameTree()->root(); |
// Navigate first child cross-site. |
GURL frame_url(embedded_test_server()->GetURL("b.com", "/title1.html")); |
@@ -3676,9 +3596,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 = GetWebContents()->GetFrameTree()->root(); |
// Navigate first child cross-site. |
GURL frame_url(embedded_test_server()->GetURL("b.com", "/title1.html")); |
@@ -3729,9 +3647,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 = GetWebContents()->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 +3705,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 = GetWebContents()->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 +3778,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 = GetWebContents()->GetFrameTree()->root(); |
// Open a popup with a cross-site page that has a subframe. |
GURL popup_url(embedded_test_server()->GetURL( |
@@ -3913,9 +3825,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 = GetWebContents()->GetFrameTree()->root(); |
EXPECT_EQ( |
" Site A ------------ proxies for B\n" |
" |--Site B ------- proxies for A\n" |
@@ -3980,9 +3890,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 = GetWebContents()->GetFrameTree()->root(); |
// Open a popup with a cross-site page that has two subframes. |
GURL popup_url(embedded_test_server()->GetURL( |
@@ -4069,9 +3977,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 = GetWebContents()->GetFrameTree()->root(); |
RenderFrameHostImpl* rfh = root->current_frame_host(); |
RenderViewHostImpl* rvh = rfh->render_view_host(); |
RenderFrameDeletedObserver deleted_observer(rfh); |
@@ -4132,9 +4038,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 = GetWebContents()->GetFrameTree()->root(); |
EXPECT_EQ( |
" Site A ------------ proxies for B\n" |
@@ -4194,9 +4098,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 = GetWebContents()->GetFrameTree()->root(); |
EXPECT_EQ( |
" Site A ------------ proxies for B C\n" |
@@ -4273,9 +4175,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 = GetWebContents()->GetFrameTree()->root(); |
EXPECT_EQ( |
" Site A ------------ proxies for B C D\n" |
@@ -4341,9 +4241,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 = GetWebContents()->GetFrameTree()->root(); |
EXPECT_EQ( |
" Site A ------------ proxies for B C\n" |
@@ -4480,9 +4378,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 = GetWebContents()->GetFrameTree()->root(); |
FrameTreeNode* child_node = root->child_at(0); |
EXPECT_NE(shell()->web_contents()->GetSiteInstance(), |
@@ -4501,9 +4397,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); |
+ GetWebContents()->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,8 +4441,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()); |
+ WebContentsImpl* web_contents = GetWebContents(); |
FrameTreeNode* root = web_contents->GetFrameTree()->root(); |
ASSERT_EQ(1U, root->child_count()); |
@@ -4603,8 +4497,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()); |
+ WebContentsImpl* web_contents = GetWebContents(); |
FrameTreeNode* root = web_contents->GetFrameTree()->root(); |
ASSERT_EQ(1U, root->child_count()); |
@@ -4739,8 +4632,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()); |
+ WebContentsImpl* web_contents = GetWebContents(); |
FrameTreeNode* root = web_contents->GetFrameTree()->root(); |
ASSERT_EQ(1U, root->child_count()); |
@@ -4828,8 +4720,7 @@ 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()); |
+ WebContentsImpl* web_contents = GetWebContents(); |
FrameTreeNode* root = web_contents->GetFrameTree()->root(); |
GURL frame_url( |
@@ -4994,9 +4885,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 = GetWebContents()->GetFrameTree()->root(); |
ASSERT_EQ(1U, root->child_count()); |
FrameTreeNode* child_node = root->child_at(0); |
@@ -5029,8 +4918,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(); |
+ GetWebContents()->GetInputEventRouter(); |
// Target right-click event to child frame. |
blink::WebMouseEvent click_event; |
@@ -5232,10 +5120,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 = GetWebContents()->GetFrameTree()->root()->child_at(0); |
EXPECT_TRUE(node); |
EXPECT_NE(node->current_frame_host()->GetSiteInstance(), |
node->parent()->current_frame_host()->GetSiteInstance()); |
@@ -5309,8 +5194,7 @@ 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()); |
+ WebContentsImpl* web_contents = GetWebContents(); |
EXPECT_EQ(2U, web_contents->GetFrameTree()->root()->child_count()); |
// Capture the FrameTreeNode this test will be navigating. |
@@ -5374,9 +5258,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 = GetWebContents()->GetFrameTree()->root(); |
TestNavigationObserver observer(shell()->web_contents()); |
@@ -5414,9 +5296,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 = GetWebContents()->GetFrameTree()->root(); |
// Set sandbox flags for child frame. |
EXPECT_TRUE(ExecuteScript( |
@@ -5470,9 +5350,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 = GetWebContents()->GetFrameTree()->root(); |
// Set sandbox flags for child frame. |
EXPECT_TRUE(ExecuteScript( |
@@ -5522,9 +5400,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 = GetWebContents()->GetFrameTree()->root(); |
// Set sandbox flags for child frame. |
EXPECT_TRUE(ExecuteScript(root->current_frame_host(), |
@@ -5593,9 +5469,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 = GetWebContents()->GetFrameTree()->root(); |
// Set sandbox flags for child frame, specifying that popups opened from it |
// should not be sandboxed. |
@@ -5664,9 +5538,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 = GetWebContents()->GetFrameTree()->root(); |
NavigateFrameToURL(root->child_at(0), navigate_url); |
EXPECT_TRUE(shell()->web_contents()->DisplayedInsecureContent()); |
@@ -5692,9 +5564,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 = GetWebContents()->GetFrameTree()->root(); |
EXPECT_TRUE(root->current_replication_state() |
.should_enforce_strict_mixed_content_checking); |
EXPECT_TRUE(root->child_at(0) |
@@ -5733,9 +5603,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 = GetWebContents()->GetFrameTree()->root(); |
ASSERT_EQ(1U, root->child_count()); |
FrameTreeNode* mixed_child = root->child_at(0)->child_at(0); |
ASSERT_TRUE(mixed_child); |
@@ -5751,9 +5619,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 = GetWebContents()->GetFrameTree()->root(); |
RenderWidgetHost* root_render_widget_host = |
root->current_frame_host()->GetRenderWidgetHost(); |
@@ -5775,6 +5641,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 = GetWebContents()->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", GetWebContents()->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", GetWebContents()->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", GetWebContents()->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", GetWebContents()->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 +5788,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 = GetWebContents()->GetFrameTree()->root(); |
// Add a load event handler for the iframe element. |
EXPECT_TRUE(ExecuteScript(shell()->web_contents(), |
@@ -5853,9 +5856,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 = GetWebContents()->GetFrameTree()->root(); |
FrameTreeNode* child = root->child_at(0); |
const char* properties[] = {"screenX", "screenY", "outerWidth", |