Chromium Code Reviews| 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 44c4be84b596733cabe7ab3e764bc85e5a78c109..4a00e5d9a9e72b2515d98c86b6825a797678cb7d 100644 |
| --- a/chrome/browser/safe_browsing/safe_browsing_service_browsertest.cc |
| +++ b/chrome/browser/safe_browsing/safe_browsing_service_browsertest.cc |
| @@ -381,6 +381,51 @@ 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::WindowedNotificationObserver signal( |
| + NotificationType::LOAD_STOP, |
| + Source<NavigationController>( |
| + &browser()->GetSelectedTabContents()->controller())); |
| + browser()->OpenURL(malware_url, GURL(), CURRENT_TAB, PageTransition::TYPED); |
| + signal.Wait(); |
|
gavinp
2011/03/08 22:33:04
I use the WindowedNotificationObserver here, inste
|
| + |
| + EXPECT_TRUE(ShowingInterstitialPage()); |
| +} |
| + |
| } // namespace |
| class TestSBClient |