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 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
323 // state is being checked. | 323 // state is being checked. |
324 RenderFrameHostDeletedObserver rfh_observer(old_rfh); | 324 RenderFrameHostDeletedObserver rfh_observer(old_rfh); |
325 RenderViewHostDeletedObserver rvh_observer(old_rfh->GetRenderViewHost()); | 325 RenderViewHostDeletedObserver rvh_observer(old_rfh->GetRenderViewHost()); |
326 active_rfh->SendNavigate(max_page_id + 1, entry_id, true, url); | 326 active_rfh->SendNavigate(max_page_id + 1, entry_id, true, url); |
327 | 327 |
328 // Make sure that we start to run the unload handler at the time of commit. | 328 // Make sure that we start to run the unload handler at the time of commit. |
329 bool expecting_rfh_shutdown = false; | 329 bool expecting_rfh_shutdown = false; |
330 if (old_rfh != active_rfh && !rfh_observer.deleted()) { | 330 if (old_rfh != active_rfh && !rfh_observer.deleted()) { |
331 EXPECT_EQ(RenderFrameHostImpl::STATE_PENDING_SWAP_OUT, | 331 EXPECT_EQ(RenderFrameHostImpl::STATE_PENDING_SWAP_OUT, |
332 old_rfh->rfh_state()); | 332 old_rfh->rfh_state()); |
333 if (!old_rfh->GetSiteInstance()->active_frame_count()) { | 333 if (!old_rfh->GetSiteInstance()->active_frame_count() || |
| 334 base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 335 switches::kSitePerProcess)) { |
334 expecting_rfh_shutdown = true; | 336 expecting_rfh_shutdown = true; |
335 EXPECT_TRUE( | 337 EXPECT_TRUE( |
336 old_rfh->frame_tree_node()->render_manager()->IsPendingDeletion( | 338 old_rfh->frame_tree_node()->render_manager()->IsPendingDeletion( |
337 old_rfh)); | 339 old_rfh)); |
338 } | 340 } |
339 } | 341 } |
340 | 342 |
341 // Simulate the swap out ACK coming from the pending renderer. This should | 343 // Simulate the swap out ACK coming from the pending renderer. This should |
342 // either shut down the old RFH or leave it in a swapped out state. | 344 // either shut down the old RFH or leave it in a swapped out state. |
343 if (old_rfh != active_rfh) { | 345 if (old_rfh != active_rfh) { |
344 old_rfh->OnSwappedOut(); | 346 old_rfh->OnSwappedOut(); |
345 if (expecting_rfh_shutdown) { | 347 if (expecting_rfh_shutdown) { |
346 EXPECT_TRUE(rfh_observer.deleted()); | 348 EXPECT_TRUE(rfh_observer.deleted()); |
347 EXPECT_TRUE(rvh_observer.deleted()); | 349 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 350 switches::kSitePerProcess)) { |
| 351 EXPECT_TRUE(rvh_observer.deleted()); |
| 352 } |
348 } else { | 353 } else { |
349 EXPECT_EQ(RenderFrameHostImpl::STATE_SWAPPED_OUT, | 354 EXPECT_EQ(RenderFrameHostImpl::STATE_SWAPPED_OUT, |
350 old_rfh->rfh_state()); | 355 old_rfh->rfh_state()); |
351 } | 356 } |
352 } | 357 } |
353 EXPECT_EQ(active_rfh, contents()->GetMainFrame()); | 358 EXPECT_EQ(active_rfh, contents()->GetMainFrame()); |
354 EXPECT_EQ(NULL, contents()->GetPendingMainFrame()); | 359 EXPECT_EQ(NULL, contents()->GetPendingMainFrame()); |
355 } | 360 } |
356 | 361 |
357 bool ShouldSwapProcesses(RenderFrameHostManager* manager, | 362 bool ShouldSwapProcesses(RenderFrameHostManager* manager, |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
520 // for synchronous messages, which cannot be ignored without leaving the | 525 // for synchronous messages, which cannot be ignored without leaving the |
521 // renderer in a stuck state. See http://crbug.com/93427. | 526 // renderer in a stuck state. See http://crbug.com/93427. |
522 TEST_F(RenderFrameHostManagerTest, FilterMessagesWhileSwappedOut) { | 527 TEST_F(RenderFrameHostManagerTest, FilterMessagesWhileSwappedOut) { |
523 const GURL kChromeURL("chrome://foo"); | 528 const GURL kChromeURL("chrome://foo"); |
524 const GURL kDestUrl("http://www.google.com/"); | 529 const GURL kDestUrl("http://www.google.com/"); |
525 std::vector<FaviconURL> icons; | 530 std::vector<FaviconURL> icons; |
526 | 531 |
527 // Navigate our first tab to a chrome url and then to the destination. | 532 // Navigate our first tab to a chrome url and then to the destination. |
528 NavigateActiveAndCommit(kChromeURL); | 533 NavigateActiveAndCommit(kChromeURL); |
529 TestRenderFrameHost* ntp_rfh = contents()->GetMainFrame(); | 534 TestRenderFrameHost* ntp_rfh = contents()->GetMainFrame(); |
| 535 TestRenderViewHost* ntp_rvh = ntp_rfh->GetRenderViewHost(); |
530 | 536 |
531 // Send an update favicon message and make sure it works. | 537 // Send an update favicon message and make sure it works. |
532 { | 538 { |
533 PluginFaviconMessageObserver observer(contents()); | 539 PluginFaviconMessageObserver observer(contents()); |
534 EXPECT_TRUE(ntp_rfh->GetRenderViewHost()->OnMessageReceived( | 540 EXPECT_TRUE(ntp_rfh->GetRenderViewHost()->OnMessageReceived( |
535 ViewHostMsg_UpdateFaviconURL( | 541 ViewHostMsg_UpdateFaviconURL( |
536 ntp_rfh->GetRenderViewHost()->GetRoutingID(), icons))); | 542 ntp_rfh->GetRenderViewHost()->GetRoutingID(), icons))); |
537 EXPECT_TRUE(observer.favicon_received()); | 543 EXPECT_TRUE(observer.favicon_received()); |
538 } | 544 } |
539 // Create one more frame in the same SiteInstance where ntp_rfh | 545 // Create one more frame in the same SiteInstance where ntp_rfh |
(...skipping 12 matching lines...) Expand all Loading... |
552 PluginFaviconMessageObserver observer(contents()); | 558 PluginFaviconMessageObserver observer(contents()); |
553 EXPECT_TRUE( | 559 EXPECT_TRUE( |
554 dest_rfh->GetRenderViewHost()->OnMessageReceived( | 560 dest_rfh->GetRenderViewHost()->OnMessageReceived( |
555 ViewHostMsg_UpdateFaviconURL( | 561 ViewHostMsg_UpdateFaviconURL( |
556 dest_rfh->GetRenderViewHost()->GetRoutingID(), icons))); | 562 dest_rfh->GetRenderViewHost()->GetRoutingID(), icons))); |
557 EXPECT_TRUE(observer.favicon_received()); | 563 EXPECT_TRUE(observer.favicon_received()); |
558 } | 564 } |
559 | 565 |
560 // The old renderer, being slow, now updates the favicon. It should be | 566 // The old renderer, being slow, now updates the favicon. It should be |
561 // filtered out and not take effect. | 567 // filtered out and not take effect. |
562 EXPECT_TRUE(ntp_rfh->is_swapped_out()); | |
563 { | 568 { |
564 PluginFaviconMessageObserver observer(contents()); | 569 PluginFaviconMessageObserver observer(contents()); |
565 EXPECT_TRUE( | 570 EXPECT_TRUE( |
566 ntp_rfh->GetRenderViewHost()->OnMessageReceived( | 571 ntp_rvh->OnMessageReceived( |
567 ViewHostMsg_UpdateFaviconURL( | 572 ViewHostMsg_UpdateFaviconURL( |
568 dest_rfh->GetRenderViewHost()->GetRoutingID(), icons))); | 573 dest_rfh->GetRenderViewHost()->GetRoutingID(), icons))); |
569 EXPECT_FALSE(observer.favicon_received()); | 574 EXPECT_FALSE(observer.favicon_received()); |
570 } | 575 } |
571 | 576 |
| 577 // In --site-per-process, the RenderFrameHost is deleted on cross-process |
| 578 // navigation, so the rest of the test case doesn't apply. |
| 579 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 580 switches::kSitePerProcess)) { |
| 581 return; |
| 582 } |
| 583 |
572 #if defined(ENABLE_PLUGINS) | 584 #if defined(ENABLE_PLUGINS) |
573 // The same logic should apply to RenderFrameHosts as well and routing through | 585 // The same logic should apply to RenderFrameHosts as well and routing through |
574 // swapped out RFH shouldn't be allowed. Use a PluginCrashObserver to check | 586 // swapped out RFH shouldn't be allowed. Use a PluginCrashObserver to check |
575 // if the IPC message is allowed through or not. | 587 // if the IPC message is allowed through or not. |
576 { | 588 { |
577 PluginFaviconMessageObserver observer(contents()); | 589 PluginFaviconMessageObserver observer(contents()); |
578 EXPECT_TRUE(ntp_rfh->OnMessageReceived( | 590 EXPECT_TRUE(ntp_rfh->OnMessageReceived( |
579 FrameHostMsg_PluginCrashed( | 591 FrameHostMsg_PluginCrashed( |
580 ntp_rfh->GetRoutingID(), base::FilePath(), 0))); | 592 ntp_rfh->GetRoutingID(), base::FilePath(), 0))); |
581 EXPECT_FALSE(observer.plugin_crashed()); | 593 EXPECT_FALSE(observer.plugin_crashed()); |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
666 } | 678 } |
667 | 679 |
668 // Ensure that frames aren't added to the frame tree, if the message is coming | 680 // Ensure that frames aren't added to the frame tree, if the message is coming |
669 // from a process different than the parent frame's current RenderFrameHost | 681 // from a process different than the parent frame's current RenderFrameHost |
670 // process. Otherwise it is possible to have collisions of routing ids, as they | 682 // process. Otherwise it is possible to have collisions of routing ids, as they |
671 // are scoped per process. See https://crbug.com/415059. | 683 // are scoped per process. See https://crbug.com/415059. |
672 TEST_F(RenderFrameHostManagerTest, DropCreateChildFrameWhileSwappedOut) { | 684 TEST_F(RenderFrameHostManagerTest, DropCreateChildFrameWhileSwappedOut) { |
673 const GURL kUrl1("http://foo.com"); | 685 const GURL kUrl1("http://foo.com"); |
674 const GURL kUrl2("http://www.google.com/"); | 686 const GURL kUrl2("http://www.google.com/"); |
675 | 687 |
| 688 // This test is invalid in --site-per-process mode, as swapped-out is no |
| 689 // longer used. |
| 690 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 691 switches::kSitePerProcess)) { |
| 692 return; |
| 693 } |
| 694 |
676 // Navigate to the first site. | 695 // Navigate to the first site. |
677 NavigateActiveAndCommit(kUrl1); | 696 NavigateActiveAndCommit(kUrl1); |
678 TestRenderFrameHost* initial_rfh = contents()->GetMainFrame(); | 697 TestRenderFrameHost* initial_rfh = contents()->GetMainFrame(); |
679 { | 698 { |
680 RenderFrameHostCreatedObserver observer(contents()); | 699 RenderFrameHostCreatedObserver observer(contents()); |
681 initial_rfh->OnCreateChildFrame( | 700 initial_rfh->OnCreateChildFrame( |
682 initial_rfh->GetProcess()->GetNextRoutingID(), | 701 initial_rfh->GetProcess()->GetNextRoutingID(), |
683 blink::WebTreeScopeType::Document, std::string(), | 702 blink::WebTreeScopeType::Document, std::string(), |
684 blink::WebSandboxFlags::None); | 703 blink::WebSandboxFlags::None); |
685 EXPECT_TRUE(observer.created()); | 704 EXPECT_TRUE(observer.created()); |
(...skipping 18 matching lines...) Expand all Loading... |
704 RenderFrameHostCreatedObserver observer(contents()); | 723 RenderFrameHostCreatedObserver observer(contents()); |
705 initial_rfh->OnCreateChildFrame( | 724 initial_rfh->OnCreateChildFrame( |
706 initial_rfh->GetProcess()->GetNextRoutingID(), | 725 initial_rfh->GetProcess()->GetNextRoutingID(), |
707 blink::WebTreeScopeType::Document, std::string(), | 726 blink::WebTreeScopeType::Document, std::string(), |
708 blink::WebSandboxFlags::None); | 727 blink::WebSandboxFlags::None); |
709 EXPECT_FALSE(observer.created()); | 728 EXPECT_FALSE(observer.created()); |
710 } | 729 } |
711 } | 730 } |
712 | 731 |
713 TEST_F(RenderFrameHostManagerTest, WhiteListSwapCompositorFrame) { | 732 TEST_F(RenderFrameHostManagerTest, WhiteListSwapCompositorFrame) { |
| 733 // TODO(nasko): Check with kenrb whether this test can be rewritten and |
| 734 // whether it makes sense when swapped out is replaced with proxies. |
| 735 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 736 switches::kSitePerProcess)) { |
| 737 return; |
| 738 } |
714 TestRenderFrameHost* swapped_out_rfh = CreateSwappedOutRenderFrameHost(); | 739 TestRenderFrameHost* swapped_out_rfh = CreateSwappedOutRenderFrameHost(); |
715 TestRenderWidgetHostView* swapped_out_rwhv = | 740 TestRenderWidgetHostView* swapped_out_rwhv = |
716 static_cast<TestRenderWidgetHostView*>( | 741 static_cast<TestRenderWidgetHostView*>( |
717 swapped_out_rfh->GetRenderViewHost()->GetView()); | 742 swapped_out_rfh->GetRenderViewHost()->GetView()); |
718 EXPECT_FALSE(swapped_out_rwhv->did_swap_compositor_frame()); | 743 EXPECT_FALSE(swapped_out_rwhv->did_swap_compositor_frame()); |
719 | 744 |
720 MockRenderProcessHost* process_host = swapped_out_rfh->GetProcess(); | 745 MockRenderProcessHost* process_host = swapped_out_rfh->GetProcess(); |
721 process_host->sink().ClearMessages(); | 746 process_host->sink().ClearMessages(); |
722 | 747 |
723 cc::CompositorFrame frame; | 748 cc::CompositorFrame frame; |
724 ViewHostMsg_SwapCompositorFrame msg( | 749 ViewHostMsg_SwapCompositorFrame msg( |
725 rvh()->GetRoutingID(), 0, frame, std::vector<IPC::Message>()); | 750 rvh()->GetRoutingID(), 0, frame, std::vector<IPC::Message>()); |
726 | 751 |
727 EXPECT_TRUE(swapped_out_rfh->render_view_host()->OnMessageReceived(msg)); | 752 EXPECT_TRUE(swapped_out_rfh->render_view_host()->OnMessageReceived(msg)); |
728 EXPECT_TRUE(swapped_out_rwhv->did_swap_compositor_frame()); | 753 EXPECT_TRUE(swapped_out_rwhv->did_swap_compositor_frame()); |
729 } | 754 } |
730 | 755 |
731 // Test if RenderViewHost::GetRenderWidgetHosts() only returns active | 756 // Test if RenderViewHost::GetRenderWidgetHosts() only returns active |
732 // widgets. | 757 // widgets. |
733 TEST_F(RenderFrameHostManagerTest, GetRenderWidgetHostsReturnsActiveViews) { | 758 TEST_F(RenderFrameHostManagerTest, GetRenderWidgetHostsReturnsActiveViews) { |
| 759 // This test is invalid in --site-per-process mode, as swapped-out is no |
| 760 // longer used. |
| 761 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 762 switches::kSitePerProcess)) { |
| 763 return; |
| 764 } |
| 765 |
734 TestRenderFrameHost* swapped_out_rfh = CreateSwappedOutRenderFrameHost(); | 766 TestRenderFrameHost* swapped_out_rfh = CreateSwappedOutRenderFrameHost(); |
735 EXPECT_TRUE(swapped_out_rfh->is_swapped_out()); | 767 EXPECT_TRUE(swapped_out_rfh->is_swapped_out()); |
736 | 768 |
737 scoped_ptr<RenderWidgetHostIterator> widgets( | 769 scoped_ptr<RenderWidgetHostIterator> widgets( |
738 RenderWidgetHost::GetRenderWidgetHosts()); | 770 RenderWidgetHost::GetRenderWidgetHosts()); |
739 // We know that there is the only one active widget. Another view is | 771 // We know that there is the only one active widget. Another view is |
740 // now swapped out, so the swapped out view is not included in the | 772 // now swapped out, so the swapped out view is not included in the |
741 // list. | 773 // list. |
742 RenderWidgetHost* widget = widgets->GetNextHost(); | 774 RenderWidgetHost* widget = widgets->GetNextHost(); |
743 EXPECT_FALSE(widgets->GetNextHost()); | 775 EXPECT_FALSE(widgets->GetNextHost()); |
744 RenderViewHost* rvh = RenderViewHost::From(widget); | 776 RenderViewHost* rvh = RenderViewHost::From(widget); |
745 EXPECT_TRUE(static_cast<RenderViewHostImpl*>(rvh)->is_active()); | 777 EXPECT_TRUE(static_cast<RenderViewHostImpl*>(rvh)->is_active()); |
746 } | 778 } |
747 | 779 |
748 // Test if RenderViewHost::GetRenderWidgetHosts() returns a subset of | 780 // Test if RenderViewHost::GetRenderWidgetHosts() returns a subset of |
749 // RenderViewHostImpl::GetAllRenderWidgetHosts(). | 781 // RenderViewHostImpl::GetAllRenderWidgetHosts(). |
750 // RenderViewHost::GetRenderWidgetHosts() returns only active widgets, but | 782 // RenderViewHost::GetRenderWidgetHosts() returns only active widgets, but |
751 // RenderViewHostImpl::GetAllRenderWidgetHosts() returns everything | 783 // RenderViewHostImpl::GetAllRenderWidgetHosts() returns everything |
752 // including swapped out ones. | 784 // including swapped out ones. |
753 TEST_F(RenderFrameHostManagerTest, | 785 TEST_F(RenderFrameHostManagerTest, |
754 GetRenderWidgetHostsWithinGetAllRenderWidgetHosts) { | 786 GetRenderWidgetHostsWithinGetAllRenderWidgetHosts) { |
| 787 // This test is invalid in --site-per-process mode, as swapped-out is no |
| 788 // longer used. |
| 789 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 790 switches::kSitePerProcess)) { |
| 791 return; |
| 792 } |
| 793 |
755 TestRenderFrameHost* swapped_out_rfh = CreateSwappedOutRenderFrameHost(); | 794 TestRenderFrameHost* swapped_out_rfh = CreateSwappedOutRenderFrameHost(); |
756 EXPECT_TRUE(swapped_out_rfh->is_swapped_out()); | 795 EXPECT_TRUE(swapped_out_rfh->is_swapped_out()); |
757 | 796 |
758 scoped_ptr<RenderWidgetHostIterator> widgets( | 797 scoped_ptr<RenderWidgetHostIterator> widgets( |
759 RenderWidgetHost::GetRenderWidgetHosts()); | 798 RenderWidgetHost::GetRenderWidgetHosts()); |
760 | 799 |
761 while (RenderWidgetHost* w = widgets->GetNextHost()) { | 800 while (RenderWidgetHost* w = widgets->GetNextHost()) { |
762 bool found = false; | 801 bool found = false; |
763 scoped_ptr<RenderWidgetHostIterator> all_widgets( | 802 scoped_ptr<RenderWidgetHostIterator> all_widgets( |
764 RenderWidgetHostImpl::GetAllRenderWidgetHosts()); | 803 RenderWidgetHostImpl::GetAllRenderWidgetHosts()); |
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1102 SiteInstance* blank_instance = SiteInstance::Create(browser_context()); | 1141 SiteInstance* blank_instance = SiteInstance::Create(browser_context()); |
1103 blank_instance->GetProcess()->Init(); | 1142 blank_instance->GetProcess()->Init(); |
1104 | 1143 |
1105 // Create a blank tab. | 1144 // Create a blank tab. |
1106 scoped_ptr<TestWebContents> web_contents1( | 1145 scoped_ptr<TestWebContents> web_contents1( |
1107 TestWebContents::Create(browser_context(), blank_instance)); | 1146 TestWebContents::Create(browser_context(), blank_instance)); |
1108 RenderFrameHostManager* manager1 = | 1147 RenderFrameHostManager* manager1 = |
1109 web_contents1->GetRenderManagerForTesting(); | 1148 web_contents1->GetRenderManagerForTesting(); |
1110 // Test the case that new RVH is considered live. | 1149 // Test the case that new RVH is considered live. |
1111 manager1->current_host()->CreateRenderView( | 1150 manager1->current_host()->CreateRenderView( |
1112 base::string16(), -1, MSG_ROUTING_NONE, -1, false); | 1151 base::string16(), -1, MSG_ROUTING_NONE, -1, |
| 1152 FrameReplicationState(), false); |
1113 EXPECT_TRUE(manager1->current_host()->IsRenderViewLive()); | 1153 EXPECT_TRUE(manager1->current_host()->IsRenderViewLive()); |
1114 EXPECT_TRUE(manager1->current_frame_host()->IsRenderFrameLive()); | 1154 EXPECT_TRUE(manager1->current_frame_host()->IsRenderFrameLive()); |
1115 | 1155 |
1116 // Navigate to a WebUI page. | 1156 // Navigate to a WebUI page. |
1117 const GURL kUrl1("chrome://foo"); | 1157 const GURL kUrl1("chrome://foo"); |
1118 NavigationEntryImpl entry1(NULL /* instance */, -1 /* page_id */, kUrl1, | 1158 NavigationEntryImpl entry1(NULL /* instance */, -1 /* page_id */, kUrl1, |
1119 Referrer(), base::string16() /* title */, | 1159 Referrer(), base::string16() /* title */, |
1120 ui::PAGE_TRANSITION_TYPED, | 1160 ui::PAGE_TRANSITION_TYPED, |
1121 false /* is_renderer_init */); | 1161 false /* is_renderer_init */); |
1122 RenderFrameHostImpl* host1 = NavigateToEntry(manager1, entry1); | 1162 RenderFrameHostImpl* host1 = NavigateToEntry(manager1, entry1); |
(...skipping 13 matching lines...) Expand all Loading... |
1136 host1->render_view_host()->GetEnabledBindings() & BINDINGS_POLICY_WEB_UI); | 1176 host1->render_view_host()->GetEnabledBindings() & BINDINGS_POLICY_WEB_UI); |
1137 | 1177 |
1138 // Now simulate clicking a link that opens in a new tab. | 1178 // Now simulate clicking a link that opens in a new tab. |
1139 scoped_ptr<TestWebContents> web_contents2( | 1179 scoped_ptr<TestWebContents> web_contents2( |
1140 TestWebContents::Create(browser_context(), webui_instance)); | 1180 TestWebContents::Create(browser_context(), webui_instance)); |
1141 RenderFrameHostManager* manager2 = | 1181 RenderFrameHostManager* manager2 = |
1142 web_contents2->GetRenderManagerForTesting(); | 1182 web_contents2->GetRenderManagerForTesting(); |
1143 // Make sure the new RVH is considered live. This is usually done in | 1183 // Make sure the new RVH is considered live. This is usually done in |
1144 // RenderWidgetHost::Init when opening a new tab from a link. | 1184 // RenderWidgetHost::Init when opening a new tab from a link. |
1145 manager2->current_host()->CreateRenderView( | 1185 manager2->current_host()->CreateRenderView( |
1146 base::string16(), -1, MSG_ROUTING_NONE, -1, false); | 1186 base::string16(), -1, MSG_ROUTING_NONE, -1, |
| 1187 FrameReplicationState(), false); |
1147 EXPECT_TRUE(manager2->current_host()->IsRenderViewLive()); | 1188 EXPECT_TRUE(manager2->current_host()->IsRenderViewLive()); |
1148 | 1189 |
1149 const GURL kUrl2("chrome://foo/bar"); | 1190 const GURL kUrl2("chrome://foo/bar"); |
1150 NavigationEntryImpl entry2(NULL /* instance */, -1 /* page_id */, kUrl2, | 1191 NavigationEntryImpl entry2(NULL /* instance */, -1 /* page_id */, kUrl2, |
1151 Referrer(), base::string16() /* title */, | 1192 Referrer(), base::string16() /* title */, |
1152 ui::PAGE_TRANSITION_LINK, | 1193 ui::PAGE_TRANSITION_LINK, |
1153 true /* is_renderer_init */); | 1194 true /* is_renderer_init */); |
1154 RenderFrameHostImpl* host2 = NavigateToEntry(manager2, entry2); | 1195 RenderFrameHostImpl* host2 = NavigateToEntry(manager2, entry2); |
1155 | 1196 |
1156 // No cross-process transition happens because we are already in the right | 1197 // No cross-process transition happens because we are already in the right |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1306 // Now go back, but suppose the SwapOut_ACK isn't received. This shouldn't | 1347 // Now go back, but suppose the SwapOut_ACK isn't received. This shouldn't |
1307 // happen, but we have seen it when going back quickly across many entries | 1348 // happen, but we have seen it when going back quickly across many entries |
1308 // (http://crbug.com/93427). | 1349 // (http://crbug.com/93427). |
1309 contents()->GetController().GoBack(); | 1350 contents()->GetController().GoBack(); |
1310 EXPECT_TRUE(rfh2->IsWaitingForBeforeUnloadACK()); | 1351 EXPECT_TRUE(rfh2->IsWaitingForBeforeUnloadACK()); |
1311 contents()->GetMainFrame()->PrepareForCommit(); | 1352 contents()->GetMainFrame()->PrepareForCommit(); |
1312 EXPECT_FALSE(rfh2->IsWaitingForBeforeUnloadACK()); | 1353 EXPECT_FALSE(rfh2->IsWaitingForBeforeUnloadACK()); |
1313 | 1354 |
1314 // The back navigation commits. | 1355 // The back navigation commits. |
1315 const NavigationEntry* entry1 = contents()->GetController().GetPendingEntry(); | 1356 const NavigationEntry* entry1 = contents()->GetController().GetPendingEntry(); |
1316 rfh1->SendNavigate(entry1->GetPageID(), entry1->GetUniqueID(), false, | 1357 contents()->GetPendingMainFrame()->SendNavigate( |
1317 entry1->GetURL()); | 1358 entry1->GetPageID(), entry1->GetUniqueID(), false, entry1->GetURL()); |
1318 EXPECT_TRUE(rfh2->IsWaitingForUnloadACK()); | 1359 EXPECT_TRUE(rfh2->IsWaitingForUnloadACK()); |
1319 EXPECT_EQ(RenderFrameHostImpl::STATE_PENDING_SWAP_OUT, rfh2->rfh_state()); | 1360 EXPECT_EQ(RenderFrameHostImpl::STATE_PENDING_SWAP_OUT, rfh2->rfh_state()); |
1320 | 1361 |
1321 // We should be able to navigate forward. | 1362 // We should be able to navigate forward. |
1322 contents()->GetController().GoForward(); | 1363 contents()->GetController().GoForward(); |
1323 contents()->GetMainFrame()->PrepareForCommit(); | 1364 contents()->GetMainFrame()->PrepareForCommit(); |
1324 const NavigationEntry* entry2 = contents()->GetController().GetPendingEntry(); | 1365 const NavigationEntry* entry2 = contents()->GetController().GetPendingEntry(); |
1325 rfh2->SendNavigate(entry2->GetPageID(), entry2->GetUniqueID(), false, | 1366 contents()->GetPendingMainFrame()->SendNavigate( |
1326 entry2->GetURL()); | 1367 entry2->GetPageID(), entry2->GetUniqueID(), false, entry2->GetURL()); |
1327 EXPECT_EQ(rfh2, main_test_rfh()); | 1368 EXPECT_EQ(RenderFrameHostImpl::STATE_DEFAULT, main_test_rfh()->rfh_state()); |
1328 EXPECT_EQ(RenderFrameHostImpl::STATE_DEFAULT, rfh2->rfh_state()); | 1369 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( |
1329 EXPECT_EQ(RenderFrameHostImpl::STATE_PENDING_SWAP_OUT, rfh1->rfh_state()); | 1370 switches::kSitePerProcess)) { |
1330 rfh1->OnSwappedOut(); | 1371 EXPECT_EQ(rfh2, main_test_rfh()); |
1331 EXPECT_TRUE(rfh1->is_swapped_out()); | 1372 EXPECT_EQ(RenderFrameHostImpl::STATE_PENDING_SWAP_OUT, rfh1->rfh_state()); |
1332 EXPECT_EQ(RenderFrameHostImpl::STATE_SWAPPED_OUT, rfh1->rfh_state()); | 1373 rfh1->OnSwappedOut(); |
| 1374 EXPECT_TRUE(rfh1->is_swapped_out()); |
| 1375 EXPECT_EQ(RenderFrameHostImpl::STATE_SWAPPED_OUT, rfh1->rfh_state()); |
| 1376 } |
1333 } | 1377 } |
1334 | 1378 |
1335 // Test that we create swapped out RFHs for the opener chain when navigating an | 1379 // Test that we create swapped out RFHs for the opener chain when navigating an |
1336 // opened tab cross-process. This allows us to support certain cross-process | 1380 // opened tab cross-process. This allows us to support certain cross-process |
1337 // JavaScript calls (http://crbug.com/99202). | 1381 // JavaScript calls (http://crbug.com/99202). |
1338 TEST_F(RenderFrameHostManagerTest, CreateSwappedOutOpenerRFHs) { | 1382 TEST_F(RenderFrameHostManagerTest, CreateSwappedOutOpenerRFHs) { |
1339 const GURL kUrl1("http://www.google.com/"); | 1383 const GURL kUrl1("http://www.google.com/"); |
1340 const GURL kUrl2("http://www.chromium.org/"); | 1384 const GURL kUrl2("http://www.chromium.org/"); |
1341 const GURL kChromeUrl("chrome://foo"); | 1385 const GURL kChromeUrl("chrome://foo"); |
| 1386 bool is_site_per_process = base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 1387 switches::kSitePerProcess); |
1342 | 1388 |
1343 // Navigate to an initial URL. | 1389 // Navigate to an initial URL. |
1344 contents()->NavigateAndCommit(kUrl1); | 1390 contents()->NavigateAndCommit(kUrl1); |
1345 RenderFrameHostManager* manager = contents()->GetRenderManagerForTesting(); | 1391 RenderFrameHostManager* manager = contents()->GetRenderManagerForTesting(); |
1346 TestRenderFrameHost* rfh1 = main_test_rfh(); | 1392 TestRenderFrameHost* rfh1 = main_test_rfh(); |
| 1393 scoped_refptr<SiteInstanceImpl> site_instance1 = rfh1->GetSiteInstance(); |
| 1394 RenderFrameHostDeletedObserver rfh1_deleted_observer(rfh1); |
1347 TestRenderViewHost* rvh1 = test_rvh(); | 1395 TestRenderViewHost* rvh1 = test_rvh(); |
1348 | 1396 |
1349 // Create 2 new tabs and simulate them being the opener chain for the main | 1397 // Create 2 new tabs and simulate them being the opener chain for the main |
1350 // tab. They should be in the same SiteInstance. | 1398 // tab. They should be in the same SiteInstance. |
1351 scoped_ptr<TestWebContents> opener1( | 1399 scoped_ptr<TestWebContents> opener1( |
1352 TestWebContents::Create(browser_context(), rfh1->GetSiteInstance())); | 1400 TestWebContents::Create(browser_context(), site_instance1.get())); |
1353 RenderFrameHostManager* opener1_manager = | 1401 RenderFrameHostManager* opener1_manager = |
1354 opener1->GetRenderManagerForTesting(); | 1402 opener1->GetRenderManagerForTesting(); |
1355 contents()->SetOpener(opener1.get()); | 1403 contents()->SetOpener(opener1.get()); |
1356 | 1404 |
1357 scoped_ptr<TestWebContents> opener2( | 1405 scoped_ptr<TestWebContents> opener2( |
1358 TestWebContents::Create(browser_context(), rfh1->GetSiteInstance())); | 1406 TestWebContents::Create(browser_context(), site_instance1.get())); |
1359 RenderFrameHostManager* opener2_manager = | 1407 RenderFrameHostManager* opener2_manager = |
1360 opener2->GetRenderManagerForTesting(); | 1408 opener2->GetRenderManagerForTesting(); |
1361 opener1->SetOpener(opener2.get()); | 1409 opener1->SetOpener(opener2.get()); |
1362 | 1410 |
1363 // Navigate to a cross-site URL (different SiteInstance but same | 1411 // Navigate to a cross-site URL (different SiteInstance but same |
1364 // BrowsingInstance). | 1412 // BrowsingInstance). |
1365 contents()->NavigateAndCommit(kUrl2); | 1413 contents()->NavigateAndCommit(kUrl2); |
1366 TestRenderFrameHost* rfh2 = main_test_rfh(); | 1414 TestRenderFrameHost* rfh2 = main_test_rfh(); |
1367 TestRenderViewHost* rvh2 = test_rvh(); | 1415 TestRenderViewHost* rvh2 = test_rvh(); |
1368 EXPECT_NE(rfh1->GetSiteInstance(), rfh2->GetSiteInstance()); | 1416 EXPECT_NE(site_instance1, rfh2->GetSiteInstance()); |
1369 EXPECT_TRUE(rfh1->GetSiteInstance()->IsRelatedSiteInstance( | 1417 EXPECT_TRUE(site_instance1->IsRelatedSiteInstance(rfh2->GetSiteInstance())); |
1370 rfh2->GetSiteInstance())); | |
1371 | 1418 |
1372 // Ensure rvh1 is placed on swapped out list of the current tab. | 1419 // Ensure rvh1 is placed on swapped out list of the current tab. |
1373 EXPECT_TRUE(manager->IsOnSwappedOutList(rfh1)); | 1420 if (!is_site_per_process) { |
1374 EXPECT_TRUE(manager->IsRVHOnSwappedOutList(rvh1)); | 1421 EXPECT_TRUE(manager->IsRVHOnSwappedOutList(rvh1)); |
1375 EXPECT_EQ(rfh1, | 1422 EXPECT_FALSE(rfh1_deleted_observer.deleted()); |
1376 manager->GetRenderFrameProxyHost(rfh1->GetSiteInstance()) | 1423 EXPECT_TRUE(manager->IsOnSwappedOutList(rfh1)); |
1377 ->render_frame_host()); | 1424 EXPECT_EQ(rfh1, |
| 1425 manager->GetRenderFrameProxyHost(site_instance1.get()) |
| 1426 ->render_frame_host()); |
| 1427 } else { |
| 1428 EXPECT_TRUE(rfh1_deleted_observer.deleted()); |
| 1429 EXPECT_TRUE(manager->GetRenderFrameProxyHost(site_instance1.get())); |
| 1430 } |
1378 EXPECT_EQ(rvh1, | 1431 EXPECT_EQ(rvh1, |
1379 manager->GetSwappedOutRenderViewHost(rvh1->GetSiteInstance())); | 1432 manager->GetSwappedOutRenderViewHost(rvh1->GetSiteInstance())); |
1380 | 1433 |
1381 // Ensure a swapped out RFH and RFH is created in the first opener tab. | 1434 // Ensure a swapped out RFH and RFH is created in the first opener tab. |
1382 RenderFrameProxyHost* opener1_proxy = | 1435 RenderFrameProxyHost* opener1_proxy = |
1383 opener1_manager->GetRenderFrameProxyHost(rfh2->GetSiteInstance()); | 1436 opener1_manager->GetRenderFrameProxyHost(rfh2->GetSiteInstance()); |
1384 RenderFrameHostImpl* opener1_rfh = opener1_proxy->render_frame_host(); | 1437 RenderFrameHostImpl* opener1_rfh = opener1_proxy->render_frame_host(); |
1385 TestRenderViewHost* opener1_rvh = static_cast<TestRenderViewHost*>( | 1438 TestRenderViewHost* opener1_rvh = static_cast<TestRenderViewHost*>( |
1386 opener1_manager->GetSwappedOutRenderViewHost(rvh2->GetSiteInstance())); | 1439 opener1_manager->GetSwappedOutRenderViewHost(rvh2->GetSiteInstance())); |
1387 EXPECT_TRUE(opener1_manager->IsOnSwappedOutList(opener1_rfh)); | 1440 if (!is_site_per_process) { |
1388 EXPECT_TRUE(opener1_manager->IsRVHOnSwappedOutList(opener1_rvh)); | 1441 EXPECT_TRUE(opener1_manager->IsOnSwappedOutList(opener1_rfh)); |
1389 EXPECT_TRUE(opener1_rfh->is_swapped_out()); | 1442 EXPECT_TRUE(opener1_manager->IsRVHOnSwappedOutList(opener1_rvh)); |
| 1443 EXPECT_TRUE(opener1_rfh->is_swapped_out()); |
| 1444 } else { |
| 1445 EXPECT_FALSE(opener1_rfh); |
| 1446 } |
1390 EXPECT_FALSE(opener1_rvh->is_active()); | 1447 EXPECT_FALSE(opener1_rvh->is_active()); |
1391 | 1448 |
1392 // Ensure a swapped out RFH and RVH is created in the second opener tab. | 1449 // Ensure a swapped out RFH and RVH is created in the second opener tab. |
1393 RenderFrameProxyHost* opener2_proxy = | 1450 RenderFrameProxyHost* opener2_proxy = |
1394 opener2_manager->GetRenderFrameProxyHost(rfh2->GetSiteInstance()); | 1451 opener2_manager->GetRenderFrameProxyHost(rfh2->GetSiteInstance()); |
1395 RenderFrameHostImpl* opener2_rfh = opener2_proxy->render_frame_host(); | 1452 RenderFrameHostImpl* opener2_rfh = opener2_proxy->render_frame_host(); |
1396 TestRenderViewHost* opener2_rvh = static_cast<TestRenderViewHost*>( | 1453 TestRenderViewHost* opener2_rvh = static_cast<TestRenderViewHost*>( |
1397 opener2_manager->GetSwappedOutRenderViewHost(rvh2->GetSiteInstance())); | 1454 opener2_manager->GetSwappedOutRenderViewHost(rvh2->GetSiteInstance())); |
1398 EXPECT_TRUE(opener2_manager->IsOnSwappedOutList(opener2_rfh)); | 1455 if (!is_site_per_process) { |
1399 EXPECT_TRUE(opener2_manager->IsRVHOnSwappedOutList(opener2_rvh)); | 1456 EXPECT_TRUE(opener2_manager->IsOnSwappedOutList(opener2_rfh)); |
1400 EXPECT_TRUE(opener2_rfh->is_swapped_out()); | 1457 EXPECT_TRUE(opener2_manager->IsRVHOnSwappedOutList(opener2_rvh)); |
| 1458 EXPECT_TRUE(opener2_rfh->is_swapped_out()); |
| 1459 } else { |
| 1460 EXPECT_FALSE(opener2_rfh); |
| 1461 } |
1401 EXPECT_FALSE(opener2_rvh->is_active()); | 1462 EXPECT_FALSE(opener2_rvh->is_active()); |
1402 | 1463 |
1403 // Navigate to a cross-BrowsingInstance URL. | 1464 // Navigate to a cross-BrowsingInstance URL. |
1404 contents()->NavigateAndCommit(kChromeUrl); | 1465 contents()->NavigateAndCommit(kChromeUrl); |
1405 TestRenderFrameHost* rfh3 = main_test_rfh(); | 1466 TestRenderFrameHost* rfh3 = main_test_rfh(); |
1406 EXPECT_NE(rfh1->GetSiteInstance(), rfh3->GetSiteInstance()); | 1467 EXPECT_NE(site_instance1, rfh3->GetSiteInstance()); |
1407 EXPECT_FALSE(rfh1->GetSiteInstance()->IsRelatedSiteInstance( | 1468 EXPECT_FALSE(site_instance1->IsRelatedSiteInstance(rfh3->GetSiteInstance())); |
1408 rfh3->GetSiteInstance())); | |
1409 | 1469 |
1410 // No scripting is allowed across BrowsingInstances, so we should not create | 1470 // No scripting is allowed across BrowsingInstances, so we should not create |
1411 // swapped out RVHs for the opener chain in this case. | 1471 // swapped out RVHs for the opener chain in this case. |
1412 EXPECT_FALSE(opener1_manager->GetRenderFrameProxyHost( | 1472 EXPECT_FALSE(opener1_manager->GetRenderFrameProxyHost( |
1413 rfh3->GetSiteInstance())); | 1473 rfh3->GetSiteInstance())); |
1414 EXPECT_FALSE(opener1_manager->GetSwappedOutRenderViewHost( | 1474 EXPECT_FALSE(opener1_manager->GetSwappedOutRenderViewHost( |
1415 rfh3->GetSiteInstance())); | 1475 rfh3->GetSiteInstance())); |
1416 EXPECT_FALSE(opener2_manager->GetRenderFrameProxyHost( | 1476 EXPECT_FALSE(opener2_manager->GetRenderFrameProxyHost( |
1417 rfh3->GetSiteInstance())); | 1477 rfh3->GetSiteInstance())); |
1418 EXPECT_FALSE(opener2_manager->GetSwappedOutRenderViewHost( | 1478 EXPECT_FALSE(opener2_manager->GetSwappedOutRenderViewHost( |
1419 rfh3->GetSiteInstance())); | 1479 rfh3->GetSiteInstance())); |
1420 } | 1480 } |
1421 | 1481 |
1422 // Test that a page can disown the opener of the WebContents. | 1482 // Test that a page can disown the opener of the WebContents. |
1423 TEST_F(RenderFrameHostManagerTest, DisownOpener) { | 1483 TEST_F(RenderFrameHostManagerTest, DisownOpener) { |
1424 const GURL kUrl1("http://www.google.com/"); | 1484 const GURL kUrl1("http://www.google.com/"); |
1425 const GURL kUrl2("http://www.chromium.org/"); | 1485 const GURL kUrl2("http://www.chromium.org/"); |
1426 | 1486 |
1427 // Navigate to an initial URL. | 1487 // Navigate to an initial URL. |
1428 contents()->NavigateAndCommit(kUrl1); | 1488 contents()->NavigateAndCommit(kUrl1); |
1429 TestRenderFrameHost* rfh1 = main_test_rfh(); | 1489 TestRenderFrameHost* rfh1 = main_test_rfh(); |
| 1490 scoped_refptr<SiteInstanceImpl> site_instance1 = rfh1->GetSiteInstance(); |
1430 | 1491 |
1431 // Create a new tab and simulate having it be the opener for the main tab. | 1492 // Create a new tab and simulate having it be the opener for the main tab. |
1432 scoped_ptr<TestWebContents> opener1( | 1493 scoped_ptr<TestWebContents> opener1( |
1433 TestWebContents::Create(browser_context(), rfh1->GetSiteInstance())); | 1494 TestWebContents::Create(browser_context(), rfh1->GetSiteInstance())); |
1434 contents()->SetOpener(opener1.get()); | 1495 contents()->SetOpener(opener1.get()); |
1435 EXPECT_TRUE(contents()->HasOpener()); | 1496 EXPECT_TRUE(contents()->HasOpener()); |
1436 | 1497 |
1437 // Navigate to a cross-site URL (different SiteInstance but same | 1498 // Navigate to a cross-site URL (different SiteInstance but same |
1438 // BrowsingInstance). | 1499 // BrowsingInstance). |
1439 contents()->NavigateAndCommit(kUrl2); | 1500 contents()->NavigateAndCommit(kUrl2); |
1440 TestRenderFrameHost* rfh2 = main_test_rfh(); | 1501 TestRenderFrameHost* rfh2 = main_test_rfh(); |
1441 EXPECT_NE(rfh1->GetSiteInstance(), rfh2->GetSiteInstance()); | 1502 EXPECT_NE(site_instance1, rfh2->GetSiteInstance()); |
1442 | 1503 |
1443 // Disown the opener from rfh2. | 1504 // Disown the opener from rfh2. |
1444 rfh2->DidDisownOpener(); | 1505 rfh2->DidDisownOpener(); |
1445 | 1506 |
1446 // Ensure the opener is cleared. | 1507 // Ensure the opener is cleared. |
1447 EXPECT_FALSE(contents()->HasOpener()); | 1508 EXPECT_FALSE(contents()->HasOpener()); |
1448 } | 1509 } |
1449 | 1510 |
1450 // Test that a page can disown a same-site opener of the WebContents. | 1511 // Test that a page can disown a same-site opener of the WebContents. |
1451 TEST_F(RenderFrameHostManagerTest, DisownSameSiteOpener) { | 1512 TEST_F(RenderFrameHostManagerTest, DisownSameSiteOpener) { |
(...skipping 17 matching lines...) Expand all Loading... |
1469 } | 1530 } |
1470 | 1531 |
1471 // Test that a page can disown the opener just as a cross-process navigation is | 1532 // Test that a page can disown the opener just as a cross-process navigation is |
1472 // in progress. | 1533 // in progress. |
1473 TEST_F(RenderFrameHostManagerTest, DisownOpenerDuringNavigation) { | 1534 TEST_F(RenderFrameHostManagerTest, DisownOpenerDuringNavigation) { |
1474 const GURL kUrl1("http://www.google.com/"); | 1535 const GURL kUrl1("http://www.google.com/"); |
1475 const GURL kUrl2("http://www.chromium.org/"); | 1536 const GURL kUrl2("http://www.chromium.org/"); |
1476 | 1537 |
1477 // Navigate to an initial URL. | 1538 // Navigate to an initial URL. |
1478 contents()->NavigateAndCommit(kUrl1); | 1539 contents()->NavigateAndCommit(kUrl1); |
1479 TestRenderFrameHost* rfh1 = main_test_rfh(); | 1540 scoped_refptr<SiteInstanceImpl> site_instance1 = |
| 1541 main_test_rfh()->GetSiteInstance(); |
1480 | 1542 |
1481 // Create a new tab and simulate having it be the opener for the main tab. | 1543 // Create a new tab and simulate having it be the opener for the main tab. |
1482 scoped_ptr<TestWebContents> opener1( | 1544 scoped_ptr<TestWebContents> opener1( |
1483 TestWebContents::Create(browser_context(), rfh1->GetSiteInstance())); | 1545 TestWebContents::Create(browser_context(), site_instance1.get())); |
1484 contents()->SetOpener(opener1.get()); | 1546 contents()->SetOpener(opener1.get()); |
1485 EXPECT_TRUE(contents()->HasOpener()); | 1547 EXPECT_TRUE(contents()->HasOpener()); |
1486 | 1548 |
1487 // Navigate to a cross-site URL (different SiteInstance but same | 1549 // Navigate to a cross-site URL (different SiteInstance but same |
1488 // BrowsingInstance). | 1550 // BrowsingInstance). |
1489 contents()->NavigateAndCommit(kUrl2); | 1551 contents()->NavigateAndCommit(kUrl2); |
1490 TestRenderFrameHost* rfh2 = main_test_rfh(); | 1552 TestRenderFrameHost* rfh2 = main_test_rfh(); |
1491 EXPECT_NE(rfh1->GetSiteInstance(), rfh2->GetSiteInstance()); | 1553 EXPECT_NE(site_instance1, rfh2->GetSiteInstance()); |
1492 | 1554 |
1493 // Start a back navigation so that rfh1 becomes the pending RFH. | 1555 // Start a back navigation. |
1494 contents()->GetController().GoBack(); | 1556 contents()->GetController().GoBack(); |
1495 contents()->GetMainFrame()->PrepareForCommit(); | 1557 contents()->GetMainFrame()->PrepareForCommit(); |
1496 | 1558 |
1497 // Disown the opener from rfh2. | 1559 // Disown the opener from rfh2. |
1498 rfh2->DidDisownOpener(); | 1560 rfh2->DidDisownOpener(); |
1499 | 1561 |
1500 // Ensure the opener is cleared. | 1562 // Ensure the opener is cleared. |
1501 EXPECT_FALSE(contents()->HasOpener()); | 1563 EXPECT_FALSE(contents()->HasOpener()); |
1502 | 1564 |
1503 // The back navigation commits. | 1565 // The back navigation commits. |
1504 const NavigationEntry* entry1 = contents()->GetController().GetPendingEntry(); | 1566 const NavigationEntry* entry1 = contents()->GetController().GetPendingEntry(); |
1505 rfh1->SendNavigate(entry1->GetPageID(), entry1->GetUniqueID(), false, | 1567 contents()->GetPendingMainFrame()->SendNavigate( |
1506 entry1->GetURL()); | 1568 entry1->GetPageID(), entry1->GetUniqueID(), false, entry1->GetURL()); |
1507 | 1569 |
1508 // Ensure the opener is still cleared. | 1570 // Ensure the opener is still cleared. |
1509 EXPECT_FALSE(contents()->HasOpener()); | 1571 EXPECT_FALSE(contents()->HasOpener()); |
1510 } | 1572 } |
1511 | 1573 |
1512 // Test that a page can disown the opener just after a cross-process navigation | 1574 // Test that a page can disown the opener just after a cross-process navigation |
1513 // commits. | 1575 // commits. |
1514 TEST_F(RenderFrameHostManagerTest, DisownOpenerAfterNavigation) { | 1576 TEST_F(RenderFrameHostManagerTest, DisownOpenerAfterNavigation) { |
1515 const GURL kUrl1("http://www.google.com/"); | 1577 const GURL kUrl1("http://www.google.com/"); |
1516 const GURL kUrl2("http://www.chromium.org/"); | 1578 const GURL kUrl2("http://www.chromium.org/"); |
1517 | 1579 |
1518 // Navigate to an initial URL. | 1580 // Navigate to an initial URL. |
1519 contents()->NavigateAndCommit(kUrl1); | 1581 contents()->NavigateAndCommit(kUrl1); |
1520 TestRenderFrameHost* rfh1 = main_test_rfh(); | 1582 scoped_refptr<SiteInstanceImpl> site_instance1 = |
| 1583 main_test_rfh()->GetSiteInstance(); |
1521 | 1584 |
1522 // Create a new tab and simulate having it be the opener for the main tab. | 1585 // Create a new tab and simulate having it be the opener for the main tab. |
1523 scoped_ptr<TestWebContents> opener1( | 1586 scoped_ptr<TestWebContents> opener1( |
1524 TestWebContents::Create(browser_context(), rfh1->GetSiteInstance())); | 1587 TestWebContents::Create(browser_context(), site_instance1.get())); |
1525 contents()->SetOpener(opener1.get()); | 1588 contents()->SetOpener(opener1.get()); |
1526 EXPECT_TRUE(contents()->HasOpener()); | 1589 EXPECT_TRUE(contents()->HasOpener()); |
1527 | 1590 |
1528 // Navigate to a cross-site URL (different SiteInstance but same | 1591 // Navigate to a cross-site URL (different SiteInstance but same |
1529 // BrowsingInstance). | 1592 // BrowsingInstance). |
1530 contents()->NavigateAndCommit(kUrl2); | 1593 contents()->NavigateAndCommit(kUrl2); |
1531 TestRenderFrameHost* rfh2 = main_test_rfh(); | 1594 TestRenderFrameHost* rfh2 = main_test_rfh(); |
1532 EXPECT_NE(rfh1->GetSiteInstance(), rfh2->GetSiteInstance()); | 1595 EXPECT_NE(site_instance1, rfh2->GetSiteInstance()); |
1533 | 1596 |
1534 // Commit a back navigation before the DidDisownOpener message arrives. | 1597 // Commit a back navigation before the DidDisownOpener message arrives. |
1535 // rfh1 will be kept alive because of the opener tab. | |
1536 contents()->GetController().GoBack(); | 1598 contents()->GetController().GoBack(); |
1537 contents()->GetMainFrame()->PrepareForCommit(); | 1599 contents()->GetMainFrame()->PrepareForCommit(); |
1538 const NavigationEntry* entry1 = contents()->GetController().GetPendingEntry(); | 1600 const NavigationEntry* entry1 = contents()->GetController().GetPendingEntry(); |
1539 rfh1->SendNavigate(entry1->GetPageID(), entry1->GetUniqueID(), false, | 1601 contents()->GetPendingMainFrame()->SendNavigate( |
1540 entry1->GetURL()); | 1602 entry1->GetPageID(), entry1->GetUniqueID(), false, entry1->GetURL()); |
1541 | 1603 |
1542 // Disown the opener from rfh2. | 1604 // Disown the opener from rfh2. |
1543 rfh2->DidDisownOpener(); | 1605 rfh2->DidDisownOpener(); |
1544 EXPECT_FALSE(contents()->HasOpener()); | 1606 EXPECT_FALSE(contents()->HasOpener()); |
1545 } | 1607 } |
1546 | 1608 |
1547 // Test that we clean up swapped out RenderViewHosts when a process hosting | 1609 // Test that we clean up swapped out RenderViewHosts when a process hosting |
1548 // those associated RenderViews crashes. http://crbug.com/258993 | 1610 // those associated RenderViews crashes. http://crbug.com/258993 |
1549 TEST_F(RenderFrameHostManagerTest, CleanUpSwappedOutRVHOnProcessCrash) { | 1611 TEST_F(RenderFrameHostManagerTest, CleanUpSwappedOutRVHOnProcessCrash) { |
1550 const GURL kUrl1("http://www.google.com/"); | 1612 const GURL kUrl1("http://www.google.com/"); |
1551 const GURL kUrl2("http://www.chromium.org/"); | 1613 const GURL kUrl2("http://www.chromium.org/"); |
1552 | 1614 |
1553 // Navigate to an initial URL. | 1615 // Navigate to an initial URL. |
1554 contents()->NavigateAndCommit(kUrl1); | 1616 contents()->NavigateAndCommit(kUrl1); |
1555 TestRenderFrameHost* rfh1 = contents()->GetMainFrame(); | 1617 TestRenderFrameHost* rfh1 = contents()->GetMainFrame(); |
1556 | 1618 |
1557 // Create a new tab as an opener for the main tab. | 1619 // Create a new tab as an opener for the main tab. |
1558 scoped_ptr<TestWebContents> opener1( | 1620 scoped_ptr<TestWebContents> opener1( |
1559 TestWebContents::Create(browser_context(), rfh1->GetSiteInstance())); | 1621 TestWebContents::Create(browser_context(), rfh1->GetSiteInstance())); |
1560 RenderFrameHostManager* opener1_manager = | 1622 RenderFrameHostManager* opener1_manager = |
1561 opener1->GetRenderManagerForTesting(); | 1623 opener1->GetRenderManagerForTesting(); |
1562 contents()->SetOpener(opener1.get()); | 1624 contents()->SetOpener(opener1.get()); |
1563 | 1625 |
1564 // Make sure the new opener RVH is considered live. | 1626 // Make sure the new opener RVH is considered live. |
1565 opener1_manager->current_host()->CreateRenderView( | 1627 opener1_manager->current_host()->CreateRenderView( |
1566 base::string16(), -1, MSG_ROUTING_NONE, -1, false); | 1628 base::string16(), -1, MSG_ROUTING_NONE, -1, |
| 1629 FrameReplicationState(), false); |
1567 EXPECT_TRUE(opener1_manager->current_host()->IsRenderViewLive()); | 1630 EXPECT_TRUE(opener1_manager->current_host()->IsRenderViewLive()); |
1568 EXPECT_TRUE(opener1_manager->current_frame_host()->IsRenderFrameLive()); | 1631 EXPECT_TRUE(opener1_manager->current_frame_host()->IsRenderFrameLive()); |
1569 | 1632 |
1570 // Use a cross-process navigation in the opener to swap out the old RVH. | 1633 // Use a cross-process navigation in the opener to swap out the old RVH. |
1571 EXPECT_FALSE( | 1634 EXPECT_FALSE( |
1572 opener1_manager->GetSwappedOutRenderViewHost(rfh1->GetSiteInstance())); | 1635 opener1_manager->GetSwappedOutRenderViewHost(rfh1->GetSiteInstance())); |
1573 opener1->NavigateAndCommit(kUrl2); | 1636 opener1->NavigateAndCommit(kUrl2); |
1574 EXPECT_TRUE( | 1637 EXPECT_TRUE( |
1575 opener1_manager->GetSwappedOutRenderViewHost(rfh1->GetSiteInstance())); | 1638 opener1_manager->GetSwappedOutRenderViewHost(rfh1->GetSiteInstance())); |
1576 | 1639 |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1627 EXPECT_NE(rvh1->GetSiteInstance(), rvh2->GetSiteInstance()); | 1690 EXPECT_NE(rvh1->GetSiteInstance(), rvh2->GetSiteInstance()); |
1628 EXPECT_TRUE(rvh1->GetSiteInstance()->IsRelatedSiteInstance( | 1691 EXPECT_TRUE(rvh1->GetSiteInstance()->IsRelatedSiteInstance( |
1629 rvh2->GetSiteInstance())); | 1692 rvh2->GetSiteInstance())); |
1630 | 1693 |
1631 // Ensure a swapped out RFH and RVH is created in the first opener tab. | 1694 // Ensure a swapped out RFH and RVH is created in the first opener tab. |
1632 RenderFrameProxyHost* opener1_proxy = | 1695 RenderFrameProxyHost* opener1_proxy = |
1633 opener1_manager->GetRenderFrameProxyHost(rvh2->GetSiteInstance()); | 1696 opener1_manager->GetRenderFrameProxyHost(rvh2->GetSiteInstance()); |
1634 RenderFrameHostImpl* opener1_rfh = opener1_proxy->render_frame_host(); | 1697 RenderFrameHostImpl* opener1_rfh = opener1_proxy->render_frame_host(); |
1635 TestRenderViewHost* opener1_rvh = static_cast<TestRenderViewHost*>( | 1698 TestRenderViewHost* opener1_rvh = static_cast<TestRenderViewHost*>( |
1636 opener1_manager->GetSwappedOutRenderViewHost(rvh2->GetSiteInstance())); | 1699 opener1_manager->GetSwappedOutRenderViewHost(rvh2->GetSiteInstance())); |
1637 EXPECT_TRUE(opener1_manager->IsOnSwappedOutList(opener1_rfh)); | 1700 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( |
1638 EXPECT_TRUE(opener1_manager->IsRVHOnSwappedOutList(opener1_rvh)); | 1701 switches::kSitePerProcess)) { |
1639 EXPECT_TRUE(opener1_rfh->is_swapped_out()); | 1702 EXPECT_TRUE(opener1_manager->IsOnSwappedOutList(opener1_rfh)); |
| 1703 EXPECT_TRUE(opener1_manager->IsRVHOnSwappedOutList(opener1_rvh)); |
| 1704 EXPECT_TRUE(opener1_rfh->is_swapped_out()); |
| 1705 } else { |
| 1706 EXPECT_FALSE(opener1_rfh); |
| 1707 } |
1640 EXPECT_FALSE(opener1_rvh->is_active()); | 1708 EXPECT_FALSE(opener1_rvh->is_active()); |
1641 | 1709 |
1642 // Ensure the new RVH has WebUI bindings. | 1710 // Ensure the new RVH has WebUI bindings. |
1643 EXPECT_TRUE(rvh2->GetEnabledBindings() & BINDINGS_POLICY_WEB_UI); | 1711 EXPECT_TRUE(rvh2->GetEnabledBindings() & BINDINGS_POLICY_WEB_UI); |
1644 } | 1712 } |
1645 | 1713 |
1646 // Test that we reuse the same guest SiteInstance if we navigate across sites. | 1714 // Test that we reuse the same guest SiteInstance if we navigate across sites. |
1647 TEST_F(RenderFrameHostManagerTest, NoSwapOnGuestNavigations) { | 1715 TEST_F(RenderFrameHostManagerTest, NoSwapOnGuestNavigations) { |
1648 GURL guest_url(std::string(kGuestScheme).append("://abc123")); | 1716 GURL guest_url(std::string(kGuestScheme).append("://abc123")); |
1649 SiteInstance* instance = | 1717 SiteInstance* instance = |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1867 ui::PAGE_TRANSITION_TYPED); | 1935 ui::PAGE_TRANSITION_TYPED); |
1868 EXPECT_FALSE(contents()->CrossProcessNavigationPending()); | 1936 EXPECT_FALSE(contents()->CrossProcessNavigationPending()); |
1869 EXPECT_EQ(rfh2, contents()->GetMainFrame()); | 1937 EXPECT_EQ(rfh2, contents()->GetMainFrame()); |
1870 EXPECT_TRUE(contents()->GetPendingMainFrame() == NULL); | 1938 EXPECT_TRUE(contents()->GetPendingMainFrame() == NULL); |
1871 EXPECT_EQ(RenderFrameHostImpl::STATE_DEFAULT, rfh2->rfh_state()); | 1939 EXPECT_EQ(RenderFrameHostImpl::STATE_DEFAULT, rfh2->rfh_state()); |
1872 EXPECT_EQ(RenderFrameHostImpl::STATE_PENDING_SWAP_OUT, rfh1->rfh_state()); | 1940 EXPECT_EQ(RenderFrameHostImpl::STATE_PENDING_SWAP_OUT, rfh1->rfh_state()); |
1873 | 1941 |
1874 // Simulate the swap out ack. | 1942 // Simulate the swap out ack. |
1875 rfh1->OnSwappedOut(); | 1943 rfh1->OnSwappedOut(); |
1876 | 1944 |
1877 // rfh1 should be swapped out. | 1945 // rfh1 should be swapped out or deleted in --site-per-process. |
1878 EXPECT_FALSE(rfh_deleted_observer.deleted()); | 1946 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( |
1879 EXPECT_TRUE(rfh1->is_swapped_out()); | 1947 switches::kSitePerProcess)) { |
| 1948 EXPECT_FALSE(rfh_deleted_observer.deleted()); |
| 1949 EXPECT_TRUE(rfh1->is_swapped_out()); |
| 1950 } else { |
| 1951 EXPECT_TRUE(rfh_deleted_observer.deleted()); |
| 1952 } |
1880 } | 1953 } |
1881 | 1954 |
1882 // Test that the RenderViewHost is properly swapped out if a navigation in the | 1955 // Test that the RenderViewHost is properly swapped out if a navigation in the |
1883 // new renderer commits before sending the SwapOut message to the old renderer. | 1956 // new renderer commits before sending the SwapOut message to the old renderer. |
1884 // This simulates a cross-site navigation to a synchronously committing URL | 1957 // This simulates a cross-site navigation to a synchronously committing URL |
1885 // (e.g., a data URL) and ensures it works properly. | 1958 // (e.g., a data URL) and ensures it works properly. |
1886 TEST_F(RenderFrameHostManagerTest, | 1959 TEST_F(RenderFrameHostManagerTest, |
1887 CommitNewNavigationBeforeSendingSwapOut) { | 1960 CommitNewNavigationBeforeSendingSwapOut) { |
1888 const GURL kUrl1("http://www.google.com/"); | 1961 const GURL kUrl1("http://www.google.com/"); |
1889 const GURL kUrl2("http://www.chromium.org/"); | 1962 const GURL kUrl2("http://www.chromium.org/"); |
1890 | 1963 |
1891 // Navigate to the first page. | 1964 // Navigate to the first page. |
1892 contents()->NavigateAndCommit(kUrl1); | 1965 contents()->NavigateAndCommit(kUrl1); |
1893 TestRenderFrameHost* rfh1 = contents()->GetMainFrame(); | 1966 TestRenderFrameHost* rfh1 = contents()->GetMainFrame(); |
1894 RenderFrameHostDeletedObserver rfh_deleted_observer(rfh1); | 1967 RenderFrameHostDeletedObserver rfh_deleted_observer(rfh1); |
1895 EXPECT_EQ(RenderFrameHostImpl::STATE_DEFAULT, rfh1->rfh_state()); | 1968 EXPECT_EQ(RenderFrameHostImpl::STATE_DEFAULT, rfh1->rfh_state()); |
1896 | 1969 |
1897 // Increment the number of active frames in SiteInstanceImpl so that rfh1 is | 1970 // Increment the number of active frames in SiteInstanceImpl so that rfh1 is |
1898 // not deleted on swap out. | 1971 // not deleted on swap out. |
1899 rfh1->GetSiteInstance()->increment_active_frame_count(); | 1972 scoped_refptr<SiteInstanceImpl> site_instance = rfh1->GetSiteInstance(); |
| 1973 site_instance->increment_active_frame_count(); |
1900 | 1974 |
1901 // Navigate to new site, simulating onbeforeunload approval. | 1975 // Navigate to new site, simulating onbeforeunload approval. |
1902 controller().LoadURL( | 1976 controller().LoadURL( |
1903 kUrl2, Referrer(), ui::PAGE_TRANSITION_LINK, std::string()); | 1977 kUrl2, Referrer(), ui::PAGE_TRANSITION_LINK, std::string()); |
1904 int entry_id = controller().GetPendingEntry()->GetUniqueID(); | 1978 int entry_id = controller().GetPendingEntry()->GetUniqueID(); |
1905 rfh1->PrepareForCommit(); | 1979 rfh1->PrepareForCommit(); |
1906 EXPECT_TRUE(contents()->CrossProcessNavigationPending()); | 1980 EXPECT_TRUE(contents()->CrossProcessNavigationPending()); |
1907 TestRenderFrameHost* rfh2 = contents()->GetPendingMainFrame(); | 1981 TestRenderFrameHost* rfh2 = contents()->GetPendingMainFrame(); |
1908 | 1982 |
1909 // The new page commits. | 1983 // The new page commits. |
1910 contents()->TestDidNavigate(rfh2, 1, entry_id, true, kUrl2, | 1984 contents()->TestDidNavigate(rfh2, 1, entry_id, true, kUrl2, |
1911 ui::PAGE_TRANSITION_TYPED); | 1985 ui::PAGE_TRANSITION_TYPED); |
1912 EXPECT_FALSE(contents()->CrossProcessNavigationPending()); | 1986 EXPECT_FALSE(contents()->CrossProcessNavigationPending()); |
1913 EXPECT_EQ(rfh2, contents()->GetMainFrame()); | 1987 EXPECT_EQ(rfh2, contents()->GetMainFrame()); |
1914 EXPECT_TRUE(contents()->GetPendingMainFrame() == NULL); | 1988 EXPECT_TRUE(contents()->GetPendingMainFrame() == NULL); |
1915 EXPECT_EQ(RenderFrameHostImpl::STATE_DEFAULT, rfh2->rfh_state()); | 1989 EXPECT_EQ(RenderFrameHostImpl::STATE_DEFAULT, rfh2->rfh_state()); |
1916 EXPECT_EQ(RenderFrameHostImpl::STATE_PENDING_SWAP_OUT, rfh1->rfh_state()); | 1990 EXPECT_EQ(RenderFrameHostImpl::STATE_PENDING_SWAP_OUT, rfh1->rfh_state()); |
1917 | 1991 |
1918 // Simulate the swap out ack. | 1992 // Simulate the swap out ack. |
1919 rfh1->OnSwappedOut(); | 1993 rfh1->OnSwappedOut(); |
1920 | 1994 |
1921 // rfh1 should be swapped out. | 1995 // rfh1 should be swapped out. |
1922 EXPECT_FALSE(rfh_deleted_observer.deleted()); | 1996 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
1923 EXPECT_TRUE(rfh1->is_swapped_out()); | 1997 switches::kSitePerProcess)) { |
| 1998 EXPECT_TRUE(rfh_deleted_observer.deleted()); |
| 1999 EXPECT_TRUE(contents()->GetFrameTree()->root()->render_manager() |
| 2000 ->GetRenderFrameProxyHost(site_instance.get())); |
| 2001 } else { |
| 2002 EXPECT_FALSE(rfh_deleted_observer.deleted()); |
| 2003 EXPECT_TRUE(rfh1->is_swapped_out()); |
| 2004 } |
1924 } | 2005 } |
1925 | 2006 |
1926 // Test that a RenderFrameHost is properly deleted or swapped out when a | 2007 // Test that a RenderFrameHost is properly deleted when a cross-site navigation |
1927 // cross-site navigation is cancelled. | 2008 // is cancelled. |
1928 TEST_F(RenderFrameHostManagerTest, | 2009 TEST_F(RenderFrameHostManagerTest, |
1929 CancelPendingProperlyDeletesOrSwaps) { | 2010 CancelPendingProperlyDeletesOrSwaps) { |
1930 const GURL kUrl1("http://www.google.com/"); | 2011 const GURL kUrl1("http://www.google.com/"); |
1931 const GURL kUrl2("http://www.chromium.org/"); | 2012 const GURL kUrl2("http://www.chromium.org/"); |
1932 RenderFrameHostImpl* pending_rfh = NULL; | 2013 RenderFrameHostImpl* pending_rfh = NULL; |
1933 base::TimeTicks now = base::TimeTicks::Now(); | 2014 base::TimeTicks now = base::TimeTicks::Now(); |
1934 | 2015 |
1935 // Navigate to the first page. | 2016 // Navigate to the first page. |
1936 contents()->NavigateAndCommit(kUrl1); | 2017 contents()->NavigateAndCommit(kUrl1); |
1937 TestRenderFrameHost* rfh1 = main_test_rfh(); | 2018 TestRenderFrameHost* rfh1 = main_test_rfh(); |
(...skipping 19 matching lines...) Expand all Loading... |
1957 | 2038 |
1958 // Start another cross-site navigation. | 2039 // Start another cross-site navigation. |
1959 controller().LoadURL( | 2040 controller().LoadURL( |
1960 kUrl2, Referrer(), ui::PAGE_TRANSITION_LINK, std::string()); | 2041 kUrl2, Referrer(), ui::PAGE_TRANSITION_LINK, std::string()); |
1961 { | 2042 { |
1962 pending_rfh = contents()->GetFrameTree()->root()->render_manager() | 2043 pending_rfh = contents()->GetFrameTree()->root()->render_manager() |
1963 ->pending_frame_host(); | 2044 ->pending_frame_host(); |
1964 RenderFrameHostDeletedObserver rfh_deleted_observer(pending_rfh); | 2045 RenderFrameHostDeletedObserver rfh_deleted_observer(pending_rfh); |
1965 | 2046 |
1966 // Increment the number of active frames in the new SiteInstance, which will | 2047 // Increment the number of active frames in the new SiteInstance, which will |
1967 // cause the pending RFH to be swapped out instead of deleted. | 2048 // cause the pending RFH to be deleted and a RenderFrameProxyHost to be |
1968 pending_rfh->GetSiteInstance()->increment_active_frame_count(); | 2049 // created. |
| 2050 scoped_refptr<SiteInstanceImpl> site_instance = |
| 2051 pending_rfh->GetSiteInstance(); |
| 2052 site_instance->increment_active_frame_count(); |
1969 | 2053 |
1970 contents()->GetMainFrame()->OnMessageReceived( | 2054 contents()->GetMainFrame()->OnMessageReceived( |
1971 FrameHostMsg_BeforeUnload_ACK(0, false, now, now)); | 2055 FrameHostMsg_BeforeUnload_ACK(0, false, now, now)); |
1972 EXPECT_FALSE(contents()->CrossProcessNavigationPending()); | 2056 EXPECT_FALSE(contents()->CrossProcessNavigationPending()); |
1973 EXPECT_FALSE(rfh_deleted_observer.deleted()); | 2057 |
| 2058 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 2059 switches::kSitePerProcess)) { |
| 2060 EXPECT_TRUE(rfh_deleted_observer.deleted()); |
| 2061 EXPECT_TRUE(contents()->GetFrameTree()->root()->render_manager() |
| 2062 ->GetRenderFrameProxyHost(site_instance.get())); |
| 2063 } else { |
| 2064 EXPECT_FALSE(rfh_deleted_observer.deleted()); |
| 2065 } |
1974 } | 2066 } |
1975 } | 2067 } |
1976 | 2068 |
1977 // Test that a pending RenderFrameHost in a non-root frame tree node is properly | 2069 // Test that a pending RenderFrameHost in a non-root frame tree node is properly |
1978 // deleted when the node is detached. Motivated by http://crbug.com/441357 and | 2070 // deleted when the node is detached. Motivated by http://crbug.com/441357 and |
1979 // http://crbug.com/444955. | 2071 // http://crbug.com/444955. |
1980 TEST_F(RenderFrameHostManagerTest, DetachPendingChild) { | 2072 TEST_F(RenderFrameHostManagerTest, DetachPendingChild) { |
1981 base::CommandLine::ForCurrentProcess()->AppendSwitch( | 2073 base::CommandLine::ForCurrentProcess()->AppendSwitch( |
1982 switches::kSitePerProcess); | 2074 switches::kSitePerProcess); |
1983 | 2075 |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2157 EXPECT_FALSE(contents2->GetMainFrame()->IsRenderFrameLive()); | 2249 EXPECT_FALSE(contents2->GetMainFrame()->IsRenderFrameLive()); |
2158 contents2->NavigateAndCommit(kUrl3); | 2250 contents2->NavigateAndCommit(kUrl3); |
2159 EXPECT_TRUE(contents2->GetMainFrame()->IsRenderFrameLive()); | 2251 EXPECT_TRUE(contents2->GetMainFrame()->IsRenderFrameLive()); |
2160 EXPECT_NE(nullptr, | 2252 EXPECT_NE(nullptr, |
2161 iframe->GetRenderFrameProxyHost(contents1->GetSiteInstance())); | 2253 iframe->GetRenderFrameProxyHost(contents1->GetSiteInstance())); |
2162 EXPECT_EQ(nullptr, | 2254 EXPECT_EQ(nullptr, |
2163 iframe->GetRenderFrameProxyHost(contents2->GetSiteInstance())); | 2255 iframe->GetRenderFrameProxyHost(contents2->GetSiteInstance())); |
2164 } | 2256 } |
2165 | 2257 |
2166 } // namespace content | 2258 } // namespace content |
OLD | NEW |