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

Side by Side 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, 4 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "chrome/browser/safe_browsing/browser_feature_extractor.h" 5 #include "chrome/browser/safe_browsing/browser_feature_extractor.h"
6 6
7 #include <map> 7 #include <map>
8 #include <string> 8 #include <string>
9 9
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after
442 features::kPageTransitionType))); 442 features::kPageTransitionType)));
443 EXPECT_EQ(0U, 443 EXPECT_EQ(0U,
444 features.count(StringPrintf("%s%s", 444 features.count(StringPrintf("%s%s",
445 features::kHostPrefix, 445 features::kHostPrefix,
446 features::kIsFirstNavigation))); 446 features::kIsFirstNavigation)));
447 EXPECT_EQ(5.0, features[features::kPageTransitionType]); 447 EXPECT_EQ(5.0, features[features::kPageTransitionType]);
448 EXPECT_EQ(1.0, features[std::string(features::kBadIpFetch) + "193.5.163.8"]); 448 EXPECT_EQ(1.0, features[std::string(features::kBadIpFetch) + "193.5.163.8"]);
449 EXPECT_FALSE(features.count(std::string(features::kBadIpFetch) + 449 EXPECT_FALSE(features.count(std::string(features::kBadIpFetch) +
450 "23.94.78.1")); 450 "23.94.78.1"));
451 } 451 }
452
453 TEST_F(BrowserFeatureExtractorTest, SafeBrowsingFeatures) {
454 contents()->NavigateAndCommit(GURL("http://www.foo.com/malware.html"));
455 ClientPhishingRequest request;
456 request.set_url("http://www.foo.com/malware.html");
457 request.set_client_score(0.5);
458
459 browse_info_->unsafe_resource.reset(new SafeBrowsingService::UnsafeResource);
460 browse_info_->unsafe_resource->url = GURL("http://www.malware.com/");
461 browse_info_->unsafe_resource->original_url = GURL("http://www.good.com/");
462 browse_info_->unsafe_resource->is_subresource = true;
463 browse_info_->unsafe_resource->threat_type = SafeBrowsingService::URL_MALWARE;
464
465 ExtractFeatures(&request);
466 std::map<std::string, double> features;
467 GetFeatureMap(request, &features);
468 EXPECT_TRUE(features.count(StringPrintf("%s%s",
469 features::kSafeBrowsingMaliciousUrl,
470 "http://www.malware.com/")));
471 EXPECT_TRUE(features.count(StringPrintf("%s%s",
472 features::kSafeBrowsingOriginalUrl,
473 "http://www.good.com/")));
474 EXPECT_DOUBLE_EQ(1.0, features[features::kSafeBrowsingIsSubresource]);
475 EXPECT_DOUBLE_EQ(2.0, features[features::kSafeBrowsingThreatType]);
476 }
452 } // namespace safe_browsing 477 } // namespace safe_browsing
OLDNEW
« 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