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

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

Issue 2796283005: Adding UseCounter specific for extensions (Closed)
Patch Set: bug fix Created 3 years, 8 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* const kFeaturesHistogramName = "Blink.UseCounter.Features";
16 const char* const kCSSHistogramName = "Blink.UseCounter.CSSProperties"; 16 const char* const kCSSHistogramName = "Blink.UseCounter.CSSProperties";
17 const char* const kAnimatedCSSHistogramName = 17 const char* const kAnimatedCSSHistogramName =
18 "Blink.UseCounter.AnimatedCSSProperties"; 18 "Blink.UseCounter.AnimatedCSSProperties";
19 const char* const kExtensionFeaturesHistogramName =
Rick Byers 2017/04/28 15:04:40 nit: please add this to the unaffected_histograms
20 "Blink.UseCounter.Extensions.Features";
19 21
20 const char* const kSVGFeaturesHistogramName = 22 const char* const kSVGFeaturesHistogramName =
21 "Blink.UseCounter.SVGImage.Features"; 23 "Blink.UseCounter.SVGImage.Features";
22 const char* const kSVGCSSHistogramName = 24 const char* const kSVGCSSHistogramName =
23 "Blink.UseCounter.SVGImage.CSSProperties"; 25 "Blink.UseCounter.SVGImage.CSSProperties";
24 const char* const kSVGAnimatedCSSHistogramName = 26 const char* const kSVGAnimatedCSSHistogramName =
25 "Blink.UseCounter.SVGImage.AnimatedCSSProperties"; 27 "Blink.UseCounter.SVGImage.AnimatedCSSProperties";
26 28
27 const char* const kLegacyFeaturesHistogramName = "WebCore.FeatureObserver"; 29 const char* const kLegacyFeaturesHistogramName = "WebCore.FeatureObserver";
28 const char* const kLegacyCSSHistogramName = 30 const char* const kLegacyCSSHistogramName =
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 }, 233 },
232 [&](CSSPropertyID property) { use_counter.CountAnimatedCSS(property); }, 234 [&](CSSPropertyID property) { use_counter.CountAnimatedCSS(property); },
233 [](CSSPropertyID property) -> int { 235 [](CSSPropertyID property) -> int {
234 return UseCounter::MapCSSPropertyIdToCSSSampleIdForHistogram(property); 236 return UseCounter::MapCSSPropertyIdToCSSSampleIdForHistogram(property);
235 }, 237 },
236 [&](KURL kurl) { use_counter.DidCommitLoad(kurl); }, "about:blank", 238 [&](KURL kurl) { use_counter.DidCommitLoad(kurl); }, "about:blank",
237 // In practice SVGs always appear to be loaded with an about:blank URL 239 // In practice SVGs always appear to be loaded with an about:blank URL
238 1 /* page visit bucket */); 240 1 /* page visit bucket */);
239 } 241 }
240 242
243 TEST(UseCounterTest, RecordingExtensions) {
244 UseCounter use_counter(UseCounter::kExtensionContext);
245 HistogramBasicTest<UseCounter::Feature>(
246 kExtensionFeaturesHistogramName, kLegacyFeaturesHistogramName,
247 {kSVGFeaturesHistogramName, kFeaturesHistogramName}, UseCounter::kFetch,
248 UseCounter::kFetchBodyStream,
249 [&](UseCounter::Feature feature) -> bool {
250 return use_counter.HasRecordedMeasurement(feature);
251 },
252 [&](UseCounter::Feature feature) {
253 use_counter.RecordMeasurement(feature);
254 },
255 [](UseCounter::Feature feature) -> int { return feature; },
256 [&](KURL kurl) { use_counter.DidCommitLoad(kurl); },
257 "chrome-extension://dummysite", UseCounter::kPageVisits);
258 }
259
241 // Failing on Android: crbug.com/667913 260 // Failing on Android: crbug.com/667913
242 #if OS(ANDROID) 261 #if OS(ANDROID)
243 #define MAYBE_InspectorDisablesMeasurement DISABLED_InspectorDisablesMeasurement 262 #define MAYBE_InspectorDisablesMeasurement DISABLED_InspectorDisablesMeasurement
244 #else 263 #else
245 #define MAYBE_InspectorDisablesMeasurement InspectorDisablesMeasurement 264 #define MAYBE_InspectorDisablesMeasurement InspectorDisablesMeasurement
246 #endif 265 #endif
247 TEST(UseCounterTest, MAYBE_InspectorDisablesMeasurement) { 266 TEST(UseCounterTest, MAYBE_InspectorDisablesMeasurement) {
248 UseCounter use_counter; 267 UseCounter use_counter;
249 HistogramTester histogram_tester; 268 HistogramTester histogram_tester;
250 269
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
444 463
445 deprecation_.UnmuteForInspector(); 464 deprecation_.UnmuteForInspector();
446 Deprecation::WarnOnDeprecatedProperties(GetFrame(), property); 465 Deprecation::WarnOnDeprecatedProperties(GetFrame(), property);
447 // TODO: use the actually deprecated property to get a deprecation message. 466 // TODO: use the actually deprecated property to get a deprecation message.
448 EXPECT_FALSE(deprecation_.IsSuppressed(property)); 467 EXPECT_FALSE(deprecation_.IsSuppressed(property));
449 Deprecation::CountDeprecation(GetFrame(), feature); 468 Deprecation::CountDeprecation(GetFrame(), feature);
450 EXPECT_TRUE(use_counter_.HasRecordedMeasurement(feature)); 469 EXPECT_TRUE(use_counter_.HasRecordedMeasurement(feature));
451 } 470 }
452 471
453 } // namespace blink 472 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698