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" |
11 | 11 |
12 #include "base/bind.h" | 12 #include "base/bind.h" |
13 #include "base/callback.h" | 13 #include "base/callback.h" |
14 #include "base/command_line.h" | 14 #include "base/command_line.h" |
15 #include "base/compiler_specific.h" | 15 #include "base/compiler_specific.h" |
| 16 #include "base/location.h" |
16 #include "base/memory/weak_ptr.h" | 17 #include "base/memory/weak_ptr.h" |
17 #include "base/message_loop/message_loop.h" | 18 #include "base/single_thread_task_runner.h" |
18 #include "base/strings/string_number_conversions.h" | 19 #include "base/strings/string_number_conversions.h" |
| 20 #include "base/thread_task_runner_handle.h" |
19 #include "base/time/time.h" | 21 #include "base/time/time.h" |
20 #include "chrome/browser/ui/browser.h" | 22 #include "chrome/browser/ui/browser.h" |
21 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 23 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
22 #include "chrome/common/chrome_switches.h" | 24 #include "chrome/common/chrome_switches.h" |
23 #include "chrome/renderer/safe_browsing/features.h" | 25 #include "chrome/renderer/safe_browsing/features.h" |
24 #include "chrome/renderer/safe_browsing/mock_feature_extractor_clock.h" | 26 #include "chrome/renderer/safe_browsing/mock_feature_extractor_clock.h" |
25 #include "chrome/renderer/safe_browsing/test_utils.h" | 27 #include "chrome/renderer/safe_browsing/test_utils.h" |
26 #include "chrome/test/base/in_process_browser_test.h" | 28 #include "chrome/test/base/in_process_browser_test.h" |
27 #include "chrome/test/base/ui_test_utils.h" | 29 #include "chrome/test/base/ui_test_utils.h" |
28 #include "content/public/browser/interstitial_page.h" | 30 #include "content/public/browser/interstitial_page.h" |
(...skipping 26 matching lines...) Expand all Loading... |
55 | 57 |
56 class PhishingDOMFeatureExtractorTest : public InProcessBrowserTest { | 58 class PhishingDOMFeatureExtractorTest : public InProcessBrowserTest { |
57 public: | 59 public: |
58 content::WebContents* GetWebContents() { | 60 content::WebContents* GetWebContents() { |
59 return browser()->tab_strip_model()->GetActiveWebContents(); | 61 return browser()->tab_strip_model()->GetActiveWebContents(); |
60 } | 62 } |
61 | 63 |
62 // Helper for the SubframeRemoval test that posts a message to remove | 64 // Helper for the SubframeRemoval test that posts a message to remove |
63 // the iframe "frame1" from the document. | 65 // the iframe "frame1" from the document. |
64 void ScheduleRemoveIframe() { | 66 void ScheduleRemoveIframe() { |
65 base::MessageLoop::current()->PostTask( | 67 base::ThreadTaskRunnerHandle::Get()->PostTask( |
66 FROM_HERE, | 68 FROM_HERE, base::Bind(&PhishingDOMFeatureExtractorTest::RemoveIframe, |
67 base::Bind(&PhishingDOMFeatureExtractorTest::RemoveIframe, | 69 weak_factory_.GetWeakPtr())); |
68 weak_factory_.GetWeakPtr())); | |
69 } | 70 } |
70 | 71 |
71 protected: | 72 protected: |
72 PhishingDOMFeatureExtractorTest() : weak_factory_(this) {} | 73 PhishingDOMFeatureExtractorTest() : weak_factory_(this) {} |
73 | 74 |
74 ~PhishingDOMFeatureExtractorTest() override {} | 75 ~PhishingDOMFeatureExtractorTest() override {} |
75 | 76 |
76 void SetUpCommandLine(base::CommandLine* command_line) override { | 77 void SetUpCommandLine(base::CommandLine* command_line) override { |
77 command_line->AppendSwitch(switches::kSingleProcess); | 78 command_line->AppendSwitch(switches::kSingleProcess); |
78 #if defined(OS_WIN) | 79 #if defined(OS_WIN) |
(...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
542 LoadHtml( | 543 LoadHtml( |
543 "host.com", | 544 "host.com", |
544 "<html><head></head><body>" | 545 "<html><head></head><body>" |
545 "<iframe src=\"frame.html\" id=\"frame1\"></iframe>" | 546 "<iframe src=\"frame.html\" id=\"frame1\"></iframe>" |
546 "<form></form></body></html>"); | 547 "<form></form></body></html>"); |
547 ASSERT_TRUE(ExtractFeatures(&features)); | 548 ASSERT_TRUE(ExtractFeatures(&features)); |
548 ExpectFeatureMapsAreEqual(features, expected_features); | 549 ExpectFeatureMapsAreEqual(features, expected_features); |
549 } | 550 } |
550 | 551 |
551 } // namespace safe_browsing | 552 } // namespace safe_browsing |
OLD | NEW |