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

Side by Side Diff: chrome/browser/policy/policy_browsertest.cc

Issue 2214393003: Change network error titles to just the hostname (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add missing braces Created 4 years, 4 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 <stddef.h> 5 #include <stddef.h>
6 #include <stdint.h> 6 #include <stdint.h>
7 7
8 #include <algorithm> 8 #include <algorithm>
9 #include <memory> 9 #include <memory>
10 #include <string> 10 #include <string>
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after
364 }; 364 };
365 365
366 // Verifies that the given url |spec| can be opened. This assumes that |spec| 366 // Verifies that the given url |spec| can be opened. This assumes that |spec|
367 // points at empty.html in the test data dir. 367 // points at empty.html in the test data dir.
368 void CheckCanOpenURL(Browser* browser, const char* spec) { 368 void CheckCanOpenURL(Browser* browser, const char* spec) {
369 GURL url(spec); 369 GURL url(spec);
370 ui_test_utils::NavigateToURL(browser, url); 370 ui_test_utils::NavigateToURL(browser, url);
371 content::WebContents* contents = 371 content::WebContents* contents =
372 browser->tab_strip_model()->GetActiveWebContents(); 372 browser->tab_strip_model()->GetActiveWebContents();
373 EXPECT_EQ(url, contents->GetURL()); 373 EXPECT_EQ(url, contents->GetURL());
374 base::string16 spec16 = base::UTF8ToUTF16(url.spec()); 374
375 base::string16 title = 375 base::string16 title;
Thiemo Nagel 2016/08/09 18:24:58 To make this more understandable, could you maybe
376 l10n_util::GetStringFUTF16(IDS_ERRORPAGES_TITLE_BLOCKED, spec16); 376 if (url.has_host()) {
377 title = base::UTF8ToUTF16(url.host());
378 } else {
379 // Local file paths show the full URL.
Thiemo Nagel 2016/08/09 18:24:57 Nit: Please drop duplicate blank.
380 title = base::UTF8ToUTF16(url.spec());
381 }
377 EXPECT_NE(title, contents->GetTitle()); 382 EXPECT_NE(title, contents->GetTitle());
378 } 383 }
379 384
380 // Verifies that access to the given url |spec| is blocked. 385 // Verifies that access to the given url |spec| is blocked.
381 void CheckURLIsBlocked(Browser* browser, const char* spec) { 386 void CheckURLIsBlocked(Browser* browser, const char* spec) {
382 GURL url(spec); 387 GURL url(spec);
383 ui_test_utils::NavigateToURL(browser, url); 388 ui_test_utils::NavigateToURL(browser, url);
384 content::WebContents* contents = 389 content::WebContents* contents =
385 browser->tab_strip_model()->GetActiveWebContents(); 390 browser->tab_strip_model()->GetActiveWebContents();
386 EXPECT_EQ(url, contents->GetURL()); 391 EXPECT_EQ(url, contents->GetURL());
387 base::string16 spec16 = base::UTF8ToUTF16(url.spec()); 392
388 base::string16 title = 393 base::string16 title;
Thiemo Nagel 2016/08/09 18:24:57 Same as above.
389 l10n_util::GetStringFUTF16(IDS_ERRORPAGES_TITLE_BLOCKED, spec16); 394 if (url.has_host()) {
395 title = base::UTF8ToUTF16(url.host());
396 } else {
397 // Local file paths show the full URL.
Thiemo Nagel 2016/08/09 18:24:58 Nit: Please drop duplicate blank.
398 title = base::UTF8ToUTF16(url.spec());
399 }
390 EXPECT_EQ(title, contents->GetTitle()); 400 EXPECT_EQ(title, contents->GetTitle());
391 401
392 // Verify that the expected error page is being displayed. 402 // Verify that the expected error page is being displayed.
393 bool result = false; 403 bool result = false;
394 EXPECT_TRUE(content::ExecuteScriptAndExtractBool( 404 EXPECT_TRUE(content::ExecuteScriptAndExtractBool(
395 contents, 405 contents,
396 "var textContent = document.body.textContent;" 406 "var textContent = document.body.textContent;"
397 "var hasError = textContent.indexOf('ERR_BLOCKED_BY_ADMINISTRATOR') >= 0;" 407 "var hasError = textContent.indexOf('ERR_BLOCKED_BY_ADMINISTRATOR') >= 0;"
398 "domAutomationController.send(hasError);", 408 "domAutomationController.send(hasError);",
399 &result)); 409 &result));
(...skipping 3723 matching lines...) Expand 10 before | Expand all | Expand 10 after
4123 4133
4124 SetEmptyPolicy(); 4134 SetEmptyPolicy();
4125 // Policy not set. 4135 // Policy not set.
4126 CheckSystemTimezoneAutomaticDetectionPolicyUnset(); 4136 CheckSystemTimezoneAutomaticDetectionPolicyUnset();
4127 EXPECT_TRUE(CheckResolveTimezoneByGeolocation(true, false)); 4137 EXPECT_TRUE(CheckResolveTimezoneByGeolocation(true, false));
4128 EXPECT_TRUE(manager->TimeZoneResolverShouldBeRunningForTests()); 4138 EXPECT_TRUE(manager->TimeZoneResolverShouldBeRunningForTests());
4129 } 4139 }
4130 #endif // defined(OS_CHROMEOS) 4140 #endif // defined(OS_CHROMEOS)
4131 4141
4132 } // namespace policy 4142 } // namespace policy
OLDNEW
« no previous file with comments | « chrome/browser/content_settings/content_settings_browsertest.cc ('k') | components/error_page/common/localized_error.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698