Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(242)

Side by Side Diff: chrome/browser/net/errorpage_browsertest.cc

Issue 2913733002: Add a browser test for access control for file: scheme (Closed)
Patch Set: Rework the patch per feedback Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <memory> 5 #include <memory>
6 #include <utility> 6 #include <utility>
7 7
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
11 #include "base/files/scoped_temp_dir.h" 11 #include "base/files/scoped_temp_dir.h"
12 #include "base/logging.h" 12 #include "base/logging.h"
13 #include "base/macros.h" 13 #include "base/macros.h"
14 #include "base/memory/ptr_util.h" 14 #include "base/memory/ptr_util.h"
15 #include "base/memory/weak_ptr.h" 15 #include "base/memory/weak_ptr.h"
16 #include "base/path_service.h" 16 #include "base/path_service.h"
17 #include "base/strings/stringprintf.h" 17 #include "base/strings/stringprintf.h"
18 #include "base/strings/utf_string_conversions.h" 18 #include "base/strings/utf_string_conversions.h"
19 #include "base/synchronization/lock.h" 19 #include "base/synchronization/lock.h"
20 #include "base/task_scheduler/post_task.h" 20 #include "base/task_scheduler/post_task.h"
21 #include "base/threading/sequenced_worker_pool.h" 21 #include "base/threading/sequenced_worker_pool.h"
22 #include "base/threading/thread_restrictions.h" 22 #include "base/threading/thread_restrictions.h"
23 #include "base/values.h" 23 #include "base/values.h"
24 #include "build/build_config.h" 24 #include "build/build_config.h"
25 #include "chrome/browser/browsing_data/browsing_data_helper.h" 25 #include "chrome/browser/browsing_data/browsing_data_helper.h"
26 #include "chrome/browser/browsing_data/chrome_browsing_data_remover_delegate.h" 26 #include "chrome/browser/browsing_data/chrome_browsing_data_remover_delegate.h"
27 #include "chrome/browser/net/errorpage_test_util.h"
27 #include "chrome/browser/net/net_error_diagnostics_dialog.h" 28 #include "chrome/browser/net/net_error_diagnostics_dialog.h"
28 #include "chrome/browser/net/url_request_mock_util.h" 29 #include "chrome/browser/net/url_request_mock_util.h"
29 #include "chrome/browser/profiles/profile.h" 30 #include "chrome/browser/profiles/profile.h"
30 #include "chrome/browser/search_engines/ui_thread_search_terms_data.h" 31 #include "chrome/browser/search_engines/ui_thread_search_terms_data.h"
31 #include "chrome/browser/ui/browser.h" 32 #include "chrome/browser/ui/browser.h"
32 #include "chrome/browser/ui/browser_commands.h" 33 #include "chrome/browser/ui/browser_commands.h"
33 #include "chrome/browser/ui/tabs/tab_strip_model.h" 34 #include "chrome/browser/ui/tabs/tab_strip_model.h"
34 #include "chrome/common/chrome_paths.h" 35 #include "chrome/common/chrome_paths.h"
35 #include "chrome/common/chrome_switches.h" 36 #include "chrome/common/chrome_switches.h"
36 #include "chrome/common/pref_names.h" 37 #include "chrome/common/pref_names.h"
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 #endif 83 #endif
83 #include "components/policy/core/common/mock_configuration_policy_provider.h" 84 #include "components/policy/core/common/mock_configuration_policy_provider.h"
84 85
85 using content::BrowserThread; 86 using content::BrowserThread;
86 using content::NavigationController; 87 using content::NavigationController;
87 using net::URLRequestFailedJob; 88 using net::URLRequestFailedJob;
88 using net::URLRequestTestJob; 89 using net::URLRequestTestJob;
89 90
90 namespace { 91 namespace {
91 92
92 // Returns true if |text| is displayed on the page |browser| is currently
93 // displaying. Uses "innerText", so will miss hidden text, and whitespace
94 // space handling may be weird.
95 bool WARN_UNUSED_RESULT IsDisplayingText(Browser* browser,
96 const std::string& text) {
97 // clang-format off
98 std::string command = base::StringPrintf(R"(
99 function isNodeVisible(node) {
100 if (!node || node.classList.contains('hidden'))
101 return false;
102 if (!node.parentElement)
103 return true;
104 // Otherwise, we must check all parent nodes
105 return isNodeVisible(node.parentElement);
106 }
107 var node = document.evaluate("//*[contains(text(),'%s')]", document,
108 null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
109 domAutomationController.send(isNodeVisible(node));
110 )", text.c_str());
111 // clang-format on
112 bool result = false;
113 EXPECT_TRUE(content::ExecuteScriptAndExtractBool(
114 browser->tab_strip_model()->GetActiveWebContents(), command, &result));
115 return result;
116 }
117
118 // Expands the more box on the currently displayed error page. 93 // Expands the more box on the currently displayed error page.
119 void ToggleHelpBox(Browser* browser) { 94 void ToggleHelpBox(Browser* browser) {
120 EXPECT_TRUE(content::ExecuteScript( 95 EXPECT_TRUE(content::ExecuteScript(
121 browser->tab_strip_model()->GetActiveWebContents(), 96 browser->tab_strip_model()->GetActiveWebContents(),
122 "document.getElementById('details-button').click();")); 97 "document.getElementById('details-button').click();"));
123 } 98 }
124 99
125 // Returns true if the diagnostics link suggestion is displayed. 100 // Returns true if the diagnostics link suggestion is displayed.
126 bool WARN_UNUSED_RESULT IsDisplayingDiagnosticsLink(Browser* browser) { 101 bool WARN_UNUSED_RESULT IsDisplayingDiagnosticsLink(Browser* browser) {
127 std::string command = base::StringPrintf( 102 std::string command = base::StringPrintf(
128 "var diagnose_link = document.getElementById('diagnose-link');" 103 "var diagnose_link = document.getElementById('diagnose-link');"
129 "domAutomationController.send(diagnose_link != null);"); 104 "domAutomationController.send(diagnose_link != null);");
130 bool result = false; 105 bool result = false;
131 EXPECT_TRUE(content::ExecuteScriptAndExtractBool( 106 EXPECT_TRUE(content::ExecuteScriptAndExtractBool(
132 browser->tab_strip_model()->GetActiveWebContents(), command, &result)); 107 browser->tab_strip_model()->GetActiveWebContents(), command, &result));
133 return result; 108 return result;
134 } 109 }
135 110
136 // Checks that the local error page is being displayed, without remotely 111 // Checks that the local error page is being displayed, without remotely
137 // retrieved navigation corrections, and with the specified error string. 112 // retrieved navigation corrections, and with the specified error string.
138 void ExpectDisplayingLocalErrorPage(Browser* browser, 113 void ExpectDisplayingLocalErrorPage(Browser* browser,
139 const std::string& error_string) { 114 const std::string& error_string) {
140 EXPECT_TRUE(IsDisplayingText(browser, error_string)); 115 EXPECT_TRUE(errorpage_test_util::IsDisplayingText(browser, error_string));
141 116
142 // Locally generated error pages should not have navigation corrections. 117 // Locally generated error pages should not have navigation corrections.
143 EXPECT_FALSE(IsDisplayingText(browser, "http://mock.http/title2.html")); 118 EXPECT_FALSE(errorpage_test_util::IsDisplayingText(
119 browser, "http://mock.http/title2.html"));
144 120
145 // Locally generated error pages should not have a link with search terms. 121 // Locally generated error pages should not have a link with search terms.
146 EXPECT_FALSE(IsDisplayingText(browser, "search query")); 122 EXPECT_FALSE(errorpage_test_util::IsDisplayingText(browser, "search query"));
147 } 123 }
148 124
149 // Checks that the local error page is being displayed, without remotely 125 // Checks that the local error page is being displayed, without remotely
150 // retrieved navigation corrections, and with the specified error code. 126 // retrieved navigation corrections, and with the specified error code.
151 void ExpectDisplayingLocalErrorPage(Browser* browser, net::Error error_code) { 127 void ExpectDisplayingLocalErrorPage(Browser* browser, net::Error error_code) {
152 ExpectDisplayingLocalErrorPage(browser, net::ErrorToShortString(error_code)); 128 ExpectDisplayingLocalErrorPage(browser, net::ErrorToShortString(error_code));
153 } 129 }
154 130
155 // Checks that an error page with information retrieved from the navigation 131 // Checks that an error page with information retrieved from the navigation
156 // correction service is being displayed, with the specified specified error 132 // correction service is being displayed, with the specified specified error
157 // string. 133 // string.
158 void ExpectDisplayingNavigationCorrections(Browser* browser, 134 void ExpectDisplayingNavigationCorrections(Browser* browser,
159 const std::string& error_string) { 135 const std::string& error_string) {
160 EXPECT_TRUE(IsDisplayingText(browser, error_string)); 136 EXPECT_TRUE(errorpage_test_util::IsDisplayingText(browser, error_string));
161 137
162 // Check that the mock navigation corrections are displayed. 138 // Check that the mock navigation corrections are displayed.
163 EXPECT_TRUE(IsDisplayingText(browser, "http://mock.http/title2.html")); 139 EXPECT_TRUE(errorpage_test_util::IsDisplayingText(
140 browser, "http://mock.http/title2.html"));
164 141
165 // Check that the search terms are displayed as a link. 142 // Check that the search terms are displayed as a link.
166 EXPECT_TRUE(IsDisplayingText(browser, "search query")); 143 EXPECT_TRUE(errorpage_test_util::IsDisplayingText(browser, "search query"));
167 144
168 // The diagnostics button isn't displayed when corrections were 145 // The diagnostics button isn't displayed when corrections were
169 // retrieved from a remote server. 146 // retrieved from a remote server.
170 EXPECT_FALSE(IsDisplayingDiagnosticsLink(browser)); 147 EXPECT_FALSE(IsDisplayingDiagnosticsLink(browser));
171 } 148 }
172 149
173 // Checks that an error page with information retrieved from the navigation 150 // Checks that an error page with information retrieved from the navigation
174 // correction service is being displayed, with the specified specified error 151 // correction service is being displayed, with the specified specified error
175 // code. 152 // code.
176 void ExpectDisplayingNavigationCorrections(Browser* browser, 153 void ExpectDisplayingNavigationCorrections(Browser* browser,
(...skipping 814 matching lines...) Expand 10 before | Expand all | Expand 10 after
991 browser()->profile()->GetRequestContext(); 968 browser()->profile()->GetRequestContext();
992 BrowserThread::PostTask( 969 BrowserThread::PostTask(
993 BrowserThread::IO, FROM_HERE, 970 BrowserThread::IO, FROM_HERE,
994 base::BindOnce(&InterceptNetworkTransactions, 971 base::BindOnce(&InterceptNetworkTransactions,
995 base::RetainedRef(url_request_context_getter), 972 base::RetainedRef(url_request_context_getter),
996 net::ERR_FAILED)); 973 net::ERR_FAILED));
997 974
998 // With no navigation corrections to load, there's only one navigation. 975 // With no navigation corrections to load, there's only one navigation.
999 ui_test_utils::NavigateToURL(browser(), test_url); 976 ui_test_utils::NavigateToURL(browser(), test_url);
1000 EXPECT_TRUE(ProbeStaleCopyValue(true)); 977 EXPECT_TRUE(ProbeStaleCopyValue(true));
1001 EXPECT_TRUE(IsDisplayingText(browser(), GetShowSavedButtonLabel())); 978 EXPECT_TRUE(errorpage_test_util::IsDisplayingText(browser(),
979 GetShowSavedButtonLabel()));
1002 EXPECT_NE(base::ASCIIToUTF16("Nocache Test Page"), 980 EXPECT_NE(base::ASCIIToUTF16("Nocache Test Page"),
1003 browser()->tab_strip_model()->GetActiveWebContents()->GetTitle()); 981 browser()->tab_strip_model()->GetActiveWebContents()->GetTitle());
1004 982
1005 // Confirm that loading the stale copy from the cache works. 983 // Confirm that loading the stale copy from the cache works.
1006 content::TestNavigationObserver same_tab_observer( 984 content::TestNavigationObserver same_tab_observer(
1007 browser()->tab_strip_model()->GetActiveWebContents(), 1); 985 browser()->tab_strip_model()->GetActiveWebContents(), 1);
1008 ASSERT_TRUE(ReloadStaleCopyFromCache()); 986 ASSERT_TRUE(ReloadStaleCopyFromCache());
1009 same_tab_observer.Wait(); 987 same_tab_observer.Wait();
1010 EXPECT_EQ(base::ASCIIToUTF16("Nocache Test Page"), 988 EXPECT_EQ(base::ASCIIToUTF16("Nocache Test Page"),
1011 browser()->tab_strip_model()->GetActiveWebContents()->GetTitle()); 989 browser()->tab_strip_model()->GetActiveWebContents()->GetTitle());
1012 990
1013 // Reload the same URL with a post request; confirm the error page is told 991 // Reload the same URL with a post request; confirm the error page is told
1014 // that there is no cached copy. 992 // that there is no cached copy.
1015 ui_test_utils::NavigateToURLWithPost(browser(), test_url); 993 ui_test_utils::NavigateToURLWithPost(browser(), test_url);
1016 EXPECT_TRUE(ProbeStaleCopyValue(false)); 994 EXPECT_TRUE(ProbeStaleCopyValue(false));
1017 EXPECT_FALSE(IsDisplayingText(browser(), GetShowSavedButtonLabel())); 995 EXPECT_FALSE(errorpage_test_util::IsDisplayingText(
996 browser(), GetShowSavedButtonLabel()));
1018 EXPECT_EQ(0, link_doctor_interceptor()->num_requests()); 997 EXPECT_EQ(0, link_doctor_interceptor()->num_requests());
1019 998
1020 // Clear the cache and reload the same URL; confirm the error page is told 999 // Clear the cache and reload the same URL; confirm the error page is told
1021 // that there is no cached copy. 1000 // that there is no cached copy.
1022 content::BrowsingDataRemover* remover = 1001 content::BrowsingDataRemover* remover =
1023 content::BrowserContext::GetBrowsingDataRemover(browser()->profile()); 1002 content::BrowserContext::GetBrowsingDataRemover(browser()->profile());
1024 remover->Remove(base::Time(), base::Time::Max(), 1003 remover->Remove(base::Time(), base::Time::Max(),
1025 content::BrowsingDataRemover::DATA_TYPE_CACHE, 1004 content::BrowsingDataRemover::DATA_TYPE_CACHE,
1026 content::BrowsingDataRemover::ORIGIN_TYPE_UNPROTECTED_WEB); 1005 content::BrowsingDataRemover::ORIGIN_TYPE_UNPROTECTED_WEB);
1027 ui_test_utils::NavigateToURL(browser(), test_url); 1006 ui_test_utils::NavigateToURL(browser(), test_url);
1028 EXPECT_TRUE(ProbeStaleCopyValue(false)); 1007 EXPECT_TRUE(ProbeStaleCopyValue(false));
1029 EXPECT_FALSE(IsDisplayingText(browser(), GetShowSavedButtonLabel())); 1008 EXPECT_FALSE(errorpage_test_util::IsDisplayingText(
1009 browser(), GetShowSavedButtonLabel()));
1030 EXPECT_EQ(0, link_doctor_interceptor()->num_requests()); 1010 EXPECT_EQ(0, link_doctor_interceptor()->num_requests());
1031 } 1011 }
1032 1012
1033 // Check that the easter egg is present and initialised and is not disabled. 1013 // Check that the easter egg is present and initialised and is not disabled.
1034 IN_PROC_BROWSER_TEST_F(ErrorPageTest, CheckEasterEggIsNotDisabled) { 1014 IN_PROC_BROWSER_TEST_F(ErrorPageTest, CheckEasterEggIsNotDisabled) {
1035 ui_test_utils::NavigateToURL(browser(), 1015 ui_test_utils::NavigateToURL(browser(),
1036 URLRequestFailedJob::GetMockHttpUrl(net::ERR_INTERNET_DISCONNECTED)); 1016 URLRequestFailedJob::GetMockHttpUrl(net::ERR_INTERNET_DISCONNECTED));
1037 1017
1038 content::WebContents* web_contents = 1018 content::WebContents* web_contents =
1039 browser()->tab_strip_model()->GetActiveWebContents(); 1019 browser()->tab_strip_model()->GetActiveWebContents();
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
1123 GURL test_url("http://error.page.auto.reload"); 1103 GURL test_url("http://error.page.auto.reload");
1124 const int kRequestsToFail = 3; 1104 const int kRequestsToFail = 3;
1125 InstallInterceptor(test_url, kRequestsToFail); 1105 InstallInterceptor(test_url, kRequestsToFail);
1126 ui_test_utils::NavigateToURLBlockUntilNavigationsComplete( 1106 ui_test_utils::NavigateToURLBlockUntilNavigationsComplete(
1127 browser(), test_url, 2); 1107 browser(), test_url, 2);
1128 1108
1129 EXPECT_EQ(2, interceptor()->failures()); 1109 EXPECT_EQ(2, interceptor()->failures());
1130 EXPECT_EQ(2, interceptor()->requests()); 1110 EXPECT_EQ(2, interceptor()->requests());
1131 1111
1132 ToggleHelpBox(browser()); 1112 ToggleHelpBox(browser());
1133 EXPECT_TRUE(IsDisplayingText( 1113 EXPECT_TRUE(errorpage_test_util::IsDisplayingText(
1134 browser(), l10n_util::GetStringUTF8( 1114 browser(), l10n_util::GetStringUTF8(
1135 IDS_ERRORPAGES_SUGGESTION_CHECK_CONNECTION_HEADER))); 1115 IDS_ERRORPAGES_SUGGESTION_CHECK_CONNECTION_HEADER)));
1136 1116
1137 content::WebContents* web_contents = 1117 content::WebContents* web_contents =
1138 browser()->tab_strip_model()->GetActiveWebContents(); 1118 browser()->tab_strip_model()->GetActiveWebContents();
1139 content::TestNavigationObserver nav_observer(web_contents, 1); 1119 content::TestNavigationObserver nav_observer(web_contents, 1);
1140 web_contents->GetMainFrame()->ExecuteJavaScriptForTests( 1120 web_contents->GetMainFrame()->ExecuteJavaScriptForTests(
1141 base::ASCIIToUTF16("document.getElementById('reload-button').click();")); 1121 base::ASCIIToUTF16("document.getElementById('reload-button').click();"));
1142 nav_observer.Wait(); 1122 nav_observer.Wait();
1143 EXPECT_FALSE(IsDisplayingText( 1123 EXPECT_FALSE(errorpage_test_util::IsDisplayingText(
1144 browser(), l10n_util::GetStringUTF8( 1124 browser(), l10n_util::GetStringUTF8(
1145 IDS_ERRORPAGES_SUGGESTION_CHECK_CONNECTION_HEADER))); 1125 IDS_ERRORPAGES_SUGGESTION_CHECK_CONNECTION_HEADER)));
1146 } 1126 }
1147 1127
1148 // Make sure that a same document navigation does not cause issues with the 1128 // Make sure that a same document navigation does not cause issues with the
1149 // auto-reload timer. Note that this test was added due to this case causing 1129 // auto-reload timer. Note that this test was added due to this case causing
1150 // a crash. On regression, this test may hang due to a crashed renderer. 1130 // a crash. On regression, this test may hang due to a crashed renderer.
1151 IN_PROC_BROWSER_TEST_F(ErrorPageAutoReloadTest, IgnoresSameDocumentNavigation) { 1131 IN_PROC_BROWSER_TEST_F(ErrorPageAutoReloadTest, IgnoresSameDocumentNavigation) {
1152 GURL test_url("http://error.page.auto.reload"); 1132 GURL test_url("http://error.page.auto.reload");
1153 InstallInterceptor(test_url, 2); 1133 InstallInterceptor(test_url, 2);
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
1273 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter = 1253 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter =
1274 browser()->profile()->GetRequestContext(); 1254 browser()->profile()->GetRequestContext();
1275 BrowserThread::PostTask( 1255 BrowserThread::PostTask(
1276 BrowserThread::IO, FROM_HERE, 1256 BrowserThread::IO, FROM_HERE,
1277 base::BindOnce(&InterceptNetworkTransactions, 1257 base::BindOnce(&InterceptNetworkTransactions,
1278 base::RetainedRef(url_request_context_getter), 1258 base::RetainedRef(url_request_context_getter),
1279 net::ERR_CONNECTION_FAILED)); 1259 net::ERR_CONNECTION_FAILED));
1280 1260
1281 ui_test_utils::NavigateToURLBlockUntilNavigationsComplete( 1261 ui_test_utils::NavigateToURLBlockUntilNavigationsComplete(
1282 browser(), test_url, 2); 1262 browser(), test_url, 2);
1283 EXPECT_TRUE(IsDisplayingText(browser(), GetShowSavedButtonLabel())); 1263 EXPECT_TRUE(errorpage_test_util::IsDisplayingText(browser(),
1264 GetShowSavedButtonLabel()));
1284 EXPECT_TRUE(ProbeStaleCopyValue(true)); 1265 EXPECT_TRUE(ProbeStaleCopyValue(true));
1285 1266
1286 // Confirm that loading the stale copy from the cache works. 1267 // Confirm that loading the stale copy from the cache works.
1287 content::TestNavigationObserver same_tab_observer( 1268 content::TestNavigationObserver same_tab_observer(
1288 browser()->tab_strip_model()->GetActiveWebContents(), 1); 1269 browser()->tab_strip_model()->GetActiveWebContents(), 1);
1289 ASSERT_TRUE(ReloadStaleCopyFromCache()); 1270 ASSERT_TRUE(ReloadStaleCopyFromCache());
1290 same_tab_observer.Wait(); 1271 same_tab_observer.Wait();
1291 EXPECT_EQ(base::ASCIIToUTF16("Nocache Test Page"), 1272 EXPECT_EQ(base::ASCIIToUTF16("Nocache Test Page"),
1292 browser()->tab_strip_model()->GetActiveWebContents()->GetTitle()); 1273 browser()->tab_strip_model()->GetActiveWebContents()->GetTitle());
1293 1274
1294 // Clear the cache and reload the same URL; confirm the error page is told 1275 // Clear the cache and reload the same URL; confirm the error page is told
1295 // that there is no cached copy. 1276 // that there is no cached copy.
1296 content::BrowsingDataRemover* remover = 1277 content::BrowsingDataRemover* remover =
1297 content::BrowserContext::GetBrowsingDataRemover(browser()->profile()); 1278 content::BrowserContext::GetBrowsingDataRemover(browser()->profile());
1298 remover->Remove(base::Time(), base::Time::Max(), 1279 remover->Remove(base::Time(), base::Time::Max(),
1299 content::BrowsingDataRemover::DATA_TYPE_CACHE, 1280 content::BrowsingDataRemover::DATA_TYPE_CACHE,
1300 content::BrowsingDataRemover::ORIGIN_TYPE_UNPROTECTED_WEB); 1281 content::BrowsingDataRemover::ORIGIN_TYPE_UNPROTECTED_WEB);
1301 ui_test_utils::NavigateToURLBlockUntilNavigationsComplete( 1282 ui_test_utils::NavigateToURLBlockUntilNavigationsComplete(
1302 browser(), test_url, 2); 1283 browser(), test_url, 2);
1303 EXPECT_TRUE(ProbeStaleCopyValue(false)); 1284 EXPECT_TRUE(ProbeStaleCopyValue(false));
1304 EXPECT_FALSE(IsDisplayingText(browser(), GetShowSavedButtonLabel())); 1285 EXPECT_FALSE(errorpage_test_util::IsDisplayingText(
1286 browser(), GetShowSavedButtonLabel()));
1305 } 1287 }
1306 1288
1307 class ErrorPageOfflineTest : public ErrorPageTest { 1289 class ErrorPageOfflineTest : public ErrorPageTest {
1308 protected: 1290 protected:
1309 1291
1310 void SetUpInProcessBrowserTestFixture() override { 1292 void SetUpInProcessBrowserTestFixture() override {
1311 #if defined(OS_CHROMEOS) 1293 #if defined(OS_CHROMEOS)
1312 if (enroll_) { 1294 if (enroll_) {
1313 // Set up fake install attributes. 1295 // Set up fake install attributes.
1314 std::unique_ptr<chromeos::StubInstallAttributes> attributes = 1296 std::unique_ptr<chromeos::StubInstallAttributes> attributes =
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
1497 "\\u043f\\u0440\\u0435\\u0437\\u0438\\u0434\\u0435\\u043d\\u0442." 1479 "\\u043f\\u0440\\u0435\\u0437\\u0438\\u0434\\u0435\\u043d\\u0442."
1498 "\\u0440\\u0444"; 1480 "\\u0440\\u0444";
1499 1481
1500 // Make sure error page shows correct unicode for IDN. 1482 // Make sure error page shows correct unicode for IDN.
1501 IN_PROC_BROWSER_TEST_F(ErrorPageForIDNTest, IDN) { 1483 IN_PROC_BROWSER_TEST_F(ErrorPageForIDNTest, IDN) {
1502 // ERR_UNSAFE_PORT will not trigger navigation corrections. 1484 // ERR_UNSAFE_PORT will not trigger navigation corrections.
1503 ui_test_utils::NavigateToURL( 1485 ui_test_utils::NavigateToURL(
1504 browser(), 1486 browser(),
1505 URLRequestFailedJob::GetMockHttpUrlForHostname(net::ERR_UNSAFE_PORT, 1487 URLRequestFailedJob::GetMockHttpUrlForHostname(net::ERR_UNSAFE_PORT,
1506 kHostname)); 1488 kHostname));
1507 EXPECT_TRUE(IsDisplayingText(browser(), kHostnameJSUnicode)); 1489 EXPECT_TRUE(
1490 errorpage_test_util::IsDisplayingText(browser(), kHostnameJSUnicode));
1508 } 1491 }
1509 1492
1510 // Make sure HTTP/0.9 is disabled on non-default ports by default. 1493 // Make sure HTTP/0.9 is disabled on non-default ports by default.
1511 IN_PROC_BROWSER_TEST_F(ErrorPageTest, Http09WeirdPort) { 1494 IN_PROC_BROWSER_TEST_F(ErrorPageTest, Http09WeirdPort) {
1512 ASSERT_TRUE(embedded_test_server()->Start()); 1495 ASSERT_TRUE(embedded_test_server()->Start());
1513 ui_test_utils::NavigateToURL( 1496 ui_test_utils::NavigateToURL(
1514 browser(), embedded_test_server()->GetURL("/echo-raw?spam")); 1497 browser(), embedded_test_server()->GetURL("/echo-raw?spam"));
1515 ExpectDisplayingLocalErrorPage(browser(), net::ERR_INVALID_HTTP_RESPONSE); 1498 ExpectDisplayingLocalErrorPage(browser(), net::ERR_INVALID_HTTP_RESPONSE);
1516 } 1499 }
1517 1500
(...skipping 20 matching lines...) Expand all
1538 }; 1521 };
1539 1522
1540 // Make sure HTTP/0.9 works on non-default ports when enabled by policy. 1523 // Make sure HTTP/0.9 works on non-default ports when enabled by policy.
1541 IN_PROC_BROWSER_TEST_F(ErrorPageWithHttp09OnNonDefaultPortsTest, 1524 IN_PROC_BROWSER_TEST_F(ErrorPageWithHttp09OnNonDefaultPortsTest,
1542 Http09WeirdPortEnabled) { 1525 Http09WeirdPortEnabled) {
1543 const char kHttp09Response[] = "JumboShrimp"; 1526 const char kHttp09Response[] = "JumboShrimp";
1544 ASSERT_TRUE(embedded_test_server()->Start()); 1527 ASSERT_TRUE(embedded_test_server()->Start());
1545 ui_test_utils::NavigateToURL( 1528 ui_test_utils::NavigateToURL(
1546 browser(), embedded_test_server()->GetURL(std::string("/echo-raw?") + 1529 browser(), embedded_test_server()->GetURL(std::string("/echo-raw?") +
1547 kHttp09Response)); 1530 kHttp09Response));
1548 EXPECT_TRUE(IsDisplayingText(browser(), kHttp09Response)); 1531 EXPECT_TRUE(
1532 errorpage_test_util::IsDisplayingText(browser(), kHttp09Response));
1549 } 1533 }
1550 1534
1551 } // namespace 1535 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698