Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "core/frame/Deprecation.h" | 5 #include "core/frame/Deprecation.h" |
| 6 #include "core/frame/UseCounter.h" | 6 #include "core/frame/UseCounter.h" |
| 7 #include "core/page/Page.h" | 7 #include "core/page/Page.h" |
| 8 #include "core/testing/DummyPageHolder.h" | 8 #include "core/testing/DummyPageHolder.h" |
| 9 #include "platform/testing/HistogramTester.h" | 9 #include "platform/testing/HistogramTester.h" |
| 10 #include "platform/testing/URLTestHelpers.h" | 10 #include "platform/testing/URLTestHelpers.h" |
| 11 #include "platform/weborigin/KURL.h" | 11 #include "platform/weborigin/KURL.h" |
| 12 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
| 13 | 13 |
| 14 namespace { | 14 namespace { |
| 15 const char* const kFeaturesHistogramName = "Blink.UseCounter.Features"; | 15 const char kFeaturesHistogramName[] = "Blink.UseCounter.Features"; |
| 16 const char* const kCSSHistogramName = "Blink.UseCounter.CSSProperties"; | 16 const char kCSSHistogramName[] = "Blink.UseCounter.CSSProperties"; |
| 17 const char* const kAnimatedCSSHistogramName = | 17 const char kAnimatedCSSHistogramName[] = |
| 18 "Blink.UseCounter.AnimatedCSSProperties"; | 18 "Blink.UseCounter.AnimatedCSSProperties"; |
| 19 const char kExtensionFeaturesHistogramName[] = | |
| 20 "Blink.UseCounter.Extensions.Features"; | |
| 19 | 21 |
| 20 const char* const kSVGFeaturesHistogramName = | 22 const char kSVGFeaturesHistogramName[] = "Blink.UseCounter.SVGImage.Features"; |
| 21 "Blink.UseCounter.SVGImage.Features"; | 23 const char kSVGCSSHistogramName[] = "Blink.UseCounter.SVGImage.CSSProperties"; |
| 22 const char* const kSVGCSSHistogramName = | 24 const char kSVGAnimatedCSSHistogramName[] = |
| 23 "Blink.UseCounter.SVGImage.CSSProperties"; | |
| 24 const char* const kSVGAnimatedCSSHistogramName = | |
| 25 "Blink.UseCounter.SVGImage.AnimatedCSSProperties"; | 25 "Blink.UseCounter.SVGImage.AnimatedCSSProperties"; |
| 26 | 26 |
| 27 const char* const kLegacyFeaturesHistogramName = "WebCore.FeatureObserver"; | 27 const char kLegacyFeaturesHistogramName[] = "WebCore.FeatureObserver"; |
| 28 const char* const kLegacyCSSHistogramName = | 28 const char kLegacyCSSHistogramName[] = "WebCore.FeatureObserver.CSSProperties"; |
| 29 "WebCore.FeatureObserver.CSSProperties"; | 29 |
| 30 // In practice, SVGs always appear to be loaded with an about:blank URL | |
| 31 const char kSvgUrl[] = "about:blank"; | |
| 32 const char* const kInternalUrl = kSvgUrl; | |
| 33 const char kHttpsUrl[] = "https://dummysite.com/"; | |
| 34 const char kExtensionUrl[] = "chrome-extension://dummysite/"; | |
| 35 | |
| 36 int GetPageVisitsBucketforHistogram(const std::string& histogram_name) { | |
| 37 if (histogram_name.find("CSS") == std::string::npos) | |
| 38 return blink::UseCounter::kPageVisits; | |
| 39 // For CSS histograms, the page visits bucket should be 1. | |
| 40 return 1; | |
| 30 } | 41 } |
| 31 | 42 |
| 43 } // namespace | |
| 44 | |
| 32 namespace blink { | 45 namespace blink { |
| 33 | 46 |
| 34 template <typename T> | 47 template <typename T> |
| 35 void HistogramBasicTest(const std::string& histogram, | 48 void HistogramBasicTest(const std::string& histogram, |
| 36 const std::string& legacy_histogram, | 49 const std::string& legacy_histogram, |
| 37 const std::vector<std::string>& unaffected_histograms, | |
| 38 T item, | 50 T item, |
| 39 T second_item, | 51 T second_item, |
| 40 std::function<bool(T)> counted, | 52 std::function<bool(T)> counted, |
| 41 std::function<void(T)> count, | 53 std::function<void(T)> count, |
| 42 std::function<int(T)> histogram_map, | 54 std::function<int(T)> histogram_map, |
| 43 std::function<void(KURL)> did_commit_load, | 55 std::function<void(KURL)> did_commit_load, |
| 44 const std::string& url, | 56 const std::string& url) { |
| 45 int page_visit_bucket) { | |
| 46 HistogramTester histogram_tester; | 57 HistogramTester histogram_tester; |
| 47 | 58 |
| 59 int page_visit_bucket = GetPageVisitsBucketforHistogram(histogram); | |
| 60 | |
| 48 // Test recording a single (arbitrary) counter | 61 // Test recording a single (arbitrary) counter |
| 49 EXPECT_FALSE(counted(item)); | 62 EXPECT_FALSE(counted(item)); |
| 50 count(item); | 63 count(item); |
| 51 EXPECT_TRUE(counted(item)); | 64 EXPECT_TRUE(counted(item)); |
| 52 histogram_tester.ExpectUniqueSample(histogram, histogram_map(item), 1); | 65 histogram_tester.ExpectUniqueSample(histogram, histogram_map(item), 1); |
| 53 if (!legacy_histogram.empty()) { | 66 if (!legacy_histogram.empty()) { |
| 54 histogram_tester.ExpectTotalCount(legacy_histogram, 0); | 67 histogram_tester.ExpectTotalCount(legacy_histogram, 0); |
| 55 } | 68 } |
| 56 | 69 |
| 57 // Test that repeated measurements have no effect | 70 // Test that repeated measurements have no effect |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 102 did_commit_load(URLTestHelpers::ToKURL(url)); | 115 did_commit_load(URLTestHelpers::ToKURL(url)); |
| 103 if (!legacy_histogram.empty()) { | 116 if (!legacy_histogram.empty()) { |
| 104 histogram_tester.ExpectBucketCount(legacy_histogram, histogram_map(item), | 117 histogram_tester.ExpectBucketCount(legacy_histogram, histogram_map(item), |
| 105 2); | 118 2); |
| 106 histogram_tester.ExpectBucketCount(legacy_histogram, | 119 histogram_tester.ExpectBucketCount(legacy_histogram, |
| 107 histogram_map(second_item), 1); | 120 histogram_map(second_item), 1); |
| 108 histogram_tester.ExpectBucketCount(legacy_histogram, page_visit_bucket, 2); | 121 histogram_tester.ExpectBucketCount(legacy_histogram, page_visit_bucket, 2); |
| 109 histogram_tester.ExpectTotalCount(legacy_histogram, 5); | 122 histogram_tester.ExpectTotalCount(legacy_histogram, 5); |
| 110 } | 123 } |
| 111 | 124 |
| 112 for (size_t i = 0; i < unaffected_histograms.size(); ++i) { | 125 // For all histograms, no other histograms besides |histogram| should |
| 113 histogram_tester.ExpectTotalCount(unaffected_histograms[i], 0); | 126 // be affected. Legacy histograms are not included in the list because they |
| 127 // soon will be removed. | |
| 128 for (const auto& unaffected_histogram : | |
| 129 {kAnimatedCSSHistogramName, kCSSHistogramName, | |
| 130 kExtensionFeaturesHistogramName, kFeaturesHistogramName, | |
| 131 kSVGAnimatedCSSHistogramName, kSVGCSSHistogramName, | |
| 132 kSVGFeaturesHistogramName}) { | |
| 133 if (unaffected_histogram == histogram) | |
| 134 continue; | |
| 135 | |
| 136 // The expected total count for unaffected histograms should be either: | |
| 137 // a. 0, for "non-CSS" histograms (their "page visits" bucket should be | |
| 138 // empty); or | |
| 139 // b. The value of the "page visits" bucket, for "CSS" histograms. | |
|
Rick Byers
2017/05/12 17:51:21
nit: This comment seems slightly wrong. Rather th
lunalu1
2017/05/15 14:34:28
Done.
| |
| 140 histogram_tester.ExpectTotalCount( | |
| 141 unaffected_histogram, | |
| 142 0 + histogram_tester.GetBucketCount( | |
| 143 unaffected_histogram, | |
| 144 GetPageVisitsBucketforHistogram(unaffected_histogram))); | |
| 114 } | 145 } |
| 115 } | 146 } |
| 116 | 147 |
| 117 TEST(UseCounterTest, RecordingFeatures) { | 148 TEST(UseCounterTest, RecordingFeatures) { |
| 118 UseCounter use_counter; | 149 UseCounter use_counter; |
| 119 HistogramBasicTest<UseCounter::Feature>( | 150 HistogramBasicTest<UseCounter::Feature>( |
| 120 kFeaturesHistogramName, kLegacyFeaturesHistogramName, | 151 kFeaturesHistogramName, kLegacyFeaturesHistogramName, UseCounter::kFetch, |
| 121 {kSVGFeaturesHistogramName, kSVGCSSHistogramName, | 152 UseCounter::kFetchBodyStream, |
| 122 kSVGAnimatedCSSHistogramName}, | |
| 123 UseCounter::kFetch, UseCounter::kFetchBodyStream, | |
| 124 [&](UseCounter::Feature feature) -> bool { | 153 [&](UseCounter::Feature feature) -> bool { |
| 125 return use_counter.HasRecordedMeasurement(feature); | 154 return use_counter.HasRecordedMeasurement(feature); |
| 126 }, | 155 }, |
| 127 [&](UseCounter::Feature feature) { | 156 [&](UseCounter::Feature feature) { |
| 128 use_counter.RecordMeasurement(feature); | 157 use_counter.RecordMeasurement(feature); |
| 129 }, | 158 }, |
| 130 [](UseCounter::Feature feature) -> int { return feature; }, | 159 [](UseCounter::Feature feature) -> int { return feature; }, |
| 131 [&](KURL kurl) { use_counter.DidCommitLoad(kurl); }, | 160 [&](KURL kurl) { use_counter.DidCommitLoad(kurl); }, kHttpsUrl); |
| 132 "https://dummysite.com/", UseCounter::kPageVisits); | |
| 133 } | 161 } |
| 134 | 162 |
| 135 TEST(UseCounterTest, RecordingCSSProperties) { | 163 TEST(UseCounterTest, RecordingCSSProperties) { |
| 136 UseCounter use_counter; | 164 UseCounter use_counter; |
| 137 HistogramBasicTest<CSSPropertyID>( | 165 HistogramBasicTest<CSSPropertyID>( |
| 138 kCSSHistogramName, kLegacyCSSHistogramName, | 166 kCSSHistogramName, kLegacyCSSHistogramName, CSSPropertyFont, |
| 139 {kSVGFeaturesHistogramName, kSVGCSSHistogramName, | 167 CSSPropertyZoom, |
| 140 kSVGAnimatedCSSHistogramName}, | |
| 141 CSSPropertyFont, CSSPropertyZoom, | |
| 142 [&](CSSPropertyID property) -> bool { | 168 [&](CSSPropertyID property) -> bool { |
| 143 return use_counter.IsCounted(property); | 169 return use_counter.IsCounted(property); |
| 144 }, | 170 }, |
| 145 [&](CSSPropertyID property) { | 171 [&](CSSPropertyID property) { |
| 146 use_counter.Count(kHTMLStandardMode, property); | 172 use_counter.Count(kHTMLStandardMode, property); |
| 147 }, | 173 }, |
| 148 [](CSSPropertyID property) -> int { | 174 [](CSSPropertyID property) -> int { |
| 149 return UseCounter::MapCSSPropertyIdToCSSSampleIdForHistogram(property); | 175 return UseCounter::MapCSSPropertyIdToCSSSampleIdForHistogram(property); |
| 150 }, | 176 }, |
| 151 [&](KURL kurl) { use_counter.DidCommitLoad(kurl); }, | 177 [&](KURL kurl) { use_counter.DidCommitLoad(kurl); }, kHttpsUrl); |
| 152 "https://dummysite.com/", 1 /* page visit bucket */); | |
| 153 } | 178 } |
| 154 | 179 |
| 155 TEST(UseCounterTest, RecordingAnimatedCSSProperties) { | 180 TEST(UseCounterTest, RecordingAnimatedCSSProperties) { |
| 156 UseCounter use_counter; | 181 UseCounter use_counter; |
| 157 HistogramBasicTest<CSSPropertyID>( | 182 HistogramBasicTest<CSSPropertyID>( |
| 158 kAnimatedCSSHistogramName, "", | 183 kAnimatedCSSHistogramName, "", CSSPropertyOpacity, CSSPropertyVariable, |
| 159 {kSVGCSSHistogramName, kSVGAnimatedCSSHistogramName}, CSSPropertyOpacity, | |
| 160 CSSPropertyVariable, | |
| 161 [&](CSSPropertyID property) -> bool { | 184 [&](CSSPropertyID property) -> bool { |
| 162 return use_counter.IsCountedAnimatedCSS(property); | 185 return use_counter.IsCountedAnimatedCSS(property); |
| 163 }, | 186 }, |
| 164 [&](CSSPropertyID property) { use_counter.CountAnimatedCSS(property); }, | 187 [&](CSSPropertyID property) { use_counter.CountAnimatedCSS(property); }, |
| 165 [](CSSPropertyID property) -> int { | 188 [](CSSPropertyID property) -> int { |
| 166 return UseCounter::MapCSSPropertyIdToCSSSampleIdForHistogram(property); | 189 return UseCounter::MapCSSPropertyIdToCSSSampleIdForHistogram(property); |
| 167 }, | 190 }, |
| 168 [&](KURL kurl) { use_counter.DidCommitLoad(kurl); }, | 191 [&](KURL kurl) { use_counter.DidCommitLoad(kurl); }, kHttpsUrl); |
| 169 "https://dummysite.com/", 1 /* page visit bucket */); | 192 } |
| 193 | |
| 194 TEST(UseCounterTest, RecordingExtensions) { | |
| 195 UseCounter use_counter(UseCounter::kExtensionContext); | |
| 196 HistogramBasicTest<UseCounter::Feature>( | |
| 197 kExtensionFeaturesHistogramName, kLegacyFeaturesHistogramName, | |
| 198 UseCounter::kFetch, UseCounter::kFetchBodyStream, | |
| 199 [&](UseCounter::Feature feature) -> bool { | |
| 200 return use_counter.HasRecordedMeasurement(feature); | |
| 201 }, | |
| 202 [&](UseCounter::Feature feature) { | |
| 203 use_counter.RecordMeasurement(feature); | |
| 204 }, | |
| 205 [](UseCounter::Feature feature) -> int { return feature; }, | |
| 206 [&](KURL kurl) { use_counter.DidCommitLoad(kurl); }, kExtensionUrl); | |
| 170 } | 207 } |
| 171 | 208 |
| 172 TEST(UseCounterTest, SVGImageContextFeatures) { | 209 TEST(UseCounterTest, SVGImageContextFeatures) { |
| 173 UseCounter use_counter(UseCounter::kSVGImageContext); | 210 UseCounter use_counter(UseCounter::kSVGImageContext); |
| 174 HistogramBasicTest<UseCounter::Feature>( | 211 HistogramBasicTest<UseCounter::Feature>( |
| 175 kSVGFeaturesHistogramName, kLegacyFeaturesHistogramName, | 212 kSVGFeaturesHistogramName, kLegacyFeaturesHistogramName, |
| 176 {kFeaturesHistogramName, kCSSHistogramName, kAnimatedCSSHistogramName}, | |
| 177 UseCounter::kSVGSMILAdditiveAnimation, | 213 UseCounter::kSVGSMILAdditiveAnimation, |
| 178 UseCounter::kSVGSMILAnimationElementTiming, | 214 UseCounter::kSVGSMILAnimationElementTiming, |
| 179 [&](UseCounter::Feature feature) -> bool { | 215 [&](UseCounter::Feature feature) -> bool { |
| 180 return use_counter.HasRecordedMeasurement(feature); | 216 return use_counter.HasRecordedMeasurement(feature); |
| 181 }, | 217 }, |
| 182 [&](UseCounter::Feature feature) { | 218 [&](UseCounter::Feature feature) { |
| 183 use_counter.RecordMeasurement(feature); | 219 use_counter.RecordMeasurement(feature); |
| 184 }, | 220 }, |
| 185 [](UseCounter::Feature feature) -> int { return feature; }, | 221 [](UseCounter::Feature feature) -> int { return feature; }, |
| 186 [&](KURL kurl) { use_counter.DidCommitLoad(kurl); }, "about:blank", | 222 [&](KURL kurl) { use_counter.DidCommitLoad(kurl); }, kSvgUrl); |
| 187 // In practice SVGs always appear to be loaded with an about:blank URL | |
| 188 UseCounter::kPageVisits); | |
| 189 } | 223 } |
| 190 | 224 |
| 191 TEST(UseCounterTest, SVGImageContextCSSProperties) { | 225 TEST(UseCounterTest, SVGImageContextCSSProperties) { |
| 192 UseCounter use_counter(UseCounter::kSVGImageContext); | 226 UseCounter use_counter(UseCounter::kSVGImageContext); |
| 193 HistogramBasicTest<CSSPropertyID>( | 227 HistogramBasicTest<CSSPropertyID>( |
| 194 kSVGCSSHistogramName, kLegacyCSSHistogramName, | 228 kSVGCSSHistogramName, kLegacyCSSHistogramName, CSSPropertyFont, |
| 195 {kFeaturesHistogramName, kCSSHistogramName, kAnimatedCSSHistogramName}, | 229 CSSPropertyZoom, |
| 196 CSSPropertyFont, CSSPropertyZoom, | |
| 197 [&](CSSPropertyID property) -> bool { | 230 [&](CSSPropertyID property) -> bool { |
| 198 return use_counter.IsCounted(property); | 231 return use_counter.IsCounted(property); |
| 199 }, | 232 }, |
| 200 [&](CSSPropertyID property) { | 233 [&](CSSPropertyID property) { |
| 201 use_counter.Count(kHTMLStandardMode, property); | 234 use_counter.Count(kHTMLStandardMode, property); |
| 202 }, | 235 }, |
| 203 [](CSSPropertyID property) -> int { | 236 [](CSSPropertyID property) -> int { |
| 204 return UseCounter::MapCSSPropertyIdToCSSSampleIdForHistogram(property); | 237 return UseCounter::MapCSSPropertyIdToCSSSampleIdForHistogram(property); |
| 205 }, | 238 }, |
| 206 [&](KURL kurl) { use_counter.DidCommitLoad(kurl); }, "about:blank", | 239 [&](KURL kurl) { use_counter.DidCommitLoad(kurl); }, kSvgUrl); |
| 207 // In practice SVGs always appear to be loaded with an about:blank URL | |
| 208 1 /* page visit bucket */); | |
| 209 } | 240 } |
| 210 | 241 |
| 211 TEST(UseCounterTest, SVGImageContextAnimatedCSSProperties) { | 242 TEST(UseCounterTest, SVGImageContextAnimatedCSSProperties) { |
| 212 UseCounter use_counter(UseCounter::kSVGImageContext); | 243 UseCounter use_counter(UseCounter::kSVGImageContext); |
| 213 HistogramBasicTest<CSSPropertyID>( | 244 HistogramBasicTest<CSSPropertyID>( |
| 214 kSVGAnimatedCSSHistogramName, "", | 245 kSVGAnimatedCSSHistogramName, "", CSSPropertyOpacity, CSSPropertyVariable, |
| 215 {kCSSHistogramName, kAnimatedCSSHistogramName}, CSSPropertyOpacity, | |
| 216 CSSPropertyVariable, | |
| 217 [&](CSSPropertyID property) -> bool { | 246 [&](CSSPropertyID property) -> bool { |
| 218 return use_counter.IsCountedAnimatedCSS(property); | 247 return use_counter.IsCountedAnimatedCSS(property); |
| 219 }, | 248 }, |
| 220 [&](CSSPropertyID property) { use_counter.CountAnimatedCSS(property); }, | 249 [&](CSSPropertyID property) { use_counter.CountAnimatedCSS(property); }, |
| 221 [](CSSPropertyID property) -> int { | 250 [](CSSPropertyID property) -> int { |
| 222 return UseCounter::MapCSSPropertyIdToCSSSampleIdForHistogram(property); | 251 return UseCounter::MapCSSPropertyIdToCSSSampleIdForHistogram(property); |
| 223 }, | 252 }, |
| 224 [&](KURL kurl) { use_counter.DidCommitLoad(kurl); }, "about:blank", | 253 [&](KURL kurl) { use_counter.DidCommitLoad(kurl); }, kSvgUrl); |
| 225 // In practice SVGs always appear to be loaded with an about:blank URL | |
| 226 1 /* page visit bucket */); | |
| 227 } | 254 } |
| 228 | 255 |
| 229 TEST(UseCounterTest, InspectorDisablesMeasurement) { | 256 TEST(UseCounterTest, InspectorDisablesMeasurement) { |
| 230 UseCounter use_counter; | 257 UseCounter use_counter; |
| 231 HistogramTester histogram_tester; | 258 HistogramTester histogram_tester; |
| 232 | 259 |
| 233 // The specific feature we use here isn't important. | 260 // The specific feature we use here isn't important. |
| 234 UseCounter::Feature feature = UseCounter::Feature::kSVGSMILElementInDocument; | 261 UseCounter::Feature feature = UseCounter::Feature::kSVGSMILElementInDocument; |
| 235 CSSPropertyID property = CSSPropertyFontWeight; | 262 CSSPropertyID property = CSSPropertyFontWeight; |
| 236 CSSParserMode parser_mode = kHTMLStandardMode; | 263 CSSParserMode parser_mode = kHTMLStandardMode; |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 297 UseCounter use_counter; | 324 UseCounter use_counter; |
| 298 HistogramTester histogram_tester; | 325 HistogramTester histogram_tester; |
| 299 | 326 |
| 300 // Counters triggered before any load are always reported. | 327 // Counters triggered before any load are always reported. |
| 301 use_counter.RecordMeasurement(UseCounter::kFetch); | 328 use_counter.RecordMeasurement(UseCounter::kFetch); |
| 302 use_counter.Count(kHTMLStandardMode, CSSPropertyFontWeight); | 329 use_counter.Count(kHTMLStandardMode, CSSPropertyFontWeight); |
| 303 ExpectHistograms(histogram_tester, 0, UseCounter::kFetch, 1, | 330 ExpectHistograms(histogram_tester, 0, UseCounter::kFetch, 1, |
| 304 CSSPropertyFontWeight, 1); | 331 CSSPropertyFontWeight, 1); |
| 305 | 332 |
| 306 // Loading an internal page doesn't bump PageVisits and metrics not reported. | 333 // Loading an internal page doesn't bump PageVisits and metrics not reported. |
| 307 use_counter.DidCommitLoad(URLTestHelpers::ToKURL("about:blank")); | 334 use_counter.DidCommitLoad(URLTestHelpers::ToKURL(kInternalUrl)); |
| 308 EXPECT_FALSE(use_counter.HasRecordedMeasurement(UseCounter::kFetch)); | 335 EXPECT_FALSE(use_counter.HasRecordedMeasurement(UseCounter::kFetch)); |
| 309 EXPECT_FALSE(use_counter.IsCounted(CSSPropertyFontWeight)); | 336 EXPECT_FALSE(use_counter.IsCounted(CSSPropertyFontWeight)); |
| 310 use_counter.RecordMeasurement(UseCounter::kFetch); | 337 use_counter.RecordMeasurement(UseCounter::kFetch); |
| 311 use_counter.Count(kHTMLStandardMode, CSSPropertyFontWeight); | 338 use_counter.Count(kHTMLStandardMode, CSSPropertyFontWeight); |
| 312 ExpectHistograms(histogram_tester, 0, UseCounter::kFetch, 1, | 339 ExpectHistograms(histogram_tester, 0, UseCounter::kFetch, 1, |
| 313 CSSPropertyFontWeight, 1); | 340 CSSPropertyFontWeight, 1); |
| 314 | 341 |
| 315 // But the fact that the features were seen is still known. | 342 // But the fact that the features were seen is still known. |
| 316 EXPECT_TRUE(use_counter.HasRecordedMeasurement(UseCounter::kFetch)); | 343 EXPECT_TRUE(use_counter.HasRecordedMeasurement(UseCounter::kFetch)); |
| 317 EXPECT_TRUE(use_counter.IsCounted(CSSPropertyFontWeight)); | 344 EXPECT_TRUE(use_counter.IsCounted(CSSPropertyFontWeight)); |
| 318 | 345 |
| 319 // Inspector muting then unmuting doesn't change the behavior. | 346 // Inspector muting then unmuting doesn't change the behavior. |
| 320 use_counter.MuteForInspector(); | 347 use_counter.MuteForInspector(); |
| 321 use_counter.UnmuteForInspector(); | 348 use_counter.UnmuteForInspector(); |
| 322 use_counter.RecordMeasurement(UseCounter::kFetch); | 349 use_counter.RecordMeasurement(UseCounter::kFetch); |
| 323 use_counter.Count(kHTMLStandardMode, CSSPropertyFontWeight); | 350 use_counter.Count(kHTMLStandardMode, CSSPropertyFontWeight); |
| 324 ExpectHistograms(histogram_tester, 0, UseCounter::kFetch, 1, | 351 ExpectHistograms(histogram_tester, 0, UseCounter::kFetch, 1, |
| 325 CSSPropertyFontWeight, 1); | 352 CSSPropertyFontWeight, 1); |
| 326 | 353 |
| 327 // If we now load a real web page, metrics are reported again. | 354 // If we now load a real web page, metrics are reported again. |
| 328 use_counter.DidCommitLoad(URLTestHelpers::ToKURL("http://foo.com/")); | 355 use_counter.DidCommitLoad(URLTestHelpers::ToKURL("http://foo.com/")); |
| 329 use_counter.RecordMeasurement(UseCounter::kFetch); | 356 use_counter.RecordMeasurement(UseCounter::kFetch); |
| 330 use_counter.Count(kHTMLStandardMode, CSSPropertyFontWeight); | 357 use_counter.Count(kHTMLStandardMode, CSSPropertyFontWeight); |
| 331 ExpectHistograms(histogram_tester, 1, UseCounter::kFetch, 2, | 358 ExpectHistograms(histogram_tester, 1, UseCounter::kFetch, 2, |
| 332 CSSPropertyFontWeight, 2); | 359 CSSPropertyFontWeight, 2); |
| 333 | 360 |
| 334 // HTTPs URLs are the same. | 361 // HTTPs URLs are the same. |
| 335 use_counter.DidCommitLoad( | 362 use_counter.DidCommitLoad(URLTestHelpers::ToKURL(kHttpsUrl)); |
| 336 URLTestHelpers::ToKURL("https://baz.com:1234/blob.html")); | |
| 337 use_counter.RecordMeasurement(UseCounter::kFetch); | 363 use_counter.RecordMeasurement(UseCounter::kFetch); |
| 338 use_counter.Count(kHTMLStandardMode, CSSPropertyFontWeight); | 364 use_counter.Count(kHTMLStandardMode, CSSPropertyFontWeight); |
| 339 ExpectHistograms(histogram_tester, 2, UseCounter::kFetch, 3, | 365 ExpectHistograms(histogram_tester, 2, UseCounter::kFetch, 3, |
| 340 CSSPropertyFontWeight, 3); | 366 CSSPropertyFontWeight, 3); |
| 341 | 367 |
| 342 // Extensions aren't counted. | 368 // Extensions aren't counted. |
| 343 use_counter.DidCommitLoad( | 369 use_counter.DidCommitLoad(URLTestHelpers::ToKURL(kExtensionUrl)); |
| 344 URLTestHelpers::ToKURL("chrome-extension://1238ba908adf/")); | |
| 345 use_counter.RecordMeasurement(UseCounter::kFetch); | 370 use_counter.RecordMeasurement(UseCounter::kFetch); |
| 346 use_counter.Count(kHTMLStandardMode, CSSPropertyFontWeight); | 371 use_counter.Count(kHTMLStandardMode, CSSPropertyFontWeight); |
| 347 ExpectHistograms(histogram_tester, 2, UseCounter::kFetch, 3, | 372 ExpectHistograms(histogram_tester, 2, UseCounter::kFetch, 3, |
| 348 CSSPropertyFontWeight, 3); | 373 CSSPropertyFontWeight, 3); |
| 349 | 374 |
| 350 // Nor is devtools | 375 // Nor is devtools |
| 351 use_counter.DidCommitLoad( | 376 use_counter.DidCommitLoad( |
| 352 URLTestHelpers::ToKURL("chrome-devtools://1238ba908adf/")); | 377 URLTestHelpers::ToKURL("chrome-devtools://1238ba908adf/")); |
| 353 use_counter.RecordMeasurement(UseCounter::kFetch); | 378 use_counter.RecordMeasurement(UseCounter::kFetch); |
| 354 use_counter.Count(kHTMLStandardMode, CSSPropertyFontWeight); | 379 use_counter.Count(kHTMLStandardMode, CSSPropertyFontWeight); |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 420 | 445 |
| 421 deprecation_.UnmuteForInspector(); | 446 deprecation_.UnmuteForInspector(); |
| 422 Deprecation::WarnOnDeprecatedProperties(GetFrame(), property); | 447 Deprecation::WarnOnDeprecatedProperties(GetFrame(), property); |
| 423 // TODO: use the actually deprecated property to get a deprecation message. | 448 // TODO: use the actually deprecated property to get a deprecation message. |
| 424 EXPECT_FALSE(deprecation_.IsSuppressed(property)); | 449 EXPECT_FALSE(deprecation_.IsSuppressed(property)); |
| 425 Deprecation::CountDeprecation(GetFrame(), feature); | 450 Deprecation::CountDeprecation(GetFrame(), feature); |
| 426 EXPECT_TRUE(use_counter_.HasRecordedMeasurement(feature)); | 451 EXPECT_TRUE(use_counter_.HasRecordedMeasurement(feature)); |
| 427 } | 452 } |
| 428 | 453 |
| 429 } // namespace blink | 454 } // namespace blink |
| OLD | NEW |