OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/command_line.h" | 5 #include "base/command_line.h" |
6 #include "base/files/file_path.h" | 6 #include "base/files/file_path.h" |
7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
8 #include "base/test/histogram_tester.h" | 8 #include "base/test/histogram_tester.h" |
9 #include "base/time/time.h" | 9 #include "base/time/time.h" |
10 #include "content/browser/compositor/test/no_transport_image_transport_factory.h
" | 10 #include "content/browser/compositor/test/no_transport_image_transport_factory.h
" |
(...skipping 2234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2245 // |contents1| -- that was http://crbug.com/473714. | 2245 // |contents1| -- that was http://crbug.com/473714. |
2246 EXPECT_FALSE(contents2->GetMainFrame()->IsRenderFrameLive()); | 2246 EXPECT_FALSE(contents2->GetMainFrame()->IsRenderFrameLive()); |
2247 contents2->NavigateAndCommit(kUrl3); | 2247 contents2->NavigateAndCommit(kUrl3); |
2248 EXPECT_TRUE(contents2->GetMainFrame()->IsRenderFrameLive()); | 2248 EXPECT_TRUE(contents2->GetMainFrame()->IsRenderFrameLive()); |
2249 EXPECT_NE(nullptr, | 2249 EXPECT_NE(nullptr, |
2250 iframe->GetRenderFrameProxyHost(contents1->GetSiteInstance())); | 2250 iframe->GetRenderFrameProxyHost(contents1->GetSiteInstance())); |
2251 EXPECT_EQ(nullptr, | 2251 EXPECT_EQ(nullptr, |
2252 iframe->GetRenderFrameProxyHost(contents2->GetSiteInstance())); | 2252 iframe->GetRenderFrameProxyHost(contents2->GetSiteInstance())); |
2253 } | 2253 } |
2254 | 2254 |
| 2255 // Ensure that we don't grant WebUI bindings to a pending RenderViewHost when |
| 2256 // creating proxies for a non-WebUI subframe navigation. This was possible due |
| 2257 // to the InitRenderView call from CreateRenderFrameProxy. |
| 2258 // See https://crbug.com/536145. |
| 2259 TEST_F(RenderFrameHostManagerTestWithSiteIsolation, |
| 2260 DontGrantPendingWebUIToSubframe) { |
| 2261 set_should_create_webui(true); |
| 2262 |
| 2263 // Make sure the initial process is live so that the pending WebUI navigation |
| 2264 // does not commit immediately. Give the page a subframe as well. |
| 2265 const GURL kUrl1("http://foo.com"); |
| 2266 RenderFrameHostImpl* main_rfh = contents()->GetMainFrame(); |
| 2267 NavigateAndCommit(kUrl1); |
| 2268 EXPECT_TRUE(main_rfh->render_view_host()->IsRenderViewLive()); |
| 2269 EXPECT_TRUE(main_rfh->IsRenderFrameLive()); |
| 2270 main_rfh->OnCreateChildFrame(main_rfh->GetProcess()->GetNextRoutingID(), |
| 2271 blink::WebTreeScopeType::Document, std::string(), |
| 2272 blink::WebSandboxFlags::None); |
| 2273 RenderFrameHostManager* subframe_rfhm = |
| 2274 contents()->GetFrameTree()->root()->child_at(0)->render_manager(); |
| 2275 |
| 2276 // Start a pending WebUI navigation in the main frame and verify that the |
| 2277 // pending RVH has bindings. |
| 2278 const GURL kWebUIUrl("chrome://foo"); |
| 2279 NavigationEntryImpl webui_entry( |
| 2280 nullptr /* instance */, -1 /* page_id */, kWebUIUrl, Referrer(), |
| 2281 base::string16() /* title */, ui::PAGE_TRANSITION_TYPED, |
| 2282 false /* is_renderer_init */); |
| 2283 RenderFrameHostManager* main_rfhm = contents()->GetRenderManagerForTesting(); |
| 2284 RenderFrameHostImpl* webui_rfh = NavigateToEntry(main_rfhm, webui_entry); |
| 2285 EXPECT_EQ(webui_rfh, GetPendingFrameHost(main_rfhm)); |
| 2286 EXPECT_TRUE(webui_rfh->render_view_host()->GetEnabledBindings() & |
| 2287 BINDINGS_POLICY_WEB_UI); |
| 2288 |
| 2289 // Before it commits, do a cross-process navigation in a subframe. This |
| 2290 // should not grant WebUI bindings to the subframe's RVH. |
| 2291 const GURL kSubframeUrl("http://bar.com"); |
| 2292 NavigationEntryImpl subframe_entry( |
| 2293 nullptr /* instance */, -1 /* page_id */, kSubframeUrl, Referrer(), |
| 2294 base::string16() /* title */, ui::PAGE_TRANSITION_LINK, |
| 2295 false /* is_renderer_init */); |
| 2296 RenderFrameHostImpl* bar_rfh = NavigateToEntry(subframe_rfhm, subframe_entry); |
| 2297 EXPECT_FALSE(bar_rfh->render_view_host()->GetEnabledBindings() & |
| 2298 BINDINGS_POLICY_WEB_UI); |
| 2299 } |
| 2300 |
2255 // Test that opener proxies are created properly with a cycle on the opener | 2301 // Test that opener proxies are created properly with a cycle on the opener |
2256 // chain. | 2302 // chain. |
2257 TEST_F(RenderFrameHostManagerTest, CreateOpenerProxiesWithCycleOnOpenerChain) { | 2303 TEST_F(RenderFrameHostManagerTest, CreateOpenerProxiesWithCycleOnOpenerChain) { |
2258 const GURL kUrl1("http://www.google.com/"); | 2304 const GURL kUrl1("http://www.google.com/"); |
2259 const GURL kUrl2("http://www.chromium.org/"); | 2305 const GURL kUrl2("http://www.chromium.org/"); |
2260 | 2306 |
2261 // Navigate to an initial URL. | 2307 // Navigate to an initial URL. |
2262 contents()->NavigateAndCommit(kUrl1); | 2308 contents()->NavigateAndCommit(kUrl1); |
2263 TestRenderFrameHost* rfh1 = main_test_rfh(); | 2309 TestRenderFrameHost* rfh1 = main_test_rfh(); |
2264 scoped_refptr<SiteInstanceImpl> site_instance1 = rfh1->GetSiteInstance(); | 2310 scoped_refptr<SiteInstanceImpl> site_instance1 = rfh1->GetSiteInstance(); |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2427 EXPECT_EQ(tree4, opener_frame_trees[3]); | 2473 EXPECT_EQ(tree4, opener_frame_trees[3]); |
2428 | 2474 |
2429 EXPECT_EQ(2U, nodes_with_back_links.size()); | 2475 EXPECT_EQ(2U, nodes_with_back_links.size()); |
2430 EXPECT_TRUE(nodes_with_back_links.find(root1->child_at(1)) != | 2476 EXPECT_TRUE(nodes_with_back_links.find(root1->child_at(1)) != |
2431 nodes_with_back_links.end()); | 2477 nodes_with_back_links.end()); |
2432 EXPECT_TRUE(nodes_with_back_links.find(root4->child_at(0)) != | 2478 EXPECT_TRUE(nodes_with_back_links.find(root4->child_at(0)) != |
2433 nodes_with_back_links.end()); | 2479 nodes_with_back_links.end()); |
2434 } | 2480 } |
2435 | 2481 |
2436 } // namespace content | 2482 } // namespace content |
OLD | NEW |