| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 // | 4 // |
| 5 // This test creates a fake safebrowsing service, where we can inject known- | 5 // This test creates a fake safebrowsing service, where we can inject known- |
| 6 // threat urls. It then uses a real browser to go to these urls, and sends | 6 // threat urls. It then uses a real browser to go to these urls, and sends |
| 7 // "goback" or "proceed" commands and verifies they work. | 7 // "goback" or "proceed" commands and verifies they work. |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 | 10 |
| (...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 497 | 497 |
| 498 void TestReportingDisabledAndDontProceed(const GURL& url) { | 498 void TestReportingDisabledAndDontProceed(const GURL& url) { |
| 499 SetURLThreatType(url, testing::get<0>(GetParam())); | 499 SetURLThreatType(url, testing::get<0>(GetParam())); |
| 500 ui_test_utils::NavigateToURL(browser(), url); | 500 ui_test_utils::NavigateToURL(browser(), url); |
| 501 ASSERT_TRUE(WaitForReady()); | 501 ASSERT_TRUE(WaitForReady()); |
| 502 | 502 |
| 503 EXPECT_EQ(HIDDEN, GetVisibility("extended-reporting-opt-in")); | 503 EXPECT_EQ(HIDDEN, GetVisibility("extended-reporting-opt-in")); |
| 504 EXPECT_EQ(HIDDEN, GetVisibility("opt-in-checkbox")); | 504 EXPECT_EQ(HIDDEN, GetVisibility("opt-in-checkbox")); |
| 505 EXPECT_EQ(HIDDEN, GetVisibility("proceed-link")); | 505 EXPECT_EQ(HIDDEN, GetVisibility("proceed-link")); |
| 506 EXPECT_TRUE(Click("details-button")); | 506 EXPECT_TRUE(Click("details-button")); |
| 507 EXPECT_EQ(VISIBLE, GetVisibility("help-link")); | 507 EXPECT_EQ(VISIBLE, GetVisibility("learn-more-link")); |
| 508 EXPECT_EQ(VISIBLE, GetVisibility("proceed-link")); | 508 EXPECT_EQ(VISIBLE, GetVisibility("proceed-link")); |
| 509 | 509 |
| 510 EXPECT_TRUE(ClickAndWaitForDetach("primary-button")); | 510 EXPECT_TRUE(ClickAndWaitForDetach("primary-button")); |
| 511 AssertNoInterstitial(false); // Assert the interstitial is gone | 511 AssertNoInterstitial(false); // Assert the interstitial is gone |
| 512 EXPECT_EQ(GURL(url::kAboutBlankURL), // Back to "about:blank" | 512 EXPECT_EQ(GURL(url::kAboutBlankURL), // Back to "about:blank" |
| 513 browser()->tab_strip_model()->GetActiveWebContents()->GetURL()); | 513 browser()->tab_strip_model()->GetActiveWebContents()->GetURL()); |
| 514 } | 514 } |
| 515 | 515 |
| 516 void VerifyResource( | 516 void VerifyResource( |
| 517 const ClientSafeBrowsingReportRequest& report, | 517 const ClientSafeBrowsingReportRequest& report, |
| (...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 837 prefs::kSafeBrowsingExtendedReportingEnabled, true); | 837 prefs::kSafeBrowsingExtendedReportingEnabled, true); |
| 838 browser()->profile()->GetPrefs()->SetBoolean( | 838 browser()->profile()->GetPrefs()->SetBoolean( |
| 839 prefs::kSafeBrowsingExtendedReportingOptInAllowed, false); | 839 prefs::kSafeBrowsingExtendedReportingOptInAllowed, false); |
| 840 | 840 |
| 841 TestReportingDisabledAndDontProceed( | 841 TestReportingDisabledAndDontProceed( |
| 842 net::URLRequestMockHTTPJob::GetMockUrl(kEmptyPage)); | 842 net::URLRequestMockHTTPJob::GetMockUrl(kEmptyPage)); |
| 843 } | 843 } |
| 844 | 844 |
| 845 IN_PROC_BROWSER_TEST_P(SafeBrowsingBlockingPageBrowserTest, LearnMore) { | 845 IN_PROC_BROWSER_TEST_P(SafeBrowsingBlockingPageBrowserTest, LearnMore) { |
| 846 SetupWarningAndNavigate(); | 846 SetupWarningAndNavigate(); |
| 847 EXPECT_TRUE(ClickAndWaitForDetach("help-link")); | 847 EXPECT_TRUE(ClickAndWaitForDetach("learn-more-link")); |
| 848 AssertNoInterstitial(false); // Assert the interstitial is gone | 848 AssertNoInterstitial(false); // Assert the interstitial is gone |
| 849 | 849 |
| 850 // We are in the help page. | 850 // We are in the help page. |
| 851 EXPECT_EQ( | 851 EXPECT_EQ( |
| 852 testing::get<0>(GetParam()) == SB_THREAT_TYPE_URL_PHISHING | 852 GURL("https://support.google.com/chrome/answer/99020").GetWithEmptyPath(), |
| 853 ? "/transparencyreport/safebrowsing/" | 853 browser() |
| 854 : "/safebrowsing/diagnostic", | 854 ->tab_strip_model() |
| 855 browser()->tab_strip_model()->GetActiveWebContents()->GetURL().path()); | 855 ->GetActiveWebContents() |
| 856 ->GetURL() |
| 857 .GetWithEmptyPath()); |
| 856 } | 858 } |
| 857 | 859 |
| 858 IN_PROC_BROWSER_TEST_P(SafeBrowsingBlockingPageBrowserTest, | 860 IN_PROC_BROWSER_TEST_P(SafeBrowsingBlockingPageBrowserTest, |
| 859 Histograms_DontProceed) { | 861 Histograms_DontProceed) { |
| 860 base::HistogramTester histograms; | 862 base::HistogramTester histograms; |
| 861 std::string prefix; | 863 std::string prefix; |
| 862 SBThreatType threat_type = testing::get<0>(GetParam()); | 864 SBThreatType threat_type = testing::get<0>(GetParam()); |
| 863 if (threat_type == SB_THREAT_TYPE_URL_MALWARE) | 865 if (threat_type == SB_THREAT_TYPE_URL_MALWARE) |
| 864 prefix = "malware"; | 866 prefix = "malware"; |
| 865 else if (threat_type == SB_THREAT_TYPE_URL_PHISHING) | 867 else if (threat_type == SB_THREAT_TYPE_URL_PHISHING) |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1041 | 1043 |
| 1042 INSTANTIATE_TEST_CASE_P( | 1044 INSTANTIATE_TEST_CASE_P( |
| 1043 SafeBrowsingBlockingPageIDNTestWithThreatType, | 1045 SafeBrowsingBlockingPageIDNTestWithThreatType, |
| 1044 SafeBrowsingBlockingPageIDNTest, | 1046 SafeBrowsingBlockingPageIDNTest, |
| 1045 testing::Combine(testing::Values(false, true), | 1047 testing::Combine(testing::Values(false, true), |
| 1046 testing::Values(SB_THREAT_TYPE_URL_MALWARE, | 1048 testing::Values(SB_THREAT_TYPE_URL_MALWARE, |
| 1047 SB_THREAT_TYPE_URL_PHISHING, | 1049 SB_THREAT_TYPE_URL_PHISHING, |
| 1048 SB_THREAT_TYPE_URL_UNWANTED))); | 1050 SB_THREAT_TYPE_URL_UNWANTED))); |
| 1049 | 1051 |
| 1050 } // namespace safe_browsing | 1052 } // namespace safe_browsing |
| OLD | NEW |