Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(54)

Unified Diff: chrome/browser/safe_browsing/safe_browsing_blocking_page_test.cc

Issue 2275123004: Downgrade security state while displaying an SB interstitial (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@dangerstate
Patch Set: Added tests Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/safe_browsing/safe_browsing_blocking_page_test.cc
diff --git a/chrome/browser/safe_browsing/safe_browsing_blocking_page_test.cc b/chrome/browser/safe_browsing/safe_browsing_blocking_page_test.cc
index e4e535bf1680978e31be1d012f794d8195354354..13f53b938f0dd1040eb4e79170387e18fabcfff5 100644
--- a/chrome/browser/safe_browsing/safe_browsing_blocking_page_test.cc
+++ b/chrome/browser/safe_browsing/safe_browsing_blocking_page_test.cc
@@ -571,6 +571,15 @@ class SafeBrowsingBlockingPageBrowserTest
EXPECT_EQ(expected_tag_name, actual_resource.tag_name());
}
+ void ExpectSecurityIndicatorDowngrade(content::WebContents* tab) {
+ ChromeSecurityStateModelClient* model_client =
+ ChromeSecurityStateModelClient::FromWebContents(tab);
+ ASSERT_TRUE(model_client);
+ EXPECT_EQ(security_state::SecurityStateModel::SECURITY_ERROR,
+ model_client->GetSecurityInfo().security_level);
+ EXPECT_TRUE(model_client->GetSecurityInfo().fails_malware_check);
+ }
+
protected:
TestThreatDetailsFactory details_factory_;
@@ -1047,36 +1056,36 @@ IN_PROC_BROWSER_TEST_P(SafeBrowsingBlockingPageBrowserTest, WhitelistUnsaved) {
// Safe Browsing interstitial.
IN_PROC_BROWSER_TEST_P(SafeBrowsingBlockingPageBrowserTest,
SecurityState_HTTP) {
+ // The security indicator should be downgraded while the interstitial shows.
SetupWarningAndNavigate();
+ WebContents* error_tab = browser()->tab_strip_model()->GetActiveWebContents();
+ ASSERT_TRUE(error_tab);
+ ExpectSecurityIndicatorDowngrade(error_tab);
+
+ // The security indicator should still be downgraded post-interstitial.
EXPECT_TRUE(ClickAndWaitForDetach("proceed-link"));
AssertNoInterstitial(true);
-
- WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents();
- ASSERT_TRUE(tab);
- ChromeSecurityStateModelClient* model_client =
- ChromeSecurityStateModelClient::FromWebContents(tab);
- ASSERT_TRUE(model_client);
- EXPECT_EQ(security_state::SecurityStateModel::SECURITY_ERROR,
- model_client->GetSecurityInfo().security_level);
- EXPECT_TRUE(model_client->GetSecurityInfo().fails_malware_check);
+ WebContents* post_tab = browser()->tab_strip_model()->GetActiveWebContents();
+ ASSERT_TRUE(post_tab);
+ ExpectSecurityIndicatorDowngrade(post_tab);
}
// Test that the security indicator is downgraded even if the website has valid
// HTTPS (meaning that the SB state overrides the HTTPS state).
IN_PROC_BROWSER_TEST_P(SafeBrowsingBlockingPageBrowserTest,
SecurityState_ValidHTTPS) {
+ // The security indicator should be downgraded while the interstitial shows.
SetupWarningAndNavigateToValidHTTPS();
+ WebContents* error_tab = browser()->tab_strip_model()->GetActiveWebContents();
+ ASSERT_TRUE(error_tab);
+ ExpectSecurityIndicatorDowngrade(error_tab);
+
+ // The security indicator should still be downgraded post-interstitial.
EXPECT_TRUE(ClickAndWaitForDetach("proceed-link"));
AssertNoInterstitial(true);
-
- WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents();
- ASSERT_TRUE(tab);
- ChromeSecurityStateModelClient* model_client =
- ChromeSecurityStateModelClient::FromWebContents(tab);
- ASSERT_TRUE(model_client);
- EXPECT_EQ(security_state::SecurityStateModel::SECURITY_ERROR,
- model_client->GetSecurityInfo().security_level);
- EXPECT_TRUE(model_client->GetSecurityInfo().fails_malware_check);
+ WebContents* post_tab = browser()->tab_strip_model()->GetActiveWebContents();
+ ASSERT_TRUE(post_tab);
+ ExpectSecurityIndicatorDowngrade(post_tab);
EXPECT_EQ(0u, model_client->GetSecurityInfo().cert_status);
}
@@ -1084,18 +1093,18 @@ IN_PROC_BROWSER_TEST_P(SafeBrowsingBlockingPageBrowserTest,
// are shown in a row (one for Safe Browsing, one for invalid HTTPS).
IN_PROC_BROWSER_TEST_P(SafeBrowsingBlockingPageBrowserTest,
SecurityState_InvalidHTTPS) {
+ // The security indicator should be downgraded while the interstitial shows.
SetupWarningAndNavigateToInvalidHTTPS();
+ WebContents* error_tab = browser()->tab_strip_model()->GetActiveWebContents();
+ ASSERT_TRUE(error_tab);
+ ExpectSecurityIndicatorDowngrade(error_tab);
+
+ // The security indicator should still be downgraded post-interstitial.
EXPECT_TRUE(ClickAndWaitForDetach("proceed-link"));
AssertNoInterstitial(true);
-
- WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents();
- ASSERT_TRUE(tab);
- ChromeSecurityStateModelClient* model_client =
- ChromeSecurityStateModelClient::FromWebContents(tab);
- ASSERT_TRUE(model_client);
- EXPECT_EQ(security_state::SecurityStateModel::SECURITY_ERROR,
- model_client->GetSecurityInfo().security_level);
- EXPECT_TRUE(model_client->GetSecurityInfo().fails_malware_check);
+ WebContents* post_tab = browser()->tab_strip_model()->GetActiveWebContents();
+ ASSERT_TRUE(post_tab);
+ ExpectSecurityIndicatorDowngrade(post_tab);
EXPECT_NE(0u, model_client->GetSecurityInfo().cert_status);
felt 2016/08/25 06:10:33 Note: this line (which depends on having a model_c
}
« no previous file with comments | « no previous file | chrome/browser/safe_browsing/ui_manager.h » ('j') | chrome/browser/safe_browsing/ui_manager.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698