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

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

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

  // More bad resources loading causing more interstitials. The new
  // interstitials should be queued.
  ShowInterstitial(true, kBadURL2);
  ShowInterstitial(true, kBadURL3);

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

  // Proceed through the 1st interstitial.
  ProceedThroughInterstitial(sb_interstitial);
  EXPECT_EQ(OK, user_response());

  // A report should have been sent.
  EXPECT_EQ(1u, ui_manager_->GetDetails()->size());
  ui_manager_->GetDetails()->clear();

  ResetUserResponse();

  // We should land to a 2nd interstitial (aggregating all the malware resources
  // loaded while the 1st interstitial was showing).
  sb_interstitial = GetSafeBrowsingBlockingPage();
  ASSERT_TRUE(sb_interstitial);

  // Proceed through the 2nd interstitial.
  ProceedThroughInterstitial(sb_interstitial);
  EXPECT_EQ(OK, user_response());

  // We did proceed, we should be back to the initial page.
  ASSERT_EQ(1, controller().GetEntryCount());
  EXPECT_EQ(kGoodURL, controller().GetActiveEntry()->GetURL().spec());

  // No report should have been sent -- we don't create a report the
  // second time.
  EXPECT_EQ(0u, ui_manager_->GetDetails()->size());
  ui_manager_->GetDetails()->clear();
}
// Tests showing a blocking page for a page that contains multiple malware
// subresources and proceeding through the multiple interstitials.
Tests showing a blocking page for a page that contains multiple malware
subresources and proceeding through the multiple interstitials.
Tests showing a blocking page for a page that contains multiple malware subresources and proceeding through the multiple interstitials .
TEST_F(SafeBrowsingBlockingPageTest,
    PageWithMultipleMalwareResourceProceed) {
  Profile* profile = Profile::FromBrowserContext(
      web_contents()->GetBrowserContext());
  profile->GetPrefs()->SetBoolean(
      prefs::kSafeBrowsingExtendedReportingEnabled, true);
  Navigate(kGoodURL, 1);
  ShowInterstitial(true, kBadURL);
  ShowInterstitial(true, kBadURL2);
  ShowInterstitial(true, kBadURL3);
  SafeBrowsingBlockingPage* sb_interstitial =
      GetSafeBrowsingBlockingPage();
  ASSERT_TRUE(sb_interstitial);
  ProceedThroughInterstitial(sb_interstitial);
  EXPECT_EQ(OK, user_response());
  EXPECT_EQ(1u, ui_manager_->GetDetails()->size());
  ui_manager_->GetDetails()->clear();
  ResetUserResponse();
  sb_interstitial = GetSafeBrowsingBlockingPage();
  ASSERT_TRUE(sb_interstitial);
  ProceedThroughInterstitial(sb_interstitial);
  EXPECT_EQ(OK, user_response());
  ASSERT_EQ(1, controller().GetEntryCount());
  EXPECT_EQ(kGoodURL, controller().GetActiveEntry()->GetURL().spec());
  EXPECT_EQ(0u, ui_manager_->GetDetails()->size());
  ui_manager_->GetDetails()->clear();
}
TEST_F ( SafeBrowsingBlockingPageTest , PageWithMultipleMalwareResourceProceed ) { Profile * profile = Profile :: FromBrowserContext ( web_contents ( ) -> GetBrowserContext ( ) ) ; profile -> GetPrefs ( ) -> SetBoolean ( prefs :: kSafeBrowsingExtendedReportingEnabled , true ) ; Navigate ( kGoodURL , 1 ) ; ShowInterstitial ( true , kBadURL ) ; ShowInterstitial ( true , kBadURL2 ) ; ShowInterstitial ( true , kBadURL3 ) ; SafeBrowsingBlockingPage * sb_interstitial = GetSafeBrowsingBlockingPage ( ) ; ASSERT_TRUE ( sb_interstitial ) ; ProceedThroughInterstitial ( sb_interstitial ) ; EXPECT_EQ ( OK , user_response ( ) ) ; EXPECT_EQ ( 1u , ui_manager_ -> GetDetails ( ) -> size ( ) ) ; ui_manager_ -> GetDetails ( ) -> clear ( ) ; ResetUserResponse ( ) ; sb_interstitial = GetSafeBrowsingBlockingPage ( ) ; ASSERT_TRUE ( sb_interstitial ) ; ProceedThroughInterstitial ( sb_interstitial ) ; EXPECT_EQ ( OK , user_response ( ) ) ; ASSERT_EQ ( 1 , controller ( ) . GetEntryCount ( ) ) ; EXPECT_EQ ( kGoodURL , controller ( ) . GetActiveEntry ( ) -> GetURL ( ) . spec ( ) ) ; EXPECT_EQ ( 0u , ui_manager_ -> GetDetails ( ) -> size ( ) ) ; ui_manager_ -> GetDetails ( ) -> clear ( ) ; }
Tests showing a blocking page for a page that contains multiple malware
subresources and proceeding through the multiple interstitials.
Tests showing a blocking page for a page that contains multiple malware subresources and proceeding through the multiple interstitials .
// Enable malware reports. // Navigate somewhere else. // Simulate that page loading a bad-resource triggering an interstitial. // More bad resources loading causing more interstitials. The new // interstitials should be queued. // Proceed through the 1st interstitial. // A report should have been sent. // We should land to a 2nd interstitial (aggregating all the malware resources // loaded while the 1st interstitial was showing). // Proceed through the 2nd interstitial. // We did proceed, we should be back to the initial page. // No report should have been sent -- we don't create a report the // second time.