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 // This test creates a safebrowsing service using test safebrowsing database | 5 // This test creates a safebrowsing service using test safebrowsing database |
6 // and a test protocol manager. It is used to test logics in safebrowsing | 6 // and a test protocol manager. It is used to test logics in safebrowsing |
7 // service. | 7 // service. |
8 | 8 |
9 #include "chrome/browser/safe_browsing/safe_browsing_service.h" | 9 #include "chrome/browser/safe_browsing/safe_browsing_service.h" |
10 | 10 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 #include "chrome/test/base/ui_test_utils.h" | 49 #include "chrome/test/base/ui_test_utils.h" |
50 #include "components/bookmarks/browser/startup_task_runner_service.h" | 50 #include "components/bookmarks/browser/startup_task_runner_service.h" |
51 #include "components/content_settings/core/browser/host_content_settings_map.h" | 51 #include "components/content_settings/core/browser/host_content_settings_map.h" |
52 #include "components/prefs/pref_service.h" | 52 #include "components/prefs/pref_service.h" |
53 #include "components/safe_browsing_db/database_manager.h" | 53 #include "components/safe_browsing_db/database_manager.h" |
54 #include "components/safe_browsing_db/metadata.pb.h" | 54 #include "components/safe_browsing_db/metadata.pb.h" |
55 #include "components/safe_browsing_db/test_database_manager.h" | 55 #include "components/safe_browsing_db/test_database_manager.h" |
56 #include "components/safe_browsing_db/util.h" | 56 #include "components/safe_browsing_db/util.h" |
57 #include "components/safe_browsing_db/v4_protocol_manager_util.h" | 57 #include "components/safe_browsing_db/v4_protocol_manager_util.h" |
58 #include "components/subresource_filter/content/browser/content_subresource_filt
er_driver_factory.h" | 58 #include "components/subresource_filter/content/browser/content_subresource_filt
er_driver_factory.h" |
| 59 #include "components/subresource_filter/core/browser/subresource_filter_features
.h" |
| 60 #include "components/subresource_filter/core/browser/subresource_filter_features
_test_support.h" |
59 #include "content/public/browser/interstitial_page.h" | 61 #include "content/public/browser/interstitial_page.h" |
60 #include "content/public/browser/navigation_entry.h" | 62 #include "content/public/browser/navigation_entry.h" |
61 #include "content/public/browser/render_frame_host.h" | 63 #include "content/public/browser/render_frame_host.h" |
62 #include "content/public/browser/web_contents.h" | 64 #include "content/public/browser/web_contents.h" |
63 #include "content/public/test/browser_test_utils.h" | 65 #include "content/public/test/browser_test_utils.h" |
64 #include "net/cookies/cookie_store.h" | 66 #include "net/cookies/cookie_store.h" |
65 #include "net/cookies/cookie_util.h" | 67 #include "net/cookies/cookie_util.h" |
66 #include "net/test/embedded_test_server/embedded_test_server.h" | 68 #include "net/test/embedded_test_server/embedded_test_server.h" |
67 #include "net/test/embedded_test_server/http_request.h" | 69 #include "net/test/embedded_test_server/http_request.h" |
68 #include "net/test/embedded_test_server/http_response.h" | 70 #include "net/test/embedded_test_server/http_response.h" |
(...skipping 823 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
892 EXPECT_TRUE(ShowingInterstitialPage()); | 894 EXPECT_TRUE(ShowingInterstitialPage()); |
893 EXPECT_TRUE(got_hit_report()); | 895 EXPECT_TRUE(got_hit_report()); |
894 EXPECT_EQ(bad_url, hit_report().malicious_url); | 896 EXPECT_EQ(bad_url, hit_report().malicious_url); |
895 EXPECT_EQ(bad_url, hit_report().page_url); | 897 EXPECT_EQ(bad_url, hit_report().page_url); |
896 EXPECT_EQ(first_url, hit_report().referrer_url); | 898 EXPECT_EQ(first_url, hit_report().referrer_url); |
897 EXPECT_FALSE(hit_report().is_subresource); | 899 EXPECT_FALSE(hit_report().is_subresource); |
898 } | 900 } |
899 | 901 |
900 IN_PROC_BROWSER_TEST_F(SafeBrowsingServiceTest, | 902 IN_PROC_BROWSER_TEST_F(SafeBrowsingServiceTest, |
901 SocEngReportingBlacklistNotEmpty) { | 903 SocEngReportingBlacklistNotEmpty) { |
| 904 subresource_filter::testing::ScopedSubresourceFilterFeatureToggle |
| 905 scoped_feature_toggle( |
| 906 base::FeatureList::OVERRIDE_ENABLE_FEATURE, |
| 907 subresource_filter::kActivationStateEnabled, |
| 908 subresource_filter::kActivationScopeNoSites, |
| 909 subresource_filter::kActivationListSocialEngineeringAdsInterstitial); |
902 // Tests that when Safe Browsing gets hit which is corresponding to the | 910 // Tests that when Safe Browsing gets hit which is corresponding to the |
903 // SOCIAL_ENGINEERING_ADS threat type, then URL is added to the Subresource | 911 // SOCIAL_ENGINEERING_ADS threat type, then URL is added to the Subresource |
904 // Filter. | 912 // Filter. |
905 GURL bad_url = embedded_test_server()->GetURL(kMalwarePage); | 913 GURL bad_url = embedded_test_server()->GetURL(kMalwarePage); |
906 | 914 |
907 SBFullHashResult malware_full_hash; | 915 SBFullHashResult malware_full_hash; |
908 GenUrlFullHashResultWithMetadata(bad_url, MALWARE, | 916 GenUrlFullHashResultWithMetadata(bad_url, MALWARE, |
909 ThreatPatternType::SOCIAL_ENGINEERING_ADS, | 917 ThreatPatternType::SOCIAL_ENGINEERING_ADS, |
910 &malware_full_hash); | 918 &malware_full_hash); |
911 SetupResponseForUrl(bad_url, malware_full_hash); | 919 SetupResponseForUrl(bad_url, malware_full_hash); |
(...skipping 845 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1757 content::Source<SafeBrowsingDatabaseManager>( | 1765 content::Source<SafeBrowsingDatabaseManager>( |
1758 sb_factory_->test_safe_browsing_service()->database_manager().get())); | 1766 sb_factory_->test_safe_browsing_service()->database_manager().get())); |
1759 BrowserThread::PostTask( | 1767 BrowserThread::PostTask( |
1760 BrowserThread::IO, FROM_HERE, | 1768 BrowserThread::IO, FROM_HERE, |
1761 base::Bind(&SafeBrowsingDatabaseManagerCookieTest::ForceUpdate, | 1769 base::Bind(&SafeBrowsingDatabaseManagerCookieTest::ForceUpdate, |
1762 base::Unretained(this))); | 1770 base::Unretained(this))); |
1763 observer.Wait(); | 1771 observer.Wait(); |
1764 } | 1772 } |
1765 | 1773 |
1766 } // namespace safe_browsing | 1774 } // namespace safe_browsing |
OLD | NEW |