| 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 "base/strings/sys_string_conversions.h" | 5 #include "base/strings/sys_string_conversions.h" |
| 6 #include "base/strings/utf_string_conversions.h" | 6 #include "base/strings/utf_string_conversions.h" |
| 7 #include "chrome/browser/extensions/component_loader.h" | 7 #include "chrome/browser/extensions/component_loader.h" |
| 8 #include "chrome/browser/extensions/extension_browsertest.h" | 8 #include "chrome/browser/extensions/extension_browsertest.h" |
| 9 #include "chrome/browser/search/search.h" |
| 9 #include "chrome/browser/ui/browser.h" | 10 #include "chrome/browser/ui/browser.h" |
| 10 #include "chrome/browser/ui/browser_window.h" | 11 #include "chrome/browser/ui/browser_window.h" |
| 11 #include "chrome/browser/ui/omnibox/location_bar.h" | 12 #include "chrome/browser/ui/omnibox/location_bar.h" |
| 12 #include "chrome/browser/ui/omnibox/omnibox_view.h" | 13 #include "chrome/browser/ui/omnibox/omnibox_view.h" |
| 13 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 14 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 14 #include "chrome/common/url_constants.h" | 15 #include "chrome/common/url_constants.h" |
| 15 #include "chrome/test/base/in_process_browser_test.h" | 16 #include "chrome/test/base/in_process_browser_test.h" |
| 16 #include "chrome/test/base/testing_profile.h" | 17 #include "chrome/test/base/testing_profile.h" |
| 17 #include "chrome/test/base/ui_test_utils.h" | 18 #include "chrome/test/base/ui_test_utils.h" |
| 18 #include "content/public/browser/navigation_controller.h" | 19 #include "content/public/browser/navigation_controller.h" |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 ui_test_utils::NavigateToURL(browser(), url); | 72 ui_test_utils::NavigateToURL(browser(), url); |
| 72 EXPECT_EQ("", GetLocationBarText()); | 73 EXPECT_EQ("", GetLocationBarText()); |
| 73 EXPECT_EQ(url, GetNavigationEntry()->GetVirtualURL()); | 74 EXPECT_EQ(url, GetNavigationEntry()->GetVirtualURL()); |
| 74 } | 75 } |
| 75 }; | 76 }; |
| 76 | 77 |
| 77 IN_PROC_BROWSER_TEST_F(ExtensionURLRewriteBrowserTest, NewTabPageURL) { | 78 IN_PROC_BROWSER_TEST_F(ExtensionURLRewriteBrowserTest, NewTabPageURL) { |
| 78 // Navigate to chrome://newtab and check that the location bar text is blank. | 79 // Navigate to chrome://newtab and check that the location bar text is blank. |
| 79 GURL url(chrome::kChromeUINewTabURL); | 80 GURL url(chrome::kChromeUINewTabURL); |
| 80 TestURLNotShown(url); | 81 TestURLNotShown(url); |
| 81 // Check that the actual URL corresponds to chrome://newtab. | 82 // Check that the actual URL corresponds to the new tab URL. |
| 82 EXPECT_EQ(url, GetNavigationEntry()->GetURL()); | 83 EXPECT_TRUE(chrome::IsNTPURL(GetNavigationEntry()->GetURL(), profile())); |
| 83 } | 84 } |
| 84 | 85 |
| 85 IN_PROC_BROWSER_TEST_F(ExtensionURLRewriteBrowserTest, NewTabPageURLOverride) { | 86 IN_PROC_BROWSER_TEST_F(ExtensionURLRewriteBrowserTest, NewTabPageURLOverride) { |
| 86 // Load an extension to override the NTP and check that the location bar text | 87 // Load an extension to override the NTP and check that the location bar text |
| 87 // is blank after navigating to chrome://newtab. | 88 // is blank after navigating to chrome://newtab. |
| 88 ASSERT_TRUE(LoadExtension(GetTestExtensionPath("newtab"))); | 89 ASSERT_TRUE(LoadExtension(GetTestExtensionPath("newtab"))); |
| 89 TestURLNotShown(GURL(chrome::kChromeUINewTabURL)); | 90 TestURLNotShown(GURL(chrome::kChromeUINewTabURL)); |
| 90 // Check that the internal URL uses the chrome-extension:// scheme. | 91 // Check that the internal URL uses the chrome-extension:// scheme. |
| 91 EXPECT_TRUE(GetNavigationEntry()->GetURL().SchemeIs( | 92 EXPECT_TRUE(GetNavigationEntry()->GetURL().SchemeIs( |
| 92 extensions::kExtensionScheme)); | 93 extensions::kExtensionScheme)); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 118 TestExtensionURLOverride(url_with_ref); | 119 TestExtensionURLOverride(url_with_ref); |
| 119 } | 120 } |
| 120 | 121 |
| 121 IN_PROC_BROWSER_TEST_F(ExtensionURLRewriteBrowserTest, BookmarksURLOverride) { | 122 IN_PROC_BROWSER_TEST_F(ExtensionURLRewriteBrowserTest, BookmarksURLOverride) { |
| 122 // Load an extension that overrides chrome://bookmarks. | 123 // Load an extension that overrides chrome://bookmarks. |
| 123 ASSERT_TRUE(LoadExtension(GetTestExtensionPath("bookmarks"))); | 124 ASSERT_TRUE(LoadExtension(GetTestExtensionPath("bookmarks"))); |
| 124 // Navigate to chrome://bookmarks and check that the location bar URL is what | 125 // Navigate to chrome://bookmarks and check that the location bar URL is what |
| 125 // was entered and the internal URL uses the chrome-extension:// scheme. | 126 // was entered and the internal URL uses the chrome-extension:// scheme. |
| 126 TestExtensionURLOverride(GURL(chrome::kChromeUIBookmarksURL)); | 127 TestExtensionURLOverride(GURL(chrome::kChromeUIBookmarksURL)); |
| 127 } | 128 } |
| OLD | NEW |