| 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_url_handler.h" | 5 #include "chrome/browser/browser_url_handler.h" |
| 6 #include "chrome/browser/chrome_thread.h" | 6 #include "chrome/browser/chrome_thread.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 25 matching lines...) Expand all Loading... |
| 36 const NavigationEntry* new_entry) const { | 36 const NavigationEntry* new_entry) const { |
| 37 return manager->ShouldSwapProcessesForNavigation(cur_entry, new_entry); | 37 return manager->ShouldSwapProcessesForNavigation(cur_entry, new_entry); |
| 38 } | 38 } |
| 39 }; | 39 }; |
| 40 | 40 |
| 41 // Tests that when you navigate from the New TabPage to another page, and | 41 // Tests that when you navigate from the New TabPage to another page, and |
| 42 // then do that same thing in another tab, that the two resulting pages have | 42 // then do that same thing in another tab, that the two resulting pages have |
| 43 // different SiteInstances, BrowsingInstances, and RenderProcessHosts. This is | 43 // different SiteInstances, BrowsingInstances, and RenderProcessHosts. This is |
| 44 // a regression test for bug 9364. | 44 // a regression test for bug 9364. |
| 45 TEST_F(RenderViewHostManagerTest, NewTabPageProcesses) { | 45 TEST_F(RenderViewHostManagerTest, NewTabPageProcesses) { |
| 46 ChromeThread ui_thread(ChromeThread::UI, MessageLoop::current()); | 46 BrowserThread ui_thread(BrowserThread::UI, MessageLoop::current()); |
| 47 GURL ntp(chrome::kChromeUINewTabURL); | 47 GURL ntp(chrome::kChromeUINewTabURL); |
| 48 GURL dest("http://www.google.com/"); | 48 GURL dest("http://www.google.com/"); |
| 49 | 49 |
| 50 // Navigate our first tab to the new tab page and then to the destination. | 50 // Navigate our first tab to the new tab page and then to the destination. |
| 51 NavigateActiveAndCommit(ntp); | 51 NavigateActiveAndCommit(ntp); |
| 52 NavigateActiveAndCommit(dest); | 52 NavigateActiveAndCommit(dest); |
| 53 | 53 |
| 54 // Make a second tab. | 54 // Make a second tab. |
| 55 TestTabContents contents2(profile_.get(), NULL); | 55 TestTabContents contents2(profile_.get(), NULL); |
| 56 | 56 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 81 | 81 |
| 82 EXPECT_EQ(active_rvh()->site_instance(), | 82 EXPECT_EQ(active_rvh()->site_instance(), |
| 83 contents2.render_view_host()->site_instance()); | 83 contents2.render_view_host()->site_instance()); |
| 84 } | 84 } |
| 85 | 85 |
| 86 // When there is an error with the specified page, renderer exits view-source | 86 // When there is an error with the specified page, renderer exits view-source |
| 87 // mode. See WebFrameImpl::DidFail(). We check by this test that | 87 // mode. See WebFrameImpl::DidFail(). We check by this test that |
| 88 // EnableViewSourceMode message is sent on every navigation regardless | 88 // EnableViewSourceMode message is sent on every navigation regardless |
| 89 // RenderView is being newly created or reused. | 89 // RenderView is being newly created or reused. |
| 90 TEST_F(RenderViewHostManagerTest, AlwaysSendEnableViewSourceMode) { | 90 TEST_F(RenderViewHostManagerTest, AlwaysSendEnableViewSourceMode) { |
| 91 ChromeThread ui_thread(ChromeThread::UI, MessageLoop::current()); | 91 BrowserThread ui_thread(BrowserThread::UI, MessageLoop::current()); |
| 92 const GURL kNtpUrl(chrome::kChromeUINewTabURL); | 92 const GURL kNtpUrl(chrome::kChromeUINewTabURL); |
| 93 const GURL kUrl("view-source:http://foo"); | 93 const GURL kUrl("view-source:http://foo"); |
| 94 | 94 |
| 95 // We have to navigate to some page at first since without this, the first | 95 // We have to navigate to some page at first since without this, the first |
| 96 // navigation will reuse the SiteInstance created by Init(), and the second | 96 // navigation will reuse the SiteInstance created by Init(), and the second |
| 97 // one will create a new SiteInstance. Because current_instance and | 97 // one will create a new SiteInstance. Because current_instance and |
| 98 // new_instance will be different, a new RenderViewHost will be created for | 98 // new_instance will be different, a new RenderViewHost will be created for |
| 99 // the second navigation. We have to avoid this in order to exercise the | 99 // the second navigation. We have to avoid this in order to exercise the |
| 100 // target code patch. | 100 // target code patch. |
| 101 NavigateActiveAndCommit(kNtpUrl); | 101 NavigateActiveAndCommit(kNtpUrl); |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 // Check the pending RenderViewHost has been committed. | 227 // Check the pending RenderViewHost has been committed. |
| 228 EXPECT_FALSE(manager.pending_render_view_host()); | 228 EXPECT_FALSE(manager.pending_render_view_host()); |
| 229 | 229 |
| 230 // We should observe a notification. | 230 // We should observe a notification. |
| 231 EXPECT_TRUE(notifications.Check1AndReset( | 231 EXPECT_TRUE(notifications.Check1AndReset( |
| 232 NotificationType::RENDER_VIEW_HOST_CHANGED)); | 232 NotificationType::RENDER_VIEW_HOST_CHANGED)); |
| 233 } | 233 } |
| 234 | 234 |
| 235 // Tests DOMUI creation. | 235 // Tests DOMUI creation. |
| 236 TEST_F(RenderViewHostManagerTest, DOMUI) { | 236 TEST_F(RenderViewHostManagerTest, DOMUI) { |
| 237 ChromeThread ui_thread(ChromeThread::UI, MessageLoop::current()); | 237 BrowserThread ui_thread(BrowserThread::UI, MessageLoop::current()); |
| 238 SiteInstance* instance = SiteInstance::CreateSiteInstance(profile_.get()); | 238 SiteInstance* instance = SiteInstance::CreateSiteInstance(profile_.get()); |
| 239 | 239 |
| 240 TestTabContents tab_contents(profile_.get(), instance); | 240 TestTabContents tab_contents(profile_.get(), instance); |
| 241 RenderViewHostManager manager(&tab_contents, &tab_contents); | 241 RenderViewHostManager manager(&tab_contents, &tab_contents); |
| 242 | 242 |
| 243 manager.Init(profile_.get(), instance, MSG_ROUTING_NONE); | 243 manager.Init(profile_.get(), instance, MSG_ROUTING_NONE); |
| 244 | 244 |
| 245 GURL url(chrome::kChromeUINewTabURL); | 245 GURL url(chrome::kChromeUINewTabURL); |
| 246 NavigationEntry entry(NULL /* instance */, -1 /* page_id */, url, | 246 NavigationEntry entry(NULL /* instance */, -1 /* page_id */, url, |
| 247 GURL() /* referrer */, string16() /* title */, | 247 GURL() /* referrer */, string16() /* title */, |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 337 // That should have cancelled the pending RVH, and the evil RVH should be the | 337 // That should have cancelled the pending RVH, and the evil RVH should be the |
| 338 // current one. | 338 // current one. |
| 339 EXPECT_TRUE(contents()->render_manager()->pending_render_view_host() == NULL); | 339 EXPECT_TRUE(contents()->render_manager()->pending_render_view_host() == NULL); |
| 340 EXPECT_EQ(evil_rvh, contents()->render_manager()->current_host()); | 340 EXPECT_EQ(evil_rvh, contents()->render_manager()->current_host()); |
| 341 | 341 |
| 342 // Also we should not have a pending navigation entry. | 342 // Also we should not have a pending navigation entry. |
| 343 NavigationEntry* entry = contents()->controller().GetActiveEntry(); | 343 NavigationEntry* entry = contents()->controller().GetActiveEntry(); |
| 344 ASSERT_TRUE(entry != NULL); | 344 ASSERT_TRUE(entry != NULL); |
| 345 EXPECT_EQ(url2, entry->url()); | 345 EXPECT_EQ(url2, entry->url()); |
| 346 } | 346 } |
| OLD | NEW |