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 "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 672 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
683 GURL url = SetupThreatIframeWarningAndNavigate(); | 683 GURL url = SetupThreatIframeWarningAndNavigate(); |
684 | 684 |
685 FakeMalwareDetails* fake_malware_details = details_factory_.get_details(); | 685 FakeMalwareDetails* fake_malware_details = details_factory_.get_details(); |
686 EXPECT_EQ(expect_malware_details, fake_malware_details != nullptr); | 686 EXPECT_EQ(expect_malware_details, fake_malware_details != nullptr); |
687 | 687 |
688 // If the DOM details from renderer did not already return when they are | 688 // If the DOM details from renderer did not already return when they are |
689 // expected, wait for them. | 689 // expected, wait for them. |
690 if (expect_malware_details) | 690 if (expect_malware_details) |
691 fake_malware_details->WaitForDOM(); | 691 fake_malware_details->WaitForDOM(); |
692 | 692 |
693 EXPECT_EQ(VISIBLE, GetVisibility("malware-opt-in")); | 693 EXPECT_EQ(VISIBLE, GetVisibility("extended-reporting-opt-in")); |
694 EXPECT_TRUE(Click("opt-in-checkbox")); | 694 EXPECT_TRUE(Click("opt-in-checkbox")); |
695 EXPECT_TRUE(ClickAndWaitForDetach("proceed-link")); | 695 EXPECT_TRUE(ClickAndWaitForDetach("proceed-link")); |
696 AssertNoInterstitial(true); // Assert the interstitial is gone | 696 AssertNoInterstitial(true); // Assert the interstitial is gone |
697 | 697 |
698 EXPECT_TRUE(browser()->profile()->GetPrefs()->GetBoolean( | 698 EXPECT_TRUE(browser()->profile()->GetPrefs()->GetBoolean( |
699 prefs::kSafeBrowsingExtendedReportingEnabled)); | 699 prefs::kSafeBrowsingExtendedReportingEnabled)); |
700 EXPECT_EQ(url, | 700 EXPECT_EQ(url, |
701 browser()->tab_strip_model()->GetActiveWebContents()->GetURL()); | 701 browser()->tab_strip_model()->GetActiveWebContents()->GetURL()); |
702 | 702 |
703 if (expect_malware_details) { | 703 if (expect_malware_details) { |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
758 | 758 |
759 net::SpawnedTestServer https_server( | 759 net::SpawnedTestServer https_server( |
760 net::SpawnedTestServer::TYPE_HTTPS, net::SpawnedTestServer::kLocalhost, | 760 net::SpawnedTestServer::TYPE_HTTPS, net::SpawnedTestServer::kLocalhost, |
761 base::FilePath(FILE_PATH_LITERAL("chrome/test/data"))); | 761 base::FilePath(FILE_PATH_LITERAL("chrome/test/data"))); |
762 ASSERT_TRUE(https_server.Start()); | 762 ASSERT_TRUE(https_server.Start()); |
763 GURL url = https_server.GetURL(kEmptyPage); | 763 GURL url = https_server.GetURL(kEmptyPage); |
764 SetURLThreatType(url, GetParam()); | 764 SetURLThreatType(url, GetParam()); |
765 ui_test_utils::NavigateToURL(browser(), url); | 765 ui_test_utils::NavigateToURL(browser(), url); |
766 ASSERT_TRUE(WaitForReady()); | 766 ASSERT_TRUE(WaitForReady()); |
767 | 767 |
768 EXPECT_EQ(HIDDEN, GetVisibility("malware-opt-in")); | 768 EXPECT_EQ(HIDDEN, GetVisibility("extended-reporting-opt-in")); |
769 EXPECT_EQ(HIDDEN, GetVisibility("opt-in-checkbox")); | 769 EXPECT_EQ(HIDDEN, GetVisibility("opt-in-checkbox")); |
770 EXPECT_EQ(HIDDEN, GetVisibility("proceed-link")); | 770 EXPECT_EQ(HIDDEN, GetVisibility("proceed-link")); |
771 EXPECT_TRUE(Click("details-button")); | 771 EXPECT_TRUE(Click("details-button")); |
772 EXPECT_EQ(VISIBLE, GetVisibility("help-link")); | 772 EXPECT_EQ(VISIBLE, GetVisibility("help-link")); |
773 EXPECT_EQ(VISIBLE, GetVisibility("proceed-link")); | 773 EXPECT_EQ(VISIBLE, GetVisibility("proceed-link")); |
774 | 774 |
775 EXPECT_TRUE(ClickAndWaitForDetach("primary-button")); | 775 EXPECT_TRUE(ClickAndWaitForDetach("primary-button")); |
776 AssertNoInterstitial(false); // Assert the interstitial is gone | 776 AssertNoInterstitial(false); // Assert the interstitial is gone |
777 EXPECT_EQ(GURL(url::kAboutBlankURL), // Back to "about:blank" | 777 EXPECT_EQ(GURL(url::kAboutBlankURL), // Back to "about:blank" |
778 browser()->tab_strip_model()->GetActiveWebContents()->GetURL()); | 778 browser()->tab_strip_model()->GetActiveWebContents()->GetURL()); |
(...skipping 10 matching lines...) Expand all Loading... |
789 ? "/transparencyreport/safebrowsing/" | 789 ? "/transparencyreport/safebrowsing/" |
790 : "/safebrowsing/diagnostic", | 790 : "/safebrowsing/diagnostic", |
791 browser()->tab_strip_model()->GetActiveWebContents()->GetURL().path()); | 791 browser()->tab_strip_model()->GetActiveWebContents()->GetURL().path()); |
792 } | 792 } |
793 | 793 |
794 INSTANTIATE_TEST_CASE_P(SafeBrowsingBlockingPageBrowserTestWithThreatType, | 794 INSTANTIATE_TEST_CASE_P(SafeBrowsingBlockingPageBrowserTestWithThreatType, |
795 SafeBrowsingBlockingPageBrowserTest, | 795 SafeBrowsingBlockingPageBrowserTest, |
796 testing::Values(SB_THREAT_TYPE_URL_MALWARE, | 796 testing::Values(SB_THREAT_TYPE_URL_MALWARE, |
797 SB_THREAT_TYPE_URL_PHISHING, | 797 SB_THREAT_TYPE_URL_PHISHING, |
798 SB_THREAT_TYPE_URL_UNWANTED)); | 798 SB_THREAT_TYPE_URL_UNWANTED)); |
OLD | NEW |