chrome/browser/safe_browsing/safe_browsing_blocking_page_unittest.cc
TEST_F(SafeBrowsingBlockingPageTest, NavigatingBackAndForth) {
  // Enable malware reports.
  Profile* profile = Profile::FromBrowserContext(
      web_contents()->GetBrowserContext());
  profile->GetPrefs()->SetBoolean(
      prefs::kSafeBrowsingExtendedReportingEnabled, true);

  // Navigate somewhere.
  Navigate(kGoodURL, 1);

  // Now navigate to a bad page triggerring an interstitial.
  controller().LoadURL(GURL(kBadURL), content::Referrer(),
                       content::PAGE_TRANSITION_TYPED, std::string());
  ShowInterstitial(false, kBadURL);
  SafeBrowsingBlockingPage* sb_interstitial =
      GetSafeBrowsingBlockingPage();
  ASSERT_TRUE(sb_interstitial);

  // Proceed, then navigate back.
  ProceedThroughInterstitial(sb_interstitial);
  Navigate(kBadURL, 2);  // Commit the navigation.
  GoBack(true);

  // We are back on the good page.
  sb_interstitial = GetSafeBrowsingBlockingPage();
  ASSERT_FALSE(sb_interstitial);
  ASSERT_EQ(2, controller().GetEntryCount());
  EXPECT_EQ(kGoodURL, controller().GetActiveEntry()->GetURL().spec());

  // Navigate forward to the malware URL.
  web_contents()->GetController().GoForward();
  ShowInterstitial(false, 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().GetEntryCount());
  EXPECT_EQ(kBadURL, controller().GetActiveEntry()->GetURL().spec());

  // Two reports should have been sent.
  EXPECT_EQ(2u, ui_manager_->GetDetails()->size());
  ui_manager_->GetDetails()->clear();
}
// Tests showing a blocking page then navigating back and forth to make sure the
// controller entries are OK.  http://crbug.com/17627
Tests showing a blocking page then navigating back and forth to make sure the
controller entries are OK.
Tests showing a blocking page then navigating back and forth to make sure the controller entries are OK .
TEST_F(SafeBrowsingBlockingPageTest, NavigatingBackAndForth) {
  Profile* profile = Profile::FromBrowserContext(
      web_contents()->GetBrowserContext());
  profile->GetPrefs()->SetBoolean(
      prefs::kSafeBrowsingExtendedReportingEnabled, true);
  Navigate(kGoodURL, 1);
  controller().LoadURL(GURL(kBadURL), content::Referrer(),
                       content::PAGE_TRANSITION_TYPED, std::string());
  ShowInterstitial(false, kBadURL);
  SafeBrowsingBlockingPage* sb_interstitial =
      GetSafeBrowsingBlockingPage();
  ASSERT_TRUE(sb_interstitial);
  ProceedThroughInterstitial(sb_interstitial);
  Navigate(kBadURL, 2);  
  GoBack(true);
  sb_interstitial = GetSafeBrowsingBlockingPage();
  ASSERT_FALSE(sb_interstitial);
  ASSERT_EQ(2, controller().GetEntryCount());
  EXPECT_EQ(kGoodURL, controller().GetActiveEntry()->GetURL().spec());
  web_contents()->GetController().GoForward();
  ShowInterstitial(false, kBadURL);
  sb_interstitial = GetSafeBrowsingBlockingPage();
  ASSERT_TRUE(sb_interstitial);
  ProceedThroughInterstitial(sb_interstitial);
  Navigate(kBadURL, 2);  
  sb_interstitial = GetSafeBrowsingBlockingPage();
  ASSERT_FALSE(sb_interstitial);
  ASSERT_EQ(2, controller().GetEntryCount());
  EXPECT_EQ(kBadURL, controller().GetActiveEntry()->GetURL().spec());
  EXPECT_EQ(2u, ui_manager_->GetDetails()->size());
  ui_manager_->GetDetails()->clear();
}
TEST_F ( SafeBrowsingBlockingPageTest , NavigatingBackAndForth ) { Profile * profile = Profile :: FromBrowserContext ( web_contents ( ) -> GetBrowserContext ( ) ) ; profile -> GetPrefs ( ) -> SetBoolean ( prefs :: kSafeBrowsingExtendedReportingEnabled , true ) ; Navigate ( kGoodURL , 1 ) ; controller ( ) . LoadURL ( GURL ( kBadURL ) , content :: Referrer ( ) , content :: PAGE_TRANSITION_TYPED , std :: string ( ) ) ; ShowInterstitial ( false , kBadURL ) ; SafeBrowsingBlockingPage * sb_interstitial = GetSafeBrowsingBlockingPage ( ) ; ASSERT_TRUE ( sb_interstitial ) ; ProceedThroughInterstitial ( sb_interstitial ) ; Navigate ( kBadURL , 2 ) ; GoBack ( true ) ; sb_interstitial = GetSafeBrowsingBlockingPage ( ) ; ASSERT_FALSE ( sb_interstitial ) ; ASSERT_EQ ( 2 , controller ( ) . GetEntryCount ( ) ) ; EXPECT_EQ ( kGoodURL , controller ( ) . GetActiveEntry ( ) -> GetURL ( ) . spec ( ) ) ; web_contents ( ) -> GetController ( ) . GoForward ( ) ; ShowInterstitial ( false , kBadURL ) ; sb_interstitial = GetSafeBrowsingBlockingPage ( ) ; ASSERT_TRUE ( sb_interstitial ) ; ProceedThroughInterstitial ( sb_interstitial ) ; Navigate ( kBadURL , 2 ) ; sb_interstitial = GetSafeBrowsingBlockingPage ( ) ; ASSERT_FALSE ( sb_interstitial ) ; ASSERT_EQ ( 2 , controller ( ) . GetEntryCount ( ) ) ; EXPECT_EQ ( kBadURL , controller ( ) . GetActiveEntry ( ) -> GetURL ( ) . spec ( ) ) ; EXPECT_EQ ( 2u , ui_manager_ -> GetDetails ( ) -> size ( ) ) ; ui_manager_ -> GetDetails ( ) -> clear ( ) ; }
Tests showing a blocking page then navigating back and forth to make sure the
controller entries are OK.  http://crbug.com/17627
Tests showing a blocking page then navigating back and forth to make sure the controller entries are OK . http : // crbug . com / 17627
// Enable malware reports. // Navigate somewhere. // Now navigate to a bad page triggerring an interstitial. // Proceed, then navigate back. // Commit the navigation. // We are back on the good page. // Navigate forward to the malware URL. // Let's proceed and make sure everything is OK (bug 17627). // Commit the navigation. // Two reports should have been sent.