summaryrefslogtreecommitdiffstats
path: root/chrome/browser/safe_browsing/safe_browsing_blocking_page_unittest.cc
diff options
context:
space:
mode:
authorjcampan@chromium.org <jcampan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-15 00:35:18 +0000
committerjcampan@chromium.org <jcampan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-15 00:35:18 +0000
commit80858db5b5149edb29e9d214bee784aee880d050 (patch)
treefa3cc30551091083c29ff4d10f8a680234df1086 /chrome/browser/safe_browsing/safe_browsing_blocking_page_unittest.cc
parent4297f09429c220e8bcd68d7fa493a9ab7aa7ace7 (diff)
downloadchromium_src-80858db5b5149edb29e9d214bee784aee880d050.zip
chromium_src-80858db5b5149edb29e9d214bee784aee880d050.tar.gz
chromium_src-80858db5b5149edb29e9d214bee784aee880d050.tar.bz2
Fixing a bug with interstitial pages triggered with malware.
BUG=http://crbug.com/17627 TEST=See bug. Review URL: http://codereview.chromium.org/273022 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@29071 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/safe_browsing/safe_browsing_blocking_page_unittest.cc')
-rw-r--r--chrome/browser/safe_browsing/safe_browsing_blocking_page_unittest.cc45
1 files changed, 45 insertions, 0 deletions
diff --git a/chrome/browser/safe_browsing/safe_browsing_blocking_page_unittest.cc b/chrome/browser/safe_browsing/safe_browsing_blocking_page_unittest.cc
index e0a0f77..de0ba2d 100644
--- a/chrome/browser/safe_browsing/safe_browsing_blocking_page_unittest.cc
+++ b/chrome/browser/safe_browsing/safe_browsing_blocking_page_unittest.cc
@@ -102,6 +102,13 @@ class SafeBrowsingBlockingPageTest : public RenderViewHostTestHarness,
contents()->TestDidNavigate(contents_->render_view_host(), params);
}
+ void GoBack() {
+ NavigationEntry* entry = contents()->controller().GetEntryAtOffset(-1);
+ ASSERT_TRUE(entry);
+ contents()->controller().GoBack();
+ Navigate(entry->url().spec().c_str(), entry->page_id());
+ }
+
void ShowInterstitial(ResourceType::Type resource_type,
const char* url) {
SafeBrowsingService::UnsafeResource resource;
@@ -355,3 +362,41 @@ TEST_F(SafeBrowsingBlockingPageTest, PageWithMultipleMalwareResourceProceed) {
ASSERT_EQ(1, controller().entry_count());
EXPECT_EQ(kGoodURL, controller().GetActiveEntry()->url().spec());
}
+
+// Tests showing a blocking page then navigating back and forth to make sure the
+// controller entries are OK. http://crbug.com/17627
+TEST_F(SafeBrowsingBlockingPageTest, NavigatingBackAndForth) {
+ // Navigate somewhere.
+ Navigate(kGoodURL, 1);
+
+ // Now navigate to a bad page triggerring an interstitial.
+ controller().LoadURL(GURL(kBadURL), GURL(), PageTransition::TYPED);
+ ShowInterstitial(ResourceType::MAIN_FRAME, kBadURL);
+ SafeBrowsingBlockingPage* sb_interstitial = GetSafeBrowsingBlockingPage();
+ ASSERT_TRUE(sb_interstitial);
+
+ // Proceed, then navigate back.
+ ProceedThroughInterstitial(sb_interstitial);
+ Navigate(kBadURL, 2); // Commit the navigation.
+ GoBack();
+
+ // We are back on the good page.
+ sb_interstitial = GetSafeBrowsingBlockingPage();
+ ASSERT_FALSE(sb_interstitial);
+ ASSERT_EQ(2, controller().entry_count());
+ EXPECT_EQ(kGoodURL, controller().GetActiveEntry()->url().spec());
+
+ // Navigate forward to the malware URL.
+ contents()->controller().GoForward();
+ ShowInterstitial(ResourceType::MAIN_FRAME, kBadURL);
+ sb_interstitial = GetSafeBrowsingBlockingPage();
+ ASSERT_TRUE(sb_interstitial);
+
+ // Let's proceed and make sure everything is OK (bug 17627).
+ ProceedThroughInterstitial(sb_interstitial);
+ Navigate(kBadURL, 2); // Commit the navigation.
+ sb_interstitial = GetSafeBrowsingBlockingPage();
+ ASSERT_FALSE(sb_interstitial);
+ ASSERT_EQ(2, controller().entry_count());
+ EXPECT_EQ(kBadURL, controller().GetActiveEntry()->url().spec());
+}