| Index: chrome/browser/content_settings/content_settings_browsertest.cc
|
| diff --git a/chrome/browser/content_settings/content_settings_browsertest.cc b/chrome/browser/content_settings/content_settings_browsertest.cc
|
| index f107c8fd70d206e5adf6da4e29953cf8cf16f4e9..fc9374de0a531e3ce6b792eb895a9aa9ebddf4d6 100644
|
| --- a/chrome/browser/content_settings/content_settings_browsertest.cc
|
| +++ b/chrome/browser/content_settings/content_settings_browsertest.cc
|
| @@ -23,6 +23,8 @@
|
| #include "chrome/test/base/ui_test_utils.h"
|
| #include "components/content_settings/core/browser/cookie_settings.h"
|
| #include "components/content_settings/core/browser/host_content_settings_map.h"
|
| +#include "components/network_session_configurator/switches.h"
|
| +#include "components/rappor/test_rappor_service.h"
|
| #include "content/public/browser/browser_thread.h"
|
| #include "content/public/browser/notification_observer.h"
|
| #include "content/public/browser/notification_service.h"
|
| @@ -37,6 +39,7 @@
|
| #include "media/cdm/cdm_paths.h"
|
| #include "net/dns/mock_host_resolver.h"
|
| #include "net/test/embedded_test_server/embedded_test_server.h"
|
| +#include "net/test/embedded_test_server/request_handler_util.h"
|
| #include "net/test/url_request/url_request_mock_http_job.h"
|
|
|
| #include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR.
|
| @@ -247,6 +250,60 @@ IN_PROC_BROWSER_TEST_F(ContentSettingsTest, RedirectLoopCookies) {
|
| IsContentBlocked(CONTENT_SETTINGS_TYPE_COOKIES));
|
| }
|
|
|
| +class ContentSettingsIgnoreCertErrorsTest : public ContentSettingsTest {
|
| + protected:
|
| + void SetUpCommandLine(base::CommandLine* command_line) override {
|
| + command_line->AppendSwitch(switches::kIgnoreCertificateErrors);
|
| + }
|
| +};
|
| +
|
| +// Tests that a RAPPOR metric is recorded when mixed script is
|
| +// blocked. Regression test for https://crbug.com/536975.
|
| +//
|
| +// This test fixture sets up the browser to ignore certificate errors,
|
| +// so that a non-matching, non-local hostname can be used for the
|
| +// test. This is because Rappor treats local hostnames as slightly
|
| +// special, so it's a little nicer to test with a non-local hostname.
|
| +IN_PROC_BROWSER_TEST_F(ContentSettingsIgnoreCertErrorsTest,
|
| + MixedScriptRapporMetric) {
|
| + host_resolver()->AddRule("*", "127.0.0.1");
|
| + ASSERT_TRUE(https_server_.Start());
|
| + ASSERT_TRUE(embedded_test_server()->Start());
|
| + std::string replacement_path;
|
| + base::StringPairs replacement_text;
|
| + replacement_text.push_back(
|
| + make_pair("REPLACE_WITH_HOST_AND_PORT",
|
| + embedded_test_server()->host_port_pair().ToString()));
|
| + net::test_server::GetFilePathWithReplacements(
|
| + "/ssl/page_runs_insecure_content.html", replacement_text,
|
| + &replacement_path);
|
| + GURL url = https_server_.GetURL(replacement_path);
|
| +
|
| + // Rappor treats local hostnames a little bit special (e.g. records
|
| + // "127.0.0.1" as "localhost"), so use a non-local hostname for
|
| + // convenience.
|
| + GURL::Replacements replace_host;
|
| + replace_host.SetHostStr("example.test");
|
| + url = url.ReplaceComponents(replace_host);
|
| +
|
| + rappor::TestRapporService rappor_service;
|
| + TabSpecificContentSettings* tab_specific_content_settings =
|
| + TabSpecificContentSettings::FromWebContents(
|
| + browser()->tab_strip_model()->GetWebContentsAt(0));
|
| + tab_specific_content_settings->SetRapporServiceForTesting(&rappor_service);
|
| + EXPECT_EQ(0, rappor_service.GetReportsCount());
|
| +
|
| + ui_test_utils::NavigateToURL(browser(), url);
|
| +
|
| + EXPECT_EQ(1, rappor_service.GetReportsCount());
|
| + std::string sample;
|
| + rappor::RapporType type;
|
| + EXPECT_TRUE(rappor_service.GetRecordedSampleForMetric(
|
| + "ContentSettings.MixedScript.DisplayedShield", &sample, &type));
|
| + EXPECT_EQ(url.host(), sample);
|
| + EXPECT_EQ(rappor::ETLD_PLUS_ONE_RAPPOR_TYPE, type);
|
| +}
|
| +
|
| // TODO(jww): This should be removed after strict secure cookies is enabled for
|
| // all and this test should be moved into ContentSettingsTest above.
|
| class ContentSettingsStrictSecureCookiesBrowserTest
|
|
|