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

Unified Diff: chrome/browser/safe_browsing/browser_feature_extractor_unittest.cc

Issue 7538009: Send back the URL that matched the SafeBrowsing list with the CSD ping. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address Matt's comments. Created 9 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/safe_browsing/browser_feature_extractor_unittest.cc
diff --git a/chrome/browser/safe_browsing/browser_feature_extractor_unittest.cc b/chrome/browser/safe_browsing/browser_feature_extractor_unittest.cc
index 23987f353d32e500990a41240c5a6286708a2bad..e55e873ea63b92200ed599530d34199932207dfc 100644
--- a/chrome/browser/safe_browsing/browser_feature_extractor_unittest.cc
+++ b/chrome/browser/safe_browsing/browser_feature_extractor_unittest.cc
@@ -449,4 +449,29 @@ TEST_F(BrowserFeatureExtractorTest, BrowseFeatures) {
EXPECT_FALSE(features.count(std::string(features::kBadIpFetch) +
"23.94.78.1"));
}
+
+TEST_F(BrowserFeatureExtractorTest, SafeBrowsingFeatures) {
+ contents()->NavigateAndCommit(GURL("http://www.foo.com/malware.html"));
+ ClientPhishingRequest request;
+ request.set_url("http://www.foo.com/malware.html");
+ request.set_client_score(0.5);
+
+ browse_info_->unsafe_resource.reset(new SafeBrowsingService::UnsafeResource);
+ browse_info_->unsafe_resource->url = GURL("http://www.malware.com/");
+ browse_info_->unsafe_resource->original_url = GURL("http://www.good.com/");
+ browse_info_->unsafe_resource->is_subresource = true;
+ browse_info_->unsafe_resource->threat_type = SafeBrowsingService::URL_MALWARE;
+
+ ExtractFeatures(&request);
+ std::map<std::string, double> features;
+ GetFeatureMap(request, &features);
+ EXPECT_TRUE(features.count(StringPrintf("%s%s",
+ features::kSafeBrowsingMaliciousUrl,
+ "http://www.malware.com/")));
+ EXPECT_TRUE(features.count(StringPrintf("%s%s",
+ features::kSafeBrowsingOriginalUrl,
+ "http://www.good.com/")));
+ EXPECT_DOUBLE_EQ(1.0, features[features::kSafeBrowsingIsSubresource]);
+ EXPECT_DOUBLE_EQ(2.0, features[features::kSafeBrowsingThreatType]);
+}
} // namespace safe_browsing
« no previous file with comments | « chrome/browser/safe_browsing/browser_feature_extractor.cc ('k') | chrome/browser/safe_browsing/client_side_detection_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698