| 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 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 253 const GURL kChromeURL("chrome://foo"); | 253 const GURL kChromeURL("chrome://foo"); |
| 254 const GURL kDestUrl("http://www.google.com/"); | 254 const GURL kDestUrl("http://www.google.com/"); |
| 255 | 255 |
| 256 // Navigate our first tab to a chrome url and then to the destination. | 256 // Navigate our first tab to a chrome url and then to the destination. |
| 257 NavigateActiveAndCommit(kChromeURL); | 257 NavigateActiveAndCommit(kChromeURL); |
| 258 TestRenderViewHost* ntp_rvh = static_cast<TestRenderViewHost*>( | 258 TestRenderViewHost* ntp_rvh = static_cast<TestRenderViewHost*>( |
| 259 contents()->GetRenderManagerForTesting()->current_host()); | 259 contents()->GetRenderManagerForTesting()->current_host()); |
| 260 | 260 |
| 261 // Send an update title message and make sure it works. | 261 // Send an update title message and make sure it works. |
| 262 const string16 ntp_title = ASCIIToUTF16("NTP Title"); | 262 const string16 ntp_title = ASCIIToUTF16("NTP Title"); |
| 263 WebKit::WebTextDirection direction = WebKit::WebTextDirectionLeftToRight; | 263 blink::WebTextDirection direction = blink::WebTextDirectionLeftToRight; |
| 264 EXPECT_TRUE(ntp_rvh->OnMessageReceived( | 264 EXPECT_TRUE(ntp_rvh->OnMessageReceived( |
| 265 ViewHostMsg_UpdateTitle(rvh()->GetRoutingID(), 0, ntp_title, direction))); | 265 ViewHostMsg_UpdateTitle(rvh()->GetRoutingID(), 0, ntp_title, direction))); |
| 266 EXPECT_EQ(ntp_title, contents()->GetTitle()); | 266 EXPECT_EQ(ntp_title, contents()->GetTitle()); |
| 267 | 267 |
| 268 // Navigate to a cross-site URL. | 268 // Navigate to a cross-site URL. |
| 269 contents()->GetController().LoadURL( | 269 contents()->GetController().LoadURL( |
| 270 kDestUrl, Referrer(), PAGE_TRANSITION_LINK, std::string()); | 270 kDestUrl, Referrer(), PAGE_TRANSITION_LINK, std::string()); |
| 271 EXPECT_TRUE(contents()->cross_navigation_pending()); | 271 EXPECT_TRUE(contents()->cross_navigation_pending()); |
| 272 TestRenderViewHost* dest_rvh = static_cast<TestRenderViewHost*>( | 272 TestRenderViewHost* dest_rvh = static_cast<TestRenderViewHost*>( |
| 273 contents()->GetRenderManagerForTesting()->pending_render_view_host()); | 273 contents()->GetRenderManagerForTesting()->pending_render_view_host()); |
| (...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 617 EXPECT_TRUE(host == manager.current_host()); | 617 EXPECT_TRUE(host == manager.current_host()); |
| 618 ASSERT_TRUE(host); | 618 ASSERT_TRUE(host); |
| 619 EXPECT_FALSE(static_cast<SiteInstanceImpl*>(host->GetSiteInstance())-> | 619 EXPECT_FALSE(static_cast<SiteInstanceImpl*>(host->GetSiteInstance())-> |
| 620 HasSite()); | 620 HasSite()); |
| 621 static_cast<SiteInstanceImpl*>(host->GetSiteInstance())->SetSite(kUrl1); | 621 static_cast<SiteInstanceImpl*>(host->GetSiteInstance())->SetSite(kUrl1); |
| 622 | 622 |
| 623 // 2) Navigate to next site. ------------------------- | 623 // 2) Navigate to next site. ------------------------- |
| 624 const GURL kUrl2("http://www.google.com/foo"); | 624 const GURL kUrl2("http://www.google.com/foo"); |
| 625 NavigationEntryImpl entry2( | 625 NavigationEntryImpl entry2( |
| 626 NULL /* instance */, -1 /* page_id */, kUrl2, | 626 NULL /* instance */, -1 /* page_id */, kUrl2, |
| 627 Referrer(kUrl1, WebKit::WebReferrerPolicyDefault), | 627 Referrer(kUrl1, blink::WebReferrerPolicyDefault), |
| 628 string16() /* title */, PAGE_TRANSITION_LINK, | 628 string16() /* title */, PAGE_TRANSITION_LINK, |
| 629 true /* is_renderer_init */); | 629 true /* is_renderer_init */); |
| 630 host = manager.Navigate(entry2); | 630 host = manager.Navigate(entry2); |
| 631 | 631 |
| 632 // The RenderViewHost created in Init will be reused. | 632 // The RenderViewHost created in Init will be reused. |
| 633 EXPECT_TRUE(host == manager.current_host()); | 633 EXPECT_TRUE(host == manager.current_host()); |
| 634 EXPECT_FALSE(manager.pending_render_view_host()); | 634 EXPECT_FALSE(manager.pending_render_view_host()); |
| 635 | 635 |
| 636 // Commit. | 636 // Commit. |
| 637 manager.DidNavigateMainFrame(host); | 637 manager.DidNavigateMainFrame(host); |
| 638 EXPECT_TRUE(host == manager.current_host()); | 638 EXPECT_TRUE(host == manager.current_host()); |
| 639 ASSERT_TRUE(host); | 639 ASSERT_TRUE(host); |
| 640 EXPECT_TRUE(static_cast<SiteInstanceImpl*>(host->GetSiteInstance())-> | 640 EXPECT_TRUE(static_cast<SiteInstanceImpl*>(host->GetSiteInstance())-> |
| 641 HasSite()); | 641 HasSite()); |
| 642 | 642 |
| 643 // 3) Cross-site navigate to next site. -------------- | 643 // 3) Cross-site navigate to next site. -------------- |
| 644 const GURL kUrl3("http://webkit.org/"); | 644 const GURL kUrl3("http://webkit.org/"); |
| 645 NavigationEntryImpl entry3( | 645 NavigationEntryImpl entry3( |
| 646 NULL /* instance */, -1 /* page_id */, kUrl3, | 646 NULL /* instance */, -1 /* page_id */, kUrl3, |
| 647 Referrer(kUrl2, WebKit::WebReferrerPolicyDefault), | 647 Referrer(kUrl2, blink::WebReferrerPolicyDefault), |
| 648 string16() /* title */, PAGE_TRANSITION_LINK, | 648 string16() /* title */, PAGE_TRANSITION_LINK, |
| 649 false /* is_renderer_init */); | 649 false /* is_renderer_init */); |
| 650 host = manager.Navigate(entry3); | 650 host = manager.Navigate(entry3); |
| 651 | 651 |
| 652 // A new RenderViewHost should be created. | 652 // A new RenderViewHost should be created. |
| 653 EXPECT_TRUE(manager.pending_render_view_host()); | 653 EXPECT_TRUE(manager.pending_render_view_host()); |
| 654 ASSERT_EQ(host, manager.pending_render_view_host()); | 654 ASSERT_EQ(host, manager.pending_render_view_host()); |
| 655 | 655 |
| 656 notifications.Reset(); | 656 notifications.Reset(); |
| 657 | 657 |
| (...skipping 552 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1210 EXPECT_EQ(host, manager.current_host()); | 1210 EXPECT_EQ(host, manager.current_host()); |
| 1211 ASSERT_TRUE(host); | 1211 ASSERT_TRUE(host); |
| 1212 EXPECT_TRUE(static_cast<SiteInstanceImpl*>(host->GetSiteInstance())-> | 1212 EXPECT_TRUE(static_cast<SiteInstanceImpl*>(host->GetSiteInstance())-> |
| 1213 HasSite()); | 1213 HasSite()); |
| 1214 | 1214 |
| 1215 // 2) Navigate to a different domain. ------------------------- | 1215 // 2) Navigate to a different domain. ------------------------- |
| 1216 // Guests stay in the same process on navigation. | 1216 // Guests stay in the same process on navigation. |
| 1217 const GURL kUrl2("http://www.chromium.org"); | 1217 const GURL kUrl2("http://www.chromium.org"); |
| 1218 NavigationEntryImpl entry2( | 1218 NavigationEntryImpl entry2( |
| 1219 NULL /* instance */, -1 /* page_id */, kUrl2, | 1219 NULL /* instance */, -1 /* page_id */, kUrl2, |
| 1220 Referrer(kUrl1, WebKit::WebReferrerPolicyDefault), | 1220 Referrer(kUrl1, blink::WebReferrerPolicyDefault), |
| 1221 string16() /* title */, PAGE_TRANSITION_LINK, | 1221 string16() /* title */, PAGE_TRANSITION_LINK, |
| 1222 true /* is_renderer_init */); | 1222 true /* is_renderer_init */); |
| 1223 host = manager.Navigate(entry2); | 1223 host = manager.Navigate(entry2); |
| 1224 | 1224 |
| 1225 // The RenderViewHost created in Init will be reused. | 1225 // The RenderViewHost created in Init will be reused. |
| 1226 EXPECT_EQ(host, manager.current_host()); | 1226 EXPECT_EQ(host, manager.current_host()); |
| 1227 EXPECT_FALSE(manager.pending_render_view_host()); | 1227 EXPECT_FALSE(manager.pending_render_view_host()); |
| 1228 | 1228 |
| 1229 // Commit. | 1229 // Commit. |
| 1230 manager.DidNavigateMainFrame(host); | 1230 manager.DidNavigateMainFrame(host); |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1303 Source<RenderWidgetHost>(host2)); | 1303 Source<RenderWidgetHost>(host2)); |
| 1304 manager.ShouldClosePage(false, true, base::TimeTicks()); | 1304 manager.ShouldClosePage(false, true, base::TimeTicks()); |
| 1305 | 1305 |
| 1306 EXPECT_TRUE( | 1306 EXPECT_TRUE( |
| 1307 notifications.Check1AndReset(NOTIFICATION_RENDER_WIDGET_HOST_DESTROYED)); | 1307 notifications.Check1AndReset(NOTIFICATION_RENDER_WIDGET_HOST_DESTROYED)); |
| 1308 EXPECT_FALSE(manager.pending_render_view_host()); | 1308 EXPECT_FALSE(manager.pending_render_view_host()); |
| 1309 EXPECT_EQ(host, manager.current_host()); | 1309 EXPECT_EQ(host, manager.current_host()); |
| 1310 } | 1310 } |
| 1311 | 1311 |
| 1312 } // namespace content | 1312 } // namespace content |
| OLD | NEW |