| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/renderer/safe_browsing/phishing_classifier.h" | 5 #include "chrome/renderer/safe_browsing/phishing_classifier.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 260 EXPECT_EQ(0U, features.features().size()); | 260 EXPECT_EQ(0U, features.features().size()); |
| 261 EXPECT_EQ(PhishingClassifier::kInvalidScore, phishy_score); | 261 EXPECT_EQ(PhishingClassifier::kInvalidScore, phishy_score); |
| 262 | 262 |
| 263 // Extraction should fail for this case because the URL is a POST request. | 263 // Extraction should fail for this case because the URL is a POST request. |
| 264 LoadHtmlPost("host.net", "<html><body>content</body></html>"); | 264 LoadHtmlPost("host.net", "<html><body>content</body></html>"); |
| 265 EXPECT_FALSE(RunPhishingClassifier(&page_text, &phishy_score, &features)); | 265 EXPECT_FALSE(RunPhishingClassifier(&page_text, &phishy_score, &features)); |
| 266 EXPECT_EQ(0U, features.features().size()); | 266 EXPECT_EQ(0U, features.features().size()); |
| 267 EXPECT_EQ(PhishingClassifier::kInvalidScore, phishy_score); | 267 EXPECT_EQ(PhishingClassifier::kInvalidScore, phishy_score); |
| 268 } | 268 } |
| 269 | 269 |
| 270 IN_PROC_BROWSER_TEST_F(PhishingClassifierTest, DisableDetection) { | 270 // Flaky on Mac Blink bots: crbug.com/316709 |
| 271 #if defined(OS_MACOSX) |
| 272 #define MAYBE_DisableDetection DISABLED_DisableDetection |
| 273 #else |
| 274 #define MAYBE_DisableDetection DisableDetection |
| 275 #endif |
| 276 |
| 277 IN_PROC_BROWSER_TEST_F(PhishingClassifierTest, MAYBE_DisableDetection) { |
| 271 // No scorer yet, so the classifier is not ready. | 278 // No scorer yet, so the classifier is not ready. |
| 272 EXPECT_FALSE(classifier_->is_ready()); | 279 EXPECT_FALSE(classifier_->is_ready()); |
| 273 | 280 |
| 274 // Now set the scorer. | 281 // Now set the scorer. |
| 275 classifier_->set_phishing_scorer(scorer_.get()); | 282 classifier_->set_phishing_scorer(scorer_.get()); |
| 276 EXPECT_TRUE(classifier_->is_ready()); | 283 EXPECT_TRUE(classifier_->is_ready()); |
| 277 | 284 |
| 278 // Set a NULL scorer, which turns detection back off. | 285 // Set a NULL scorer, which turns detection back off. |
| 279 classifier_->set_phishing_scorer(NULL); | 286 classifier_->set_phishing_scorer(NULL); |
| 280 EXPECT_FALSE(classifier_->is_ready()); | 287 EXPECT_FALSE(classifier_->is_ready()); |
| 281 } | 288 } |
| 282 | 289 |
| 283 } // namespace safe_browsing | 290 } // namespace safe_browsing |
| OLD | NEW |