chrome/browser/safe_browsing/safe_browsing_blocking_page_unittest.cc
TEST_F(SafeBrowsingBlockingPageTest, MalwarePageDontProceed) {
  // Enable malware details.
  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);

  base::RunLoop().RunUntilIdle();

  // Simulate the user clicking "don't proceed".
  DontProceedThroughInterstitial(sb_interstitial);

  // The interstitial should be gone.
  EXPECT_EQ(CANCEL, user_response());
  EXPECT_FALSE(GetSafeBrowsingBlockingPage());

  // We did not proceed, the pending entry should be gone.
  EXPECT_FALSE(controller().GetPendingEntry());

  // 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 not proceeding.
Tests showing a blocking page for a malware page and not proceeding.
Tests showing a blocking page for a malware page and not proceeding .
TEST_F(SafeBrowsingBlockingPageTest, MalwarePageDontProceed) {
  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);
  base::RunLoop().RunUntilIdle();
  DontProceedThroughInterstitial(sb_interstitial);
  EXPECT_EQ(CANCEL, user_response());
  EXPECT_FALSE(GetSafeBrowsingBlockingPage());
  EXPECT_FALSE(controller().GetPendingEntry());
  EXPECT_EQ(1u, ui_manager_->GetDetails()->size());
  ui_manager_->GetDetails()->clear();
}
TEST_F ( SafeBrowsingBlockingPageTest , MalwarePageDontProceed ) { 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 ) ; base :: RunLoop ( ) . RunUntilIdle ( ) ; DontProceedThroughInterstitial ( sb_interstitial ) ; EXPECT_EQ ( CANCEL , user_response ( ) ) ; EXPECT_FALSE ( GetSafeBrowsingBlockingPage ( ) ) ; EXPECT_FALSE ( controller ( ) . GetPendingEntry ( ) ) ; EXPECT_EQ ( 1u , ui_manager_ -> GetDetails ( ) -> size ( ) ) ; ui_manager_ -> GetDetails ( ) -> clear ( ) ; }
Tests showing a blocking page for a malware page and not proceeding.
Tests showing a blocking page for a malware page and not proceeding .
// Enable malware details. // Start a load. // Simulate the load causing a safe browsing interstitial to be shown. // Simulate the user clicking "don't proceed". // The interstitial should be gone. // We did not proceed, the pending entry should be gone. // A report should have been sent.