| 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 4bff659b8f4d0b6f296ff8aa3408b0da7d65f0b0..0949bbf697f8d58427563bb2b01912341348b808 100644
|
| --- a/chrome/browser/safe_browsing/safe_browsing_service_browsertest.cc
|
| +++ b/chrome/browser/safe_browsing/safe_browsing_service_browsertest.cc
|
| @@ -355,6 +355,39 @@ 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);
|
| +
|
| + // After adding the url to safebrowsing database and getfullhash result,
|
| + // we should see the interstitial page.
|
| + 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());
|
| +}
|
| +
|
| // This test uses SafeBrowsingService::Client to directly interact with
|
| // SafeBrowsingService.
|
| class TestSBClient
|
|
|