Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1216)

Side by Side Diff: content/browser/frame_host/render_frame_host_manager_unittest.cc

Issue 1141283002: Replicate whether a frame is in a document or shadow tree. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix typo Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/frame_host/cross_site_transferring_request.h" 10 #include "content/browser/frame_host/cross_site_transferring_request.h"
(...skipping 652 matching lines...) Expand 10 before | Expand all | Expand 10 after
663 TEST_F(RenderFrameHostManagerTest, DropCreateChildFrameWhileSwappedOut) { 663 TEST_F(RenderFrameHostManagerTest, DropCreateChildFrameWhileSwappedOut) {
664 const GURL kUrl1("http://foo.com"); 664 const GURL kUrl1("http://foo.com");
665 const GURL kUrl2("http://www.google.com/"); 665 const GURL kUrl2("http://www.google.com/");
666 666
667 // Navigate to the first site. 667 // Navigate to the first site.
668 NavigateActiveAndCommit(kUrl1); 668 NavigateActiveAndCommit(kUrl1);
669 TestRenderFrameHost* initial_rfh = contents()->GetMainFrame(); 669 TestRenderFrameHost* initial_rfh = contents()->GetMainFrame();
670 { 670 {
671 RenderFrameHostCreatedObserver observer(contents()); 671 RenderFrameHostCreatedObserver observer(contents());
672 initial_rfh->OnCreateChildFrame( 672 initial_rfh->OnCreateChildFrame(
673 initial_rfh->GetProcess()->GetNextRoutingID(), std::string(), 673 initial_rfh->GetProcess()->GetNextRoutingID(),
674 SandboxFlags::NONE); 674 blink::WebTreeScopeType::Document, std::string(), SandboxFlags::NONE);
675 EXPECT_TRUE(observer.created()); 675 EXPECT_TRUE(observer.created());
676 } 676 }
677 677
678 // Create one more frame in the same SiteInstance where initial_rfh 678 // Create one more frame in the same SiteInstance where initial_rfh
679 // exists so that initial_rfh doesn't get deleted on navigation to another 679 // exists so that initial_rfh doesn't get deleted on navigation to another
680 // site. 680 // site.
681 initial_rfh->GetSiteInstance()->increment_active_frame_count(); 681 initial_rfh->GetSiteInstance()->increment_active_frame_count();
682 682
683 // Navigate to a cross-site URL. 683 // Navigate to a cross-site URL.
684 NavigateActiveAndCommit(kUrl2); 684 NavigateActiveAndCommit(kUrl2);
685 EXPECT_TRUE(initial_rfh->is_swapped_out()); 685 EXPECT_TRUE(initial_rfh->is_swapped_out());
686 686
687 TestRenderFrameHost* dest_rfh = contents()->GetMainFrame(); 687 TestRenderFrameHost* dest_rfh = contents()->GetMainFrame();
688 ASSERT_TRUE(dest_rfh); 688 ASSERT_TRUE(dest_rfh);
689 EXPECT_NE(initial_rfh, dest_rfh); 689 EXPECT_NE(initial_rfh, dest_rfh);
690 690
691 { 691 {
692 // Since the old RFH is now swapped out, it shouldn't process any messages 692 // Since the old RFH is now swapped out, it shouldn't process any messages
693 // to create child frames. 693 // to create child frames.
694 RenderFrameHostCreatedObserver observer(contents()); 694 RenderFrameHostCreatedObserver observer(contents());
695 initial_rfh->OnCreateChildFrame( 695 initial_rfh->OnCreateChildFrame(
696 initial_rfh->GetProcess()->GetNextRoutingID(), std::string(), 696 initial_rfh->GetProcess()->GetNextRoutingID(),
697 SandboxFlags::NONE); 697 blink::WebTreeScopeType::Document, std::string(), SandboxFlags::NONE);
698 EXPECT_FALSE(observer.created()); 698 EXPECT_FALSE(observer.created());
699 } 699 }
700 } 700 }
701 701
702 TEST_F(RenderFrameHostManagerTest, WhiteListSwapCompositorFrame) { 702 TEST_F(RenderFrameHostManagerTest, WhiteListSwapCompositorFrame) {
703 TestRenderFrameHost* swapped_out_rfh = CreateSwappedOutRenderFrameHost(); 703 TestRenderFrameHost* swapped_out_rfh = CreateSwappedOutRenderFrameHost();
704 TestRenderWidgetHostView* swapped_out_rwhv = 704 TestRenderWidgetHostView* swapped_out_rwhv =
705 static_cast<TestRenderWidgetHostView*>( 705 static_cast<TestRenderWidgetHostView*>(
706 swapped_out_rfh->GetRenderViewHost()->GetView()); 706 swapped_out_rfh->GetRenderViewHost()->GetView());
707 EXPECT_FALSE(swapped_out_rwhv->did_swap_compositor_frame()); 707 EXPECT_FALSE(swapped_out_rwhv->did_swap_compositor_frame());
(...skipping 1261 matching lines...) Expand 10 before | Expand all | Expand 10 after
1969 base::CommandLine::ForCurrentProcess()->AppendSwitch( 1969 base::CommandLine::ForCurrentProcess()->AppendSwitch(
1970 switches::kSitePerProcess); 1970 switches::kSitePerProcess);
1971 1971
1972 const GURL kUrlA("http://www.google.com/"); 1972 const GURL kUrlA("http://www.google.com/");
1973 const GURL kUrlB("http://webkit.org/"); 1973 const GURL kUrlB("http://webkit.org/");
1974 1974
1975 // Create a page with two child frames. 1975 // Create a page with two child frames.
1976 contents()->NavigateAndCommit(kUrlA); 1976 contents()->NavigateAndCommit(kUrlA);
1977 contents()->GetMainFrame()->OnCreateChildFrame( 1977 contents()->GetMainFrame()->OnCreateChildFrame(
1978 contents()->GetMainFrame()->GetProcess()->GetNextRoutingID(), 1978 contents()->GetMainFrame()->GetProcess()->GetNextRoutingID(),
1979 std::string("frame_name"), SandboxFlags::NONE); 1979 blink::WebTreeScopeType::Document, "frame_name", SandboxFlags::NONE);
1980 contents()->GetMainFrame()->OnCreateChildFrame( 1980 contents()->GetMainFrame()->OnCreateChildFrame(
1981 contents()->GetMainFrame()->GetProcess()->GetNextRoutingID(), 1981 contents()->GetMainFrame()->GetProcess()->GetNextRoutingID(),
1982 std::string("frame_name"), SandboxFlags::NONE); 1982 blink::WebTreeScopeType::Document, "frame_name", SandboxFlags::NONE);
1983 RenderFrameHostManager* root_manager = 1983 RenderFrameHostManager* root_manager =
1984 contents()->GetFrameTree()->root()->render_manager(); 1984 contents()->GetFrameTree()->root()->render_manager();
1985 RenderFrameHostManager* iframe1 = 1985 RenderFrameHostManager* iframe1 =
1986 contents()->GetFrameTree()->root()->child_at(0)->render_manager(); 1986 contents()->GetFrameTree()->root()->child_at(0)->render_manager();
1987 RenderFrameHostManager* iframe2 = 1987 RenderFrameHostManager* iframe2 =
1988 contents()->GetFrameTree()->root()->child_at(1)->render_manager(); 1988 contents()->GetFrameTree()->root()->child_at(1)->render_manager();
1989 1989
1990 // 1) The first navigation. 1990 // 1) The first navigation.
1991 NavigationEntryImpl entryA(NULL /* instance */, -1 /* page_id */, kUrlA, 1991 NavigationEntryImpl entryA(NULL /* instance */, -1 /* page_id */, kUrlA,
1992 Referrer(), base::string16() /* title */, 1992 Referrer(), base::string16() /* title */,
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
2110 2110
2111 // Reload |contents1|. 2111 // Reload |contents1|.
2112 contents1->NavigateAndCommit(kUrl1); 2112 contents1->NavigateAndCommit(kUrl1);
2113 EXPECT_TRUE(contents1->GetMainFrame()->IsRenderFrameLive()); 2113 EXPECT_TRUE(contents1->GetMainFrame()->IsRenderFrameLive());
2114 EXPECT_FALSE(contents2->GetMainFrame()->IsRenderFrameLive()); 2114 EXPECT_FALSE(contents2->GetMainFrame()->IsRenderFrameLive());
2115 EXPECT_EQ(contents1->GetSiteInstance(), contents2->GetSiteInstance()); 2115 EXPECT_EQ(contents1->GetSiteInstance(), contents2->GetSiteInstance());
2116 2116
2117 // |contents1| creates an out of process iframe. 2117 // |contents1| creates an out of process iframe.
2118 contents1->GetMainFrame()->OnCreateChildFrame( 2118 contents1->GetMainFrame()->OnCreateChildFrame(
2119 contents1->GetMainFrame()->GetProcess()->GetNextRoutingID(), 2119 contents1->GetMainFrame()->GetProcess()->GetNextRoutingID(),
2120 std::string("frame_name"), SandboxFlags::NONE); 2120 blink::WebTreeScopeType::Document, "frame_name", SandboxFlags::NONE);
2121 RenderFrameHostManager* iframe = 2121 RenderFrameHostManager* iframe =
2122 contents()->GetFrameTree()->root()->child_at(0)->render_manager(); 2122 contents()->GetFrameTree()->root()->child_at(0)->render_manager();
2123 NavigationEntryImpl entry(NULL /* instance */, -1 /* page_id */, kUrl2, 2123 NavigationEntryImpl entry(NULL /* instance */, -1 /* page_id */, kUrl2,
2124 Referrer(kUrl1, blink::WebReferrerPolicyDefault), 2124 Referrer(kUrl1, blink::WebReferrerPolicyDefault),
2125 base::string16() /* title */, 2125 base::string16() /* title */,
2126 ui::PAGE_TRANSITION_LINK, 2126 ui::PAGE_TRANSITION_LINK,
2127 false /* is_renderer_init */); 2127 false /* is_renderer_init */);
2128 RenderFrameHostImpl* cross_site = NavigateToEntry(iframe, entry); 2128 RenderFrameHostImpl* cross_site = NavigateToEntry(iframe, entry);
2129 iframe->DidNavigateFrame(cross_site, true); 2129 iframe->DidNavigateFrame(cross_site, true);
2130 2130
(...skipping 11 matching lines...) Expand all
2142 EXPECT_FALSE(contents2->GetMainFrame()->IsRenderFrameLive()); 2142 EXPECT_FALSE(contents2->GetMainFrame()->IsRenderFrameLive());
2143 contents2->NavigateAndCommit(kUrl3); 2143 contents2->NavigateAndCommit(kUrl3);
2144 EXPECT_TRUE(contents2->GetMainFrame()->IsRenderFrameLive()); 2144 EXPECT_TRUE(contents2->GetMainFrame()->IsRenderFrameLive());
2145 EXPECT_NE(nullptr, 2145 EXPECT_NE(nullptr,
2146 iframe->GetRenderFrameProxyHost(contents1->GetSiteInstance())); 2146 iframe->GetRenderFrameProxyHost(contents1->GetSiteInstance()));
2147 EXPECT_EQ(nullptr, 2147 EXPECT_EQ(nullptr,
2148 iframe->GetRenderFrameProxyHost(contents2->GetSiteInstance())); 2148 iframe->GetRenderFrameProxyHost(contents2->GetSiteInstance()));
2149 } 2149 }
2150 2150
2151 } // namespace content 2151 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698