| Index: content/browser/tab_contents/render_view_host_manager_unittest.cc
|
| diff --git a/content/browser/tab_contents/render_view_host_manager_unittest.cc b/content/browser/tab_contents/render_view_host_manager_unittest.cc
|
| index c5ada3f2c2f0f86c12f75097b6ae0d27bff528fa..6e6ca41661a5ea7dbd9aa5003d3d589997ec5a1f 100644
|
| --- a/content/browser/tab_contents/render_view_host_manager_unittest.cc
|
| +++ b/content/browser/tab_contents/render_view_host_manager_unittest.cc
|
| @@ -4,7 +4,6 @@
|
|
|
| #include "chrome/browser/browser_url_handler.h"
|
| #include "chrome/common/render_messages.h"
|
| -#include "chrome/common/url_constants.h"
|
| #include "chrome/test/test_notification_tracker.h"
|
| #include "chrome/test/testing_profile.h"
|
| #include "content/browser/browser_thread.h"
|
| @@ -17,6 +16,7 @@
|
| #include "content/common/notification_details.h"
|
| #include "content/common/notification_source.h"
|
| #include "content/common/page_transition_types.h"
|
| +#include "content/common/test_url_constants.h"
|
| #include "content/common/view_messages.h"
|
| #include "testing/gtest/include/gtest/gtest.h"
|
| #include "webkit/glue/webkit_glue.h"
|
| @@ -60,12 +60,12 @@ class RenderViewHostManagerTest : public RenderViewHostTestHarness {
|
| // a regression test for bug 9364.
|
| TEST_F(RenderViewHostManagerTest, NewTabPageProcesses) {
|
| BrowserThread ui_thread(BrowserThread::UI, MessageLoop::current());
|
| - GURL ntp(chrome::kChromeUINewTabURL);
|
| - GURL dest("http://www.google.com/");
|
| + const GURL kNtpUrl(chrome::kTestNewTabURL);
|
| + const GURL kDestUrl("http://www.google.com/");
|
|
|
| // Navigate our first tab to the new tab page and then to the destination.
|
| - NavigateActiveAndCommit(ntp);
|
| - NavigateActiveAndCommit(dest);
|
| + NavigateActiveAndCommit(kNtpUrl);
|
| + NavigateActiveAndCommit(kDestUrl);
|
|
|
| // Make a second tab.
|
| TestTabContents contents2(profile_.get(), NULL);
|
| @@ -73,14 +73,14 @@ TEST_F(RenderViewHostManagerTest, NewTabPageProcesses) {
|
| // Load the two URLs in the second tab. Note that the first navigation creates
|
| // a RVH that's not pending (since there is no cross-site transition), so
|
| // we use the committed one, but the second one is the opposite.
|
| - contents2.controller().LoadURL(ntp, GURL(), PageTransition::LINK);
|
| + contents2.controller().LoadURL(kNtpUrl, GURL(), PageTransition::LINK);
|
| TestRenderViewHost* ntp_rvh2 = static_cast<TestRenderViewHost*>(
|
| contents2.render_manager()->current_host());
|
| - ntp_rvh2->SendNavigate(100, ntp);
|
| - contents2.controller().LoadURL(dest, GURL(), PageTransition::LINK);
|
| + ntp_rvh2->SendNavigate(100, kNtpUrl);
|
| + contents2.controller().LoadURL(kDestUrl, GURL(), PageTransition::LINK);
|
| TestRenderViewHost* dest_rvh2 = static_cast<TestRenderViewHost*>(
|
| contents2.render_manager()->pending_render_view_host());
|
| - dest_rvh2->SendNavigate(101, dest);
|
| + dest_rvh2->SendNavigate(101, kDestUrl);
|
| ntp_rvh2->OnSwapOutACK();
|
|
|
| // The two RVH's should be different in every way.
|
| @@ -91,12 +91,12 @@ TEST_F(RenderViewHostManagerTest, NewTabPageProcesses) {
|
|
|
| // Navigate both to the new tab page, and verify that they share a
|
| // SiteInstance.
|
| - NavigateActiveAndCommit(ntp);
|
| + NavigateActiveAndCommit(kNtpUrl);
|
|
|
| - contents2.controller().LoadURL(ntp, GURL(), PageTransition::LINK);
|
| + contents2.controller().LoadURL(kNtpUrl, GURL(), PageTransition::LINK);
|
| dest_rvh2->SendShouldCloseACK(true);
|
| static_cast<TestRenderViewHost*>(contents2.render_manager()->
|
| - pending_render_view_host())->SendNavigate(102, ntp);
|
| + pending_render_view_host())->SendNavigate(102, kNtpUrl);
|
| dest_rvh2->OnSwapOutACK();
|
|
|
| EXPECT_EQ(active_rvh()->site_instance(),
|
| @@ -109,7 +109,7 @@ TEST_F(RenderViewHostManagerTest, NewTabPageProcesses) {
|
| // RenderView is being newly created or reused.
|
| TEST_F(RenderViewHostManagerTest, AlwaysSendEnableViewSourceMode) {
|
| BrowserThread ui_thread(BrowserThread::UI, MessageLoop::current());
|
| - const GURL kNtpUrl(chrome::kChromeUINewTabURL);
|
| + const GURL kNtpUrl(chrome::kTestNewTabURL);
|
| const GURL kUrl("view-source:http://foo");
|
|
|
| // We have to navigate to some page at first since without this, the first
|
| @@ -191,8 +191,8 @@ TEST_F(RenderViewHostManagerTest, Navigate) {
|
| RenderViewHost* host;
|
|
|
| // 1) The first navigation. --------------------------
|
| - GURL url1("http://www.google.com/");
|
| - NavigationEntry entry1(NULL /* instance */, -1 /* page_id */, url1,
|
| + const GURL kUrl1("http://www.google.com/");
|
| + NavigationEntry entry1(NULL /* instance */, -1 /* page_id */, kUrl1,
|
| GURL() /* referrer */, string16() /* title */,
|
| PageTransition::TYPED);
|
| host = manager.Navigate(entry1);
|
| @@ -207,12 +207,12 @@ TEST_F(RenderViewHostManagerTest, Navigate) {
|
| EXPECT_TRUE(host == manager.current_host());
|
| ASSERT_TRUE(host);
|
| EXPECT_FALSE(host->site_instance()->has_site());
|
| - host->site_instance()->SetSite(url1);
|
| + host->site_instance()->SetSite(kUrl1);
|
|
|
| // 2) Navigate to next site. -------------------------
|
| - GURL url2("http://www.google.com/foo");
|
| - NavigationEntry entry2(NULL /* instance */, -1 /* page_id */, url2,
|
| - url1 /* referrer */, string16() /* title */,
|
| + const GURL kUrl2("http://www.google.com/foo");
|
| + NavigationEntry entry2(NULL /* instance */, -1 /* page_id */, kUrl2,
|
| + kUrl1 /* referrer */, string16() /* title */,
|
| PageTransition::LINK);
|
| host = manager.Navigate(entry2);
|
|
|
| @@ -227,9 +227,9 @@ TEST_F(RenderViewHostManagerTest, Navigate) {
|
| EXPECT_TRUE(host->site_instance()->has_site());
|
|
|
| // 3) Cross-site navigate to next site. --------------
|
| - GURL url3("http://webkit.org/");
|
| - NavigationEntry entry3(NULL /* instance */, -1 /* page_id */, url3,
|
| - url2 /* referrer */, string16() /* title */,
|
| + const GURL kUrl3("http://webkit.org/");
|
| + NavigationEntry entry3(NULL /* instance */, -1 /* page_id */, kUrl3,
|
| + kUrl2 /* referrer */, string16() /* title */,
|
| PageTransition::LINK);
|
| host = manager.Navigate(entry3);
|
|
|
| @@ -262,8 +262,8 @@ TEST_F(RenderViewHostManagerTest, WebUI) {
|
|
|
| manager.Init(profile_.get(), instance, MSG_ROUTING_NONE);
|
|
|
| - GURL url(chrome::kChromeUINewTabURL);
|
| - NavigationEntry entry(NULL /* instance */, -1 /* page_id */, url,
|
| + const GURL kUrl(chrome::kTestNewTabURL);
|
| + NavigationEntry entry(NULL /* instance */, -1 /* page_id */, kUrl,
|
| GURL() /* referrer */, string16() /* title */,
|
| PageTransition::TYPED);
|
| RenderViewHost* host = manager.Navigate(entry);
|
| @@ -277,7 +277,7 @@ TEST_F(RenderViewHostManagerTest, WebUI) {
|
| // try to re-use the SiteInstance/process for non DOM-UI things that may
|
| // get loaded in between.
|
| EXPECT_TRUE(host->site_instance()->has_site());
|
| - EXPECT_EQ(url, host->site_instance()->site());
|
| + EXPECT_EQ(kUrl, host->site_instance()->site());
|
|
|
| // The Web UI is committed immediately because the RenderViewHost has not been
|
| // used yet. UpdateRendererStateForNavigate() took the short cut path.
|
| @@ -300,13 +300,13 @@ TEST_F(RenderViewHostManagerTest, NonWebUIChromeURLs) {
|
| manager.Init(profile_.get(), instance, MSG_ROUTING_NONE);
|
|
|
| // NTP is a Web UI page.
|
| - GURL ntp_url(chrome::kChromeUINewTabURL);
|
| - NavigationEntry ntp_entry(NULL /* instance */, -1 /* page_id */, ntp_url,
|
| + const GURL kNtpUrl(chrome::kTestNewTabURL);
|
| + NavigationEntry ntp_entry(NULL /* instance */, -1 /* page_id */, kNtpUrl,
|
| GURL() /* referrer */, string16() /* title */,
|
| PageTransition::TYPED);
|
|
|
| // about: URLs are not Web UI pages.
|
| - GURL about_url(chrome::kAboutMemoryURL);
|
| + GURL about_url(chrome::kTestMemoryURL);
|
| // Rewrite so it looks like chrome://about/memory
|
| bool reverse_on_redirect = false;
|
| BrowserURLHandler::GetInstance()->RewriteURLIfNecessary(
|
| @@ -321,15 +321,15 @@ TEST_F(RenderViewHostManagerTest, NonWebUIChromeURLs) {
|
| // Tests that we don't end up in an inconsistent state if a page does a back and
|
| // then reload. http://crbug.com/51680
|
| TEST_F(RenderViewHostManagerTest, PageDoesBackAndReload) {
|
| - GURL url1("http://www.google.com/");
|
| - GURL url2("http://www.evil-site.com/");
|
| + const GURL kUrl1("http://www.google.com/");
|
| + const GURL kUrl2("http://www.evil-site.com/");
|
|
|
| // Navigate to a safe site, then an evil site.
|
| // This will switch RenderViewHosts. We cannot assert that the first and
|
| // second RVHs are different, though, because the first one may be promptly
|
| // deleted.
|
| - contents()->NavigateAndCommit(url1);
|
| - contents()->NavigateAndCommit(url2);
|
| + contents()->NavigateAndCommit(kUrl1);
|
| + contents()->NavigateAndCommit(kUrl2);
|
| RenderViewHost* evil_rvh = contents()->render_view_host();
|
|
|
| // Now let's simulate the evil page calling history.back().
|
| @@ -342,13 +342,13 @@ TEST_F(RenderViewHostManagerTest, PageDoesBackAndReload) {
|
| // Before that RVH has committed, the evil page reloads itself.
|
| ViewHostMsg_FrameNavigate_Params params;
|
| params.page_id = 1;
|
| - params.url = url2;
|
| + params.url = kUrl2;
|
| params.transition = PageTransition::CLIENT_REDIRECT;
|
| params.should_update_history = false;
|
| params.gesture = NavigationGestureAuto;
|
| params.was_within_same_page = false;
|
| params.is_post = false;
|
| - params.content_state = webkit_glue::CreateHistoryStateForURL(GURL(url2));
|
| + params.content_state = webkit_glue::CreateHistoryStateForURL(GURL(kUrl2));
|
| contents()->TestDidNavigate(evil_rvh, params);
|
|
|
| // That should have cancelled the pending RVH, and the evil RVH should be the
|
| @@ -359,5 +359,5 @@ TEST_F(RenderViewHostManagerTest, PageDoesBackAndReload) {
|
| // Also we should not have a pending navigation entry.
|
| NavigationEntry* entry = contents()->controller().GetActiveEntry();
|
| ASSERT_TRUE(entry != NULL);
|
| - EXPECT_EQ(url2, entry->url());
|
| + EXPECT_EQ(kUrl2, entry->url());
|
| }
|
|
|