| 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 // 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_dom_feature_extractor.h" | 10 #include "chrome/renderer/safe_browsing/phishing_dom_feature_extractor.h" |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 } | 72 } |
| 73 | 73 |
| 74 // Completion callback for feature extraction. | 74 // Completion callback for feature extraction. |
| 75 void ExtractionDone(bool success) { | 75 void ExtractionDone(bool success) { |
| 76 success_ = success; | 76 success_ = success; |
| 77 message_loop_.Quit(); | 77 message_loop_.Quit(); |
| 78 } | 78 } |
| 79 | 79 |
| 80 // Does the actual work of removing the iframe "frame1" from the document. | 80 // Does the actual work of removing the iframe "frame1" from the document. |
| 81 void RemoveIframe() { | 81 void RemoveIframe() { |
| 82 WebKit::WebFrame* main_frame = GetMainFrame(); | 82 blink::WebFrame* main_frame = GetMainFrame(); |
| 83 ASSERT_TRUE(main_frame); | 83 ASSERT_TRUE(main_frame); |
| 84 main_frame->executeScript( | 84 main_frame->executeScript( |
| 85 WebKit::WebString( | 85 blink::WebString( |
| 86 "document.body.removeChild(document.getElementById('frame1'));")); | 86 "document.body.removeChild(document.getElementById('frame1'));")); |
| 87 } | 87 } |
| 88 | 88 |
| 89 MockFeatureExtractorClock clock_; | 89 MockFeatureExtractorClock clock_; |
| 90 scoped_ptr<PhishingDOMFeatureExtractor> extractor_; | 90 scoped_ptr<PhishingDOMFeatureExtractor> extractor_; |
| 91 bool success_; // holds the success value from ExtractFeatures | 91 bool success_; // holds the success value from ExtractFeatures |
| 92 base::WeakPtrFactory<PhishingDOMFeatureExtractorTest> weak_factory_; | 92 base::WeakPtrFactory<PhishingDOMFeatureExtractorTest> weak_factory_; |
| 93 }; | 93 }; |
| 94 | 94 |
| 95 TEST_F(PhishingDOMFeatureExtractorTest, FormFeatures) { | 95 TEST_F(PhishingDOMFeatureExtractorTest, FormFeatures) { |
| (...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 394 expected_features.AddBooleanFeature(features::kPageHasForms); | 394 expected_features.AddBooleanFeature(features::kPageHasForms); |
| 395 expected_features.AddBooleanFeature(features::kPageHasPswdInputs); | 395 expected_features.AddBooleanFeature(features::kPageHasPswdInputs); |
| 396 | 396 |
| 397 FeatureMap features; | 397 FeatureMap features; |
| 398 LoadURL("http://host.com/"); | 398 LoadURL("http://host.com/"); |
| 399 ASSERT_TRUE(ExtractFeatures(&features)); | 399 ASSERT_TRUE(ExtractFeatures(&features)); |
| 400 ExpectFeatureMapsAreEqual(features, expected_features); | 400 ExpectFeatureMapsAreEqual(features, expected_features); |
| 401 } | 401 } |
| 402 | 402 |
| 403 } // namespace safe_browsing | 403 } // namespace safe_browsing |
| OLD | NEW |