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

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: Fix merge conflict 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 359 matching lines...) Expand 10 before | Expand all | Expand 10 after
370 }; 370 };
371 371
372 // Verifies that the given url |spec| can be opened. This assumes that |spec| 372 // Verifies that the given url |spec| can be opened. This assumes that |spec|
373 // points at empty.html in the test data dir. 373 // points at empty.html in the test data dir.
374 void CheckCanOpenURL(Browser* browser, const char* spec) { 374 void CheckCanOpenURL(Browser* browser, const char* spec) {
375 GURL url(spec); 375 GURL url(spec);
376 ui_test_utils::NavigateToURL(browser, url); 376 ui_test_utils::NavigateToURL(browser, url);
377 content::WebContents* contents = 377 content::WebContents* contents =
378 browser->tab_strip_model()->GetActiveWebContents(); 378 browser->tab_strip_model()->GetActiveWebContents();
379 EXPECT_EQ(url, contents->GetURL()); 379 EXPECT_EQ(url, contents->GetURL());
380 base::string16 spec16 = base::UTF8ToUTF16(url.spec()); 380
381 base::string16 title = 381 base::string16 blocked_page_title;
382 l10n_util::GetStringFUTF16(IDS_ERRORPAGES_TITLE_BLOCKED, spec16); 382 if (url.has_host()) {
383 EXPECT_NE(title, contents->GetTitle()); 383 blocked_page_title = base::UTF8ToUTF16(url.host());
384 } else {
385 // Local file paths show the full URL.
386 blocked_page_title = base::UTF8ToUTF16(url.spec());
387 }
388 EXPECT_NE(blocked_page_title, contents->GetTitle());
384 } 389 }
385 390
386 // Verifies that access to the given url |spec| is blocked. 391 // Verifies that access to the given url |spec| is blocked.
387 void CheckURLIsBlocked(Browser* browser, const char* spec) { 392 void CheckURLIsBlocked(Browser* browser, const char* spec) {
388 GURL url(spec); 393 GURL url(spec);
389 ui_test_utils::NavigateToURL(browser, url); 394 ui_test_utils::NavigateToURL(browser, url);
390 content::WebContents* contents = 395 content::WebContents* contents =
391 browser->tab_strip_model()->GetActiveWebContents(); 396 browser->tab_strip_model()->GetActiveWebContents();
392 EXPECT_EQ(url, contents->GetURL()); 397 EXPECT_EQ(url, contents->GetURL());
393 base::string16 spec16 = base::UTF8ToUTF16(url.spec()); 398
394 base::string16 title = 399 base::string16 blocked_page_title;
395 l10n_util::GetStringFUTF16(IDS_ERRORPAGES_TITLE_BLOCKED, spec16); 400 if (url.has_host()) {
396 EXPECT_EQ(title, contents->GetTitle()); 401 blocked_page_title = base::UTF8ToUTF16(url.host());
402 } else {
403 // Local file paths show the full URL.
404 blocked_page_title = base::UTF8ToUTF16(url.spec());
405 }
406 EXPECT_EQ(blocked_page_title, contents->GetTitle());
397 407
398 // Verify that the expected error page is being displayed. 408 // Verify that the expected error page is being displayed.
399 bool result = false; 409 bool result = false;
400 EXPECT_TRUE(content::ExecuteScriptAndExtractBool( 410 EXPECT_TRUE(content::ExecuteScriptAndExtractBool(
401 contents, 411 contents,
402 "var textContent = document.body.textContent;" 412 "var textContent = document.body.textContent;"
403 "var hasError = textContent.indexOf('ERR_BLOCKED_BY_ADMINISTRATOR') >= 0;" 413 "var hasError = textContent.indexOf('ERR_BLOCKED_BY_ADMINISTRATOR') >= 0;"
404 "domAutomationController.send(hasError);", 414 "domAutomationController.send(hasError);",
405 &result)); 415 &result));
406 EXPECT_TRUE(result); 416 EXPECT_TRUE(result);
(...skipping 3770 matching lines...) Expand 10 before | Expand all | Expand 10 after
4177 4187
4178 SetEmptyPolicy(); 4188 SetEmptyPolicy();
4179 // Policy not set. 4189 // Policy not set.
4180 CheckSystemTimezoneAutomaticDetectionPolicyUnset(); 4190 CheckSystemTimezoneAutomaticDetectionPolicyUnset();
4181 EXPECT_TRUE(CheckResolveTimezoneByGeolocation(true, false)); 4191 EXPECT_TRUE(CheckResolveTimezoneByGeolocation(true, false));
4182 EXPECT_TRUE(manager->TimeZoneResolverShouldBeRunningForTests()); 4192 EXPECT_TRUE(manager->TimeZoneResolverShouldBeRunningForTests());
4183 } 4193 }
4184 #endif // defined(OS_CHROMEOS) 4194 #endif // defined(OS_CHROMEOS)
4185 4195
4186 } // namespace policy 4196 } // 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