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

  // Start a load.
  controller().LoadURL(GURL(kBadURL), content::Referrer(),
                       content::PAGE_TRANSITION_TYPED, std::string());

  // Simulate the load causing a safe browsing interstitial to be shown.
  ShowInterstitial(false, kBadURL);
  SafeBrowsingBlockingPage* sb_interstitial =
      GetSafeBrowsingBlockingPage();
  ASSERT_TRUE(sb_interstitial);

  // Simulate the user clicking "proceed".
  ProceedThroughInterstitial(sb_interstitial);

  // The interstitial is shown until the navigation commits.
  ASSERT_TRUE(InterstitialPage::GetInterstitialPage(web_contents()));
  // Commit the navigation.
  Navigate(kBadURL, 1);
  // The interstitial should be gone now.
  ASSERT_FALSE(InterstitialPage::GetInterstitialPage(web_contents()));

  // A report should have been sent.
  EXPECT_EQ(1u, ui_manager_->GetDetails()->size());
  ui_manager_->GetDetails()->clear();
}
// Tests showing a blocking page for a malware page and then proceeding.
Tests showing a blocking page for a malware page and then proceeding.
Tests showing a blocking page for a malware page and then proceeding .
TEST_F(SafeBrowsingBlockingPageTest, MalwarePageProceed) {
  Profile* profile = Profile::FromBrowserContext(
      web_contents()->GetBrowserContext());
  profile->GetPrefs()->SetBoolean(
      prefs::kSafeBrowsingExtendedReportingEnabled, true);
  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);
  ASSERT_TRUE(InterstitialPage::GetInterstitialPage(web_contents()));
  Navigate(kBadURL, 1);
  ASSERT_FALSE(InterstitialPage::GetInterstitialPage(web_contents()));
  EXPECT_EQ(1u, ui_manager_->GetDetails()->size());
  ui_manager_->GetDetails()->clear();
}
TEST_F ( SafeBrowsingBlockingPageTest , MalwarePageProceed ) { Profile * profile = Profile :: FromBrowserContext ( web_contents ( ) -> GetBrowserContext ( ) ) ; profile -> GetPrefs ( ) -> SetBoolean ( prefs :: kSafeBrowsingExtendedReportingEnabled , true ) ; 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 ) ; ASSERT_TRUE ( InterstitialPage :: GetInterstitialPage ( web_contents ( ) ) ) ; Navigate ( kBadURL , 1 ) ; ASSERT_FALSE ( InterstitialPage :: GetInterstitialPage ( web_contents ( ) ) ) ; EXPECT_EQ ( 1u , ui_manager_ -> GetDetails ( ) -> size ( ) ) ; ui_manager_ -> GetDetails ( ) -> clear ( ) ; }
Tests showing a blocking page for a malware page and then proceeding.
Tests showing a blocking page for a malware page and then proceeding .
// Enable malware reports. // Start a load. // Simulate the load causing a safe browsing interstitial to be shown. // Simulate the user clicking "proceed". // The interstitial is shown until the navigation commits. // Commit the navigation. // The interstitial should be gone now. // A report should have been sent.