| 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/files/file_path.h" | 5 #include "base/files/file_path.h" |
| 6 #include "base/strings/utf_string_conversions.h" | 6 #include "base/strings/utf_string_conversions.h" |
| 7 #include "content/browser/frame_host/cross_site_transferring_request.h" | 7 #include "content/browser/frame_host/cross_site_transferring_request.h" |
| 8 #include "content/browser/frame_host/navigation_controller_impl.h" | 8 #include "content/browser/frame_host/navigation_controller_impl.h" |
| 9 #include "content/browser/frame_host/navigation_entry_impl.h" | 9 #include "content/browser/frame_host/navigation_entry_impl.h" |
| 10 #include "content/browser/frame_host/navigator.h" | 10 #include "content/browser/frame_host/navigator.h" |
| (...skipping 1042 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1053 // Create a blank tab. | 1053 // Create a blank tab. |
| 1054 scoped_ptr<TestWebContents> web_contents1( | 1054 scoped_ptr<TestWebContents> web_contents1( |
| 1055 TestWebContents::Create(browser_context(), blank_instance)); | 1055 TestWebContents::Create(browser_context(), blank_instance)); |
| 1056 FrameTree tree1(web_contents1->GetFrameTree()->root()->navigator(), | 1056 FrameTree tree1(web_contents1->GetFrameTree()->root()->navigator(), |
| 1057 web_contents1.get(), web_contents1.get(), | 1057 web_contents1.get(), web_contents1.get(), |
| 1058 web_contents1.get(), web_contents1.get()); | 1058 web_contents1.get(), web_contents1.get()); |
| 1059 RenderFrameHostManager* manager1 = tree1.root()->render_manager(); | 1059 RenderFrameHostManager* manager1 = tree1.root()->render_manager(); |
| 1060 manager1->Init( | 1060 manager1->Init( |
| 1061 browser_context(), blank_instance, MSG_ROUTING_NONE, MSG_ROUTING_NONE); | 1061 browser_context(), blank_instance, MSG_ROUTING_NONE, MSG_ROUTING_NONE); |
| 1062 // Test the case that new RVH is considered live. | 1062 // Test the case that new RVH is considered live. |
| 1063 manager1->current_host()->CreateRenderView(base::string16(), -1, -1); | 1063 manager1->current_host()->CreateRenderView(base::string16(), -1, -1, false); |
| 1064 | 1064 |
| 1065 // Navigate to a WebUI page. | 1065 // Navigate to a WebUI page. |
| 1066 const GURL kUrl1("chrome://foo"); | 1066 const GURL kUrl1("chrome://foo"); |
| 1067 NavigationEntryImpl entry1(NULL /* instance */, -1 /* page_id */, kUrl1, | 1067 NavigationEntryImpl entry1(NULL /* instance */, -1 /* page_id */, kUrl1, |
| 1068 Referrer(), base::string16() /* title */, | 1068 Referrer(), base::string16() /* title */, |
| 1069 PAGE_TRANSITION_TYPED, | 1069 PAGE_TRANSITION_TYPED, |
| 1070 false /* is_renderer_init */); | 1070 false /* is_renderer_init */); |
| 1071 RenderFrameHostImpl* host1 = manager1->Navigate(entry1); | 1071 RenderFrameHostImpl* host1 = manager1->Navigate(entry1); |
| 1072 | 1072 |
| 1073 // We should have a pending navigation to the WebUI RenderViewHost. | 1073 // We should have a pending navigation to the WebUI RenderViewHost. |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1088 scoped_ptr<TestWebContents> web_contents2( | 1088 scoped_ptr<TestWebContents> web_contents2( |
| 1089 TestWebContents::Create(browser_context(), webui_instance)); | 1089 TestWebContents::Create(browser_context(), webui_instance)); |
| 1090 FrameTree tree2(web_contents2->GetFrameTree()->root()->navigator(), | 1090 FrameTree tree2(web_contents2->GetFrameTree()->root()->navigator(), |
| 1091 web_contents2.get(), web_contents2.get(), | 1091 web_contents2.get(), web_contents2.get(), |
| 1092 web_contents2.get(), web_contents2.get()); | 1092 web_contents2.get(), web_contents2.get()); |
| 1093 RenderFrameHostManager* manager2 = tree2.root()->render_manager(); | 1093 RenderFrameHostManager* manager2 = tree2.root()->render_manager(); |
| 1094 manager2->Init( | 1094 manager2->Init( |
| 1095 browser_context(), webui_instance, MSG_ROUTING_NONE, MSG_ROUTING_NONE); | 1095 browser_context(), webui_instance, MSG_ROUTING_NONE, MSG_ROUTING_NONE); |
| 1096 // Make sure the new RVH is considered live. This is usually done in | 1096 // Make sure the new RVH is considered live. This is usually done in |
| 1097 // RenderWidgetHost::Init when opening a new tab from a link. | 1097 // RenderWidgetHost::Init when opening a new tab from a link. |
| 1098 manager2->current_host()->CreateRenderView(base::string16(), -1, -1); | 1098 manager2->current_host()->CreateRenderView(base::string16(), -1, -1, false); |
| 1099 | 1099 |
| 1100 const GURL kUrl2("chrome://foo/bar"); | 1100 const GURL kUrl2("chrome://foo/bar"); |
| 1101 NavigationEntryImpl entry2(NULL /* instance */, -1 /* page_id */, kUrl2, | 1101 NavigationEntryImpl entry2(NULL /* instance */, -1 /* page_id */, kUrl2, |
| 1102 Referrer(), base::string16() /* title */, | 1102 Referrer(), base::string16() /* title */, |
| 1103 PAGE_TRANSITION_LINK, | 1103 PAGE_TRANSITION_LINK, |
| 1104 true /* is_renderer_init */); | 1104 true /* is_renderer_init */); |
| 1105 RenderFrameHostImpl* host2 = manager2->Navigate(entry2); | 1105 RenderFrameHostImpl* host2 = manager2->Navigate(entry2); |
| 1106 | 1106 |
| 1107 // No cross-process transition happens because we are already in the right | 1107 // No cross-process transition happens because we are already in the right |
| 1108 // SiteInstance. We should grant bindings immediately. | 1108 // SiteInstance. We should grant bindings immediately. |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1290 TestRenderViewHost* rvh1 = test_rvh(); | 1290 TestRenderViewHost* rvh1 = test_rvh(); |
| 1291 | 1291 |
| 1292 // Create a new tab as an opener for the main tab. | 1292 // Create a new tab as an opener for the main tab. |
| 1293 scoped_ptr<TestWebContents> opener1( | 1293 scoped_ptr<TestWebContents> opener1( |
| 1294 TestWebContents::Create(browser_context(), rvh1->GetSiteInstance())); | 1294 TestWebContents::Create(browser_context(), rvh1->GetSiteInstance())); |
| 1295 RenderFrameHostManager* opener1_manager = | 1295 RenderFrameHostManager* opener1_manager = |
| 1296 opener1->GetRenderManagerForTesting(); | 1296 opener1->GetRenderManagerForTesting(); |
| 1297 contents()->SetOpener(opener1.get()); | 1297 contents()->SetOpener(opener1.get()); |
| 1298 | 1298 |
| 1299 // Make sure the new opener RVH is considered live. | 1299 // Make sure the new opener RVH is considered live. |
| 1300 opener1_manager->current_host()->CreateRenderView(base::string16(), -1, -1); | 1300 opener1_manager->current_host()->CreateRenderView( |
| 1301 base::string16(), -1, -1, false); |
| 1301 | 1302 |
| 1302 // Use a cross-process navigation in the opener to swap out the old RVH. | 1303 // Use a cross-process navigation in the opener to swap out the old RVH. |
| 1303 EXPECT_FALSE(opener1_manager->GetSwappedOutRenderViewHost( | 1304 EXPECT_FALSE(opener1_manager->GetSwappedOutRenderViewHost( |
| 1304 rvh1->GetSiteInstance())); | 1305 rvh1->GetSiteInstance())); |
| 1305 opener1->NavigateAndCommit(kUrl2); | 1306 opener1->NavigateAndCommit(kUrl2); |
| 1306 EXPECT_TRUE(opener1_manager->GetSwappedOutRenderViewHost( | 1307 EXPECT_TRUE(opener1_manager->GetSwappedOutRenderViewHost( |
| 1307 rvh1->GetSiteInstance())); | 1308 rvh1->GetSiteInstance())); |
| 1308 | 1309 |
| 1309 // Fake a process crash. | 1310 // Fake a process crash. |
| 1310 RenderProcessHost::RendererClosedDetails details( | 1311 RenderProcessHost::RendererClosedDetails details( |
| (...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1759 | 1760 |
| 1760 // Simulate the swap out ack. | 1761 // Simulate the swap out ack. |
| 1761 rvh1->OnSwappedOut(false); | 1762 rvh1->OnSwappedOut(false); |
| 1762 | 1763 |
| 1763 // rvh1 should be swapped out. | 1764 // rvh1 should be swapped out. |
| 1764 EXPECT_FALSE(rvh_deleted_observer.deleted()); | 1765 EXPECT_FALSE(rvh_deleted_observer.deleted()); |
| 1765 EXPECT_TRUE(rvh1->IsSwappedOut()); | 1766 EXPECT_TRUE(rvh1->IsSwappedOut()); |
| 1766 } | 1767 } |
| 1767 | 1768 |
| 1768 } // namespace content | 1769 } // namespace content |
| OLD | NEW |