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 | 5 // This test creates a fake safebrowsing service, where we can inject |
6 // malware and phishing urls. It then uses a real browser to go to | 6 // malware and phishing urls. It then uses a real browser to go to |
7 // these urls, and sends "goback" or "proceed" commands and verifies | 7 // these urls, and sends "goback" or "proceed" commands and verifies |
8 // they work. | 8 // they work. |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 663 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
674 EXPECT_EQ(HIDDEN, GetVisibility("show-diagnostic-link")); | 674 EXPECT_EQ(HIDDEN, GetVisibility("show-diagnostic-link")); |
675 EXPECT_EQ(HIDDEN, GetVisibility("report-error-link")); | 675 EXPECT_EQ(HIDDEN, GetVisibility("report-error-link")); |
676 EXPECT_EQ(HIDDEN, GetVisibility("proceed")); | 676 EXPECT_EQ(HIDDEN, GetVisibility("proceed")); |
677 EXPECT_TRUE(Click("see-more-link")); | 677 EXPECT_TRUE(Click("see-more-link")); |
678 EXPECT_EQ(VISIBLE, GetVisibility("show-diagnostic-link")); | 678 EXPECT_EQ(VISIBLE, GetVisibility("show-diagnostic-link")); |
679 EXPECT_EQ(HIDDEN, GetVisibility("report-error-link")); | 679 EXPECT_EQ(HIDDEN, GetVisibility("report-error-link")); |
680 EXPECT_EQ(VISIBLE, GetVisibility("proceed")); | 680 EXPECT_EQ(VISIBLE, GetVisibility("proceed")); |
681 | 681 |
682 EXPECT_TRUE(ClickAndWaitForDetach("back")); | 682 EXPECT_TRUE(ClickAndWaitForDetach("back")); |
683 AssertNoInterstitial(false); // Assert the interstitial is gone | 683 AssertNoInterstitial(false); // Assert the interstitial is gone |
684 EXPECT_EQ( | 684 EXPECT_EQ(GURL(url::kAboutBlankURL), // Back to "about:blank" |
685 GURL(content::kAboutBlankURL), // Back to "about:blank" | 685 browser()->tab_strip_model()->GetActiveWebContents()->GetURL()); |
686 browser()->tab_strip_model()->GetActiveWebContents()->GetURL()); | |
687 } | 686 } |
688 | 687 |
689 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageTest, MalwareProceed) { | 688 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageTest, MalwareProceed) { |
690 GURL url = SetupWarningAndNavigate(SB_THREAT_TYPE_URL_MALWARE); | 689 GURL url = SetupWarningAndNavigate(SB_THREAT_TYPE_URL_MALWARE); |
691 | 690 |
692 EXPECT_TRUE(ClickAndWaitForDetach("proceed")); | 691 EXPECT_TRUE(ClickAndWaitForDetach("proceed")); |
693 AssertNoInterstitial(true); // Assert the interstitial is gone. | 692 AssertNoInterstitial(true); // Assert the interstitial is gone. |
694 EXPECT_EQ(url, | 693 EXPECT_EQ(url, |
695 browser()->tab_strip_model()->GetActiveWebContents()->GetURL()); | 694 browser()->tab_strip_model()->GetActiveWebContents()->GetURL()); |
696 } | 695 } |
(...skipping 29 matching lines...) Expand all Loading... |
726 EXPECT_EQ(HIDDEN, GetVisibility("report-error-link")); | 725 EXPECT_EQ(HIDDEN, GetVisibility("report-error-link")); |
727 EXPECT_EQ(HIDDEN, GetVisibility("proceed")); | 726 EXPECT_EQ(HIDDEN, GetVisibility("proceed")); |
728 EXPECT_TRUE(Click("see-more-link")); | 727 EXPECT_TRUE(Click("see-more-link")); |
729 EXPECT_EQ(VISIBLE, GetVisibility("show-diagnostic-link")); | 728 EXPECT_EQ(VISIBLE, GetVisibility("show-diagnostic-link")); |
730 EXPECT_EQ(HIDDEN, GetVisibility("report-error-link")); | 729 EXPECT_EQ(HIDDEN, GetVisibility("report-error-link")); |
731 EXPECT_EQ(VISIBLE, GetVisibility("proceed")); | 730 EXPECT_EQ(VISIBLE, GetVisibility("proceed")); |
732 | 731 |
733 EXPECT_TRUE(ClickAndWaitForDetach("back")); | 732 EXPECT_TRUE(ClickAndWaitForDetach("back")); |
734 AssertNoInterstitial(false); // Assert the interstitial is gone | 733 AssertNoInterstitial(false); // Assert the interstitial is gone |
735 | 734 |
736 EXPECT_EQ( | 735 EXPECT_EQ(GURL(url::kAboutBlankURL), // Back to "about:blank" |
737 GURL(content::kAboutBlankURL), // Back to "about:blank" | 736 browser()->tab_strip_model()->GetActiveWebContents()->GetURL()); |
738 browser()->tab_strip_model()->GetActiveWebContents()->GetURL()); | |
739 } | 737 } |
740 | 738 |
741 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageTest, MalwareIframeProceed) { | 739 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageTest, MalwareIframeProceed) { |
742 GURL url = SetupMalwareIframeWarningAndNavigate(); | 740 GURL url = SetupMalwareIframeWarningAndNavigate(); |
743 | 741 |
744 EXPECT_TRUE(ClickAndWaitForDetach("proceed")); | 742 EXPECT_TRUE(ClickAndWaitForDetach("proceed")); |
745 AssertNoInterstitial(true); // Assert the interstitial is gone | 743 AssertNoInterstitial(true); // Assert the interstitial is gone |
746 | 744 |
747 EXPECT_EQ(url, | 745 EXPECT_EQ(url, |
748 browser()->tab_strip_model()->GetActiveWebContents()->GetURL()); | 746 browser()->tab_strip_model()->GetActiveWebContents()->GetURL()); |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
815 EXPECT_EQ(HIDDEN, GetVisibility("proceed")); | 813 EXPECT_EQ(HIDDEN, GetVisibility("proceed")); |
816 EXPECT_EQ(HIDDEN, GetVisibility("proceed-span")); | 814 EXPECT_EQ(HIDDEN, GetVisibility("proceed-span")); |
817 EXPECT_TRUE(Click("see-more-link")); | 815 EXPECT_TRUE(Click("see-more-link")); |
818 EXPECT_EQ(VISIBLE, GetVisibility("show-diagnostic-link")); | 816 EXPECT_EQ(VISIBLE, GetVisibility("show-diagnostic-link")); |
819 EXPECT_EQ(HIDDEN, GetVisibility("proceed")); | 817 EXPECT_EQ(HIDDEN, GetVisibility("proceed")); |
820 EXPECT_EQ(HIDDEN, GetVisibility("proceed-span")); | 818 EXPECT_EQ(HIDDEN, GetVisibility("proceed-span")); |
821 | 819 |
822 // The "proceed" command should go back instead, if proceeding is disabled. | 820 // The "proceed" command should go back instead, if proceeding is disabled. |
823 EXPECT_TRUE(ClickAndWaitForDetach("proceed")); | 821 EXPECT_TRUE(ClickAndWaitForDetach("proceed")); |
824 AssertNoInterstitial(true); | 822 AssertNoInterstitial(true); |
825 EXPECT_EQ( | 823 EXPECT_EQ(GURL(url::kAboutBlankURL), // Back to "about:blank" |
826 GURL(content::kAboutBlankURL), // Back to "about:blank" | 824 browser()->tab_strip_model()->GetActiveWebContents()->GetURL()); |
827 browser()->tab_strip_model()->GetActiveWebContents()->GetURL()); | |
828 } | 825 } |
829 | 826 |
830 // Verifies that the reporting checkbox is hidden on non-HTTP pages. | 827 // Verifies that the reporting checkbox is hidden on non-HTTP pages. |
831 // TODO(mattm): Should also verify that no report is sent, but there isn't a | 828 // TODO(mattm): Should also verify that no report is sent, but there isn't a |
832 // good way to do that in the current design. | 829 // good way to do that in the current design. |
833 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageTest, ReportingDisabled) { | 830 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageTest, ReportingDisabled) { |
834 #if defined(OS_WIN) && defined(USE_ASH) | 831 #if defined(OS_WIN) && defined(USE_ASH) |
835 // Disable this test in Metro+Ash for now (http://crbug.com/262796). | 832 // Disable this test in Metro+Ash for now (http://crbug.com/262796). |
836 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) | 833 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) |
837 return; | 834 return; |
(...skipping 13 matching lines...) Expand all Loading... |
851 | 848 |
852 EXPECT_EQ(HIDDEN, GetVisibility("check-report")); | 849 EXPECT_EQ(HIDDEN, GetVisibility("check-report")); |
853 EXPECT_EQ(HIDDEN, GetVisibility("show-diagnostic-link")); | 850 EXPECT_EQ(HIDDEN, GetVisibility("show-diagnostic-link")); |
854 EXPECT_EQ(HIDDEN, GetVisibility("proceed")); | 851 EXPECT_EQ(HIDDEN, GetVisibility("proceed")); |
855 EXPECT_TRUE(Click("see-more-link")); | 852 EXPECT_TRUE(Click("see-more-link")); |
856 EXPECT_EQ(VISIBLE, GetVisibility("show-diagnostic-link")); | 853 EXPECT_EQ(VISIBLE, GetVisibility("show-diagnostic-link")); |
857 EXPECT_EQ(VISIBLE, GetVisibility("proceed")); | 854 EXPECT_EQ(VISIBLE, GetVisibility("proceed")); |
858 | 855 |
859 EXPECT_TRUE(ClickAndWaitForDetach("back")); | 856 EXPECT_TRUE(ClickAndWaitForDetach("back")); |
860 AssertNoInterstitial(false); // Assert the interstitial is gone | 857 AssertNoInterstitial(false); // Assert the interstitial is gone |
861 EXPECT_EQ( | 858 EXPECT_EQ(GURL(url::kAboutBlankURL), // Back to "about:blank" |
862 GURL(content::kAboutBlankURL), // Back to "about:blank" | 859 browser()->tab_strip_model()->GetActiveWebContents()->GetURL()); |
863 browser()->tab_strip_model()->GetActiveWebContents()->GetURL()); | |
864 } | 860 } |
865 | 861 |
866 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageTest, PhishingDontProceed) { | 862 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageTest, PhishingDontProceed) { |
867 #if defined(OS_WIN) && defined(USE_ASH) | 863 #if defined(OS_WIN) && defined(USE_ASH) |
868 // Disable this test in Metro+Ash for now (http://crbug.com/262796). | 864 // Disable this test in Metro+Ash for now (http://crbug.com/262796). |
869 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) | 865 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) |
870 return; | 866 return; |
871 #endif | 867 #endif |
872 | 868 |
873 SetupWarningAndNavigate(SB_THREAT_TYPE_URL_PHISHING); | 869 SetupWarningAndNavigate(SB_THREAT_TYPE_URL_PHISHING); |
874 | 870 |
875 EXPECT_EQ(HIDDEN, GetVisibility("malware-icon")); | 871 EXPECT_EQ(HIDDEN, GetVisibility("malware-icon")); |
876 EXPECT_EQ(HIDDEN, GetVisibility("subresource-icon")); | 872 EXPECT_EQ(HIDDEN, GetVisibility("subresource-icon")); |
877 EXPECT_EQ(VISIBLE, GetVisibility("phishing-icon")); | 873 EXPECT_EQ(VISIBLE, GetVisibility("phishing-icon")); |
878 EXPECT_EQ(HIDDEN, GetVisibility("check-report")); | 874 EXPECT_EQ(HIDDEN, GetVisibility("check-report")); |
879 EXPECT_EQ(HIDDEN, GetVisibility("show-diagnostic-link")); | 875 EXPECT_EQ(HIDDEN, GetVisibility("show-diagnostic-link")); |
880 EXPECT_EQ(HIDDEN, GetVisibility("report-error-link")); | 876 EXPECT_EQ(HIDDEN, GetVisibility("report-error-link")); |
881 EXPECT_EQ(HIDDEN, GetVisibility("proceed")); | 877 EXPECT_EQ(HIDDEN, GetVisibility("proceed")); |
882 EXPECT_TRUE(Click("see-more-link")); | 878 EXPECT_TRUE(Click("see-more-link")); |
883 EXPECT_EQ(HIDDEN, GetVisibility("show-diagnostic-link")); | 879 EXPECT_EQ(HIDDEN, GetVisibility("show-diagnostic-link")); |
884 EXPECT_EQ(VISIBLE, GetVisibility("report-error-link")); | 880 EXPECT_EQ(VISIBLE, GetVisibility("report-error-link")); |
885 EXPECT_EQ(VISIBLE, GetVisibility("proceed")); | 881 EXPECT_EQ(VISIBLE, GetVisibility("proceed")); |
886 | 882 |
887 EXPECT_TRUE(ClickAndWaitForDetach("back")); | 883 EXPECT_TRUE(ClickAndWaitForDetach("back")); |
888 AssertNoInterstitial(false); // Assert the interstitial is gone | 884 AssertNoInterstitial(false); // Assert the interstitial is gone |
889 EXPECT_EQ( | 885 EXPECT_EQ(GURL(url::kAboutBlankURL), // We are back to "about:blank". |
890 GURL(content::kAboutBlankURL), // We are back to "about:blank". | 886 browser()->tab_strip_model()->GetActiveWebContents()->GetURL()); |
891 browser()->tab_strip_model()->GetActiveWebContents()->GetURL()); | |
892 } | 887 } |
893 | 888 |
894 // http://crbug.com/247763 | 889 // http://crbug.com/247763 |
895 #if defined(OS_WIN) | 890 #if defined(OS_WIN) |
896 // Temporarily re-enabled to get some logs. | 891 // Temporarily re-enabled to get some logs. |
897 #define MAYBE_PhishingProceed PhishingProceed | 892 #define MAYBE_PhishingProceed PhishingProceed |
898 #else | 893 #else |
899 #define MAYBE_PhishingProceed PhishingProceed | 894 #define MAYBE_PhishingProceed PhishingProceed |
900 #endif | 895 #endif |
901 | 896 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
940 LOG(INFO) << "2"; | 935 LOG(INFO) << "2"; |
941 AssertNoInterstitial(false); // Assert the interstitial is gone | 936 AssertNoInterstitial(false); // Assert the interstitial is gone |
942 | 937 |
943 LOG(INFO) << "3"; | 938 LOG(INFO) << "3"; |
944 // We are in the help page. | 939 // We are in the help page. |
945 EXPECT_EQ( | 940 EXPECT_EQ( |
946 "/transparencyreport/safebrowsing/", | 941 "/transparencyreport/safebrowsing/", |
947 browser()->tab_strip_model()->GetActiveWebContents()->GetURL().path()); | 942 browser()->tab_strip_model()->GetActiveWebContents()->GetURL().path()); |
948 LOG(INFO) << "4"; | 943 LOG(INFO) << "4"; |
949 } | 944 } |
OLD | NEW |