diff options
author | avi@chromium.org <avi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-05-24 19:38:31 +0000 |
---|---|---|
committer | avi@chromium.org <avi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-05-24 19:38:31 +0000 |
commit | a30f7d3b75631070c2eae4c68f1dfb730234d0b6 (patch) | |
tree | ba3d03efdf7f6da64d1ff427b11ecafbab7126a2 | |
parent | 7d36dcaef8f2a5c030ec5402e3fbe1f515a6d737 (diff) | |
download | chromium_src-a30f7d3b75631070c2eae4c68f1dfb730234d0b6.zip chromium_src-a30f7d3b75631070c2eae4c68f1dfb730234d0b6.tar.gz chromium_src-a30f7d3b75631070c2eae4c68f1dfb730234d0b6.tar.bz2 |
Finish removing url_constants from content/.
BUG=76697
TEST=compiles
Review URL: http://codereview.chromium.org/7049010
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@86469 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/renderer_host/render_process_host_chrome_browsertest.cc | 120 | ||||
-rw-r--r-- | chrome/chrome_tests.gypi | 4 | ||||
-rw-r--r-- | content/browser/DEPS | 1 | ||||
-rw-r--r-- | content/browser/child_process_security_policy_unittest.cc | 15 | ||||
-rw-r--r-- | content/browser/renderer_host/render_process_host_browsertest.cc | 145 | ||||
-rw-r--r-- | content/browser/renderer_host/render_process_host_browsertest.h | 18 | ||||
-rw-r--r-- | content/browser/renderer_host/resource_dispatcher_host_uitest.cc | 5 | ||||
-rw-r--r-- | content/browser/tab_contents/render_view_host_manager_unittest.cc | 70 | ||||
-rw-r--r-- | content/common/test_url_constants.cc | 16 | ||||
-rw-r--r-- | content/common/test_url_constants.h | 43 |
10 files changed, 266 insertions, 171 deletions
diff --git a/chrome/browser/renderer_host/render_process_host_chrome_browsertest.cc b/chrome/browser/renderer_host/render_process_host_chrome_browsertest.cc new file mode 100644 index 0000000..31295f6 --- /dev/null +++ b/chrome/browser/renderer_host/render_process_host_chrome_browsertest.cc @@ -0,0 +1,120 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "content/browser/renderer_host/render_process_host_browsertest.h" + +#include "base/command_line.h" +#include "chrome/browser/debugger/devtools_manager.h" +#include "chrome/browser/ui/browser.h" +#include "chrome/common/chrome_switches.h" +#include "chrome/common/url_constants.h" +#include "chrome/test/ui_test_utils.h" +#include "content/browser/renderer_host/render_process_host.h" +#include "content/browser/renderer_host/render_view_host.h" +#include "content/browser/renderer_host/render_view_host_delegate.h" + +namespace { + +RenderViewHost* FindFirstDevToolsHost() { + RenderProcessHost::iterator hosts = RenderProcessHost::AllHostsIterator(); + for (; !hosts.IsAtEnd(); hosts.Advance()) { + RenderProcessHost* render_process_host = hosts.GetCurrentValue(); + DCHECK(render_process_host); + if (!render_process_host->HasConnection()) + continue; + RenderProcessHost::listeners_iterator iter( + render_process_host->ListenersIterator()); + for (; !iter.IsAtEnd(); iter.Advance()) { + const RenderWidgetHost* widget = + static_cast<const RenderWidgetHost*>(iter.GetCurrentValue()); + DCHECK(widget); + if (!widget || !widget->IsRenderView()) + continue; + RenderViewHost* host = const_cast<RenderViewHost*>( + static_cast<const RenderViewHost*>(widget)); + RenderViewHostDelegate* host_delegate = host->delegate(); + GURL url = host_delegate->GetURL(); + if (url.SchemeIs(chrome::kChromeDevToolsScheme)) + return host; + } + } + return NULL; +} + +} // namespace + +// Ensure that DevTools opened to debug DevTools is launched in a separate +// process when --process-per-tab is set. See crbug.com/69873. +IN_PROC_BROWSER_TEST_F(RenderProcessHostTest, DevToolsOnSelfInOwnProcessPPT) { + CommandLine& parsed_command_line = *CommandLine::ForCurrentProcess(); + parsed_command_line.AppendSwitch(switches::kProcessPerTab); + + int tab_count = 1; + int host_count = 1; + +#if defined(TOUCH_UI) + ++host_count; // For the touch keyboard. +#endif + + GURL page1("data:text/html,hello world1"); + browser()->ShowSingletonTab(page1); + if (browser()->tab_count() == tab_count) + ui_test_utils::WaitForNewTab(browser()); + tab_count++; + host_count++; + EXPECT_EQ(tab_count, browser()->tab_count()); + EXPECT_EQ(host_count, RenderProcessHostCount()); + + // DevTools start in docked mode (no new tab), in a separate process. + browser()->ToggleDevToolsWindow(DEVTOOLS_TOGGLE_ACTION_INSPECT); + host_count++; + EXPECT_EQ(tab_count, browser()->tab_count()); + EXPECT_EQ(host_count, RenderProcessHostCount()); + + RenderViewHost* devtools = FindFirstDevToolsHost(); + DCHECK(devtools); + + // DevTools start in a separate process. + DevToolsManager::GetInstance()->ToggleDevToolsWindow( + devtools, DEVTOOLS_TOGGLE_ACTION_INSPECT); + host_count++; + EXPECT_EQ(tab_count, browser()->tab_count()); + EXPECT_EQ(host_count, RenderProcessHostCount()); +} + +// Ensure that DevTools opened to debug DevTools is launched in a separate +// process. See crbug.com/69873. +IN_PROC_BROWSER_TEST_F(RenderProcessHostTest, DevToolsOnSelfInOwnProcess) { + int tab_count = 1; + int host_count = 1; + +#if defined(TOUCH_UI) + ++host_count; // For the touch keyboard. +#endif + + GURL page1("data:text/html,hello world1"); + browser()->ShowSingletonTab(page1); + if (browser()->tab_count() == tab_count) + ui_test_utils::WaitForNewTab(browser()); + tab_count++; + host_count++; + EXPECT_EQ(tab_count, browser()->tab_count()); + EXPECT_EQ(host_count, RenderProcessHostCount()); + + // DevTools start in docked mode (no new tab), in a separate process. + browser()->ToggleDevToolsWindow(DEVTOOLS_TOGGLE_ACTION_INSPECT); + host_count++; + EXPECT_EQ(tab_count, browser()->tab_count()); + EXPECT_EQ(host_count, RenderProcessHostCount()); + + RenderViewHost* devtools = FindFirstDevToolsHost(); + DCHECK(devtools); + + // DevTools start in a separate process. + DevToolsManager::GetInstance()->ToggleDevToolsWindow( + devtools, DEVTOOLS_TOGGLE_ACTION_INSPECT); + host_count++; + EXPECT_EQ(tab_count, browser()->tab_count()); + EXPECT_EQ(host_count, RenderProcessHostCount()); +} diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi index eba1936..33e4f42 100644 --- a/chrome/chrome_tests.gypi +++ b/chrome/chrome_tests.gypi @@ -199,6 +199,8 @@ '../content/browser/tab_contents/test_tab_contents.h', '../content/common/notification_observer_mock.cc', '../content/common/notification_observer_mock.h', + '../content/common/test_url_constants.cc', + '../content/common/test_url_constants.h', '../ui/gfx/image_unittest_util.h', '../ui/gfx/image_unittest_util.cc', ], @@ -2405,6 +2407,7 @@ 'browser/popup_blocker_browsertest.cc', 'browser/prerender/prerender_browsertest.cc', 'browser/printing/print_dialog_cloud_uitest.cc', + 'browser/renderer_host/render_process_host_chrome_browsertest.cc', 'browser/renderer_host/web_cache_manager_browsertest.cc', 'browser/safe_browsing/safe_browsing_blocking_page_test.cc', 'browser/safe_browsing/safe_browsing_service_browsertest.cc', @@ -2469,6 +2472,7 @@ '../content/browser/in_process_webkit/indexed_db_browsertest.cc', '../content/browser/plugin_service_browsertest.cc', '../content/browser/renderer_host/render_process_host_browsertest.cc', + '../content/browser/renderer_host/render_process_host_browsertest.h', '../content/browser/renderer_host/render_view_host_browsertest.cc', '../content/browser/renderer_host/render_view_host_manager_browsertest.cc', '../content/browser/speech/speech_input_browsertest.cc', diff --git a/content/browser/DEPS b/content/browser/DEPS index 4f3a8f0..b20da8e 100644 --- a/content/browser/DEPS +++ b/content/browser/DEPS @@ -108,5 +108,4 @@ include_rules = [ "+chrome/browser/ui/browser.h",
"+chrome/browser/ui/cocoa/find_pasteboard.h",
"+chrome/common/net/test_url_fetcher_factory.h",
- "+chrome/common/url_constants.h",
]
diff --git a/content/browser/child_process_security_policy_unittest.cc b/content/browser/child_process_security_policy_unittest.cc index 632aabb..f1f214c 100644 --- a/content/browser/child_process_security_policy_unittest.cc +++ b/content/browser/child_process_security_policy_unittest.cc @@ -7,8 +7,9 @@ #include "base/basictypes.h" #include "base/file_path.h" #include "base/platform_file.h" -#include "chrome/common/url_constants.h" #include "content/browser/child_process_security_policy.h" +#include "content/common/test_url_constants.h" +#include "content/common/url_constants.h" #include "net/url_request/url_request.h" #include "net/url_request/url_request_test_job.h" #include "testing/gtest/include/gtest/gtest.h" @@ -118,17 +119,17 @@ TEST_F(ChildProcessSecurityPolicyTest, AboutTest) { EXPECT_FALSE(p->CanRequestURL(kRendererID, GURL("about:CrASh"))); EXPECT_FALSE(p->CanRequestURL(kRendererID, GURL("abOuT:cAChe"))); - p->GrantRequestURL(kRendererID, GURL(chrome::kAboutMemoryURL)); - EXPECT_FALSE(p->CanRequestURL(kRendererID, GURL(chrome::kAboutMemoryURL))); + p->GrantRequestURL(kRendererID, GURL(chrome::kTestMemoryURL)); + EXPECT_FALSE(p->CanRequestURL(kRendererID, GURL(chrome::kTestMemoryURL))); p->GrantRequestURL(kRendererID, GURL(chrome::kAboutCrashURL)); EXPECT_FALSE(p->CanRequestURL(kRendererID, GURL(chrome::kAboutCrashURL))); - p->GrantRequestURL(kRendererID, GURL(chrome::kAboutCacheURL)); - EXPECT_FALSE(p->CanRequestURL(kRendererID, GURL(chrome::kAboutCacheURL))); + p->GrantRequestURL(kRendererID, GURL(chrome::kTestCacheURL)); + EXPECT_FALSE(p->CanRequestURL(kRendererID, GURL(chrome::kTestCacheURL))); - p->GrantRequestURL(kRendererID, GURL(chrome::kAboutHangURL)); - EXPECT_FALSE(p->CanRequestURL(kRendererID, GURL(chrome::kAboutHangURL))); + p->GrantRequestURL(kRendererID, GURL(chrome::kTestHangURL)); + EXPECT_FALSE(p->CanRequestURL(kRendererID, GURL(chrome::kTestHangURL))); p->Remove(kRendererID); } diff --git a/content/browser/renderer_host/render_process_host_browsertest.cc b/content/browser/renderer_host/render_process_host_browsertest.cc index 4c442cf..360fab2 100644 --- a/content/browser/renderer_host/render_process_host_browsertest.cc +++ b/content/browser/renderer_host/render_process_host_browsertest.cc @@ -2,62 +2,30 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "content/browser/renderer_host/render_process_host_browsertest.h" + #include "base/command_line.h" -#include "chrome/browser/debugger/devtools_manager.h" #include "chrome/browser/ui/browser.h" #include "chrome/common/chrome_switches.h" -#include "chrome/common/url_constants.h" -#include "chrome/test/in_process_browser_test.h" #include "chrome/test/ui_test_utils.h" #include "content/browser/renderer_host/render_process_host.h" -#include "content/browser/renderer_host/render_view_host.h" -#include "content/browser/renderer_host/render_widget_host.h" -#include "content/browser/site_instance.h" #include "content/browser/tab_contents/tab_contents.h" +#include "content/common/test_url_constants.h" -class RenderProcessHostTest : public InProcessBrowserTest { - public: - RenderProcessHostTest() { - EnableDOMAutomation(); - } - - int RenderProcessHostCount() { - RenderProcessHost::iterator hosts = RenderProcessHost::AllHostsIterator(); - int count = 0; - while (!hosts.IsAtEnd()) { - if (hosts.GetCurrentValue()->HasConnection()) - count++; - hosts.Advance(); - } - return count; - } +RenderProcessHostTest::RenderProcessHostTest() { + EnableDOMAutomation(); +} - RenderViewHost* FindFirstDevToolsHost() { - RenderProcessHost::iterator hosts = RenderProcessHost::AllHostsIterator(); - for (; !hosts.IsAtEnd(); hosts.Advance()) { - RenderProcessHost* render_process_host = hosts.GetCurrentValue(); - DCHECK(render_process_host); - if (!render_process_host->HasConnection()) - continue; - RenderProcessHost::listeners_iterator iter( - render_process_host->ListenersIterator()); - for (; !iter.IsAtEnd(); iter.Advance()) { - const RenderWidgetHost* widget = - static_cast<const RenderWidgetHost*>(iter.GetCurrentValue()); - DCHECK(widget); - if (!widget || !widget->IsRenderView()) - continue; - RenderViewHost* host = const_cast<RenderViewHost*>( - static_cast<const RenderViewHost*>(widget)); - RenderViewHostDelegate* host_delegate = host->delegate(); - GURL url = host_delegate->GetURL(); - if (url.SchemeIs(chrome::kChromeDevToolsScheme)) - return host; - } - } - return NULL; +int RenderProcessHostTest::RenderProcessHostCount() { + RenderProcessHost::iterator hosts = RenderProcessHost::AllHostsIterator(); + int count = 0; + while (!hosts.IsAtEnd()) { + if (hosts.GetCurrentValue()->HasConnection()) + count++; + hosts.Advance(); } -}; + return count; +} IN_PROC_BROWSER_TEST_F(RenderProcessHostTest, ProcessPerTab) { // Set max renderers to 1 to force running out of processes. @@ -74,7 +42,7 @@ IN_PROC_BROWSER_TEST_F(RenderProcessHostTest, ProcessPerTab) { #endif // Change the first tab to be the new tab page (TYPE_WEBUI). - GURL newtab(chrome::kChromeUINewTabURL); + GURL newtab(chrome::kTestNewTabURL); ui_test_utils::NavigateToURL(browser(), newtab); EXPECT_EQ(tab_count, browser()->tab_count()); EXPECT_EQ(host_count, RenderProcessHostCount()); @@ -115,81 +83,6 @@ IN_PROC_BROWSER_TEST_F(RenderProcessHostTest, ProcessPerTab) { EXPECT_EQ(host_count, RenderProcessHostCount()); } -// Ensure that DevTools opened to debug DevTools is launched in a separate -// process when --process-per-tab is set. See crbug.com/69873. -IN_PROC_BROWSER_TEST_F(RenderProcessHostTest, DevToolsOnSelfInOwnProcessPPT) { - CommandLine& parsed_command_line = *CommandLine::ForCurrentProcess(); - parsed_command_line.AppendSwitch(switches::kProcessPerTab); - - int tab_count = 1; - int host_count = 1; - -#if defined(TOUCH_UI) - ++host_count; // For the touch keyboard. -#endif - - GURL page1("data:text/html,hello world1"); - browser()->ShowSingletonTab(page1); - if (browser()->tab_count() == tab_count) - ui_test_utils::WaitForNewTab(browser()); - tab_count++; - host_count++; - EXPECT_EQ(tab_count, browser()->tab_count()); - EXPECT_EQ(host_count, RenderProcessHostCount()); - - // DevTools start in docked mode (no new tab), in a separate process. - browser()->ToggleDevToolsWindow(DEVTOOLS_TOGGLE_ACTION_INSPECT); - host_count++; - EXPECT_EQ(tab_count, browser()->tab_count()); - EXPECT_EQ(host_count, RenderProcessHostCount()); - - RenderViewHost* devtools = FindFirstDevToolsHost(); - DCHECK(devtools); - - // DevTools start in a separate process. - DevToolsManager::GetInstance()->ToggleDevToolsWindow( - devtools, DEVTOOLS_TOGGLE_ACTION_INSPECT); - host_count++; - EXPECT_EQ(tab_count, browser()->tab_count()); - EXPECT_EQ(host_count, RenderProcessHostCount()); -} - -// Ensure that DevTools opened to debug DevTools is launched in a separate -// process. See crbug.com/69873. -IN_PROC_BROWSER_TEST_F(RenderProcessHostTest, DevToolsOnSelfInOwnProcess) { - int tab_count = 1; - int host_count = 1; - -#if defined(TOUCH_UI) - ++host_count; // For the touch keyboard. -#endif - - GURL page1("data:text/html,hello world1"); - browser()->ShowSingletonTab(page1); - if (browser()->tab_count() == tab_count) - ui_test_utils::WaitForNewTab(browser()); - tab_count++; - host_count++; - EXPECT_EQ(tab_count, browser()->tab_count()); - EXPECT_EQ(host_count, RenderProcessHostCount()); - - // DevTools start in docked mode (no new tab), in a separate process. - browser()->ToggleDevToolsWindow(DEVTOOLS_TOGGLE_ACTION_INSPECT); - host_count++; - EXPECT_EQ(tab_count, browser()->tab_count()); - EXPECT_EQ(host_count, RenderProcessHostCount()); - - RenderViewHost* devtools = FindFirstDevToolsHost(); - DCHECK(devtools); - - // DevTools start in a separate process. - DevToolsManager::GetInstance()->ToggleDevToolsWindow( - devtools, DEVTOOLS_TOGGLE_ACTION_INSPECT); - host_count++; - EXPECT_EQ(tab_count, browser()->tab_count()); - EXPECT_EQ(host_count, RenderProcessHostCount()); -} - // When we hit the max number of renderers, verify that the way we do process // sharing behaves correctly. In particular, this test is verifying that even // when we hit the max process limit, that renderers of each type will wind up @@ -211,7 +104,7 @@ IN_PROC_BROWSER_TEST_F(RenderProcessHostTest, ProcessOverflow) { #endif // Change the first tab to be the new tab page (TYPE_WEBUI). - GURL newtab(chrome::kChromeUINewTabURL); + GURL newtab(chrome::kTestNewTabURL); ui_test_utils::NavigateToURL(browser(), newtab); EXPECT_EQ(tab_count, browser()->tab_count()); tab1 = browser()->GetTabContentsAt(tab_count - 1); @@ -249,7 +142,7 @@ IN_PROC_BROWSER_TEST_F(RenderProcessHostTest, ProcessOverflow) { // Note: intentionally create this tab after the TYPE_TABBED tabs to exercise // bug 43448 where extension and WebUI tabs could get combined into normal // renderers. - GURL history(chrome::kChromeUIHistoryURL); + GURL history(chrome::kTestHistoryURL); browser()->ShowSingletonTab(history); if (browser()->tab_count() == tab_count) ui_test_utils::WaitForNewTab(browser()); @@ -262,7 +155,7 @@ IN_PROC_BROWSER_TEST_F(RenderProcessHostTest, ProcessOverflow) { // Create a TYPE_EXTENSION tab. It should be in its own process. // (the bookmark manager is implemented as an extension) - GURL bookmarks(chrome::kChromeUIBookmarksURL); + GURL bookmarks(chrome::kTestBookmarksURL); browser()->ShowSingletonTab(bookmarks); if (browser()->tab_count() == tab_count) ui_test_utils::WaitForNewTab(browser()); diff --git a/content/browser/renderer_host/render_process_host_browsertest.h b/content/browser/renderer_host/render_process_host_browsertest.h new file mode 100644 index 0000000..ba67f51 --- /dev/null +++ b/content/browser/renderer_host/render_process_host_browsertest.h @@ -0,0 +1,18 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CONTENT_BROWSER_RENDERER_HOST_RENDER_PROCESS_HOST_BROWSERTEST_H_ +#define CONTENT_BROWSER_RENDERER_HOST_RENDER_PROCESS_HOST_BROWSERTEST_H_ +#pragma once + +#include "chrome/test/in_process_browser_test.h" + +class RenderProcessHostTest : public InProcessBrowserTest { + public: + RenderProcessHostTest(); + + int RenderProcessHostCount(); +}; + +#endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_PROCESS_HOST_BROWSERTEST_H_ diff --git a/content/browser/renderer_host/resource_dispatcher_host_uitest.cc b/content/browser/renderer_host/resource_dispatcher_host_uitest.cc index 7f21171..25dcc0f 100644 --- a/content/browser/renderer_host/resource_dispatcher_host_uitest.cc +++ b/content/browser/renderer_host/resource_dispatcher_host_uitest.cc @@ -12,10 +12,11 @@ #include "base/test/test_timeouts.h" #include "chrome/browser/net/url_request_failed_dns_job.h" #include "chrome/browser/net/url_request_mock_http_job.h" -#include "chrome/common/url_constants.h" #include "chrome/test/automation/browser_proxy.h" #include "chrome/test/automation/tab_proxy.h" #include "chrome/test/ui/ui_test.h" +#include "content/common/test_url_constants.h" +#include "content/common/url_constants.h" #include "net/base/net_util.h" #include "net/test/test_server.h" @@ -384,7 +385,7 @@ TEST_F(ResourceDispatcherTest, CrossSiteFailedRequest) { ASSERT_TRUE(tab.get()); // Visit another URL first to trigger a cross-site navigation. - GURL url(chrome::kChromeUINewTabURL); + GURL url(chrome::kTestNewTabURL); ASSERT_EQ(AUTOMATION_MSG_NAVIGATION_SUCCESS, tab->NavigateToURL(url)); // Visit a URL that fails without calling ResourceDispatcherHost::Read. 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 c5ada3f..6e6ca41 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()); } diff --git a/content/common/test_url_constants.cc b/content/common/test_url_constants.cc new file mode 100644 index 0000000..8d27dff --- /dev/null +++ b/content/common/test_url_constants.cc @@ -0,0 +1,16 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "content/common/test_url_constants.h" + +namespace chrome { + +const char kTestCacheURL[] = "about:cache"; +const char kTestHangURL[] = "about:hang"; +const char kTestMemoryURL[] = "about:memory"; +const char kTestNewTabURL[] = "chrome://newtab"; +const char kTestHistoryURL[] = "chrome://history/"; +const char kTestBookmarksURL[] = "chrome://bookmarks/"; + +} // namespace chrome diff --git a/content/common/test_url_constants.h b/content/common/test_url_constants.h new file mode 100644 index 0000000..4c81bb0 --- /dev/null +++ b/content/common/test_url_constants.h @@ -0,0 +1,43 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Contains constants for known URLs and portions thereof. + +#ifndef CONTENT_COMMON_TEST_URL_CONSTANTS_H_ +#define CONTENT_COMMON_TEST_URL_CONSTANTS_H_ +#pragma once + +#include "content/common/url_constants.h" + +namespace chrome { + +// Various special URLs used for testing. They have the same values as the URLs +// in chrome/common/url_constants.h, but are duplicated here so that the reverse +// dependency can be broken. + +// Various URLs used in security policy testing. +extern const char kTestCacheURL[]; +extern const char kTestHangURL[]; + +// The About pages are assumed in several tests to not be a WebUI page. +extern const char kTestMemoryURL[]; + +// The NTP is assumed in several tests to have the property that it is WebUI. +extern const char kTestNewTabURL[]; + +// The History page is assumed in several tests to have the property that it is +// WebUI. That's the case only with the ChromeBrowserContentClient +// implementation of WebUIFactory. With a different implementation that might +// not be the case. +extern const char kTestHistoryURL[]; + +// The Bookmarks page is assumed in several tests to have the property that it +// is an extension. That's the case only with the ChromeBrowserContentClient +// implementation of WebUIFactory. With a different implementation that might +// not be the case. +extern const char kTestBookmarksURL[]; + +} // namespace chrome + +#endif // CONTENT_COMMON_TEST_URL_CONSTANTS_H_ |