OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/renderer_host/test_render_view_host.h" | 6 #include "content/browser/renderer_host/test_render_view_host.h" |
7 #include "content/browser/site_instance_impl.h" | 7 #include "content/browser/site_instance_impl.h" |
8 #include "content/browser/web_contents/navigation_controller_impl.h" | 8 #include "content/browser/web_contents/navigation_controller_impl.h" |
9 #include "content/browser/web_contents/navigation_entry_impl.h" | 9 #include "content/browser/web_contents/navigation_entry_impl.h" |
10 #include "content/browser/web_contents/render_view_host_manager.h" | 10 #include "content/browser/web_contents/render_view_host_manager.h" |
(...skipping 1193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1204 EXPECT_FALSE(manager.pending_render_view_host()); | 1204 EXPECT_FALSE(manager.pending_render_view_host()); |
1205 | 1205 |
1206 // Commit. | 1206 // Commit. |
1207 manager.DidNavigateMainFrame(host); | 1207 manager.DidNavigateMainFrame(host); |
1208 EXPECT_EQ(host, manager.current_host()); | 1208 EXPECT_EQ(host, manager.current_host()); |
1209 ASSERT_TRUE(host); | 1209 ASSERT_TRUE(host); |
1210 EXPECT_EQ(static_cast<SiteInstanceImpl*>(host->GetSiteInstance()), | 1210 EXPECT_EQ(static_cast<SiteInstanceImpl*>(host->GetSiteInstance()), |
1211 instance); | 1211 instance); |
1212 } | 1212 } |
1213 | 1213 |
1214 // Tests that when specified, a navigation is done in the site instance of the | |
Charlie Reis
2013/07/31 17:16:16
I do not think we should have this behavior.
jochen (gone - plz use gerrit)
2013/07/31 18:30:52
Removed.
| |
1215 // owning WebContents. | |
1216 TEST_F(RenderViewHostManagerTest, StayWithinSiteInstance) { | |
1217 const GURL kUrl1("http://www.google.com/"); | |
1218 const GURL kUrl2("http://www.chromium.org/"); | |
1219 | |
1220 // Create a WebContents with a SiteInstance corresponding to kUrl1. | |
1221 scoped_refptr<SiteInstance> site_instance( | |
1222 SiteInstance::CreateForURL(browser_context(), kUrl1)); | |
1223 scoped_ptr<TestWebContents> contents2( | |
1224 TestWebContents::Create(browser_context(), site_instance.get())); | |
1225 | |
1226 // Navigate to kUrl2, but specify that we want to use the existing | |
1227 // SiteInstance. | |
1228 NavigationController::LoadURLParams params(kUrl2); | |
1229 params.transition_type = PAGE_TRANSITION_LINK; | |
1230 params.should_stay_in_site_instance = true; | |
1231 contents2->GetController().LoadURLWithParams(params); | |
1232 | |
1233 // Check that the RVH was created with the desired SiteInstance. | |
1234 TestRenderViewHost* dest_rvh = | |
1235 static_cast<TestRenderViewHost*>(contents2->GetRenderViewHost()); | |
1236 ASSERT_TRUE(dest_rvh); | |
1237 EXPECT_EQ(site_instance.get(), dest_rvh->GetSiteInstance()); | |
1238 } | |
1239 | |
1214 } // namespace content | 1240 } // namespace content |
OLD | NEW |