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

Unified Diff: chrome/browser/safe_browsing/safe_browsing_service_browsertest.cc

Issue 6334131: Turn off safebrowsing for PREFETCH requests (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: clean up unit test, per pending fix to 75507 Created 9 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/safe_browsing/safe_browsing_service_browsertest.cc
diff --git a/chrome/browser/safe_browsing/safe_browsing_service_browsertest.cc b/chrome/browser/safe_browsing/safe_browsing_service_browsertest.cc
index eeb302d79f77d08aca4d4913651b54c1cdb3345f..b0fd5a477c99fcf06d488e528faa81f46f9cffee 100644
--- a/chrome/browser/safe_browsing/safe_browsing_service_browsertest.cc
+++ b/chrome/browser/safe_browsing/safe_browsing_service_browsertest.cc
@@ -379,6 +379,45 @@ IN_PROC_BROWSER_TEST_F(SafeBrowsingServiceTest, Malware) {
EXPECT_TRUE(ShowingInterstitialPage());
}
+const char kPrefetchMalwarePage[] = "files/safe_browsing/prefetch_malware.html";
+
+// This test confirms that prefetches don't themselves get the
+// interstitial treatment.
+IN_PROC_BROWSER_TEST_F(SafeBrowsingServiceTest, Prefetch) {
+ GURL url = test_server()->GetURL(kPrefetchMalwarePage);
+ GURL malware_url = test_server()->GetURL(kMalwarePage);
+
+ class SetPrefetchForTest {
+ public:
+ explicit SetPrefetchForTest(bool prefetch)
+ : old_prefetch_state_(ResourceDispatcherHost::is_prefetch_enabled()) {
+ ResourceDispatcherHost::set_is_prefetch_enabled(prefetch);
+ }
+
+ ~SetPrefetchForTest() {
+ ResourceDispatcherHost::set_is_prefetch_enabled(old_prefetch_state_);
+ }
+ private:
+ bool old_prefetch_state_;
+ } set_prefetch_for_test(true);
+
+ // Even though we have added this uri to the safebrowsing database and
+ // getfullhash result, we should not see the interstitial page since the
+ // only malware was a prefetch target.
+ SBFullHashResult malware_full_hash;
+ int chunk_id = 0;
+ GenUrlFullhashResult(malware_url, safe_browsing_util::kMalwareList,
+ chunk_id, &malware_full_hash);
+ SetupResponseForUrl(malware_url, malware_full_hash);
+ ui_test_utils::NavigateToURL(browser(), url);
+ EXPECT_FALSE(ShowingInterstitialPage());
+
+ // However, when we navigate to the malware page, we should still get
+ // the interstitial.
+ ui_test_utils::NavigateToURL(browser(), malware_url);
+ EXPECT_TRUE(ShowingInterstitialPage());
+}
+
} // namespace
class TestSBClient
« no previous file with comments | « chrome/browser/renderer_host/safe_browsing_resource_handler.cc ('k') | chrome/test/data/safe_browsing/prefetch_malware.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698