| 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/strings/utf_string_conversions.h" | 5 #include "base/strings/utf_string_conversions.h" |
| 6 #include "content/browser/frame_host/navigation_controller_impl.h" | 6 #include "content/browser/frame_host/navigation_controller_impl.h" |
| 7 #include "content/browser/frame_host/navigation_entry_impl.h" | 7 #include "content/browser/frame_host/navigation_entry_impl.h" |
| 8 #include "content/browser/frame_host/render_view_host_manager.h" | 8 #include "content/browser/frame_host/render_view_host_manager.h" |
| 9 #include "content/browser/renderer_host/test_render_view_host.h" | 9 #include "content/browser/renderer_host/test_render_view_host.h" |
| 10 #include "content/browser/site_instance_impl.h" | 10 #include "content/browser/site_instance_impl.h" |
| (...skipping 548 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 559 | 559 |
| 560 // Tests the Init function by checking the initial RenderViewHost. | 560 // Tests the Init function by checking the initial RenderViewHost. |
| 561 TEST_F(RenderViewHostManagerTest, Init) { | 561 TEST_F(RenderViewHostManagerTest, Init) { |
| 562 // Using TestBrowserContext. | 562 // Using TestBrowserContext. |
| 563 SiteInstanceImpl* instance = | 563 SiteInstanceImpl* instance = |
| 564 static_cast<SiteInstanceImpl*>(SiteInstance::Create(browser_context())); | 564 static_cast<SiteInstanceImpl*>(SiteInstance::Create(browser_context())); |
| 565 EXPECT_FALSE(instance->HasSite()); | 565 EXPECT_FALSE(instance->HasSite()); |
| 566 | 566 |
| 567 scoped_ptr<TestWebContents> web_contents( | 567 scoped_ptr<TestWebContents> web_contents( |
| 568 TestWebContents::Create(browser_context(), instance)); | 568 TestWebContents::Create(browser_context(), instance)); |
| 569 RenderViewHostManager manager(web_contents.get(), web_contents.get(), | 569 RenderViewHostManager manager(web_contents->GetFrameTree()->root(), |
| 570 web_contents.get(), web_contents.get(), |
| 570 web_contents.get()); | 571 web_contents.get()); |
| 571 | 572 |
| 572 manager.Init(browser_context(), instance, MSG_ROUTING_NONE, MSG_ROUTING_NONE); | 573 manager.Init(browser_context(), instance, MSG_ROUTING_NONE, MSG_ROUTING_NONE); |
| 573 | 574 |
| 574 RenderViewHost* host = manager.current_host(); | 575 RenderViewHost* host = manager.current_host(); |
| 575 ASSERT_TRUE(host); | 576 ASSERT_TRUE(host); |
| 576 EXPECT_EQ(instance, host->GetSiteInstance()); | 577 EXPECT_EQ(instance, host->GetSiteInstance()); |
| 577 EXPECT_EQ(web_contents.get(), host->GetDelegate()); | 578 EXPECT_EQ(web_contents.get(), host->GetDelegate()); |
| 578 EXPECT_TRUE(manager.GetRenderWidgetHostView()); | 579 EXPECT_TRUE(manager.GetRenderWidgetHostView()); |
| 579 EXPECT_FALSE(manager.pending_render_view_host()); | 580 EXPECT_FALSE(manager.pending_render_view_host()); |
| 580 } | 581 } |
| 581 | 582 |
| 582 // Tests the Navigate function. We navigate three sites consecutively and check | 583 // Tests the Navigate function. We navigate three sites consecutively and check |
| 583 // how the pending/committed RenderViewHost are modified. | 584 // how the pending/committed RenderViewHost are modified. |
| 584 TEST_F(RenderViewHostManagerTest, Navigate) { | 585 TEST_F(RenderViewHostManagerTest, Navigate) { |
| 585 TestNotificationTracker notifications; | 586 TestNotificationTracker notifications; |
| 586 | 587 |
| 587 SiteInstance* instance = SiteInstance::Create(browser_context()); | 588 SiteInstance* instance = SiteInstance::Create(browser_context()); |
| 588 | 589 |
| 589 scoped_ptr<TestWebContents> web_contents( | 590 scoped_ptr<TestWebContents> web_contents( |
| 590 TestWebContents::Create(browser_context(), instance)); | 591 TestWebContents::Create(browser_context(), instance)); |
| 591 notifications.ListenFor(NOTIFICATION_RENDER_VIEW_HOST_CHANGED, | 592 notifications.ListenFor(NOTIFICATION_RENDER_VIEW_HOST_CHANGED, |
| 592 Source<WebContents>(web_contents.get())); | 593 Source<WebContents>(web_contents.get())); |
| 593 | 594 |
| 594 // Create. | 595 // Create. |
| 595 RenderViewHostManager manager(web_contents.get(), web_contents.get(), | 596 RenderViewHostManager manager(web_contents->GetFrameTree()->root(), |
| 597 web_contents.get(), web_contents.get(), |
| 596 web_contents.get()); | 598 web_contents.get()); |
| 597 | 599 |
| 598 manager.Init(browser_context(), instance, MSG_ROUTING_NONE, MSG_ROUTING_NONE); | 600 manager.Init(browser_context(), instance, MSG_ROUTING_NONE, MSG_ROUTING_NONE); |
| 599 | 601 |
| 600 RenderViewHost* host; | 602 RenderViewHost* host; |
| 601 | 603 |
| 602 // 1) The first navigation. -------------------------- | 604 // 1) The first navigation. -------------------------- |
| 603 const GURL kUrl1("http://www.google.com/"); | 605 const GURL kUrl1("http://www.google.com/"); |
| 604 NavigationEntryImpl entry1( | 606 NavigationEntryImpl entry1( |
| 605 NULL /* instance */, -1 /* page_id */, kUrl1, Referrer(), | 607 NULL /* instance */, -1 /* page_id */, kUrl1, Referrer(), |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 677 TestNotificationTracker notifications; | 679 TestNotificationTracker notifications; |
| 678 | 680 |
| 679 SiteInstance* instance = SiteInstance::Create(browser_context()); | 681 SiteInstance* instance = SiteInstance::Create(browser_context()); |
| 680 | 682 |
| 681 scoped_ptr<TestWebContents> web_contents( | 683 scoped_ptr<TestWebContents> web_contents( |
| 682 TestWebContents::Create(browser_context(), instance)); | 684 TestWebContents::Create(browser_context(), instance)); |
| 683 notifications.ListenFor(NOTIFICATION_RENDER_VIEW_HOST_CHANGED, | 685 notifications.ListenFor(NOTIFICATION_RENDER_VIEW_HOST_CHANGED, |
| 684 Source<WebContents>(web_contents.get())); | 686 Source<WebContents>(web_contents.get())); |
| 685 | 687 |
| 686 // Create. | 688 // Create. |
| 687 RenderViewHostManager manager(web_contents.get(), web_contents.get(), | 689 RenderViewHostManager manager(web_contents->GetFrameTree()->root(), |
| 690 web_contents.get(), web_contents.get(), |
| 688 web_contents.get()); | 691 web_contents.get()); |
| 689 | 692 |
| 690 manager.Init(browser_context(), instance, MSG_ROUTING_NONE, MSG_ROUTING_NONE); | 693 manager.Init(browser_context(), instance, MSG_ROUTING_NONE, MSG_ROUTING_NONE); |
| 691 | 694 |
| 692 // 1) The first navigation. -------------------------- | 695 // 1) The first navigation. -------------------------- |
| 693 const GURL kUrl1("http://www.google.com/"); | 696 const GURL kUrl1("http://www.google.com/"); |
| 694 NavigationEntryImpl entry1(NULL /* instance */, -1 /* page_id */, kUrl1, | 697 NavigationEntryImpl entry1(NULL /* instance */, -1 /* page_id */, kUrl1, |
| 695 Referrer(), string16() /* title */, | 698 Referrer(), string16() /* title */, |
| 696 PAGE_TRANSITION_TYPED, | 699 PAGE_TRANSITION_TYPED, |
| 697 false /* is_renderer_init */); | 700 false /* is_renderer_init */); |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 820 notifications.Check1AndReset(NOTIFICATION_RENDER_VIEW_HOST_CHANGED)); | 823 notifications.Check1AndReset(NOTIFICATION_RENDER_VIEW_HOST_CHANGED)); |
| 821 } | 824 } |
| 822 | 825 |
| 823 // Tests WebUI creation. | 826 // Tests WebUI creation. |
| 824 TEST_F(RenderViewHostManagerTest, WebUI) { | 827 TEST_F(RenderViewHostManagerTest, WebUI) { |
| 825 set_should_create_webui(true); | 828 set_should_create_webui(true); |
| 826 SiteInstance* instance = SiteInstance::Create(browser_context()); | 829 SiteInstance* instance = SiteInstance::Create(browser_context()); |
| 827 | 830 |
| 828 scoped_ptr<TestWebContents> web_contents( | 831 scoped_ptr<TestWebContents> web_contents( |
| 829 TestWebContents::Create(browser_context(), instance)); | 832 TestWebContents::Create(browser_context(), instance)); |
| 830 RenderViewHostManager manager(web_contents.get(), web_contents.get(), | 833 RenderViewHostManager manager(web_contents->GetFrameTree()->root(), |
| 834 web_contents.get(), web_contents.get(), |
| 831 web_contents.get()); | 835 web_contents.get()); |
| 832 | 836 |
| 833 manager.Init(browser_context(), instance, MSG_ROUTING_NONE, MSG_ROUTING_NONE); | 837 manager.Init(browser_context(), instance, MSG_ROUTING_NONE, MSG_ROUTING_NONE); |
| 834 EXPECT_FALSE(manager.current_host()->IsRenderViewLive()); | 838 EXPECT_FALSE(manager.current_host()->IsRenderViewLive()); |
| 835 | 839 |
| 836 const GURL kUrl("chrome://foo"); | 840 const GURL kUrl("chrome://foo"); |
| 837 NavigationEntryImpl entry(NULL /* instance */, -1 /* page_id */, kUrl, | 841 NavigationEntryImpl entry(NULL /* instance */, -1 /* page_id */, kUrl, |
| 838 Referrer(), string16() /* title */, | 842 Referrer(), string16() /* title */, |
| 839 PAGE_TRANSITION_TYPED, | 843 PAGE_TRANSITION_TYPED, |
| 840 false /* is_renderer_init */); | 844 false /* is_renderer_init */); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 867 | 871 |
| 868 // Tests that we can open a WebUI link in a new tab from a WebUI page and still | 872 // Tests that we can open a WebUI link in a new tab from a WebUI page and still |
| 869 // grant the correct bindings. http://crbug.com/189101. | 873 // grant the correct bindings. http://crbug.com/189101. |
| 870 TEST_F(RenderViewHostManagerTest, WebUIInNewTab) { | 874 TEST_F(RenderViewHostManagerTest, WebUIInNewTab) { |
| 871 set_should_create_webui(true); | 875 set_should_create_webui(true); |
| 872 SiteInstance* blank_instance = SiteInstance::Create(browser_context()); | 876 SiteInstance* blank_instance = SiteInstance::Create(browser_context()); |
| 873 | 877 |
| 874 // Create a blank tab. | 878 // Create a blank tab. |
| 875 scoped_ptr<TestWebContents> web_contents1( | 879 scoped_ptr<TestWebContents> web_contents1( |
| 876 TestWebContents::Create(browser_context(), blank_instance)); | 880 TestWebContents::Create(browser_context(), blank_instance)); |
| 877 RenderViewHostManager manager1(web_contents1.get(), web_contents1.get(), | 881 RenderViewHostManager manager1(web_contents1->GetFrameTree()->root(), |
| 882 web_contents1.get(), web_contents1.get(), |
| 878 web_contents1.get()); | 883 web_contents1.get()); |
| 879 manager1.Init( | 884 manager1.Init( |
| 880 browser_context(), blank_instance, MSG_ROUTING_NONE, MSG_ROUTING_NONE); | 885 browser_context(), blank_instance, MSG_ROUTING_NONE, MSG_ROUTING_NONE); |
| 881 // Test the case that new RVH is considered live. | 886 // Test the case that new RVH is considered live. |
| 882 manager1.current_host()->CreateRenderView(string16(), -1, -1); | 887 manager1.current_host()->CreateRenderView(string16(), -1, -1); |
| 883 | 888 |
| 884 // Navigate to a WebUI page. | 889 // Navigate to a WebUI page. |
| 885 const GURL kUrl1("chrome://foo"); | 890 const GURL kUrl1("chrome://foo"); |
| 886 NavigationEntryImpl entry1(NULL /* instance */, -1 /* page_id */, kUrl1, | 891 NavigationEntryImpl entry1(NULL /* instance */, -1 /* page_id */, kUrl1, |
| 887 Referrer(), string16() /* title */, | 892 Referrer(), string16() /* title */, |
| 888 PAGE_TRANSITION_TYPED, | 893 PAGE_TRANSITION_TYPED, |
| 889 false /* is_renderer_init */); | 894 false /* is_renderer_init */); |
| 890 RenderViewHost* host1 = manager1.Navigate(entry1); | 895 RenderViewHost* host1 = manager1.Navigate(entry1); |
| 891 | 896 |
| 892 // We should have a pending navigation to the WebUI RenderViewHost. | 897 // We should have a pending navigation to the WebUI RenderViewHost. |
| 893 // It should already have bindings. | 898 // It should already have bindings. |
| 894 EXPECT_EQ(host1, manager1.pending_render_view_host()); | 899 EXPECT_EQ(host1, manager1.pending_render_view_host()); |
| 895 EXPECT_NE(host1, manager1.current_host()); | 900 EXPECT_NE(host1, manager1.current_host()); |
| 896 EXPECT_TRUE(host1->GetEnabledBindings() & BINDINGS_POLICY_WEB_UI); | 901 EXPECT_TRUE(host1->GetEnabledBindings() & BINDINGS_POLICY_WEB_UI); |
| 897 | 902 |
| 898 // Commit and ensure we still have bindings. | 903 // Commit and ensure we still have bindings. |
| 899 manager1.DidNavigateMainFrame(host1); | 904 manager1.DidNavigateMainFrame(host1); |
| 900 SiteInstance* webui_instance = host1->GetSiteInstance(); | 905 SiteInstance* webui_instance = host1->GetSiteInstance(); |
| 901 EXPECT_EQ(host1, manager1.current_host()); | 906 EXPECT_EQ(host1, manager1.current_host()); |
| 902 EXPECT_TRUE(host1->GetEnabledBindings() & BINDINGS_POLICY_WEB_UI); | 907 EXPECT_TRUE(host1->GetEnabledBindings() & BINDINGS_POLICY_WEB_UI); |
| 903 | 908 |
| 904 // Now simulate clicking a link that opens in a new tab. | 909 // Now simulate clicking a link that opens in a new tab. |
| 905 scoped_ptr<TestWebContents> web_contents2( | 910 scoped_ptr<TestWebContents> web_contents2( |
| 906 TestWebContents::Create(browser_context(), webui_instance)); | 911 TestWebContents::Create(browser_context(), webui_instance)); |
| 907 RenderViewHostManager manager2(web_contents2.get(), web_contents2.get(), | 912 RenderViewHostManager manager2(web_contents2->GetFrameTree()->root(), |
| 913 web_contents2.get(), web_contents2.get(), |
| 908 web_contents2.get()); | 914 web_contents2.get()); |
| 909 manager2.Init( | 915 manager2.Init( |
| 910 browser_context(), webui_instance, MSG_ROUTING_NONE, MSG_ROUTING_NONE); | 916 browser_context(), webui_instance, MSG_ROUTING_NONE, MSG_ROUTING_NONE); |
| 911 // Make sure the new RVH is considered live. This is usually done in | 917 // Make sure the new RVH is considered live. This is usually done in |
| 912 // RenderWidgetHost::Init when opening a new tab from a link. | 918 // RenderWidgetHost::Init when opening a new tab from a link. |
| 913 manager2.current_host()->CreateRenderView(string16(), -1, -1); | 919 manager2.current_host()->CreateRenderView(string16(), -1, -1); |
| 914 | 920 |
| 915 const GURL kUrl2("chrome://foo/bar"); | 921 const GURL kUrl2("chrome://foo/bar"); |
| 916 NavigationEntryImpl entry2(NULL /* instance */, -1 /* page_id */, kUrl2, | 922 NavigationEntryImpl entry2(NULL /* instance */, -1 /* page_id */, kUrl2, |
| 917 Referrer(), string16() /* title */, | 923 Referrer(), string16() /* title */, |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1050 | 1056 |
| 1051 // Navigate to a cross-site URL (different SiteInstance but same | 1057 // Navigate to a cross-site URL (different SiteInstance but same |
| 1052 // BrowsingInstance). | 1058 // BrowsingInstance). |
| 1053 contents()->NavigateAndCommit(kUrl2); | 1059 contents()->NavigateAndCommit(kUrl2); |
| 1054 TestRenderViewHost* rvh2 = test_rvh(); | 1060 TestRenderViewHost* rvh2 = test_rvh(); |
| 1055 EXPECT_NE(rvh1->GetSiteInstance(), rvh2->GetSiteInstance()); | 1061 EXPECT_NE(rvh1->GetSiteInstance(), rvh2->GetSiteInstance()); |
| 1056 EXPECT_TRUE(rvh1->GetSiteInstance()->IsRelatedSiteInstance( | 1062 EXPECT_TRUE(rvh1->GetSiteInstance()->IsRelatedSiteInstance( |
| 1057 rvh2->GetSiteInstance())); | 1063 rvh2->GetSiteInstance())); |
| 1058 | 1064 |
| 1059 // Ensure rvh1 is placed on swapped out list of the current tab. | 1065 // Ensure rvh1 is placed on swapped out list of the current tab. |
| 1060 EXPECT_TRUE(manager->IsOnSwappedOutList(rvh1)); | 1066 EXPECT_TRUE(manager->IsRVHOnSwappedOutList(rvh1)); |
| 1061 EXPECT_EQ(rvh1, | 1067 EXPECT_EQ(rvh1, |
| 1062 manager->GetSwappedOutRenderViewHost(rvh1->GetSiteInstance())); | 1068 manager->GetSwappedOutRenderViewHost(rvh1->GetSiteInstance())); |
| 1063 | 1069 |
| 1064 // Ensure a swapped out RVH is created in the first opener tab. | 1070 // Ensure a swapped out RVH is created in the first opener tab. |
| 1065 TestRenderViewHost* opener1_rvh = static_cast<TestRenderViewHost*>( | 1071 TestRenderViewHost* opener1_rvh = static_cast<TestRenderViewHost*>( |
| 1066 opener1_manager->GetSwappedOutRenderViewHost(rvh2->GetSiteInstance())); | 1072 opener1_manager->GetSwappedOutRenderViewHost(rvh2->GetSiteInstance())); |
| 1067 EXPECT_TRUE(opener1_manager->IsOnSwappedOutList(opener1_rvh)); | 1073 EXPECT_TRUE(opener1_manager->IsRVHOnSwappedOutList(opener1_rvh)); |
| 1068 EXPECT_TRUE(opener1_rvh->is_swapped_out()); | 1074 EXPECT_TRUE(opener1_rvh->is_swapped_out()); |
| 1069 | 1075 |
| 1070 // Ensure a swapped out RVH is created in the second opener tab. | 1076 // Ensure a swapped out RVH is created in the second opener tab. |
| 1071 TestRenderViewHost* opener2_rvh = static_cast<TestRenderViewHost*>( | 1077 TestRenderViewHost* opener2_rvh = static_cast<TestRenderViewHost*>( |
| 1072 opener2_manager->GetSwappedOutRenderViewHost(rvh2->GetSiteInstance())); | 1078 opener2_manager->GetSwappedOutRenderViewHost(rvh2->GetSiteInstance())); |
| 1073 EXPECT_TRUE(opener2_manager->IsOnSwappedOutList(opener2_rvh)); | 1079 EXPECT_TRUE(opener2_manager->IsRVHOnSwappedOutList(opener2_rvh)); |
| 1074 EXPECT_TRUE(opener2_rvh->is_swapped_out()); | 1080 EXPECT_TRUE(opener2_rvh->is_swapped_out()); |
| 1075 | 1081 |
| 1076 // Navigate to a cross-BrowsingInstance URL. | 1082 // Navigate to a cross-BrowsingInstance URL. |
| 1077 contents()->NavigateAndCommit(kChromeUrl); | 1083 contents()->NavigateAndCommit(kChromeUrl); |
| 1078 TestRenderViewHost* rvh3 = test_rvh(); | 1084 TestRenderViewHost* rvh3 = test_rvh(); |
| 1079 EXPECT_NE(rvh1->GetSiteInstance(), rvh3->GetSiteInstance()); | 1085 EXPECT_NE(rvh1->GetSiteInstance(), rvh3->GetSiteInstance()); |
| 1080 EXPECT_FALSE(rvh1->GetSiteInstance()->IsRelatedSiteInstance( | 1086 EXPECT_FALSE(rvh1->GetSiteInstance()->IsRelatedSiteInstance( |
| 1081 rvh3->GetSiteInstance())); | 1087 rvh3->GetSiteInstance())); |
| 1082 | 1088 |
| 1083 // No scripting is allowed across BrowsingInstances, so we should not create | 1089 // No scripting is allowed across BrowsingInstances, so we should not create |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1159 // BrowsingInstance). | 1165 // BrowsingInstance). |
| 1160 contents()->NavigateAndCommit(kPluginUrl); | 1166 contents()->NavigateAndCommit(kPluginUrl); |
| 1161 TestRenderViewHost* rvh2 = test_rvh(); | 1167 TestRenderViewHost* rvh2 = test_rvh(); |
| 1162 EXPECT_NE(rvh1->GetSiteInstance(), rvh2->GetSiteInstance()); | 1168 EXPECT_NE(rvh1->GetSiteInstance(), rvh2->GetSiteInstance()); |
| 1163 EXPECT_TRUE(rvh1->GetSiteInstance()->IsRelatedSiteInstance( | 1169 EXPECT_TRUE(rvh1->GetSiteInstance()->IsRelatedSiteInstance( |
| 1164 rvh2->GetSiteInstance())); | 1170 rvh2->GetSiteInstance())); |
| 1165 | 1171 |
| 1166 // Ensure a swapped out RVH is created in the first opener tab. | 1172 // Ensure a swapped out RVH is created in the first opener tab. |
| 1167 TestRenderViewHost* opener1_rvh = static_cast<TestRenderViewHost*>( | 1173 TestRenderViewHost* opener1_rvh = static_cast<TestRenderViewHost*>( |
| 1168 opener1_manager->GetSwappedOutRenderViewHost(rvh2->GetSiteInstance())); | 1174 opener1_manager->GetSwappedOutRenderViewHost(rvh2->GetSiteInstance())); |
| 1169 EXPECT_TRUE(opener1_manager->IsOnSwappedOutList(opener1_rvh)); | 1175 EXPECT_TRUE(opener1_manager->IsRVHOnSwappedOutList(opener1_rvh)); |
| 1170 EXPECT_TRUE(opener1_rvh->is_swapped_out()); | 1176 EXPECT_TRUE(opener1_rvh->is_swapped_out()); |
| 1171 | 1177 |
| 1172 // Ensure the new RVH has WebUI bindings. | 1178 // Ensure the new RVH has WebUI bindings. |
| 1173 EXPECT_TRUE(rvh2->GetEnabledBindings() & BINDINGS_POLICY_WEB_UI); | 1179 EXPECT_TRUE(rvh2->GetEnabledBindings() & BINDINGS_POLICY_WEB_UI); |
| 1174 } | 1180 } |
| 1175 | 1181 |
| 1176 // Test that we reuse the same guest SiteInstance if we navigate across sites. | 1182 // Test that we reuse the same guest SiteInstance if we navigate across sites. |
| 1177 TEST_F(RenderViewHostManagerTest, NoSwapOnGuestNavigations) { | 1183 TEST_F(RenderViewHostManagerTest, NoSwapOnGuestNavigations) { |
| 1178 TestNotificationTracker notifications; | 1184 TestNotificationTracker notifications; |
| 1179 | 1185 |
| 1180 GURL guest_url(std::string(kGuestScheme).append("://abc123")); | 1186 GURL guest_url(std::string(kGuestScheme).append("://abc123")); |
| 1181 SiteInstance* instance = | 1187 SiteInstance* instance = |
| 1182 SiteInstance::CreateForURL(browser_context(), guest_url); | 1188 SiteInstance::CreateForURL(browser_context(), guest_url); |
| 1183 scoped_ptr<TestWebContents> web_contents( | 1189 scoped_ptr<TestWebContents> web_contents( |
| 1184 TestWebContents::Create(browser_context(), instance)); | 1190 TestWebContents::Create(browser_context(), instance)); |
| 1185 | 1191 |
| 1186 // Create. | 1192 // Create. |
| 1187 RenderViewHostManager manager(web_contents.get(), web_contents.get(), | 1193 RenderViewHostManager manager(web_contents->GetFrameTree()->root(), |
| 1194 web_contents.get(), web_contents.get(), |
| 1188 web_contents.get()); | 1195 web_contents.get()); |
| 1189 | 1196 |
| 1190 manager.Init(browser_context(), instance, MSG_ROUTING_NONE, MSG_ROUTING_NONE); | 1197 manager.Init(browser_context(), instance, MSG_ROUTING_NONE, MSG_ROUTING_NONE); |
| 1191 | 1198 |
| 1192 RenderViewHost* host; | 1199 RenderViewHost* host; |
| 1193 | 1200 |
| 1194 // 1) The first navigation. -------------------------- | 1201 // 1) The first navigation. -------------------------- |
| 1195 const GURL kUrl1("http://www.google.com/"); | 1202 const GURL kUrl1("http://www.google.com/"); |
| 1196 NavigationEntryImpl entry1( | 1203 NavigationEntryImpl entry1( |
| 1197 NULL /* instance */, -1 /* page_id */, kUrl1, Referrer(), | 1204 NULL /* instance */, -1 /* page_id */, kUrl1, Referrer(), |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1242 SiteInstance* instance = SiteInstance::Create(browser_context()); | 1249 SiteInstance* instance = SiteInstance::Create(browser_context()); |
| 1243 | 1250 |
| 1244 BeforeUnloadFiredWebContentsDelegate delegate; | 1251 BeforeUnloadFiredWebContentsDelegate delegate; |
| 1245 scoped_ptr<TestWebContents> web_contents( | 1252 scoped_ptr<TestWebContents> web_contents( |
| 1246 TestWebContents::Create(browser_context(), instance)); | 1253 TestWebContents::Create(browser_context(), instance)); |
| 1247 web_contents->SetDelegate(&delegate); | 1254 web_contents->SetDelegate(&delegate); |
| 1248 notifications.ListenFor(NOTIFICATION_RENDER_VIEW_HOST_CHANGED, | 1255 notifications.ListenFor(NOTIFICATION_RENDER_VIEW_HOST_CHANGED, |
| 1249 Source<WebContents>(web_contents.get())); | 1256 Source<WebContents>(web_contents.get())); |
| 1250 | 1257 |
| 1251 // Create. | 1258 // Create. |
| 1252 RenderViewHostManager manager(web_contents.get(), web_contents.get(), | 1259 RenderViewHostManager manager(web_contents->GetFrameTree()->root(), |
| 1260 web_contents.get(), web_contents.get(), |
| 1253 web_contents.get()); | 1261 web_contents.get()); |
| 1254 | 1262 |
| 1255 manager.Init(browser_context(), instance, MSG_ROUTING_NONE, MSG_ROUTING_NONE); | 1263 manager.Init(browser_context(), instance, MSG_ROUTING_NONE, MSG_ROUTING_NONE); |
| 1256 | 1264 |
| 1257 // 1) The first navigation. -------------------------- | 1265 // 1) The first navigation. -------------------------- |
| 1258 const GURL kUrl1("http://www.google.com/"); | 1266 const GURL kUrl1("http://www.google.com/"); |
| 1259 NavigationEntryImpl entry1(NULL /* instance */, -1 /* page_id */, kUrl1, | 1267 NavigationEntryImpl entry1(NULL /* instance */, -1 /* page_id */, kUrl1, |
| 1260 Referrer(), string16() /* title */, | 1268 Referrer(), string16() /* title */, |
| 1261 PAGE_TRANSITION_TYPED, | 1269 PAGE_TRANSITION_TYPED, |
| 1262 false /* is_renderer_init */); | 1270 false /* is_renderer_init */); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1303 Source<RenderWidgetHost>(host2)); | 1311 Source<RenderWidgetHost>(host2)); |
| 1304 manager.ShouldClosePage(false, true, base::TimeTicks()); | 1312 manager.ShouldClosePage(false, true, base::TimeTicks()); |
| 1305 | 1313 |
| 1306 EXPECT_TRUE( | 1314 EXPECT_TRUE( |
| 1307 notifications.Check1AndReset(NOTIFICATION_RENDER_WIDGET_HOST_DESTROYED)); | 1315 notifications.Check1AndReset(NOTIFICATION_RENDER_WIDGET_HOST_DESTROYED)); |
| 1308 EXPECT_FALSE(manager.pending_render_view_host()); | 1316 EXPECT_FALSE(manager.pending_render_view_host()); |
| 1309 EXPECT_EQ(host, manager.current_host()); | 1317 EXPECT_EQ(host, manager.current_host()); |
| 1310 } | 1318 } |
| 1311 | 1319 |
| 1312 } // namespace content | 1320 } // namespace content |
| OLD | NEW |