diff --git a/libcef/browser/test/test_helpers_impl.cc b/libcef/browser/test/test_helpers_impl.cc index 2f018844f..924d1abd4 100644 --- a/libcef/browser/test/test_helpers_impl.cc +++ b/libcef/browser/test/test_helpers_impl.cc @@ -7,6 +7,7 @@ #include "base/files/file_path.h" #include "base/path_service.h" #include "cef/include/test/cef_test_helpers.h" +#include "net/base/features.h" #include "services/network/public/cpp/features.h" void CefSetDataDirectoryForTests(const CefString& dir) { @@ -18,6 +19,7 @@ void CefSetDataDirectoryForTests(const CefString& dir) { bool CefIsFeatureEnabledForTests(const CefString& feature_name) { // Only includes values that are queried by unit tests. const base::Feature* features[] = { + &net::features::kIgnoreHSTSForLocalhost, &base::features::kUseRustJsonParser, &network::features::kReduceAcceptLanguage, }; diff --git a/tests/ceftests/certificate_error_unittest.cc b/tests/ceftests/certificate_error_unittest.cc index 736f8fe4d..753b05587 100644 --- a/tests/ceftests/certificate_error_unittest.cc +++ b/tests/ceftests/certificate_error_unittest.cc @@ -357,13 +357,11 @@ namespace { class RedirectMismatchedFromHandlerTest : public CertificateErrorTest { public: - RedirectMismatchedFromHandlerTest(bool continue_invalid_certificate, - bool redirect_from_https) + RedirectMismatchedFromHandlerTest(bool continue_invalid_certificate) : CertificateErrorTest( /*cert_type=*/CEF_TEST_CERT_OK_DOMAIN, /*expect_load_success=*/continue_invalid_certificate, - /*expect_certificate_error=*/true), - redirect_from_https_(redirect_from_https) {} + /*expect_certificate_error=*/true) {} CefRefPtr GetResourceHandler( CefRefPtr browser, @@ -384,8 +382,7 @@ class RedirectMismatchedFromHandlerTest : public CertificateErrorTest { protected: std::string GetStartURL() const override { - return redirect_from_https_ ? "https://certificate-test.com/index.html" - : "http://certificate-test.com/index.html"; + return "https://certificate-test.com/index.html"; } std::string GetEndURL() const override { @@ -393,9 +390,6 @@ class RedirectMismatchedFromHandlerTest : public CertificateErrorTest { return client::AsciiStrReplace(server_origin(), "localhost", "127.0.0.1") + "/index.html"; } - - private: - const bool redirect_from_https_; }; } // namespace @@ -403,8 +397,7 @@ class RedirectMismatchedFromHandlerTest : public CertificateErrorTest { TEST(CertificateErrorTest, RedirectMismatchedFromHttpsResourceCancel) { CefRefPtr handler = new RedirectMismatchedFromHandlerTest( - /*continue_invalid_certificate=*/false, - /*redirect_from_https=*/true); + /*continue_invalid_certificate=*/false); handler->ExecuteTest(); ReleaseAndWaitForDestructor(handler); } @@ -412,26 +405,7 @@ TEST(CertificateErrorTest, RedirectMismatchedFromHttpsResourceCancel) { TEST(CertificateErrorTest, RedirectMismatchedFromHttpsResourceContinue) { CefRefPtr handler = new RedirectMismatchedFromHandlerTest( - /*continue_invalid_certificate=*/true, - /*redirect_from_https=*/true); - handler->ExecuteTest(); - ReleaseAndWaitForDestructor(handler); -} - -TEST(CertificateErrorTest, RedirectMismatchedFromHttpResourceCancel) { - CefRefPtr handler = - new RedirectMismatchedFromHandlerTest( - /*continue_invalid_certificate=*/false, - /*redirect_from_https=*/false); - handler->ExecuteTest(); - ReleaseAndWaitForDestructor(handler); -} - -TEST(CertificateErrorTest, RedirectMismatchedFromHttpResourceContinue) { - CefRefPtr handler = - new RedirectMismatchedFromHandlerTest( - /*continue_invalid_certificate=*/true, - /*redirect_from_https=*/false); + /*continue_invalid_certificate=*/true); handler->ExecuteTest(); ReleaseAndWaitForDestructor(handler); } diff --git a/tests/ceftests/hsts_redirect_unittest.cc b/tests/ceftests/hsts_redirect_unittest.cc index 1666eaabe..13b135c23 100644 --- a/tests/ceftests/hsts_redirect_unittest.cc +++ b/tests/ceftests/hsts_redirect_unittest.cc @@ -3,6 +3,7 @@ // can be found in the LICENSE file. #include "include/base/cef_callback.h" +#include "include/test/cef_test_helpers.h" #include "include/wrapper/cef_closure_task.h" #include "tests/ceftests/test_handler.h" #include "tests/ceftests/test_server.h" @@ -178,13 +179,18 @@ class HSTSRedirectTest : public TestHandler { // explicit port component that is not equal to "80", the port component // value MUST be preserved; otherwise, if the URI does not contain an // explicit port component, the UA MUST NOT add one. - const std::string& expected_https_url = - client::AsciiStrReplace(http_url_, "http:", "https:"); - EXPECT_STREQ(expected_https_url.c_str(), new_url.ToString().c_str()) - << nav_ct_; + // + // This behavior is changed in M132 with + // https://issues.chromium.org/issues/41251622. + if (!CefIsFeatureEnabledForTests("IgnoreHSTSForLocalhost")) { + const std::string& expected_https_url = + client::AsciiStrReplace(http_url_, "http:", "https:"); + EXPECT_STREQ(expected_https_url.c_str(), new_url.ToString().c_str()) + << nav_ct_; - // Redirect to the correct HTTPS URL instead. - new_url = https_url_; + // Redirect to the correct HTTPS URL instead. + new_url = https_url_; + } } }