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

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

  // Navigate somewhere else.
  Navigate(kGoodURL, 2);

  // Simulate that page loading a bad-resource triggering an interstitial.
  ShowInterstitial(true, kBadURL);

  SafeBrowsingBlockingPage* sb_interstitial =
      GetSafeBrowsingBlockingPage();
  ASSERT_TRUE(sb_interstitial);

  // Simulate the user clicking "don't proceed".
  DontProceedThroughSubresourceInterstitial(sb_interstitial);
  EXPECT_EQ(CANCEL, user_response());
  EXPECT_FALSE(GetSafeBrowsingBlockingPage());

  // We did not proceed, we should be back to the first page, the 2nd one should
  // have been removed from the navigation controller.
  ASSERT_EQ(1, controller().GetEntryCount());
  EXPECT_EQ(kGoogleURL, controller().GetActiveEntry()->GetURL().spec());

  // A report should have been sent.
  EXPECT_EQ(1u, ui_manager_->GetDetails()->size());
  ui_manager_->GetDetails()->clear();
}
// Tests showing a blocking page for a page that contains malware subresources
// and not proceeding.
Tests showing a blocking page for a page that contains malware subresources
and not proceeding.
Tests showing a blocking page for a page that contains malware subresources and not proceeding .
TEST_F(SafeBrowsingBlockingPageTest, PageWithMalwareResourceDontProceed) {
  Profile* profile = Profile::FromBrowserContext(
      web_contents()->GetBrowserContext());
  profile->GetPrefs()->SetBoolean(
      prefs::kSafeBrowsingExtendedReportingEnabled, true);
  Navigate(kGoogleURL, 1);
  Navigate(kGoodURL, 2);
  ShowInterstitial(true, kBadURL);
  SafeBrowsingBlockingPage* sb_interstitial =
      GetSafeBrowsingBlockingPage();
  ASSERT_TRUE(sb_interstitial);
  DontProceedThroughSubresourceInterstitial(sb_interstitial);
  EXPECT_EQ(CANCEL, user_response());
  EXPECT_FALSE(GetSafeBrowsingBlockingPage());
  ASSERT_EQ(1, controller().GetEntryCount());
  EXPECT_EQ(kGoogleURL, controller().GetActiveEntry()->GetURL().spec());
  EXPECT_EQ(1u, ui_manager_->GetDetails()->size());
  ui_manager_->GetDetails()->clear();
}
TEST_F ( SafeBrowsingBlockingPageTest , PageWithMalwareResourceDontProceed ) { Profile * profile = Profile :: FromBrowserContext ( web_contents ( ) -> GetBrowserContext ( ) ) ; profile -> GetPrefs ( ) -> SetBoolean ( prefs :: kSafeBrowsingExtendedReportingEnabled , true ) ; Navigate ( kGoogleURL , 1 ) ; Navigate ( kGoodURL , 2 ) ; ShowInterstitial ( true , kBadURL ) ; SafeBrowsingBlockingPage * sb_interstitial = GetSafeBrowsingBlockingPage ( ) ; ASSERT_TRUE ( sb_interstitial ) ; DontProceedThroughSubresourceInterstitial ( sb_interstitial ) ; EXPECT_EQ ( CANCEL , user_response ( ) ) ; EXPECT_FALSE ( GetSafeBrowsingBlockingPage ( ) ) ; ASSERT_EQ ( 1 , controller ( ) . GetEntryCount ( ) ) ; EXPECT_EQ ( kGoogleURL , controller ( ) . GetActiveEntry ( ) -> GetURL ( ) . spec ( ) ) ; EXPECT_EQ ( 1u , ui_manager_ -> GetDetails ( ) -> size ( ) ) ; ui_manager_ -> GetDetails ( ) -> clear ( ) ; }
Tests showing a blocking page for a page that contains malware subresources
and not proceeding.
Tests showing a blocking page for a page that contains malware subresources and not proceeding .
// Enable malware reports. // Navigate somewhere. // Navigate somewhere else. // Simulate that page loading a bad-resource triggering an interstitial. // Simulate the user clicking "don't proceed". // We did not proceed, we should be back to the first page, the 2nd one should // have been removed from the navigation controller. // A report should have been sent.