Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(73)

Side by Side Diff: third_party/WebKit/Source/core/frame/UseCounterTest.cpp

Issue 2796283005: Adding UseCounter specific for extensions (Closed)
Patch Set: Fix compile err Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 std::string& unaffected_histogram :
129 {kAnimatedCSSHistogramName, kCSSHistogramName,
130 kExtensionFeaturesHistogramName, kFeaturesHistogramName,
131 kSVGAnimatedCSSHistogramName, kSVGCSSHistogramName,
132 kSVGFeaturesHistogramName}) {
133 if (unaffected_histogram == histogram)
134 continue;
135 // CSS histograms are never created in didCommitLoad when the context is
136 // extension.
137 if (histogram == kExtensionFeaturesHistogramName &&
138 unaffected_histogram.find("CSS") != std::string::npos)
139 continue;
140
141 // The expected total count for "Features" of unaffected histograms should
142 // be either:
143 // a. pageVisits, for "CSSFeatures"; or
144 // b. 0 (pageVisits is 0), for others, including "SVGImage.CSSFeatures"
145 // since no SVG images are loaded at all.
146 histogram_tester.ExpectTotalCount(
147 unaffected_histogram,
148 0 + histogram_tester.GetBucketCount(
149 unaffected_histogram,
150 GetPageVisitsBucketforHistogram(unaffected_histogram)));
114 } 151 }
115 } 152 }
116 153
117 TEST(UseCounterTest, RecordingFeatures) { 154 TEST(UseCounterTest, RecordingFeatures) {
118 UseCounter use_counter; 155 UseCounter use_counter;
119 HistogramBasicTest<UseCounter::Feature>( 156 HistogramBasicTest<UseCounter::Feature>(
120 kFeaturesHistogramName, kLegacyFeaturesHistogramName, 157 kFeaturesHistogramName, kLegacyFeaturesHistogramName, UseCounter::kFetch,
121 {kSVGFeaturesHistogramName, kSVGCSSHistogramName, 158 UseCounter::kFetchBodyStream,
122 kSVGAnimatedCSSHistogramName},
123 UseCounter::kFetch, UseCounter::kFetchBodyStream,
124 [&](UseCounter::Feature feature) -> bool { 159 [&](UseCounter::Feature feature) -> bool {
125 return use_counter.HasRecordedMeasurement(feature); 160 return use_counter.HasRecordedMeasurement(feature);
126 }, 161 },
127 [&](UseCounter::Feature feature) { 162 [&](UseCounter::Feature feature) {
128 use_counter.RecordMeasurement(feature); 163 use_counter.RecordMeasurement(feature);
129 }, 164 },
130 [](UseCounter::Feature feature) -> int { return feature; }, 165 [](UseCounter::Feature feature) -> int { return feature; },
131 [&](KURL kurl) { use_counter.DidCommitLoad(kurl); }, 166 [&](KURL kurl) { use_counter.DidCommitLoad(kurl); }, kHttpsUrl);
132 "https://dummysite.com/", UseCounter::kPageVisits);
133 } 167 }
134 168
135 TEST(UseCounterTest, RecordingCSSProperties) { 169 TEST(UseCounterTest, RecordingCSSProperties) {
136 UseCounter use_counter; 170 UseCounter use_counter;
137 HistogramBasicTest<CSSPropertyID>( 171 HistogramBasicTest<CSSPropertyID>(
138 kCSSHistogramName, kLegacyCSSHistogramName, 172 kCSSHistogramName, kLegacyCSSHistogramName, CSSPropertyFont,
139 {kSVGFeaturesHistogramName, kSVGCSSHistogramName, 173 CSSPropertyZoom,
140 kSVGAnimatedCSSHistogramName},
141 CSSPropertyFont, CSSPropertyZoom,
142 [&](CSSPropertyID property) -> bool { 174 [&](CSSPropertyID property) -> bool {
143 return use_counter.IsCounted(property); 175 return use_counter.IsCounted(property);
144 }, 176 },
145 [&](CSSPropertyID property) { 177 [&](CSSPropertyID property) {
146 use_counter.Count(kHTMLStandardMode, property); 178 use_counter.Count(kHTMLStandardMode, property);
147 }, 179 },
148 [](CSSPropertyID property) -> int { 180 [](CSSPropertyID property) -> int {
149 return UseCounter::MapCSSPropertyIdToCSSSampleIdForHistogram(property); 181 return UseCounter::MapCSSPropertyIdToCSSSampleIdForHistogram(property);
150 }, 182 },
151 [&](KURL kurl) { use_counter.DidCommitLoad(kurl); }, 183 [&](KURL kurl) { use_counter.DidCommitLoad(kurl); }, kHttpsUrl);
152 "https://dummysite.com/", 1 /* page visit bucket */);
153 } 184 }
154 185
155 TEST(UseCounterTest, RecordingAnimatedCSSProperties) { 186 TEST(UseCounterTest, RecordingAnimatedCSSProperties) {
156 UseCounter use_counter; 187 UseCounter use_counter;
157 HistogramBasicTest<CSSPropertyID>( 188 HistogramBasicTest<CSSPropertyID>(
158 kAnimatedCSSHistogramName, "", 189 kAnimatedCSSHistogramName, "", CSSPropertyOpacity, CSSPropertyVariable,
159 {kSVGCSSHistogramName, kSVGAnimatedCSSHistogramName}, CSSPropertyOpacity,
160 CSSPropertyVariable,
161 [&](CSSPropertyID property) -> bool { 190 [&](CSSPropertyID property) -> bool {
162 return use_counter.IsCountedAnimatedCSS(property); 191 return use_counter.IsCountedAnimatedCSS(property);
163 }, 192 },
164 [&](CSSPropertyID property) { use_counter.CountAnimatedCSS(property); }, 193 [&](CSSPropertyID property) { use_counter.CountAnimatedCSS(property); },
165 [](CSSPropertyID property) -> int { 194 [](CSSPropertyID property) -> int {
166 return UseCounter::MapCSSPropertyIdToCSSSampleIdForHistogram(property); 195 return UseCounter::MapCSSPropertyIdToCSSSampleIdForHistogram(property);
167 }, 196 },
168 [&](KURL kurl) { use_counter.DidCommitLoad(kurl); }, 197 [&](KURL kurl) { use_counter.DidCommitLoad(kurl); }, kHttpsUrl);
169 "https://dummysite.com/", 1 /* page visit bucket */); 198 }
199
200 TEST(UseCounterTest, RecordingExtensions) {
201 UseCounter use_counter(UseCounter::kExtensionContext);
202 HistogramBasicTest<UseCounter::Feature>(
203 kExtensionFeaturesHistogramName, kLegacyFeaturesHistogramName,
204 UseCounter::kFetch, UseCounter::kFetchBodyStream,
205 [&](UseCounter::Feature feature) -> bool {
206 return use_counter.HasRecordedMeasurement(feature);
207 },
208 [&](UseCounter::Feature feature) {
209 use_counter.RecordMeasurement(feature);
210 },
211 [](UseCounter::Feature feature) -> int { return feature; },
212 [&](KURL kurl) { use_counter.DidCommitLoad(kurl); }, kExtensionUrl);
170 } 213 }
171 214
172 TEST(UseCounterTest, SVGImageContextFeatures) { 215 TEST(UseCounterTest, SVGImageContextFeatures) {
173 UseCounter use_counter(UseCounter::kSVGImageContext); 216 UseCounter use_counter(UseCounter::kSVGImageContext);
174 HistogramBasicTest<UseCounter::Feature>( 217 HistogramBasicTest<UseCounter::Feature>(
175 kSVGFeaturesHistogramName, kLegacyFeaturesHistogramName, 218 kSVGFeaturesHistogramName, kLegacyFeaturesHistogramName,
176 {kFeaturesHistogramName, kCSSHistogramName, kAnimatedCSSHistogramName},
177 UseCounter::kSVGSMILAdditiveAnimation, 219 UseCounter::kSVGSMILAdditiveAnimation,
178 UseCounter::kSVGSMILAnimationElementTiming, 220 UseCounter::kSVGSMILAnimationElementTiming,
179 [&](UseCounter::Feature feature) -> bool { 221 [&](UseCounter::Feature feature) -> bool {
180 return use_counter.HasRecordedMeasurement(feature); 222 return use_counter.HasRecordedMeasurement(feature);
181 }, 223 },
182 [&](UseCounter::Feature feature) { 224 [&](UseCounter::Feature feature) {
183 use_counter.RecordMeasurement(feature); 225 use_counter.RecordMeasurement(feature);
184 }, 226 },
185 [](UseCounter::Feature feature) -> int { return feature; }, 227 [](UseCounter::Feature feature) -> int { return feature; },
186 [&](KURL kurl) { use_counter.DidCommitLoad(kurl); }, "about:blank", 228 [&](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 } 229 }
190 230
191 TEST(UseCounterTest, SVGImageContextCSSProperties) { 231 TEST(UseCounterTest, SVGImageContextCSSProperties) {
192 UseCounter use_counter(UseCounter::kSVGImageContext); 232 UseCounter use_counter(UseCounter::kSVGImageContext);
193 HistogramBasicTest<CSSPropertyID>( 233 HistogramBasicTest<CSSPropertyID>(
194 kSVGCSSHistogramName, kLegacyCSSHistogramName, 234 kSVGCSSHistogramName, kLegacyCSSHistogramName, CSSPropertyFont,
195 {kFeaturesHistogramName, kCSSHistogramName, kAnimatedCSSHistogramName}, 235 CSSPropertyZoom,
196 CSSPropertyFont, CSSPropertyZoom,
197 [&](CSSPropertyID property) -> bool { 236 [&](CSSPropertyID property) -> bool {
198 return use_counter.IsCounted(property); 237 return use_counter.IsCounted(property);
199 }, 238 },
200 [&](CSSPropertyID property) { 239 [&](CSSPropertyID property) {
201 use_counter.Count(kHTMLStandardMode, property); 240 use_counter.Count(kHTMLStandardMode, property);
202 }, 241 },
203 [](CSSPropertyID property) -> int { 242 [](CSSPropertyID property) -> int {
204 return UseCounter::MapCSSPropertyIdToCSSSampleIdForHistogram(property); 243 return UseCounter::MapCSSPropertyIdToCSSSampleIdForHistogram(property);
205 }, 244 },
206 [&](KURL kurl) { use_counter.DidCommitLoad(kurl); }, "about:blank", 245 [&](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 } 246 }
210 247
211 TEST(UseCounterTest, SVGImageContextAnimatedCSSProperties) { 248 TEST(UseCounterTest, SVGImageContextAnimatedCSSProperties) {
212 UseCounter use_counter(UseCounter::kSVGImageContext); 249 UseCounter use_counter(UseCounter::kSVGImageContext);
213 HistogramBasicTest<CSSPropertyID>( 250 HistogramBasicTest<CSSPropertyID>(
214 kSVGAnimatedCSSHistogramName, "", 251 kSVGAnimatedCSSHistogramName, "", CSSPropertyOpacity, CSSPropertyVariable,
215 {kCSSHistogramName, kAnimatedCSSHistogramName}, CSSPropertyOpacity,
216 CSSPropertyVariable,
217 [&](CSSPropertyID property) -> bool { 252 [&](CSSPropertyID property) -> bool {
218 return use_counter.IsCountedAnimatedCSS(property); 253 return use_counter.IsCountedAnimatedCSS(property);
219 }, 254 },
220 [&](CSSPropertyID property) { use_counter.CountAnimatedCSS(property); }, 255 [&](CSSPropertyID property) { use_counter.CountAnimatedCSS(property); },
221 [](CSSPropertyID property) -> int { 256 [](CSSPropertyID property) -> int {
222 return UseCounter::MapCSSPropertyIdToCSSSampleIdForHistogram(property); 257 return UseCounter::MapCSSPropertyIdToCSSSampleIdForHistogram(property);
223 }, 258 },
224 [&](KURL kurl) { use_counter.DidCommitLoad(kurl); }, "about:blank", 259 [&](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 } 260 }
228 261
229 TEST(UseCounterTest, InspectorDisablesMeasurement) { 262 TEST(UseCounterTest, InspectorDisablesMeasurement) {
230 UseCounter use_counter; 263 UseCounter use_counter;
231 HistogramTester histogram_tester; 264 HistogramTester histogram_tester;
232 265
233 // The specific feature we use here isn't important. 266 // The specific feature we use here isn't important.
234 UseCounter::Feature feature = UseCounter::Feature::kSVGSMILElementInDocument; 267 UseCounter::Feature feature = UseCounter::Feature::kSVGSMILElementInDocument;
235 CSSPropertyID property = CSSPropertyFontWeight; 268 CSSPropertyID property = CSSPropertyFontWeight;
236 CSSParserMode parser_mode = kHTMLStandardMode; 269 CSSParserMode parser_mode = kHTMLStandardMode;
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 UseCounter use_counter; 330 UseCounter use_counter;
298 HistogramTester histogram_tester; 331 HistogramTester histogram_tester;
299 332
300 // Counters triggered before any load are always reported. 333 // Counters triggered before any load are always reported.
301 use_counter.RecordMeasurement(UseCounter::kFetch); 334 use_counter.RecordMeasurement(UseCounter::kFetch);
302 use_counter.Count(kHTMLStandardMode, CSSPropertyFontWeight); 335 use_counter.Count(kHTMLStandardMode, CSSPropertyFontWeight);
303 ExpectHistograms(histogram_tester, 0, UseCounter::kFetch, 1, 336 ExpectHistograms(histogram_tester, 0, UseCounter::kFetch, 1,
304 CSSPropertyFontWeight, 1); 337 CSSPropertyFontWeight, 1);
305 338
306 // Loading an internal page doesn't bump PageVisits and metrics not reported. 339 // Loading an internal page doesn't bump PageVisits and metrics not reported.
307 use_counter.DidCommitLoad(URLTestHelpers::ToKURL("about:blank")); 340 use_counter.DidCommitLoad(URLTestHelpers::ToKURL(kInternalUrl));
308 EXPECT_FALSE(use_counter.HasRecordedMeasurement(UseCounter::kFetch)); 341 EXPECT_FALSE(use_counter.HasRecordedMeasurement(UseCounter::kFetch));
309 EXPECT_FALSE(use_counter.IsCounted(CSSPropertyFontWeight)); 342 EXPECT_FALSE(use_counter.IsCounted(CSSPropertyFontWeight));
310 use_counter.RecordMeasurement(UseCounter::kFetch); 343 use_counter.RecordMeasurement(UseCounter::kFetch);
311 use_counter.Count(kHTMLStandardMode, CSSPropertyFontWeight); 344 use_counter.Count(kHTMLStandardMode, CSSPropertyFontWeight);
312 ExpectHistograms(histogram_tester, 0, UseCounter::kFetch, 1, 345 ExpectHistograms(histogram_tester, 0, UseCounter::kFetch, 1,
313 CSSPropertyFontWeight, 1); 346 CSSPropertyFontWeight, 1);
314 347
315 // But the fact that the features were seen is still known. 348 // But the fact that the features were seen is still known.
316 EXPECT_TRUE(use_counter.HasRecordedMeasurement(UseCounter::kFetch)); 349 EXPECT_TRUE(use_counter.HasRecordedMeasurement(UseCounter::kFetch));
317 EXPECT_TRUE(use_counter.IsCounted(CSSPropertyFontWeight)); 350 EXPECT_TRUE(use_counter.IsCounted(CSSPropertyFontWeight));
318 351
319 // Inspector muting then unmuting doesn't change the behavior. 352 // Inspector muting then unmuting doesn't change the behavior.
320 use_counter.MuteForInspector(); 353 use_counter.MuteForInspector();
321 use_counter.UnmuteForInspector(); 354 use_counter.UnmuteForInspector();
322 use_counter.RecordMeasurement(UseCounter::kFetch); 355 use_counter.RecordMeasurement(UseCounter::kFetch);
323 use_counter.Count(kHTMLStandardMode, CSSPropertyFontWeight); 356 use_counter.Count(kHTMLStandardMode, CSSPropertyFontWeight);
324 ExpectHistograms(histogram_tester, 0, UseCounter::kFetch, 1, 357 ExpectHistograms(histogram_tester, 0, UseCounter::kFetch, 1,
325 CSSPropertyFontWeight, 1); 358 CSSPropertyFontWeight, 1);
326 359
327 // If we now load a real web page, metrics are reported again. 360 // If we now load a real web page, metrics are reported again.
328 use_counter.DidCommitLoad(URLTestHelpers::ToKURL("http://foo.com/")); 361 use_counter.DidCommitLoad(URLTestHelpers::ToKURL("http://foo.com/"));
329 use_counter.RecordMeasurement(UseCounter::kFetch); 362 use_counter.RecordMeasurement(UseCounter::kFetch);
330 use_counter.Count(kHTMLStandardMode, CSSPropertyFontWeight); 363 use_counter.Count(kHTMLStandardMode, CSSPropertyFontWeight);
331 ExpectHistograms(histogram_tester, 1, UseCounter::kFetch, 2, 364 ExpectHistograms(histogram_tester, 1, UseCounter::kFetch, 2,
332 CSSPropertyFontWeight, 2); 365 CSSPropertyFontWeight, 2);
333 366
334 // HTTPs URLs are the same. 367 // HTTPs URLs are the same.
335 use_counter.DidCommitLoad( 368 use_counter.DidCommitLoad(URLTestHelpers::ToKURL(kHttpsUrl));
336 URLTestHelpers::ToKURL("https://baz.com:1234/blob.html"));
337 use_counter.RecordMeasurement(UseCounter::kFetch); 369 use_counter.RecordMeasurement(UseCounter::kFetch);
338 use_counter.Count(kHTMLStandardMode, CSSPropertyFontWeight); 370 use_counter.Count(kHTMLStandardMode, CSSPropertyFontWeight);
339 ExpectHistograms(histogram_tester, 2, UseCounter::kFetch, 3, 371 ExpectHistograms(histogram_tester, 2, UseCounter::kFetch, 3,
340 CSSPropertyFontWeight, 3); 372 CSSPropertyFontWeight, 3);
341 373
342 // Extensions aren't counted. 374 // Extensions aren't counted.
343 use_counter.DidCommitLoad( 375 use_counter.DidCommitLoad(URLTestHelpers::ToKURL(kExtensionUrl));
344 URLTestHelpers::ToKURL("chrome-extension://1238ba908adf/"));
345 use_counter.RecordMeasurement(UseCounter::kFetch); 376 use_counter.RecordMeasurement(UseCounter::kFetch);
346 use_counter.Count(kHTMLStandardMode, CSSPropertyFontWeight); 377 use_counter.Count(kHTMLStandardMode, CSSPropertyFontWeight);
347 ExpectHistograms(histogram_tester, 2, UseCounter::kFetch, 3, 378 ExpectHistograms(histogram_tester, 2, UseCounter::kFetch, 3,
348 CSSPropertyFontWeight, 3); 379 CSSPropertyFontWeight, 3);
349 380
350 // Nor is devtools 381 // Nor is devtools
351 use_counter.DidCommitLoad( 382 use_counter.DidCommitLoad(
352 URLTestHelpers::ToKURL("chrome-devtools://1238ba908adf/")); 383 URLTestHelpers::ToKURL("chrome-devtools://1238ba908adf/"));
353 use_counter.RecordMeasurement(UseCounter::kFetch); 384 use_counter.RecordMeasurement(UseCounter::kFetch);
354 use_counter.Count(kHTMLStandardMode, CSSPropertyFontWeight); 385 use_counter.Count(kHTMLStandardMode, CSSPropertyFontWeight);
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
420 451
421 deprecation_.UnmuteForInspector(); 452 deprecation_.UnmuteForInspector();
422 Deprecation::WarnOnDeprecatedProperties(GetFrame(), property); 453 Deprecation::WarnOnDeprecatedProperties(GetFrame(), property);
423 // TODO: use the actually deprecated property to get a deprecation message. 454 // TODO: use the actually deprecated property to get a deprecation message.
424 EXPECT_FALSE(deprecation_.IsSuppressed(property)); 455 EXPECT_FALSE(deprecation_.IsSuppressed(property));
425 Deprecation::CountDeprecation(GetFrame(), feature); 456 Deprecation::CountDeprecation(GetFrame(), feature);
426 EXPECT_TRUE(use_counter_.HasRecordedMeasurement(feature)); 457 EXPECT_TRUE(use_counter_.HasRecordedMeasurement(feature));
427 } 458 }
428 459
429 } // namespace blink 460 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/frame/UseCounter.cpp ('k') | third_party/WebKit/Source/platform/testing/HistogramTester.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698