| 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 <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/values.h" | |
| 21 #include "build/build_config.h" | 20 #include "build/build_config.h" |
| 22 #include "chrome/browser/browsing_data/browsing_data_helper.h" | 21 #include "chrome/browser/browsing_data/browsing_data_helper.h" |
| 23 #include "chrome/browser/browsing_data/browsing_data_remover.h" | 22 #include "chrome/browser/browsing_data/browsing_data_remover.h" |
| 24 #include "chrome/browser/browsing_data/browsing_data_remover_factory.h" | 23 #include "chrome/browser/browsing_data/browsing_data_remover_factory.h" |
| 25 #include "chrome/browser/net/net_error_diagnostics_dialog.h" | 24 #include "chrome/browser/net/net_error_diagnostics_dialog.h" |
| 26 #include "chrome/browser/net/url_request_mock_util.h" | 25 #include "chrome/browser/net/url_request_mock_util.h" |
| 27 #include "chrome/browser/profiles/profile.h" | 26 #include "chrome/browser/profiles/profile.h" |
| 28 #include "chrome/browser/search_engines/ui_thread_search_terms_data.h" | 27 #include "chrome/browser/search_engines/ui_thread_search_terms_data.h" |
| 29 #include "chrome/browser/ui/browser.h" | 28 #include "chrome/browser/ui/browser.h" |
| 30 #include "chrome/browser/ui/browser_commands.h" | 29 #include "chrome/browser/ui/browser_commands.h" |
| 31 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 30 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 32 #include "chrome/common/chrome_paths.h" | 31 #include "chrome/common/chrome_paths.h" |
| 33 #include "chrome/common/chrome_switches.h" | 32 #include "chrome/common/chrome_switches.h" |
| 34 #include "chrome/common/pref_names.h" | 33 #include "chrome/common/pref_names.h" |
| 35 #include "chrome/test/base/in_process_browser_test.h" | 34 #include "chrome/test/base/in_process_browser_test.h" |
| 36 #include "chrome/test/base/ui_test_utils.h" | 35 #include "chrome/test/base/ui_test_utils.h" |
| 37 #include "components/error_page/common/error_page_switches.h" | 36 #include "components/error_page/common/error_page_switches.h" |
| 38 #include "components/google/core/browser/google_util.h" | 37 #include "components/google/core/browser/google_util.h" |
| 39 #include "components/policy/core/browser/browser_policy_connector.h" | |
| 40 #include "components/policy/core/common/mock_configuration_policy_provider.h" | |
| 41 #include "components/policy/core/common/policy_map.h" | |
| 42 #include "components/policy/policy_constants.h" | 38 #include "components/policy/policy_constants.h" |
| 43 #include "components/prefs/pref_service.h" | 39 #include "components/prefs/pref_service.h" |
| 44 #include "components/strings/grit/components_strings.h" | 40 #include "components/strings/grit/components_strings.h" |
| 45 #include "content/public/browser/browser_thread.h" | 41 #include "content/public/browser/browser_thread.h" |
| 46 #include "content/public/browser/notification_service.h" | 42 #include "content/public/browser/notification_service.h" |
| 47 #include "content/public/browser/notification_types.h" | 43 #include "content/public/browser/notification_types.h" |
| 48 #include "content/public/browser/render_frame_host.h" | 44 #include "content/public/browser/render_frame_host.h" |
| 49 #include "content/public/browser/render_view_host.h" | 45 #include "content/public/browser/render_view_host.h" |
| 50 #include "content/public/browser/web_contents.h" | 46 #include "content/public/browser/web_contents.h" |
| 51 #include "content/public/browser/web_contents_observer.h" | 47 #include "content/public/browser/web_contents_observer.h" |
| (...skipping 1439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1491 // Make sure error page shows correct unicode for IDN. | 1487 // Make sure error page shows correct unicode for IDN. |
| 1492 IN_PROC_BROWSER_TEST_F(ErrorPageForIDNTest, IDN) { | 1488 IN_PROC_BROWSER_TEST_F(ErrorPageForIDNTest, IDN) { |
| 1493 // ERR_UNSAFE_PORT will not trigger navigation corrections. | 1489 // ERR_UNSAFE_PORT will not trigger navigation corrections. |
| 1494 ui_test_utils::NavigateToURL( | 1490 ui_test_utils::NavigateToURL( |
| 1495 browser(), | 1491 browser(), |
| 1496 URLRequestFailedJob::GetMockHttpUrlForHostname(net::ERR_UNSAFE_PORT, | 1492 URLRequestFailedJob::GetMockHttpUrlForHostname(net::ERR_UNSAFE_PORT, |
| 1497 kHostname)); | 1493 kHostname)); |
| 1498 EXPECT_TRUE(IsDisplayingText(browser(), kHostnameJSUnicode)); | 1494 EXPECT_TRUE(IsDisplayingText(browser(), kHostnameJSUnicode)); |
| 1499 } | 1495 } |
| 1500 | 1496 |
| 1501 // Make sure HTTP/0.9 is disabled on non-default ports by default. | |
| 1502 IN_PROC_BROWSER_TEST_F(ErrorPageTest, Http09WeirdPort) { | |
| 1503 ASSERT_TRUE(embedded_test_server()->Start()); | |
| 1504 ui_test_utils::NavigateToURL( | |
| 1505 browser(), embedded_test_server()->GetURL("/echo-raw?spam")); | |
| 1506 ExpectDisplayingLocalErrorPage(browser(), net::ERR_INVALID_HTTP_RESPONSE); | |
| 1507 } | |
| 1508 | |
| 1509 class ErrorPageWithHttp09OnNonDefaultPortsTest : public InProcessBrowserTest { | |
| 1510 public: | |
| 1511 // InProcessBrowserTest: | |
| 1512 void SetUp() override { | |
| 1513 EXPECT_CALL(policy_provider_, IsInitializationComplete(testing::_)) | |
| 1514 .WillRepeatedly(testing::Return(true)); | |
| 1515 policy::PolicyMap values; | |
| 1516 values.Set(policy::key::kHttp09OnNonDefaultPortsEnabled, | |
| 1517 policy::POLICY_LEVEL_MANDATORY, policy::POLICY_SCOPE_MACHINE, | |
| 1518 policy::POLICY_SOURCE_CLOUD, | |
| 1519 base::WrapUnique(new base::FundamentalValue(true)), nullptr); | |
| 1520 policy_provider_.UpdateChromePolicy(values); | |
| 1521 policy::BrowserPolicyConnector::SetPolicyProviderForTesting( | |
| 1522 &policy_provider_); | |
| 1523 | |
| 1524 InProcessBrowserTest::SetUp(); | |
| 1525 } | |
| 1526 | |
| 1527 private: | |
| 1528 policy::MockConfigurationPolicyProvider policy_provider_; | |
| 1529 }; | |
| 1530 | |
| 1531 // Make sure HTTP/0.9 works on non-default ports when enabled by policy. | |
| 1532 IN_PROC_BROWSER_TEST_F(ErrorPageWithHttp09OnNonDefaultPortsTest, | |
| 1533 Http09WeirdPortEnabled) { | |
| 1534 const char kHttp09Response[] = "JumboShrimp"; | |
| 1535 ASSERT_TRUE(embedded_test_server()->Start()); | |
| 1536 ui_test_utils::NavigateToURL( | |
| 1537 browser(), embedded_test_server()->GetURL(std::string("/echo-raw?") + | |
| 1538 kHttp09Response)); | |
| 1539 EXPECT_TRUE(IsDisplayingText(browser(), kHttp09Response)); | |
| 1540 } | |
| 1541 | |
| 1542 } // namespace | 1497 } // namespace |
| OLD | NEW |