Chromium Code Reviews| 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 <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 Loading... | |
| 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; |
| 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. | |
| 380 title = base::UTF8ToUTF16(url.spec()); | |
|
mmenke
2016/08/08 14:23:49
Use braces on if / else bodies, when one of them t
| |
| 377 EXPECT_NE(title, contents->GetTitle()); | 381 EXPECT_NE(title, contents->GetTitle()); |
| 378 } | 382 } |
| 379 | 383 |
| 380 // Verifies that access to the given url |spec| is blocked. | 384 // Verifies that access to the given url |spec| is blocked. |
| 381 void CheckURLIsBlocked(Browser* browser, const char* spec) { | 385 void CheckURLIsBlocked(Browser* browser, const char* spec) { |
| 382 GURL url(spec); | 386 GURL url(spec); |
| 383 ui_test_utils::NavigateToURL(browser, url); | 387 ui_test_utils::NavigateToURL(browser, url); |
| 384 content::WebContents* contents = | 388 content::WebContents* contents = |
| 385 browser->tab_strip_model()->GetActiveWebContents(); | 389 browser->tab_strip_model()->GetActiveWebContents(); |
| 386 EXPECT_EQ(url, contents->GetURL()); | 390 EXPECT_EQ(url, contents->GetURL()); |
| 387 base::string16 spec16 = base::UTF8ToUTF16(url.spec()); | 391 |
| 388 base::string16 title = | 392 base::string16 title; |
| 389 l10n_util::GetStringFUTF16(IDS_ERRORPAGES_TITLE_BLOCKED, spec16); | 393 if (url.has_host()) |
| 394 title = base::UTF8ToUTF16(url.host()); | |
| 395 else | |
| 396 // Local file paths show the full URL. | |
| 397 title = base::UTF8ToUTF16(url.spec()); | |
|
mmenke
2016/08/08 14:23:49
Use braces
| |
| 390 EXPECT_EQ(title, contents->GetTitle()); | 398 EXPECT_EQ(title, contents->GetTitle()); |
| 391 | 399 |
| 392 // Verify that the expected error page is being displayed. | 400 // Verify that the expected error page is being displayed. |
| 393 bool result = false; | 401 bool result = false; |
| 394 EXPECT_TRUE(content::ExecuteScriptAndExtractBool( | 402 EXPECT_TRUE(content::ExecuteScriptAndExtractBool( |
| 395 contents, | 403 contents, |
| 396 "var textContent = document.body.textContent;" | 404 "var textContent = document.body.textContent;" |
| 397 "var hasError = textContent.indexOf('ERR_BLOCKED_BY_ADMINISTRATOR') >= 0;" | 405 "var hasError = textContent.indexOf('ERR_BLOCKED_BY_ADMINISTRATOR') >= 0;" |
| 398 "domAutomationController.send(hasError);", | 406 "domAutomationController.send(hasError);", |
| 399 &result)); | 407 &result)); |
| (...skipping 3723 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4123 | 4131 |
| 4124 SetEmptyPolicy(); | 4132 SetEmptyPolicy(); |
| 4125 // Policy not set. | 4133 // Policy not set. |
| 4126 CheckSystemTimezoneAutomaticDetectionPolicyUnset(); | 4134 CheckSystemTimezoneAutomaticDetectionPolicyUnset(); |
| 4127 EXPECT_TRUE(CheckResolveTimezoneByGeolocation(true, false)); | 4135 EXPECT_TRUE(CheckResolveTimezoneByGeolocation(true, false)); |
| 4128 EXPECT_TRUE(manager->TimeZoneResolverShouldBeRunningForTests()); | 4136 EXPECT_TRUE(manager->TimeZoneResolverShouldBeRunningForTests()); |
| 4129 } | 4137 } |
| 4130 #endif // defined(OS_CHROMEOS) | 4138 #endif // defined(OS_CHROMEOS) |
| 4131 | 4139 |
| 4132 } // namespace policy | 4140 } // namespace policy |
| OLD | NEW |