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 468adf7f11532a578712a079b0c2613db5377aab..8522dfabb81a4941e65f2773d40216f338186d1d 100644 |
--- a/chrome/browser/safe_browsing/safe_browsing_blocking_page_test.cc |
+++ b/chrome/browser/safe_browsing/safe_browsing_blocking_page_test.cc |
@@ -44,6 +44,7 @@ |
#include "components/security_interstitials/core/metrics_helper.h" |
#include "content/public/browser/interstitial_page.h" |
#include "content/public/browser/navigation_controller.h" |
+#include "content/public/browser/navigation_entry.h" |
#include "content/public/browser/notification_types.h" |
#include "content/public/browser/render_frame_host.h" |
#include "content/public/browser/render_process_host.h" |
@@ -581,6 +582,17 @@ class SafeBrowsingBlockingPageBrowserTest |
// EXPECT_EQ(cert_status, model_client->GetSecurityInfo().cert_status); |
} |
+ void ExpectNoSecurityIndicatorDowngrade(content::WebContents* tab) { |
+ ChromeSecurityStateModelClient* model_client = |
+ ChromeSecurityStateModelClient::FromWebContents(tab); |
+ ASSERT_TRUE(model_client); |
+ security_state::SecurityStateModel::SecurityInfo security_info; |
+ model_client->GetSecurityInfo(&security_info); |
+ EXPECT_EQ(security_state::SecurityStateModel::NONE, |
+ security_info.security_level); |
+ EXPECT_FALSE(security_info.fails_malware_check); |
+ } |
+ |
protected: |
TestThreatDetailsFactory details_factory_; |
@@ -1095,6 +1107,43 @@ IN_PROC_BROWSER_TEST_P(SafeBrowsingBlockingPageBrowserTest, |
ExpectSecurityIndicatorDowngrade(post_tab, 0u); |
} |
+// Test that the security indicator does not stay downgraded after |
+// clicking back from a Safe Browsing interstitial. Regression test for |
+// https://crbug.com/659709. |
+IN_PROC_BROWSER_TEST_P(SafeBrowsingBlockingPageBrowserTest, |
+ SecurityStateGoBack) { |
+ // Navigate to a page so that there is somewhere to go back to. |
+ GURL start_url = |
+ net::URLRequestMockHTTPJob::GetMockUrl("http://example.test"); |
+ ui_test_utils::NavigateToURL(browser(), start_url); |
+ |
+ // 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, 0u); |
+ |
+ // Go back. |
+ EXPECT_EQ(VISIBLE, GetVisibility("primary-button")); |
+ EXPECT_EQ(HIDDEN, GetVisibility("details")); |
+ EXPECT_EQ(HIDDEN, GetVisibility("proceed-link")); |
+ EXPECT_EQ(HIDDEN, GetVisibility("error-code")); |
+ EXPECT_TRUE(Click("details-button")); |
+ EXPECT_EQ(VISIBLE, GetVisibility("details")); |
+ EXPECT_EQ(VISIBLE, GetVisibility("proceed-link")); |
+ EXPECT_EQ(HIDDEN, GetVisibility("error-code")); |
+ EXPECT_TRUE(ClickAndWaitForDetach("primary-button")); |
+ |
+ // The security indicator should *not* still be downgraded after going back. |
+ AssertNoInterstitial(true); |
+ WebContents* post_tab = browser()->tab_strip_model()->GetActiveWebContents(); |
+ ASSERT_TRUE(post_tab); |
+ content::NavigationEntry* entry = post_tab->GetController().GetVisibleEntry(); |
+ ASSERT_TRUE(entry); |
+ EXPECT_EQ(start_url, entry->GetURL()); |
+ ExpectNoSecurityIndicatorDowngrade(post_tab); |
+} |
+ |
// Test that the security indicator is downgraded after clicking through a |
// Safe Browsing interstitial. |
IN_PROC_BROWSER_TEST_P(SafeBrowsingBlockingPageBrowserTest, |