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

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

Issue 837283003: Start replicating sandbox flags for OOPIF (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix OnCreateChildFrame usage in unit tests Created 5 years, 11 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 527 matching lines...) Expand 10 before | Expand all | Expand 10 after
538 TEST_F(RenderFrameHostManagerTest, DropCreateChildFrameWhileSwappedOut) { 538 TEST_F(RenderFrameHostManagerTest, DropCreateChildFrameWhileSwappedOut) {
539 const GURL kUrl1("http://foo.com"); 539 const GURL kUrl1("http://foo.com");
540 const GURL kUrl2("http://www.google.com/"); 540 const GURL kUrl2("http://www.google.com/");
541 541
542 // Navigate to the first site. 542 // Navigate to the first site.
543 NavigateActiveAndCommit(kUrl1); 543 NavigateActiveAndCommit(kUrl1);
544 TestRenderFrameHost* initial_rfh = contents()->GetMainFrame(); 544 TestRenderFrameHost* initial_rfh = contents()->GetMainFrame();
545 { 545 {
546 RenderFrameHostCreatedObserver observer(contents()); 546 RenderFrameHostCreatedObserver observer(contents());
547 initial_rfh->OnCreateChildFrame( 547 initial_rfh->OnCreateChildFrame(
548 initial_rfh->GetProcess()->GetNextRoutingID(), std::string()); 548 initial_rfh->GetProcess()->GetNextRoutingID(), std::string(),
549 SandboxFlags::NONE);
549 EXPECT_TRUE(observer.created()); 550 EXPECT_TRUE(observer.created());
550 } 551 }
551 552
552 // Create one more frame in the same SiteInstance where initial_rfh 553 // Create one more frame in the same SiteInstance where initial_rfh
553 // exists so that initial_rfh doesn't get deleted on navigation to another 554 // exists so that initial_rfh doesn't get deleted on navigation to another
554 // site. 555 // site.
555 initial_rfh->GetSiteInstance()->increment_active_frame_count(); 556 initial_rfh->GetSiteInstance()->increment_active_frame_count();
556 557
557 // Navigate to a cross-site URL. 558 // Navigate to a cross-site URL.
558 NavigateActiveAndCommit(kUrl2); 559 NavigateActiveAndCommit(kUrl2);
559 EXPECT_TRUE(initial_rfh->is_swapped_out()); 560 EXPECT_TRUE(initial_rfh->is_swapped_out());
560 561
561 TestRenderFrameHost* dest_rfh = contents()->GetMainFrame(); 562 TestRenderFrameHost* dest_rfh = contents()->GetMainFrame();
562 ASSERT_TRUE(dest_rfh); 563 ASSERT_TRUE(dest_rfh);
563 EXPECT_NE(initial_rfh, dest_rfh); 564 EXPECT_NE(initial_rfh, dest_rfh);
564 565
565 { 566 {
566 // Since the old RFH is now swapped out, it shouldn't process any messages 567 // Since the old RFH is now swapped out, it shouldn't process any messages
567 // to create child frames. 568 // to create child frames.
568 RenderFrameHostCreatedObserver observer(contents()); 569 RenderFrameHostCreatedObserver observer(contents());
569 initial_rfh->OnCreateChildFrame( 570 initial_rfh->OnCreateChildFrame(
570 initial_rfh->GetProcess()->GetNextRoutingID(), std::string()); 571 initial_rfh->GetProcess()->GetNextRoutingID(), std::string(),
572 SandboxFlags::NONE);
571 EXPECT_FALSE(observer.created()); 573 EXPECT_FALSE(observer.created());
572 } 574 }
573 } 575 }
574 576
575 TEST_F(RenderFrameHostManagerTest, WhiteListSwapCompositorFrame) { 577 TEST_F(RenderFrameHostManagerTest, WhiteListSwapCompositorFrame) {
576 TestRenderFrameHost* swapped_out_rfh = CreateSwappedOutRenderFrameHost(); 578 TestRenderFrameHost* swapped_out_rfh = CreateSwappedOutRenderFrameHost();
577 TestRenderWidgetHostView* swapped_out_rwhv = 579 TestRenderWidgetHostView* swapped_out_rwhv =
578 static_cast<TestRenderWidgetHostView*>( 580 static_cast<TestRenderWidgetHostView*>(
579 swapped_out_rfh->GetRenderViewHost()->GetView()); 581 swapped_out_rfh->GetRenderViewHost()->GetView());
580 EXPECT_FALSE(swapped_out_rwhv->did_swap_compositor_frame()); 582 EXPECT_FALSE(swapped_out_rwhv->did_swap_compositor_frame());
(...skipping 1194 matching lines...) Expand 10 before | Expand all | Expand 10 after
1775 switches::kSitePerProcess); 1777 switches::kSitePerProcess);
1776 1778
1777 const GURL kUrl1("http://www.google.com/"); 1779 const GURL kUrl1("http://www.google.com/");
1778 const GURL kUrl2("http://webkit.org/"); 1780 const GURL kUrl2("http://webkit.org/");
1779 1781
1780 RenderFrameHostImpl* host = NULL; 1782 RenderFrameHostImpl* host = NULL;
1781 1783
1782 contents()->NavigateAndCommit(kUrl1); 1784 contents()->NavigateAndCommit(kUrl1);
1783 contents()->GetMainFrame()->OnCreateChildFrame( 1785 contents()->GetMainFrame()->OnCreateChildFrame(
1784 contents()->GetMainFrame()->GetProcess()->GetNextRoutingID(), 1786 contents()->GetMainFrame()->GetProcess()->GetNextRoutingID(),
1785 std::string("frame_name")); 1787 std::string("frame_name"), SandboxFlags::NONE);
1786 RenderFrameHostManager* manager = 1788 RenderFrameHostManager* manager =
1787 contents()->GetFrameTree()->root()->child_at(0)->render_manager(); 1789 contents()->GetFrameTree()->root()->child_at(0)->render_manager();
1788 1790
1789 // 1) The first navigation. -------------------------- 1791 // 1) The first navigation. --------------------------
1790 NavigationEntryImpl entry1(NULL /* instance */, -1 /* page_id */, kUrl1, 1792 NavigationEntryImpl entry1(NULL /* instance */, -1 /* page_id */, kUrl1,
1791 Referrer(), base::string16() /* title */, 1793 Referrer(), base::string16() /* title */,
1792 ui::PAGE_TRANSITION_TYPED, 1794 ui::PAGE_TRANSITION_TYPED,
1793 false /* is_renderer_init */); 1795 false /* is_renderer_init */);
1794 host = manager->Navigate(entry1); 1796 host = manager->Navigate(entry1);
1795 1797
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
1844 #if 0 1846 #if 0
1845 // TODO(nick): Currently a proxy to the removed frame lingers in the parent. 1847 // TODO(nick): Currently a proxy to the removed frame lingers in the parent.
1846 // Enable this assert below once the proxies to the subframe are correctly 1848 // Enable this assert below once the proxies to the subframe are correctly
1847 // cleaned up after detach. http://crbug.com/444955. 1849 // cleaned up after detach. http://crbug.com/444955.
1848 ASSERT_TRUE(site_instance->HasOneRef()) 1850 ASSERT_TRUE(site_instance->HasOneRef())
1849 << "This SiteInstance should be destroyable now."; 1851 << "This SiteInstance should be destroyable now.";
1850 #endif 1852 #endif
1851 } 1853 }
1852 1854
1853 } // namespace content 1855 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698