| Index: content/child/site_isolation_stats_gatherer_browsertest.cc
|
| diff --git a/content/child/site_isolation_stats_gatherer_browsertest.cc b/content/child/site_isolation_stats_gatherer_browsertest.cc
|
| index 43bdd86d98f7b8ec969cd39f9f28225a283d26de..328f751a0161657fab26dde2049435e8a6a3bee2 100644
|
| --- a/content/child/site_isolation_stats_gatherer_browsertest.cc
|
| +++ b/content/child/site_isolation_stats_gatherer_browsertest.cc
|
| @@ -71,74 +71,29 @@ class SiteIsolationStatsGathererBrowserTest : public ContentBrowserTest {
|
|
|
| // A few histograms are incremented unconditionally.
|
| histograms.ExpectUniqueSample("SiteIsolation.AllResponses", 1, 1);
|
| - histograms.ExpectTotalCount("SiteIsolation.XSD.DataLength", 1);
|
| - histograms.ExpectUniqueSample("SiteIsolation.XSD.MimeType", mime_type, 1);
|
| -
|
| - // Inspect the appropriate conditionally-incremented histogram[s].
|
| - std::set<std::string> expected_metrics;
|
| - std::string base_metric = "SiteIsolation.XSD." + bucket;
|
| - base_metric += should_be_blocked ? ".Blocked" : ".NotBlocked";
|
| - expected_metrics.insert(base_metric);
|
| - if (should_be_blocked) {
|
| - expected_metrics.insert(base_metric + ".RenderableStatusCode");
|
| - } else if (MatchPattern(resource_name, "*js.*")) {
|
| - expected_metrics.insert(base_metric + ".MaybeJS");
|
| - }
|
| + std::vector<std::string> xsd_metrics;
|
| + xsd_metrics.push_back("SiteIsolation.XSD.DataLength=1");
|
| + xsd_metrics.push_back(
|
| + base::StringPrintf("SiteIsolation.XSD.MimeType[%d]=1", mime_type));
|
|
|
| - for (std::string metric : expected_metrics) {
|
| - if (MatchPattern(metric, "*.RenderableStatusCode")) {
|
| - histograms.ExpectUniqueSample(metric, RESOURCE_TYPE_XHR, 1);
|
| - } else {
|
| - histograms.ExpectUniqueSample(metric, 1, 1);
|
| + // Determine the appropriate conditionally-incremented histograms.
|
| + std::string base = "SiteIsolation.XSD." + bucket;
|
| + if (should_be_blocked) {
|
| + xsd_metrics.push_back(base + ".Blocked=1");
|
| + xsd_metrics.push_back(base + ".Blocked.RenderableStatusCode[13]=1");
|
| + static_assert(13 == RESOURCE_TYPE_XHR, "Histogram enums mustn't change.");
|
| + } else {
|
| + xsd_metrics.push_back(base + ".NotBlocked=1");
|
| + if (MatchPattern(resource_name, "*js.*")) {
|
| + xsd_metrics.push_back(base + ".NotBlocked.MaybeJS=1");
|
| }
|
| }
|
| + std::sort(xsd_metrics.begin(), xsd_metrics.end());
|
|
|
| - // Make sure no other conditionally-incremented histograms were touched.
|
| - const char* all_metrics[] = {
|
| - "SiteIsolation.XSD.HTML.Blocked",
|
| - "SiteIsolation.XSD.HTML.Blocked.NonRenderableStatusCode",
|
| - "SiteIsolation.XSD.HTML.Blocked.RenderableStatusCode",
|
| - "SiteIsolation.XSD.HTML.NoSniffBlocked",
|
| - "SiteIsolation.XSD.HTML.NoSniffBlocked.NonRenderableStatusCode",
|
| - "SiteIsolation.XSD.HTML.NoSniffBlocked.RenderableStatusCode",
|
| - "SiteIsolation.XSD.HTML.NotBlocked",
|
| - "SiteIsolation.XSD.HTML.NotBlocked.MaybeJS",
|
| - "SiteIsolation.XSD.JSON.Blocked",
|
| - "SiteIsolation.XSD.JSON.Blocked.NonRenderableStatusCode",
|
| - "SiteIsolation.XSD.JSON.Blocked.RenderableStatusCode",
|
| - "SiteIsolation.XSD.JSON.NoSniffBlocked",
|
| - "SiteIsolation.XSD.JSON.NoSniffBlocked.NonRenderableStatusCode",
|
| - "SiteIsolation.XSD.JSON.NoSniffBlocked.RenderableStatusCode",
|
| - "SiteIsolation.XSD.JSON.NotBlocked",
|
| - "SiteIsolation.XSD.JSON.NotBlocked.MaybeJS",
|
| - "SiteIsolation.XSD.Plain.HTML.Blocked",
|
| - "SiteIsolation.XSD.Plain.HTML.Blocked.NonRenderableStatusCode",
|
| - "SiteIsolation.XSD.Plain.HTML.Blocked.RenderableStatusCode",
|
| - "SiteIsolation.XSD.Plain.JSON.Blocked",
|
| - "SiteIsolation.XSD.Plain.JSON.Blocked.NonRenderableStatusCode",
|
| - "SiteIsolation.XSD.Plain.JSON.Blocked.RenderableStatusCode",
|
| - "SiteIsolation.XSD.Plain.NoSniffBlocked",
|
| - "SiteIsolation.XSD.Plain.NoSniffBlocked.NonRenderableStatusCode",
|
| - "SiteIsolation.XSD.Plain.NoSniffBlocked.RenderableStatusCode",
|
| - "SiteIsolation.XSD.Plain.NotBlocked",
|
| - "SiteIsolation.XSD.Plain.NotBlocked.MaybeJS",
|
| - "SiteIsolation.XSD.Plain.XML.Blocked",
|
| - "SiteIsolation.XSD.Plain.XML.Blocked.NonRenderableStatusCode",
|
| - "SiteIsolation.XSD.Plain.XML.Blocked.RenderableStatusCode",
|
| - "SiteIsolation.XSD.XML.Blocked",
|
| - "SiteIsolation.XSD.XML.Blocked.NonRenderableStatusCode",
|
| - "SiteIsolation.XSD.XML.Blocked.RenderableStatusCode",
|
| - "SiteIsolation.XSD.XML.NoSniffBlocked",
|
| - "SiteIsolation.XSD.XML.NoSniffBlocked.NonRenderableStatusCode",
|
| - "SiteIsolation.XSD.XML.NoSniffBlocked.RenderableStatusCode",
|
| - "SiteIsolation.XSD.XML.NotBlocked",
|
| - "SiteIsolation.XSD.XML.NotBlocked.MaybeJS"};
|
| -
|
| - for (const char* metric : all_metrics) {
|
| - if (!expected_metrics.count(metric)) {
|
| - histograms.ExpectTotalCount(metric, 0);
|
| - }
|
| - }
|
| + EXPECT_EQ(JoinString(xsd_metrics, "\n"),
|
| + histograms.GetTotalCountsForQuery("SiteIsolation.XSD."))
|
| + << "For resource_name=" << resource_name
|
| + << ", should_be_blocked=" << should_be_blocked;
|
| }
|
|
|
| private:
|
|
|