| 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 "content/browser/browser_thread_impl.h" | 5 #include "content/browser/browser_thread_impl.h" |
| 6 #include "content/browser/browser_url_handler.h" | 6 #include "content/browser/browser_url_handler.h" |
| 7 #include "content/browser/mock_content_browser_client.h" | 7 #include "content/browser/mock_content_browser_client.h" |
| 8 #include "content/browser/renderer_host/test_render_view_host.h" | 8 #include "content/browser/renderer_host/test_render_view_host.h" |
| 9 #include "content/browser/site_instance.h" | 9 #include "content/browser/site_instance_impl.h" |
| 10 #include "content/browser/tab_contents/navigation_controller_impl.h" | 10 #include "content/browser/tab_contents/navigation_controller_impl.h" |
| 11 #include "content/browser/tab_contents/navigation_entry_impl.h" | 11 #include "content/browser/tab_contents/navigation_entry_impl.h" |
| 12 #include "content/browser/tab_contents/render_view_host_manager.h" | 12 #include "content/browser/tab_contents/render_view_host_manager.h" |
| 13 #include "content/browser/tab_contents/test_tab_contents.h" | 13 #include "content/browser/tab_contents/test_tab_contents.h" |
| 14 #include "content/browser/webui/empty_web_ui_factory.h" | 14 #include "content/browser/webui/empty_web_ui_factory.h" |
| 15 #include "content/common/test_url_constants.h" | 15 #include "content/common/test_url_constants.h" |
| 16 #include "content/common/view_messages.h" | 16 #include "content/common/view_messages.h" |
| 17 #include "content/public/browser/notification_details.h" | 17 #include "content/public/browser/notification_details.h" |
| 18 #include "content/public/browser/notification_source.h" | 18 #include "content/public/browser/notification_source.h" |
| 19 #include "content/public/browser/notification_types.h" | 19 #include "content/public/browser/notification_types.h" |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 TestRenderViewHost* dest_rvh2 = static_cast<TestRenderViewHost*>( | 191 TestRenderViewHost* dest_rvh2 = static_cast<TestRenderViewHost*>( |
| 192 contents2.GetRenderManagerForTesting()->pending_render_view_host()); | 192 contents2.GetRenderManagerForTesting()->pending_render_view_host()); |
| 193 ASSERT_TRUE(dest_rvh2); | 193 ASSERT_TRUE(dest_rvh2); |
| 194 ntp_rvh2->SendShouldCloseACK(true); | 194 ntp_rvh2->SendShouldCloseACK(true); |
| 195 dest_rvh2->SendNavigate(101, kDestUrl); | 195 dest_rvh2->SendNavigate(101, kDestUrl); |
| 196 ntp_rvh2->OnSwapOutACK(); | 196 ntp_rvh2->OnSwapOutACK(); |
| 197 | 197 |
| 198 // The two RVH's should be different in every way. | 198 // The two RVH's should be different in every way. |
| 199 EXPECT_NE(active_rvh()->process(), dest_rvh2->process()); | 199 EXPECT_NE(active_rvh()->process(), dest_rvh2->process()); |
| 200 EXPECT_NE(active_rvh()->site_instance(), dest_rvh2->site_instance()); | 200 EXPECT_NE(active_rvh()->site_instance(), dest_rvh2->site_instance()); |
| 201 EXPECT_NE(active_rvh()->site_instance()->browsing_instance_, | 201 EXPECT_NE(active_rvh()->site_instance()->GetBrowsingInstance(), |
| 202 dest_rvh2->site_instance()->browsing_instance_); | 202 dest_rvh2->site_instance()->GetBrowsingInstance()); |
| 203 | 203 |
| 204 // Navigate both to the new tab page, and verify that they share a | 204 // Navigate both to the new tab page, and verify that they share a |
| 205 // SiteInstance. | 205 // SiteInstance. |
| 206 NavigateActiveAndCommit(kNtpUrl); | 206 NavigateActiveAndCommit(kNtpUrl); |
| 207 | 207 |
| 208 contents2.GetController().LoadURL( | 208 contents2.GetController().LoadURL( |
| 209 kNtpUrl, content::Referrer(), content::PAGE_TRANSITION_LINK, | 209 kNtpUrl, content::Referrer(), content::PAGE_TRANSITION_LINK, |
| 210 std::string()); | 210 std::string()); |
| 211 dest_rvh2->SendShouldCloseACK(true); | 211 dest_rvh2->SendShouldCloseACK(true); |
| 212 static_cast<TestRenderViewHost*>(contents2.GetRenderManagerForTesting()-> | 212 static_cast<TestRenderViewHost*>(contents2.GetRenderManagerForTesting()-> |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 265 EXPECT_EQ(controller().GetLastCommittedEntryIndex(), 1); | 265 EXPECT_EQ(controller().GetLastCommittedEntryIndex(), 1); |
| 266 EXPECT_FALSE(controller().GetPendingEntry()); | 266 EXPECT_FALSE(controller().GetPendingEntry()); |
| 267 // New message should be sent out to make sure to enter view-source mode. | 267 // New message should be sent out to make sure to enter view-source mode. |
| 268 EXPECT_TRUE(process()->sink().GetUniqueMessageMatching( | 268 EXPECT_TRUE(process()->sink().GetUniqueMessageMatching( |
| 269 ViewMsg_EnableViewSourceMode::ID)); | 269 ViewMsg_EnableViewSourceMode::ID)); |
| 270 } | 270 } |
| 271 | 271 |
| 272 // Tests the Init function by checking the initial RenderViewHost. | 272 // Tests the Init function by checking the initial RenderViewHost. |
| 273 TEST_F(RenderViewHostManagerTest, Init) { | 273 TEST_F(RenderViewHostManagerTest, Init) { |
| 274 // Using TestBrowserContext. | 274 // Using TestBrowserContext. |
| 275 SiteInstance* instance = SiteInstance::CreateSiteInstance(browser_context()); | 275 content::SiteInstance* instance = |
| 276 EXPECT_FALSE(instance->has_site()); | 276 content::SiteInstance::CreateSiteInstance(browser_context()); |
| 277 EXPECT_FALSE(instance->HasSite()); |
| 277 | 278 |
| 278 TestTabContents tab_contents(browser_context(), instance); | 279 TestTabContents tab_contents(browser_context(), instance); |
| 279 RenderViewHostManager manager(&tab_contents, &tab_contents); | 280 RenderViewHostManager manager(&tab_contents, &tab_contents); |
| 280 | 281 |
| 281 manager.Init(browser_context(), instance, MSG_ROUTING_NONE); | 282 manager.Init(browser_context(), instance, MSG_ROUTING_NONE); |
| 282 | 283 |
| 283 RenderViewHost* host = manager.current_host(); | 284 RenderViewHost* host = manager.current_host(); |
| 284 ASSERT_TRUE(host); | 285 ASSERT_TRUE(host); |
| 285 EXPECT_TRUE(instance == host->site_instance()); | 286 EXPECT_TRUE(instance == host->site_instance()); |
| 286 EXPECT_TRUE(&tab_contents == host->delegate()); | 287 EXPECT_TRUE(&tab_contents == host->delegate()); |
| 287 EXPECT_TRUE(manager.GetRenderWidgetHostView()); | 288 EXPECT_TRUE(manager.GetRenderWidgetHostView()); |
| 288 EXPECT_FALSE(manager.pending_render_view_host()); | 289 EXPECT_FALSE(manager.pending_render_view_host()); |
| 289 } | 290 } |
| 290 | 291 |
| 291 // Tests the Navigate function. We navigate three sites consecutively and check | 292 // Tests the Navigate function. We navigate three sites consecutively and check |
| 292 // how the pending/committed RenderViewHost are modified. | 293 // how the pending/committed RenderViewHost are modified. |
| 293 TEST_F(RenderViewHostManagerTest, Navigate) { | 294 TEST_F(RenderViewHostManagerTest, Navigate) { |
| 294 TestNotificationTracker notifications; | 295 TestNotificationTracker notifications; |
| 295 | 296 |
| 296 SiteInstance* instance = SiteInstance::CreateSiteInstance(browser_context()); | 297 content::SiteInstance* instance = |
| 298 content::SiteInstance::CreateSiteInstance(browser_context()); |
| 297 | 299 |
| 298 TestTabContents tab_contents(browser_context(), instance); | 300 TestTabContents tab_contents(browser_context(), instance); |
| 299 notifications.ListenFor( | 301 notifications.ListenFor( |
| 300 content::NOTIFICATION_RENDER_VIEW_HOST_CHANGED, | 302 content::NOTIFICATION_RENDER_VIEW_HOST_CHANGED, |
| 301 content::Source<NavigationController>( | 303 content::Source<NavigationController>( |
| 302 &tab_contents.GetController())); | 304 &tab_contents.GetController())); |
| 303 | 305 |
| 304 // Create. | 306 // Create. |
| 305 RenderViewHostManager manager(&tab_contents, &tab_contents); | 307 RenderViewHostManager manager(&tab_contents, &tab_contents); |
| 306 | 308 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 318 | 320 |
| 319 // The RenderViewHost created in Init will be reused. | 321 // The RenderViewHost created in Init will be reused. |
| 320 EXPECT_TRUE(host == manager.current_host()); | 322 EXPECT_TRUE(host == manager.current_host()); |
| 321 EXPECT_FALSE(manager.pending_render_view_host()); | 323 EXPECT_FALSE(manager.pending_render_view_host()); |
| 322 | 324 |
| 323 // Commit. | 325 // Commit. |
| 324 manager.DidNavigateMainFrame(host); | 326 manager.DidNavigateMainFrame(host); |
| 325 // Commit to SiteInstance should be delayed until RenderView commit. | 327 // Commit to SiteInstance should be delayed until RenderView commit. |
| 326 EXPECT_TRUE(host == manager.current_host()); | 328 EXPECT_TRUE(host == manager.current_host()); |
| 327 ASSERT_TRUE(host); | 329 ASSERT_TRUE(host); |
| 328 EXPECT_FALSE(host->site_instance()->has_site()); | 330 EXPECT_FALSE(host->site_instance()->HasSite()); |
| 329 host->site_instance()->SetSite(kUrl1); | 331 host->site_instance()->SetSite(kUrl1); |
| 330 | 332 |
| 331 // 2) Navigate to next site. ------------------------- | 333 // 2) Navigate to next site. ------------------------- |
| 332 const GURL kUrl2("http://www.google.com/foo"); | 334 const GURL kUrl2("http://www.google.com/foo"); |
| 333 NavigationEntryImpl entry2( | 335 NavigationEntryImpl entry2( |
| 334 NULL /* instance */, -1 /* page_id */, kUrl2, | 336 NULL /* instance */, -1 /* page_id */, kUrl2, |
| 335 content::Referrer(kUrl1, WebKit::WebReferrerPolicyDefault), | 337 content::Referrer(kUrl1, WebKit::WebReferrerPolicyDefault), |
| 336 string16() /* title */, content::PAGE_TRANSITION_LINK, | 338 string16() /* title */, content::PAGE_TRANSITION_LINK, |
| 337 true /* is_renderer_init */); | 339 true /* is_renderer_init */); |
| 338 host = manager.Navigate(entry2); | 340 host = manager.Navigate(entry2); |
| 339 | 341 |
| 340 // The RenderViewHost created in Init will be reused. | 342 // The RenderViewHost created in Init will be reused. |
| 341 EXPECT_TRUE(host == manager.current_host()); | 343 EXPECT_TRUE(host == manager.current_host()); |
| 342 EXPECT_FALSE(manager.pending_render_view_host()); | 344 EXPECT_FALSE(manager.pending_render_view_host()); |
| 343 | 345 |
| 344 // Commit. | 346 // Commit. |
| 345 manager.DidNavigateMainFrame(host); | 347 manager.DidNavigateMainFrame(host); |
| 346 EXPECT_TRUE(host == manager.current_host()); | 348 EXPECT_TRUE(host == manager.current_host()); |
| 347 ASSERT_TRUE(host); | 349 ASSERT_TRUE(host); |
| 348 EXPECT_TRUE(host->site_instance()->has_site()); | 350 EXPECT_TRUE(host->site_instance()->HasSite()); |
| 349 | 351 |
| 350 // 3) Cross-site navigate to next site. -------------- | 352 // 3) Cross-site navigate to next site. -------------- |
| 351 const GURL kUrl3("http://webkit.org/"); | 353 const GURL kUrl3("http://webkit.org/"); |
| 352 NavigationEntryImpl entry3( | 354 NavigationEntryImpl entry3( |
| 353 NULL /* instance */, -1 /* page_id */, kUrl3, | 355 NULL /* instance */, -1 /* page_id */, kUrl3, |
| 354 content::Referrer(kUrl2, WebKit::WebReferrerPolicyDefault), | 356 content::Referrer(kUrl2, WebKit::WebReferrerPolicyDefault), |
| 355 string16() /* title */, content::PAGE_TRANSITION_LINK, | 357 string16() /* title */, content::PAGE_TRANSITION_LINK, |
| 356 false /* is_renderer_init */); | 358 false /* is_renderer_init */); |
| 357 host = manager.Navigate(entry3); | 359 host = manager.Navigate(entry3); |
| 358 | 360 |
| 359 // A new RenderViewHost should be created. | 361 // A new RenderViewHost should be created. |
| 360 EXPECT_TRUE(manager.pending_render_view_host()); | 362 EXPECT_TRUE(manager.pending_render_view_host()); |
| 361 ASSERT_EQ(host, manager.pending_render_view_host()); | 363 ASSERT_EQ(host, manager.pending_render_view_host()); |
| 362 | 364 |
| 363 notifications.Reset(); | 365 notifications.Reset(); |
| 364 | 366 |
| 365 // Commit. | 367 // Commit. |
| 366 manager.DidNavigateMainFrame(manager.pending_render_view_host()); | 368 manager.DidNavigateMainFrame(manager.pending_render_view_host()); |
| 367 EXPECT_TRUE(host == manager.current_host()); | 369 EXPECT_TRUE(host == manager.current_host()); |
| 368 ASSERT_TRUE(host); | 370 ASSERT_TRUE(host); |
| 369 EXPECT_TRUE(host->site_instance()->has_site()); | 371 EXPECT_TRUE(host->site_instance()->HasSite()); |
| 370 // Check the pending RenderViewHost has been committed. | 372 // Check the pending RenderViewHost has been committed. |
| 371 EXPECT_FALSE(manager.pending_render_view_host()); | 373 EXPECT_FALSE(manager.pending_render_view_host()); |
| 372 | 374 |
| 373 // We should observe a notification. | 375 // We should observe a notification. |
| 374 EXPECT_TRUE(notifications.Check1AndReset( | 376 EXPECT_TRUE(notifications.Check1AndReset( |
| 375 content::NOTIFICATION_RENDER_VIEW_HOST_CHANGED)); | 377 content::NOTIFICATION_RENDER_VIEW_HOST_CHANGED)); |
| 376 } | 378 } |
| 377 | 379 |
| 378 // Tests the Navigate function. In this unit test we verify that the Navigate | 380 // Tests the Navigate function. In this unit test we verify that the Navigate |
| 379 // function can handle a new navigation event before the previous navigation | 381 // function can handle a new navigation event before the previous navigation |
| 380 // has been committed. This is also a regression test for | 382 // has been committed. This is also a regression test for |
| 381 // http://crbug.com/104600. | 383 // http://crbug.com/104600. |
| 382 TEST_F(RenderViewHostManagerTest, NavigateWithEarlyReNavigation) { | 384 TEST_F(RenderViewHostManagerTest, NavigateWithEarlyReNavigation) { |
| 383 TestNotificationTracker notifications; | 385 TestNotificationTracker notifications; |
| 384 | 386 |
| 385 SiteInstance* instance = SiteInstance::CreateSiteInstance(browser_context()); | 387 content::SiteInstance* instance = |
| 388 content::SiteInstance::CreateSiteInstance(browser_context()); |
| 386 | 389 |
| 387 TestTabContents tab_contents(browser_context(), instance); | 390 TestTabContents tab_contents(browser_context(), instance); |
| 388 notifications.ListenFor( | 391 notifications.ListenFor( |
| 389 content::NOTIFICATION_RENDER_VIEW_HOST_CHANGED, | 392 content::NOTIFICATION_RENDER_VIEW_HOST_CHANGED, |
| 390 content::Source<NavigationController>( | 393 content::Source<NavigationController>( |
| 391 &tab_contents.GetController())); | 394 &tab_contents.GetController())); |
| 392 | 395 |
| 393 // Create. | 396 // Create. |
| 394 RenderViewHostManager manager(&tab_contents, &tab_contents); | 397 RenderViewHostManager manager(&tab_contents, &tab_contents); |
| 395 | 398 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 411 EXPECT_TRUE(notifications.Check1AndReset( | 414 EXPECT_TRUE(notifications.Check1AndReset( |
| 412 content::NOTIFICATION_RENDER_VIEW_HOST_CHANGED)); | 415 content::NOTIFICATION_RENDER_VIEW_HOST_CHANGED)); |
| 413 notifications.Reset(); | 416 notifications.Reset(); |
| 414 | 417 |
| 415 // Commit. | 418 // Commit. |
| 416 manager.DidNavigateMainFrame(host); | 419 manager.DidNavigateMainFrame(host); |
| 417 | 420 |
| 418 // Commit to SiteInstance should be delayed until RenderView commit. | 421 // Commit to SiteInstance should be delayed until RenderView commit. |
| 419 EXPECT_TRUE(host == manager.current_host()); | 422 EXPECT_TRUE(host == manager.current_host()); |
| 420 ASSERT_TRUE(host); | 423 ASSERT_TRUE(host); |
| 421 EXPECT_FALSE(host->site_instance()->has_site()); | 424 EXPECT_FALSE(host->site_instance()->HasSite()); |
| 422 host->site_instance()->SetSite(kUrl1); | 425 host->site_instance()->SetSite(kUrl1); |
| 423 | 426 |
| 424 // 2) Cross-site navigate to next site. ------------------------- | 427 // 2) Cross-site navigate to next site. ------------------------- |
| 425 const GURL kUrl2("http://www.example.com"); | 428 const GURL kUrl2("http://www.example.com"); |
| 426 NavigationEntryImpl entry2( | 429 NavigationEntryImpl entry2( |
| 427 NULL /* instance */, -1 /* page_id */, kUrl2, content::Referrer(), | 430 NULL /* instance */, -1 /* page_id */, kUrl2, content::Referrer(), |
| 428 string16() /* title */, content::PAGE_TRANSITION_TYPED, | 431 string16() /* title */, content::PAGE_TRANSITION_TYPED, |
| 429 false /* is_renderer_init */); | 432 false /* is_renderer_init */); |
| 430 RenderViewHost* host2 = manager.Navigate(entry2); | 433 RenderViewHost* host2 = manager.Navigate(entry2); |
| 431 | 434 |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 495 // RenderViewHostManager::Navigate followed by RenderViewHost::Navigate. | 498 // RenderViewHostManager::Navigate followed by RenderViewHost::Navigate. |
| 496 // Here we need to call the latter ourselves. | 499 // Here we need to call the latter ourselves. |
| 497 host3->NavigateToURL(kUrl3); | 500 host3->NavigateToURL(kUrl3); |
| 498 EXPECT_TRUE(test_process_host3->sink().GetUniqueMessageMatching( | 501 EXPECT_TRUE(test_process_host3->sink().GetUniqueMessageMatching( |
| 499 ViewMsg_Navigate::ID)); | 502 ViewMsg_Navigate::ID)); |
| 500 | 503 |
| 501 // Commit. | 504 // Commit. |
| 502 manager.DidNavigateMainFrame(host3); | 505 manager.DidNavigateMainFrame(host3); |
| 503 EXPECT_TRUE(host3 == manager.current_host()); | 506 EXPECT_TRUE(host3 == manager.current_host()); |
| 504 ASSERT_TRUE(host3); | 507 ASSERT_TRUE(host3); |
| 505 EXPECT_TRUE(host3->site_instance()->has_site()); | 508 EXPECT_TRUE(host3->site_instance()->HasSite()); |
| 506 // Check the pending RenderViewHost has been committed. | 509 // Check the pending RenderViewHost has been committed. |
| 507 EXPECT_FALSE(manager.pending_render_view_host()); | 510 EXPECT_FALSE(manager.pending_render_view_host()); |
| 508 | 511 |
| 509 // We should observe a notification. | 512 // We should observe a notification. |
| 510 EXPECT_TRUE(notifications.Check1AndReset( | 513 EXPECT_TRUE(notifications.Check1AndReset( |
| 511 content::NOTIFICATION_RENDER_VIEW_HOST_CHANGED)); | 514 content::NOTIFICATION_RENDER_VIEW_HOST_CHANGED)); |
| 512 } | 515 } |
| 513 | 516 |
| 514 // Tests WebUI creation. | 517 // Tests WebUI creation. |
| 515 TEST_F(RenderViewHostManagerTest, WebUI) { | 518 TEST_F(RenderViewHostManagerTest, WebUI) { |
| 516 set_should_create_webui(true); | 519 set_should_create_webui(true); |
| 517 BrowserThreadImpl ui_thread(BrowserThread::UI, MessageLoop::current()); | 520 BrowserThreadImpl ui_thread(BrowserThread::UI, MessageLoop::current()); |
| 518 SiteInstance* instance = SiteInstance::CreateSiteInstance(browser_context()); | 521 content::SiteInstance* instance = |
| 522 content::SiteInstance::CreateSiteInstance(browser_context()); |
| 519 | 523 |
| 520 TestTabContents tab_contents(browser_context(), instance); | 524 TestTabContents tab_contents(browser_context(), instance); |
| 521 RenderViewHostManager manager(&tab_contents, &tab_contents); | 525 RenderViewHostManager manager(&tab_contents, &tab_contents); |
| 522 | 526 |
| 523 manager.Init(browser_context(), instance, MSG_ROUTING_NONE); | 527 manager.Init(browser_context(), instance, MSG_ROUTING_NONE); |
| 524 | 528 |
| 525 const GURL kUrl(chrome::kTestNewTabURL); | 529 const GURL kUrl(chrome::kTestNewTabURL); |
| 526 NavigationEntryImpl entry(NULL /* instance */, -1 /* page_id */, kUrl, | 530 NavigationEntryImpl entry(NULL /* instance */, -1 /* page_id */, kUrl, |
| 527 content::Referrer(), string16() /* title */, | 531 content::Referrer(), string16() /* title */, |
| 528 content::PAGE_TRANSITION_TYPED, | 532 content::PAGE_TRANSITION_TYPED, |
| 529 false /* is_renderer_init */); | 533 false /* is_renderer_init */); |
| 530 RenderViewHost* host = manager.Navigate(entry); | 534 RenderViewHost* host = manager.Navigate(entry); |
| 531 | 535 |
| 532 EXPECT_TRUE(host); | 536 EXPECT_TRUE(host); |
| 533 EXPECT_TRUE(host == manager.current_host()); | 537 EXPECT_TRUE(host == manager.current_host()); |
| 534 EXPECT_FALSE(manager.pending_render_view_host()); | 538 EXPECT_FALSE(manager.pending_render_view_host()); |
| 535 | 539 |
| 536 // It's important that the site instance get set on the Web UI page as soon | 540 // It's important that the site instance get set on the Web UI page as soon |
| 537 // as the navigation starts, rather than lazily after it commits, so we don't | 541 // as the navigation starts, rather than lazily after it commits, so we don't |
| 538 // try to re-use the SiteInstance/process for non DOM-UI things that may | 542 // try to re-use the SiteInstance/process for non DOM-UI things that may |
| 539 // get loaded in between. | 543 // get loaded in between. |
| 540 EXPECT_TRUE(host->site_instance()->has_site()); | 544 EXPECT_TRUE(host->site_instance()->HasSite()); |
| 541 EXPECT_EQ(kUrl, host->site_instance()->site()); | 545 EXPECT_EQ(kUrl, host->site_instance()->GetSite()); |
| 542 | 546 |
| 543 // The Web UI is committed immediately because the RenderViewHost has not been | 547 // The Web UI is committed immediately because the RenderViewHost has not been |
| 544 // used yet. UpdateRendererStateForNavigate() took the short cut path. | 548 // used yet. UpdateRendererStateForNavigate() took the short cut path. |
| 545 EXPECT_FALSE(manager.pending_web_ui()); | 549 EXPECT_FALSE(manager.pending_web_ui()); |
| 546 EXPECT_TRUE(manager.web_ui()); | 550 EXPECT_TRUE(manager.web_ui()); |
| 547 | 551 |
| 548 // Commit. | 552 // Commit. |
| 549 manager.DidNavigateMainFrame(host); | 553 manager.DidNavigateMainFrame(host); |
| 550 } | 554 } |
| 551 | 555 |
| 552 // Tests that chrome: URLs that are not Web UI pages do not get grouped into | 556 // Tests that chrome: URLs that are not Web UI pages do not get grouped into |
| 553 // Web UI renderers, even if --process-per-tab is enabled. In that mode, we | 557 // Web UI renderers, even if --process-per-tab is enabled. In that mode, we |
| 554 // still swap processes if ShouldSwapProcessesForNavigation is true. | 558 // still swap processes if ShouldSwapProcessesForNavigation is true. |
| 555 // Regression test for bug 46290. | 559 // Regression test for bug 46290. |
| 556 TEST_F(RenderViewHostManagerTest, NonWebUIChromeURLs) { | 560 TEST_F(RenderViewHostManagerTest, NonWebUIChromeURLs) { |
| 557 BrowserThreadImpl thread(BrowserThread::UI, &message_loop_); | 561 BrowserThreadImpl thread(BrowserThread::UI, &message_loop_); |
| 558 SiteInstance* instance = SiteInstance::CreateSiteInstance(browser_context()); | 562 content::SiteInstance* instance = |
| 563 content::SiteInstance::CreateSiteInstance(browser_context()); |
| 559 TestTabContents tab_contents(browser_context(), instance); | 564 TestTabContents tab_contents(browser_context(), instance); |
| 560 RenderViewHostManager manager(&tab_contents, &tab_contents); | 565 RenderViewHostManager manager(&tab_contents, &tab_contents); |
| 561 manager.Init(browser_context(), instance, MSG_ROUTING_NONE); | 566 manager.Init(browser_context(), instance, MSG_ROUTING_NONE); |
| 562 | 567 |
| 563 // NTP is a Web UI page. | 568 // NTP is a Web UI page. |
| 564 const GURL kNtpUrl(chrome::kTestNewTabURL); | 569 const GURL kNtpUrl(chrome::kTestNewTabURL); |
| 565 NavigationEntryImpl ntp_entry(NULL /* instance */, -1 /* page_id */, kNtpUrl, | 570 NavigationEntryImpl ntp_entry(NULL /* instance */, -1 /* page_id */, kNtpUrl, |
| 566 content::Referrer(), string16() /* title */, | 571 content::Referrer(), string16() /* title */, |
| 567 content::PAGE_TRANSITION_TYPED, | 572 content::PAGE_TRANSITION_TYPED, |
| 568 false /* is_renderer_init */); | 573 false /* is_renderer_init */); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 615 // current one. | 620 // current one. |
| 616 EXPECT_TRUE(contents()->GetRenderManagerForTesting()-> | 621 EXPECT_TRUE(contents()->GetRenderManagerForTesting()-> |
| 617 pending_render_view_host() == NULL); | 622 pending_render_view_host() == NULL); |
| 618 EXPECT_EQ(evil_rvh, contents()->GetRenderManagerForTesting()->current_host()); | 623 EXPECT_EQ(evil_rvh, contents()->GetRenderManagerForTesting()->current_host()); |
| 619 | 624 |
| 620 // Also we should not have a pending navigation entry. | 625 // Also we should not have a pending navigation entry. |
| 621 NavigationEntry* entry = contents()->GetController().GetActiveEntry(); | 626 NavigationEntry* entry = contents()->GetController().GetActiveEntry(); |
| 622 ASSERT_TRUE(entry != NULL); | 627 ASSERT_TRUE(entry != NULL); |
| 623 EXPECT_EQ(kUrl2, entry->GetURL()); | 628 EXPECT_EQ(kUrl2, entry->GetURL()); |
| 624 } | 629 } |
| OLD | NEW |