| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "chrome/browser/browser_thread.h" | 5 #include "chrome/browser/browser_thread.h" |
| 6 #include "chrome/browser/browser_url_handler.h" | 6 #include "chrome/browser/browser_url_handler.h" |
| 7 #include "chrome/browser/renderer_host/site_instance.h" | 7 #include "chrome/browser/renderer_host/site_instance.h" |
| 8 #include "chrome/browser/renderer_host/test/test_render_view_host.h" | 8 #include "chrome/browser/renderer_host/test/test_render_view_host.h" |
| 9 #include "chrome/browser/tab_contents/navigation_controller.h" | 9 #include "chrome/browser/tab_contents/navigation_controller.h" |
| 10 #include "chrome/browser/tab_contents/navigation_entry.h" | 10 #include "chrome/browser/tab_contents/navigation_entry.h" |
| (...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 246 | 246 |
| 247 GURL url(chrome::kChromeUINewTabURL); | 247 GURL url(chrome::kChromeUINewTabURL); |
| 248 NavigationEntry entry(NULL /* instance */, -1 /* page_id */, url, | 248 NavigationEntry entry(NULL /* instance */, -1 /* page_id */, url, |
| 249 GURL() /* referrer */, string16() /* title */, | 249 GURL() /* referrer */, string16() /* title */, |
| 250 PageTransition::TYPED); | 250 PageTransition::TYPED); |
| 251 RenderViewHost* host = manager.Navigate(entry); | 251 RenderViewHost* host = manager.Navigate(entry); |
| 252 | 252 |
| 253 EXPECT_TRUE(host); | 253 EXPECT_TRUE(host); |
| 254 EXPECT_TRUE(host == manager.current_host()); | 254 EXPECT_TRUE(host == manager.current_host()); |
| 255 EXPECT_FALSE(manager.pending_render_view_host()); | 255 EXPECT_FALSE(manager.pending_render_view_host()); |
| 256 EXPECT_TRUE(manager.pending_dom_ui()); | |
| 257 EXPECT_FALSE(manager.dom_ui()); | |
| 258 | 256 |
| 259 // It's important that the site instance get set on the DOM UI page as soon | 257 // It's important that the site instance get set on the DOM UI page as soon |
| 260 // as the navigation starts, rather than lazily after it commits, so we don't | 258 // as the navigation starts, rather than lazily after it commits, so we don't |
| 261 // try to re-use the SiteInstance/process for non DOM-UI things that may | 259 // try to re-use the SiteInstance/process for non DOM-UI things that may |
| 262 // get loaded in between. | 260 // get loaded in between. |
| 263 EXPECT_TRUE(host->site_instance()->has_site()); | 261 EXPECT_TRUE(host->site_instance()->has_site()); |
| 264 EXPECT_EQ(url, host->site_instance()->site()); | 262 EXPECT_EQ(url, host->site_instance()->site()); |
| 265 | 263 |
| 264 // The DOM UI is committed immediately because the RenderViewHost has not been |
| 265 // used yet. UpdateRendererStateForNavigate() took the short cut path. |
| 266 EXPECT_FALSE(manager.pending_dom_ui()); |
| 267 EXPECT_TRUE(manager.dom_ui()); |
| 268 |
| 266 // Commit. | 269 // Commit. |
| 267 manager.DidNavigateMainFrame(host); | 270 manager.DidNavigateMainFrame(host); |
| 268 | |
| 269 EXPECT_FALSE(manager.pending_dom_ui()); | |
| 270 EXPECT_TRUE(manager.dom_ui()); | |
| 271 } | 271 } |
| 272 | 272 |
| 273 // Tests that chrome: URLs that are not DOM UI pages do not get grouped into | 273 // Tests that chrome: URLs that are not DOM UI pages do not get grouped into |
| 274 // DOM UI renderers, even if --process-per-tab is enabled. In that mode, we | 274 // DOM UI renderers, even if --process-per-tab is enabled. In that mode, we |
| 275 // still swap processes if ShouldSwapProcessesForNavigation is true. | 275 // still swap processes if ShouldSwapProcessesForNavigation is true. |
| 276 // Regression test for bug 46290. | 276 // Regression test for bug 46290. |
| 277 TEST_F(RenderViewHostManagerTest, NonDOMUIChromeURLs) { | 277 TEST_F(RenderViewHostManagerTest, NonDOMUIChromeURLs) { |
| 278 SiteInstance* instance = SiteInstance::CreateSiteInstance(profile_.get()); | 278 SiteInstance* instance = SiteInstance::CreateSiteInstance(profile_.get()); |
| 279 TestTabContents tab_contents(profile_.get(), instance); | 279 TestTabContents tab_contents(profile_.get(), instance); |
| 280 RenderViewHostManager manager(&tab_contents, &tab_contents); | 280 RenderViewHostManager manager(&tab_contents, &tab_contents); |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 339 // That should have cancelled the pending RVH, and the evil RVH should be the | 339 // That should have cancelled the pending RVH, and the evil RVH should be the |
| 340 // current one. | 340 // current one. |
| 341 EXPECT_TRUE(contents()->render_manager()->pending_render_view_host() == NULL); | 341 EXPECT_TRUE(contents()->render_manager()->pending_render_view_host() == NULL); |
| 342 EXPECT_EQ(evil_rvh, contents()->render_manager()->current_host()); | 342 EXPECT_EQ(evil_rvh, contents()->render_manager()->current_host()); |
| 343 | 343 |
| 344 // Also we should not have a pending navigation entry. | 344 // Also we should not have a pending navigation entry. |
| 345 NavigationEntry* entry = contents()->controller().GetActiveEntry(); | 345 NavigationEntry* entry = contents()->controller().GetActiveEntry(); |
| 346 ASSERT_TRUE(entry != NULL); | 346 ASSERT_TRUE(entry != NULL); |
| 347 EXPECT_EQ(url2, entry->url()); | 347 EXPECT_EQ(url2, entry->url()); |
| 348 } | 348 } |
| OLD | NEW |