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

Side by Side Diff: chrome/browser/extensions/chrome_content_browser_client_extensions_part_unittest.cc

Issue 2787573003: Remove DumpWithoutCrashing from ShouldAllowOpenURL. (Closed)
Patch Set: Address asvitkine's comments 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
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/extensions/chrome_content_browser_client_extensions_par t.h"
6
7 #include <string>
8 #include <vector>
9
10 #include "base/test/histogram_tester.h"
11 #include "chrome/common/chrome_content_client.h"
12 #include "testing/gtest/include/gtest/gtest.h"
13
14 namespace extensions {
15
16 typedef testing::Test ChromeContentBrowserClientExtensionsPartTest;
17
18 // Check that empty site URLs get recorded properly in ShouldAllowOpenURL
19 // failures.
20 TEST_F(ChromeContentBrowserClientExtensionsPartTest,
21 ShouldAllowOpenURLMetricsForEmptySiteURL) {
22 base::HistogramTester uma;
23
24 auto failure_reason = ChromeContentBrowserClientExtensionsPart::
25 FAILURE_SCHEME_NOT_HTTP_OR_HTTPS_OR_EXTENSION;
26 ChromeContentBrowserClientExtensionsPart::RecordShouldAllowOpenURLFailure(
27 failure_reason, GURL());
28 uma.ExpectUniqueSample("Extensions.ShouldAllowOpenURL.Failure",
29 failure_reason, 1);
30 uma.ExpectUniqueSample("Extensions.ShouldAllowOpenURL.Failure.Scheme",
31 1 /* SCHEME_EMPTY */, 1);
32 }
33
34 // Check that a non-exhaustive list of some known schemes get recorded properly
35 // in ShouldAllowOpenURL failures.
36 TEST_F(ChromeContentBrowserClientExtensionsPartTest,
37 ShouldAllowOpenURLMetricsForKnownSchemes) {
38 base::HistogramTester uma;
39
40 ChromeContentClient content_client;
41 content::ContentClient::Schemes schemes;
42 content_client.AddAdditionalSchemes(&schemes);
43
44 std::vector<std::string> test_schemes(schemes.savable_schemes);
45 test_schemes.insert(test_schemes.end(), schemes.secure_schemes.begin(),
46 schemes.secure_schemes.end());
47 test_schemes.insert(test_schemes.end(),
48 schemes.empty_document_schemes.begin(),
49 schemes.empty_document_schemes.end());
50 test_schemes.push_back(url::kHttpScheme);
51 test_schemes.push_back(url::kHttpsScheme);
52 test_schemes.push_back(url::kFileScheme);
53
54 auto failure_reason = ChromeContentBrowserClientExtensionsPart::
55 FAILURE_RESOURCE_NOT_WEB_ACCESSIBLE;
56 for (auto scheme : test_schemes) {
57 ChromeContentBrowserClientExtensionsPart::RecordShouldAllowOpenURLFailure(
58 failure_reason, GURL(scheme + "://foo.com/"));
59 }
60
61 // There should be no unknown schemes recorded.
62 uma.ExpectUniqueSample("Extensions.ShouldAllowOpenURL.Failure",
63 failure_reason, test_schemes.size());
64 uma.ExpectTotalCount("Extensions.ShouldAllowOpenURL.Failure.Scheme",
65 test_schemes.size());
66 uma.ExpectBucketCount("Extensions.ShouldAllowOpenURL.Failure.Scheme",
67 0 /* SCHEME_UNKNOWN */, 0);
68 }
69
70 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698