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

Unified Diff: chrome/browser/safe_browsing/client_side_detection_host_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
« no previous file with comments | « chrome/browser/safe_browsing/client_side_detection_host.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/safe_browsing/client_side_detection_host_unittest.cc
diff --git a/chrome/browser/safe_browsing/client_side_detection_host_unittest.cc b/chrome/browser/safe_browsing/client_side_detection_host_unittest.cc
index aff6c93700a9e8b532497ff78467a90cc2a79582..6f7206332ca15e9821917b7ae76c19edc2d8ad8e 100644
--- a/chrome/browser/safe_browsing/client_side_detection_host_unittest.cc
+++ b/chrome/browser/safe_browsing/client_side_detection_host_unittest.cc
@@ -241,10 +241,38 @@ class ClientSideDetectionHostTest : public TabContentsWrapperTestHarness {
csd_host_->feature_extractor_.reset(extractor);
}
- void SetUnsafeUniquePageIdToCurrent() {
- csd_host_->unsafe_unique_page_id_ =
- contents()->controller().GetActiveEntry()->unique_id();
+ void SetUnsafeResourceToCurrent() {
+ SafeBrowsingService::UnsafeResource resource;
+ resource.url = GURL("http://www.malware.com/");
+ resource.original_url = contents()->GetURL();
+ resource.is_subresource = true;
+ resource.threat_type = SafeBrowsingService::URL_MALWARE;
+ // Bogus client class. We just need this class to check that the client
+ // field of the UnsafeResource gets cleared before we stored it in the
+ // host object.
+ class BogusClient : public SafeBrowsingService::Client {
+ public:
+ BogusClient() {}
+ virtual ~BogusClient() {}
+ };
+ resource.client = new BogusClient();
+ resource.render_process_host_id = contents()->GetRenderProcessHost()->id();
+ resource.render_view_id = contents()->render_view_host()->routing_id();
+ csd_host_->OnSafeBrowsingHit(resource);
+ delete resource.client;
ASSERT_TRUE(csd_host_->DidShowSBInterstitial());
+ ASSERT_TRUE(csd_host_->unsafe_resource_.get());
+ // Test that the resource above was copied.
+ EXPECT_EQ(resource.url, csd_host_->unsafe_resource_->url);
+ EXPECT_EQ(resource.original_url, csd_host_->unsafe_resource_->original_url);
+ EXPECT_EQ(resource.is_subresource,
+ csd_host_->unsafe_resource_->is_subresource);
+ EXPECT_EQ(resource.threat_type, csd_host_->unsafe_resource_->threat_type);
+ EXPECT_EQ(NULL, csd_host_->unsafe_resource_->client);
+ EXPECT_EQ(resource.render_process_host_id,
+ csd_host_->unsafe_resource_->render_process_host_id);
+ EXPECT_EQ(resource.render_view_id,
+ csd_host_->unsafe_resource_->render_view_id);
}
protected:
@@ -519,7 +547,7 @@ TEST_F(ClientSideDetectionHostTest,
&kFalse, &kFalse);
NavigateAndCommit(url);
WaitAndCheckPreClassificationChecks();
- SetUnsafeUniquePageIdToCurrent();
+ SetUnsafeResourceToCurrent();
EXPECT_CALL(*csd_service_,
SendClientReportPhishingRequest(
« no previous file with comments | « chrome/browser/safe_browsing/client_side_detection_host.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698