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

Side by Side Diff: chrome/renderer/safe_browsing/phishing_classifier_browsertest.cc

Issue 8310014: Only send the client-side phishing model to a renderer if its profile has SafeBrowsing enabled. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add a comment as Noe suggested Created 9 years, 2 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 // Note that although this is not a "browser" test, it runs as part of 5 // Note that although this is not a "browser" test, it runs as part of
6 // browser_tests. This is because WebKit does not work properly if it is 6 // browser_tests. This is because WebKit does not work properly if it is
7 // shutdown and re-initialized. Since browser_tests runs each test in a 7 // shutdown and re-initialized. Since browser_tests runs each test in a
8 // new process, this avoids the problem. 8 // new process, this avoids the problem.
9 9
10 #include "chrome/renderer/safe_browsing/phishing_classifier.h" 10 #include "chrome/renderer/safe_browsing/phishing_classifier.h"
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 EXPECT_EQ(0U, features.features().size()); 186 EXPECT_EQ(0U, features.features().size());
187 EXPECT_EQ(PhishingClassifier::kInvalidScore, phishy_score); 187 EXPECT_EQ(PhishingClassifier::kInvalidScore, phishy_score);
188 188
189 // Extraction should fail for this case because the URL is a POST request. 189 // Extraction should fail for this case because the URL is a POST request.
190 LoadURLWithPost("http://host.net/"); 190 LoadURLWithPost("http://host.net/");
191 EXPECT_FALSE(RunPhishingClassifier(&page_text, &phishy_score, &features)); 191 EXPECT_FALSE(RunPhishingClassifier(&page_text, &phishy_score, &features));
192 EXPECT_EQ(0U, features.features().size()); 192 EXPECT_EQ(0U, features.features().size());
193 EXPECT_EQ(PhishingClassifier::kInvalidScore, phishy_score); 193 EXPECT_EQ(PhishingClassifier::kInvalidScore, phishy_score);
194 } 194 }
195 195
196 TEST_F(PhishingClassifierTest, DisableDetection) {
197 // No scorer yet, so the classifier is not ready.
198 EXPECT_FALSE(classifier_->is_ready());
199
200 // Now set the scorer.
201 classifier_->set_phishing_scorer(scorer_.get());
202 EXPECT_TRUE(classifier_->is_ready());
203
204 // Set a NULL scorer, which turns detection back off.
205 classifier_->set_phishing_scorer(NULL);
206 EXPECT_FALSE(classifier_->is_ready());
207 }
208
196 } // namespace safe_browsing 209 } // namespace safe_browsing
OLDNEW
« no previous file with comments | « chrome/renderer/safe_browsing/phishing_classifier.cc ('k') | chrome/renderer/safe_browsing/phishing_classifier_delegate.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698