Chromium Code Reviews| Index: chrome/browser/extensions/window_open_apitest.cc |
| diff --git a/chrome/browser/extensions/window_open_apitest.cc b/chrome/browser/extensions/window_open_apitest.cc |
| index b62ab7da435238478b98bbecd936da3debe7f34f..f916363efdcd6583279262311e5161a3d5b8e75e 100644 |
| --- a/chrome/browser/extensions/window_open_apitest.cc |
| +++ b/chrome/browser/extensions/window_open_apitest.cc |
| @@ -15,6 +15,7 @@ |
| #include "chrome/browser/ui/browser_list.h" |
| #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| #include "chrome/common/chrome_paths.h" |
| +#include "chrome/common/url_constants.h" |
| #include "chrome/test/base/ui_test_utils.h" |
| #include "content/public/browser/notification_service.h" |
| #include "content/public/browser/notification_types.h" |
| @@ -24,6 +25,7 @@ |
| #include "content/public/common/result_codes.h" |
| #include "content/public/common/url_constants.h" |
| #include "content/public/test/browser_test_utils.h" |
| +#include "content/public/test/test_navigation_observer.h" |
| #include "extensions/browser/extension_host.h" |
| #include "extensions/browser/process_manager.h" |
| #include "extensions/common/constants.h" |
| @@ -327,3 +329,42 @@ IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, |
| 2, /* FAILURE_SCHEME_NOT_HTTP_OR_HTTPS_OR_EXTENSION */ |
| 1); |
| } |
| + |
| +// Test that navigating to an extension URL is allowed on chrome:// and |
| +// chrome-search:// pages, even for URLs that are not web-accessible. |
| +// See https://crbug.com/662602. |
| +IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, |
| + NavigateToInaccessibleResourceFromChromeURL) { |
| + // Mint an extension URL which is not web-accessible. |
| + ASSERT_TRUE(LoadExtension( |
| + test_data_dir_.AppendASCII("uitest").AppendASCII("window_open"))); |
| + GURL extension_url(extensions::Extension::GetResourceURL( |
| + extensions::Extension::GetBaseURLFromExtensionId( |
| + last_loaded_extension_id()), |
|
Devlin
2016/11/09 21:54:43
This might be cleaner as:
const Extension* extensi
alexmos
2016/11/09 22:20:31
Done for both tests. Much cleaner, thanks for the
|
| + "test.html")); |
| + |
| + content::WebContents* tab = |
| + browser()->tab_strip_model()->GetActiveWebContents(); |
| + |
| + // Navigate to the non-web-accessible URL from chrome:// and |
| + // chrome-search:// pages. Verify that the page loads correctly. |
| + GURL history_url(chrome::kChromeUIHistoryURL); |
| + GURL ntp_url(chrome::kChromeSearchLocalNtpUrl); |
| + ASSERT_TRUE(history_url.SchemeIs(content::kChromeUIScheme)); |
| + ASSERT_TRUE(ntp_url.SchemeIs(chrome::kChromeSearchScheme)); |
| + GURL start_urls[] = {history_url, ntp_url}; |
| + for (size_t i = 0; i < arraysize(start_urls); i++) { |
| + ui_test_utils::NavigateToURL(browser(), start_urls[i]); |
| + EXPECT_EQ(start_urls[i], tab->GetMainFrame()->GetLastCommittedURL()); |
| + |
| + content::TestNavigationObserver observer(tab); |
| + ASSERT_TRUE(content::ExecuteScript( |
| + tab, "location.href = '" + extension_url.spec() + "';")); |
| + observer.Wait(); |
| + EXPECT_EQ(extension_url, tab->GetMainFrame()->GetLastCommittedURL()); |
| + std::string result; |
| + ASSERT_TRUE(content::ExecuteScriptAndExtractString( |
| + tab, "domAutomationController.send(document.body.innerText)", &result)); |
| + EXPECT_EQ("HOWDIE!!!", result); |
| + } |
| +} |