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 275df6d24c6fa8455776618282692478c271b88d..8a468393605ae890419380c6bd935859ea96b464 100644 |
--- a/chrome/browser/safe_browsing/safe_browsing_blocking_page_test.cc |
+++ b/chrome/browser/safe_browsing/safe_browsing_blocking_page_test.cc |
@@ -305,18 +305,18 @@ class TestMalwareDetailsFactory : public MalwareDetailsFactory { |
}; |
// A SafeBrowingBlockingPage class that lets us wait until it's hidden. |
-class TestSafeBrowsingBlockingPage : public SafeBrowsingBlockingPageV2 { |
+class TestSafeBrowsingBlockingPageV2 : public SafeBrowsingBlockingPageV2 { |
public: |
- TestSafeBrowsingBlockingPage(SafeBrowsingUIManager* manager, |
- WebContents* web_contents, |
- const UnsafeResourceList& unsafe_resources) |
+ TestSafeBrowsingBlockingPageV2(SafeBrowsingUIManager* manager, |
+ WebContents* web_contents, |
+ const UnsafeResourceList& unsafe_resources) |
: SafeBrowsingBlockingPageV2(manager, web_contents, unsafe_resources), |
wait_for_delete_(false) { |
// Don't wait the whole 3 seconds for the browser test. |
malware_details_proceed_delay_ms_ = 100; |
} |
- virtual ~TestSafeBrowsingBlockingPage() { |
+ virtual ~TestSafeBrowsingBlockingPageV2() { |
LOG(INFO) << __FUNCTION__; |
if (!wait_for_delete_) |
return; |
@@ -350,6 +350,53 @@ class TestSafeBrowsingBlockingPage : public SafeBrowsingBlockingPageV2 { |
bool wait_for_delete_; |
}; |
+// A SafeBrowingBlockingPage class that lets us wait until it's hidden. |
+class TestSafeBrowsingBlockingPageV3 : public SafeBrowsingBlockingPageV3 { |
+ public: |
+ TestSafeBrowsingBlockingPageV3(SafeBrowsingUIManager* manager, |
+ WebContents* web_contents, |
+ const UnsafeResourceList& unsafe_resources) |
+ : SafeBrowsingBlockingPageV3(manager, web_contents, unsafe_resources), |
+ wait_for_delete_(false) { |
+ // Don't wait the whole 3 seconds for the browser test. |
+ malware_details_proceed_delay_ms_ = 100; |
+ } |
+ |
+ virtual ~TestSafeBrowsingBlockingPageV3() { |
+ LOG(INFO) << __FUNCTION__; |
+ if (!wait_for_delete_) |
+ return; |
+ |
+ // Notify that we are gone |
+ base::MessageLoopForUI::current()->Quit(); |
+ wait_for_delete_ = false; |
+ } |
+ |
+ void WaitForDelete() { |
+ LOG(INFO) << __FUNCTION__; |
+ wait_for_delete_ = true; |
+ content::RunMessageLoop(); |
+ } |
+ |
+ // InterstitialPageDelegate methods: |
+ virtual void CommandReceived(const std::string& command) OVERRIDE { |
+ LOG(INFO) << __FUNCTION__ << " " << command; |
+ SafeBrowsingBlockingPageV3::CommandReceived(command); |
+ } |
+ virtual void OnProceed() OVERRIDE { |
+ LOG(INFO) << __FUNCTION__; |
+ SafeBrowsingBlockingPageV3::OnProceed(); |
+ } |
+ virtual void OnDontProceed() OVERRIDE { |
+ LOG(INFO) << __FUNCTION__; |
+ SafeBrowsingBlockingPageV3::OnDontProceed(); |
+ } |
+ |
+ private: |
+ bool wait_for_delete_; |
+}; |
+ |
+template <class TestSBInterstitialPage> |
class TestSafeBrowsingBlockingPageFactory |
: public SafeBrowsingBlockingPageFactory { |
public: |
@@ -361,15 +408,15 @@ class TestSafeBrowsingBlockingPageFactory |
WebContents* web_contents, |
const SafeBrowsingBlockingPage::UnsafeResourceList& unsafe_resources) |
OVERRIDE { |
- return new TestSafeBrowsingBlockingPage(delegate, web_contents, |
- unsafe_resources); |
+ return new TestSBInterstitialPage(delegate, web_contents, unsafe_resources); |
} |
}; |
} // namespace |
// Tests the safe browsing blocking page in a browser. |
-class SafeBrowsingBlockingPageTest : public InProcessBrowserTest { |
+template <class TestSBInterstitialPage> |
+class SafeBrowsingBlockingPageBrowserTest : public InProcessBrowserTest { |
public: |
enum Visibility { |
VISIBILITY_ERROR = -1, |
@@ -377,7 +424,7 @@ class SafeBrowsingBlockingPageTest : public InProcessBrowserTest { |
VISIBLE = 1, |
}; |
- SafeBrowsingBlockingPageTest() { |
+ SafeBrowsingBlockingPageBrowserTest() { |
} |
virtual void SetUp() OVERRIDE { |
@@ -472,8 +519,8 @@ class SafeBrowsingBlockingPageTest : public InProcessBrowserTest { |
if (contents->ShowingInterstitialPage() && wait_for_delete) { |
// We'll get notified when the interstitial is deleted. |
- TestSafeBrowsingBlockingPage* page = |
- static_cast<TestSafeBrowsingBlockingPage*>( |
+ TestSafeBrowsingBlockingPageV2* page = |
+ static_cast<TestSafeBrowsingBlockingPageV2*>( |
contents->GetInterstitialPage()->GetDelegateForTesting()); |
page->WaitForDelete(); |
} |
@@ -623,16 +670,299 @@ class SafeBrowsingBlockingPageTest : public InProcessBrowserTest { |
return true; |
} |
+ // TEST CASES. |
mattm
2014/06/13 20:20:31
Could you use parameterized tests to avoid having
felt
2014/06/14 01:08:04
Sweet, I didn't know about IN_PROC_BROWSER_TEST_P.
|
+ |
+ void MalwareRedirectInIFrameCanceledTest() { |
+ // 1. Test the case that redirect is a subresource. |
+ MalwareRedirectCancelAndProceed("openWinIFrame"); |
+ // If the redirect was from subresource but canceled, "proceed" will |
+ // continue with the rest of resources. |
+ AssertNoInterstitial(true); |
+ } |
+ |
+ void MalwareRedirectCanceledTest() { |
+ // 2. Test the case that redirect is the only resource. |
+ MalwareRedirectCancelAndProceed("openWin"); |
+ // Clicking proceed won't do anything if the main request is cancelled |
+ // already. See crbug.com/76460. |
+ EXPECT_TRUE(YesInterstitial()); |
+ } |
+ |
+ void MalwareDontProceedTest() { |
+ #if defined(OS_WIN) && defined(USE_ASH) |
+ // Disable this test in Metro+Ash for now (http://crbug.com/262796). |
+ if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) |
+ return; |
+ #endif |
+ |
+ SetupWarningAndNavigate(SB_THREAT_TYPE_URL_MALWARE); |
+ |
+ EXPECT_EQ(VISIBLE, GetVisibility("malware-icon")); |
+ EXPECT_EQ(HIDDEN, GetVisibility("subresource-icon")); |
+ EXPECT_EQ(HIDDEN, GetVisibility("phishing-icon")); |
+ EXPECT_EQ(VISIBLE, GetVisibility("check-report")); |
+ EXPECT_EQ(HIDDEN, GetVisibility("show-diagnostic-link")); |
+ EXPECT_EQ(HIDDEN, GetVisibility("report-error-link")); |
+ EXPECT_EQ(HIDDEN, GetVisibility("proceed")); |
+ EXPECT_TRUE(Click("see-more-link")); |
+ EXPECT_EQ(VISIBLE, GetVisibility("show-diagnostic-link")); |
+ EXPECT_EQ(HIDDEN, GetVisibility("report-error-link")); |
+ EXPECT_EQ(VISIBLE, GetVisibility("proceed")); |
+ |
+ EXPECT_TRUE(ClickAndWaitForDetach("back")); |
+ AssertNoInterstitial(false); // Assert the interstitial is gone |
+ EXPECT_EQ(GURL(url::kAboutBlankURL), // Back to "about:blank" |
+ browser()->tab_strip_model()->GetActiveWebContents()->GetURL()); |
+ } |
+ |
+ void MalwareProceedTest() { |
+ GURL url = SetupWarningAndNavigate(SB_THREAT_TYPE_URL_MALWARE); |
+ |
+ EXPECT_TRUE(ClickAndWaitForDetach("proceed")); |
+ AssertNoInterstitial(true); // Assert the interstitial is gone. |
+ EXPECT_EQ(url, |
+ browser()->tab_strip_model()->GetActiveWebContents()->GetURL()); |
+ } |
+ |
+ void MalwareLearnMoreTest() { |
+ SetupWarningAndNavigate(SB_THREAT_TYPE_URL_MALWARE); |
+ |
+ EXPECT_TRUE(ClickAndWaitForDetach("learn-more-link")); |
+ AssertNoInterstitial(false); // Assert the interstitial is gone |
+ |
+ // We are in the help page. |
+ EXPECT_EQ( |
+ "/transparencyreport/safebrowsing/", |
+ browser()->tab_strip_model()->GetActiveWebContents()->GetURL().path()); |
+ } |
+ |
+ void MalwareIframeDontProceedTest() { |
+ #if defined(OS_WIN) && defined(USE_ASH) |
+ // Disable this test in Metro+Ash for now (http://crbug.com/262796). |
+ if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) |
+ return; |
+ #endif |
+ |
+ SetupMalwareIframeWarningAndNavigate(); |
+ |
+ EXPECT_EQ(HIDDEN, GetVisibility("malware-icon")); |
+ EXPECT_EQ(VISIBLE, GetVisibility("subresource-icon")); |
+ EXPECT_EQ(HIDDEN, GetVisibility("phishing-icon")); |
+ EXPECT_EQ(VISIBLE, GetVisibility("check-report")); |
+ EXPECT_EQ(HIDDEN, GetVisibility("show-diagnostic-link")); |
+ EXPECT_EQ(HIDDEN, GetVisibility("report-error-link")); |
+ EXPECT_EQ(HIDDEN, GetVisibility("proceed")); |
+ EXPECT_TRUE(Click("see-more-link")); |
+ EXPECT_EQ(VISIBLE, GetVisibility("show-diagnostic-link")); |
+ EXPECT_EQ(HIDDEN, GetVisibility("report-error-link")); |
+ EXPECT_EQ(VISIBLE, GetVisibility("proceed")); |
+ |
+ EXPECT_TRUE(ClickAndWaitForDetach("back")); |
+ AssertNoInterstitial(false); // Assert the interstitial is gone |
+ |
+ EXPECT_EQ(GURL(url::kAboutBlankURL), // Back to "about:blank" |
+ browser()->tab_strip_model()->GetActiveWebContents()->GetURL()); |
+ } |
+ |
+ void MalwareIframeProceedTest() { |
+ GURL url = SetupMalwareIframeWarningAndNavigate(); |
+ |
+ EXPECT_TRUE(ClickAndWaitForDetach("proceed")); |
+ AssertNoInterstitial(true); // Assert the interstitial is gone |
+ |
+ EXPECT_EQ(url, |
+ browser()->tab_strip_model()->GetActiveWebContents()->GetURL()); |
+ } |
+ |
+ void MalwareIframeReportDetailsTest() { |
+ scoped_refptr<content::MessageLoopRunner> malware_report_sent_runner( |
+ new content::MessageLoopRunner); |
+ SetReportSentCallback(malware_report_sent_runner->QuitClosure()); |
+ |
+ GURL url = SetupMalwareIframeWarningAndNavigate(); |
+ |
+ LOG(INFO) << "1"; |
+ |
+ // If the DOM details from renderer did not already return, wait for them. |
+ details_factory_.get_details()->WaitForDOM(); |
+ LOG(INFO) << "2"; |
+ |
+ EXPECT_TRUE(Click("check-report")); |
+ LOG(INFO) << "3"; |
+ |
+ EXPECT_TRUE(ClickAndWaitForDetach("proceed")); |
+ LOG(INFO) << "4"; |
+ AssertNoInterstitial(true); // Assert the interstitial is gone |
+ LOG(INFO) << "5"; |
+ |
+ ASSERT_TRUE(browser()->profile()->GetPrefs()->GetBoolean( |
+ prefs::kSafeBrowsingReportingEnabled)); |
+ LOG(INFO) << "6"; |
+ |
+ EXPECT_EQ(url, |
+ browser()->tab_strip_model()->GetActiveWebContents()->GetURL()); |
+ LOG(INFO) << "7"; |
+ |
+ malware_report_sent_runner->Run(); |
+ std::string serialized = GetReportSent(); |
+ safe_browsing::ClientMalwareReportRequest report; |
+ ASSERT_TRUE(report.ParseFromString(serialized)); |
+ // Verify the report is complete. |
+ EXPECT_TRUE(report.complete()); |
+ LOG(INFO) << "8"; |
+ } |
+ |
+ // Verifies that the "proceed anyway" link isn't available when it is disabled |
+ // by the corresponding policy. Also verifies that sending the "proceed" |
+ // command anyway doesn't advance to the malware site. |
+ void ProceedDisabledTest() { |
+ #if defined(OS_WIN) && defined(USE_ASH) |
+ // Disable this test in Metro+Ash for now (http://crbug.com/262796). |
+ if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) |
+ return; |
+ #endif |
+ |
+ // Simulate a policy disabling the "proceed anyway" link. |
+ browser()->profile()->GetPrefs()->SetBoolean( |
+ prefs::kSafeBrowsingProceedAnywayDisabled, true); |
+ |
+ SetupWarningAndNavigate(SB_THREAT_TYPE_URL_MALWARE); |
+ |
+ EXPECT_EQ(VISIBLE, GetVisibility("check-report")); |
+ EXPECT_EQ(HIDDEN, GetVisibility("show-diagnostic-link")); |
+ EXPECT_EQ(HIDDEN, GetVisibility("proceed")); |
+ EXPECT_EQ(HIDDEN, GetVisibility("proceed-span")); |
+ EXPECT_TRUE(Click("see-more-link")); |
+ EXPECT_EQ(VISIBLE, GetVisibility("show-diagnostic-link")); |
+ EXPECT_EQ(HIDDEN, GetVisibility("proceed")); |
+ EXPECT_EQ(HIDDEN, GetVisibility("proceed-span")); |
+ |
+ // The "proceed" command should go back instead, if proceeding is disabled. |
+ EXPECT_TRUE(ClickAndWaitForDetach("proceed")); |
+ AssertNoInterstitial(true); |
+ EXPECT_EQ(GURL(url::kAboutBlankURL), // Back to "about:blank" |
+ browser()->tab_strip_model()->GetActiveWebContents()->GetURL()); |
+ } |
+ |
+ // Verifies that the reporting checkbox is hidden on non-HTTP pages. |
+ // TODO(mattm): Should also verify that no report is sent, but there isn't a |
+ // good way to do that in the current design. |
+ void ReportingDisabledTest() { |
+ #if defined(OS_WIN) && defined(USE_ASH) |
+ // Disable this test in Metro+Ash for now (http://crbug.com/262796). |
+ if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) |
+ return; |
+ #endif |
+ |
+ browser()->profile()->GetPrefs()->SetBoolean( |
+ prefs::kSafeBrowsingReportingEnabled, true); |
+ |
+ net::SpawnedTestServer https_server( |
+ net::SpawnedTestServer::TYPE_HTTPS, net::SpawnedTestServer::kLocalhost, |
+ base::FilePath(FILE_PATH_LITERAL("chrome/test/data"))); |
+ ASSERT_TRUE(https_server.Start()); |
+ GURL url = https_server.GetURL(kEmptyPage); |
+ SetURLThreatType(url, SB_THREAT_TYPE_URL_MALWARE); |
+ ui_test_utils::NavigateToURL(browser(), url); |
+ ASSERT_TRUE(WaitForReady()); |
+ |
+ EXPECT_EQ(HIDDEN, GetVisibility("check-report")); |
+ EXPECT_EQ(HIDDEN, GetVisibility("show-diagnostic-link")); |
+ EXPECT_EQ(HIDDEN, GetVisibility("proceed")); |
+ EXPECT_TRUE(Click("see-more-link")); |
+ EXPECT_EQ(VISIBLE, GetVisibility("show-diagnostic-link")); |
+ EXPECT_EQ(VISIBLE, GetVisibility("proceed")); |
+ |
+ EXPECT_TRUE(ClickAndWaitForDetach("back")); |
+ AssertNoInterstitial(false); // Assert the interstitial is gone |
+ EXPECT_EQ(GURL(url::kAboutBlankURL), // Back to "about:blank" |
+ browser()->tab_strip_model()->GetActiveWebContents()->GetURL()); |
+ } |
+ |
+ void PhishingDontProceedTest() { |
+ #if defined(OS_WIN) && defined(USE_ASH) |
+ // Disable this test in Metro+Ash for now (http://crbug.com/262796). |
+ if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) |
+ return; |
+ #endif |
+ |
+ SetupWarningAndNavigate(SB_THREAT_TYPE_URL_PHISHING); |
+ |
+ EXPECT_EQ(HIDDEN, GetVisibility("malware-icon")); |
+ EXPECT_EQ(HIDDEN, GetVisibility("subresource-icon")); |
+ EXPECT_EQ(VISIBLE, GetVisibility("phishing-icon")); |
+ EXPECT_EQ(HIDDEN, GetVisibility("check-report")); |
+ EXPECT_EQ(HIDDEN, GetVisibility("show-diagnostic-link")); |
+ EXPECT_EQ(HIDDEN, GetVisibility("report-error-link")); |
+ EXPECT_EQ(HIDDEN, GetVisibility("proceed")); |
+ EXPECT_TRUE(Click("see-more-link")); |
+ EXPECT_EQ(HIDDEN, GetVisibility("show-diagnostic-link")); |
+ EXPECT_EQ(VISIBLE, GetVisibility("report-error-link")); |
+ EXPECT_EQ(VISIBLE, GetVisibility("proceed")); |
+ |
+ EXPECT_TRUE(ClickAndWaitForDetach("back")); |
+ AssertNoInterstitial(false); // Assert the interstitial is gone |
+ EXPECT_EQ(GURL(url::kAboutBlankURL), // We are back to "about:blank". |
+ browser()->tab_strip_model()->GetActiveWebContents()->GetURL()); |
+ } |
+ |
+ void PhishingProceedTest() { |
+ GURL url = SetupWarningAndNavigate(SB_THREAT_TYPE_URL_PHISHING); |
+ LOG(INFO) << "1"; |
+ |
+ EXPECT_TRUE(ClickAndWaitForDetach("proceed")); |
+ LOG(INFO) << "2"; |
+ AssertNoInterstitial(true); // Assert the interstitial is gone |
+ LOG(INFO) << "3"; |
+ EXPECT_EQ(url, |
+ browser()->tab_strip_model()->GetActiveWebContents()->GetURL()); |
+ LOG(INFO) << "4"; |
+ } |
+ |
+ void PhishingReportErrorTest() { |
+ SetupWarningAndNavigate(SB_THREAT_TYPE_URL_PHISHING); |
+ |
+ EXPECT_TRUE(ClickAndWaitForDetach("report-error-link")); |
+ AssertNoInterstitial(false); // Assert the interstitial is gone |
+ |
+ // We are in the error reporting page. |
+ EXPECT_EQ( |
+ "/safebrowsing/report_error/", |
+ browser()->tab_strip_model()->GetActiveWebContents()->GetURL().path()); |
+ } |
+ |
+ void PhishingLearnMoreTest() { |
+ SetupWarningAndNavigate(SB_THREAT_TYPE_URL_PHISHING); |
+ LOG(INFO) << "1"; |
+ |
+ EXPECT_TRUE(ClickAndWaitForDetach("learn-more-link")); |
+ LOG(INFO) << "2"; |
+ AssertNoInterstitial(false); // Assert the interstitial is gone |
+ |
+ LOG(INFO) << "3"; |
+ // We are in the help page. |
+ EXPECT_EQ( |
+ "/transparencyreport/safebrowsing/", |
+ browser()->tab_strip_model()->GetActiveWebContents()->GetURL().path()); |
+ LOG(INFO) << "4"; |
+ } |
+ |
protected: |
TestMalwareDetailsFactory details_factory_; |
private: |
TestSafeBrowsingServiceFactory factory_; |
- TestSafeBrowsingBlockingPageFactory blocking_page_factory_; |
+ TestSafeBrowsingBlockingPageFactory<TestSBInterstitialPage> |
+ blocking_page_factory_; |
- DISALLOW_COPY_AND_ASSIGN(SafeBrowsingBlockingPageTest); |
+ DISALLOW_COPY_AND_ASSIGN(SafeBrowsingBlockingPageBrowserTest); |
}; |
+typedef SafeBrowsingBlockingPageBrowserTest<TestSafeBrowsingBlockingPageV2> |
+ SafeBrowsingInterstitialTestV2; |
+typedef SafeBrowsingBlockingPageBrowserTest<TestSafeBrowsingBlockingPageV3> |
+ SafeBrowsingInterstitialTestV3; |
+ |
// TODO(linux_aura) http://crbug.com/163931 |
// TODO(win_aura) http://crbug.com/154081 |
#if defined(USE_AURA) && !defined(OS_CHROMEOS) |
@@ -640,110 +970,60 @@ class SafeBrowsingBlockingPageTest : public InProcessBrowserTest { |
#else |
#define MAYBE_MalwareRedirectInIFrameCanceled MalwareRedirectInIFrameCanceled |
#endif |
-IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageTest, |
+IN_PROC_BROWSER_TEST_F(SafeBrowsingInterstitialTestV2, |
mattm
2014/06/13 20:20:31
You'll need to update the test names in tools/valg
felt
2014/06/14 01:08:04
Done.
|
MAYBE_MalwareRedirectInIFrameCanceled) { |
- // 1. Test the case that redirect is a subresource. |
- MalwareRedirectCancelAndProceed("openWinIFrame"); |
- // If the redirect was from subresource but canceled, "proceed" will continue |
- // with the rest of resources. |
- AssertNoInterstitial(true); |
+ MalwareRedirectInIFrameCanceledTest(); |
} |
- |
-IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageTest, |
- MalwareRedirectCanceled) { |
- // 2. Test the case that redirect is the only resource. |
- MalwareRedirectCancelAndProceed("openWin"); |
- // Clicking proceed won't do anything if the main request is cancelled |
- // already. See crbug.com/76460. |
- EXPECT_TRUE(YesInterstitial()); |
+IN_PROC_BROWSER_TEST_F(SafeBrowsingInterstitialTestV3, |
+ MAYBE_MalwareRedirectInIFrameCanceled) { |
+ MalwareRedirectInIFrameCanceledTest(); |
} |
-IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageTest, MalwareDontProceed) { |
-#if defined(OS_WIN) && defined(USE_ASH) |
- // Disable this test in Metro+Ash for now (http://crbug.com/262796). |
- if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) |
- return; |
-#endif |
- SetupWarningAndNavigate(SB_THREAT_TYPE_URL_MALWARE); |
- |
- EXPECT_EQ(VISIBLE, GetVisibility("malware-icon")); |
- EXPECT_EQ(HIDDEN, GetVisibility("subresource-icon")); |
- EXPECT_EQ(HIDDEN, GetVisibility("phishing-icon")); |
- EXPECT_EQ(VISIBLE, GetVisibility("check-report")); |
- EXPECT_EQ(HIDDEN, GetVisibility("show-diagnostic-link")); |
- EXPECT_EQ(HIDDEN, GetVisibility("report-error-link")); |
- EXPECT_EQ(HIDDEN, GetVisibility("proceed")); |
- EXPECT_TRUE(Click("see-more-link")); |
- EXPECT_EQ(VISIBLE, GetVisibility("show-diagnostic-link")); |
- EXPECT_EQ(HIDDEN, GetVisibility("report-error-link")); |
- EXPECT_EQ(VISIBLE, GetVisibility("proceed")); |
- |
- EXPECT_TRUE(ClickAndWaitForDetach("back")); |
- AssertNoInterstitial(false); // Assert the interstitial is gone |
- EXPECT_EQ(GURL(url::kAboutBlankURL), // Back to "about:blank" |
- browser()->tab_strip_model()->GetActiveWebContents()->GetURL()); |
+IN_PROC_BROWSER_TEST_F(SafeBrowsingInterstitialTestV2, |
+ MalwareRedirectCanceled) { |
+ MalwareRedirectCanceledTest(); |
} |
- |
-IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageTest, MalwareProceed) { |
- GURL url = SetupWarningAndNavigate(SB_THREAT_TYPE_URL_MALWARE); |
- |
- EXPECT_TRUE(ClickAndWaitForDetach("proceed")); |
- AssertNoInterstitial(true); // Assert the interstitial is gone. |
- EXPECT_EQ(url, |
- browser()->tab_strip_model()->GetActiveWebContents()->GetURL()); |
+IN_PROC_BROWSER_TEST_F(SafeBrowsingInterstitialTestV3, |
+ MalwareRedirectCanceled) { |
+ MalwareRedirectCanceledTest(); |
} |
-IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageTest, |
- MalwareLearnMore) { |
- SetupWarningAndNavigate(SB_THREAT_TYPE_URL_MALWARE); |
- |
- EXPECT_TRUE(ClickAndWaitForDetach("learn-more-link")); |
- AssertNoInterstitial(false); // Assert the interstitial is gone |
- |
- // We are in the help page. |
- EXPECT_EQ( |
- "/transparencyreport/safebrowsing/", |
- browser()->tab_strip_model()->GetActiveWebContents()->GetURL().path()); |
+IN_PROC_BROWSER_TEST_F(SafeBrowsingInterstitialTestV2, MalwareDontProceed) { |
+ MalwareDontProceedTest(); |
+} |
+IN_PROC_BROWSER_TEST_F(SafeBrowsingInterstitialTestV3, MalwareDontProceed) { |
+ MalwareDontProceedTest(); |
} |
-IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageTest, |
- MalwareIframeDontProceed) { |
-#if defined(OS_WIN) && defined(USE_ASH) |
- // Disable this test in Metro+Ash for now (http://crbug.com/262796). |
- if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) |
- return; |
-#endif |
- |
- SetupMalwareIframeWarningAndNavigate(); |
- |
- EXPECT_EQ(HIDDEN, GetVisibility("malware-icon")); |
- EXPECT_EQ(VISIBLE, GetVisibility("subresource-icon")); |
- EXPECT_EQ(HIDDEN, GetVisibility("phishing-icon")); |
- EXPECT_EQ(VISIBLE, GetVisibility("check-report")); |
- EXPECT_EQ(HIDDEN, GetVisibility("show-diagnostic-link")); |
- EXPECT_EQ(HIDDEN, GetVisibility("report-error-link")); |
- EXPECT_EQ(HIDDEN, GetVisibility("proceed")); |
- EXPECT_TRUE(Click("see-more-link")); |
- EXPECT_EQ(VISIBLE, GetVisibility("show-diagnostic-link")); |
- EXPECT_EQ(HIDDEN, GetVisibility("report-error-link")); |
- EXPECT_EQ(VISIBLE, GetVisibility("proceed")); |
- |
- EXPECT_TRUE(ClickAndWaitForDetach("back")); |
- AssertNoInterstitial(false); // Assert the interstitial is gone |
- |
- EXPECT_EQ(GURL(url::kAboutBlankURL), // Back to "about:blank" |
- browser()->tab_strip_model()->GetActiveWebContents()->GetURL()); |
+IN_PROC_BROWSER_TEST_F(SafeBrowsingInterstitialTestV2, MalwareProceed) { |
+ MalwareProceedTest(); |
+} |
+IN_PROC_BROWSER_TEST_F(SafeBrowsingInterstitialTestV3, MalwareProceed) { |
+ MalwareProceedTest(); |
} |
-IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageTest, MalwareIframeProceed) { |
- GURL url = SetupMalwareIframeWarningAndNavigate(); |
+IN_PROC_BROWSER_TEST_F(SafeBrowsingInterstitialTestV2, MalwareLearnMore) { |
+ MalwareLearnMoreTest(); |
+} |
+IN_PROC_BROWSER_TEST_F(SafeBrowsingInterstitialTestV3, MalwareLearnMore) { |
+ MalwareLearnMoreTest(); |
+} |
- EXPECT_TRUE(ClickAndWaitForDetach("proceed")); |
- AssertNoInterstitial(true); // Assert the interstitial is gone |
+IN_PROC_BROWSER_TEST_F(SafeBrowsingInterstitialTestV2, |
+ MalwareIframeDontProceed) { |
+ MalwareIframeDontProceedTest(); |
+} |
+IN_PROC_BROWSER_TEST_F(SafeBrowsingInterstitialTestV3, |
+ MalwareIframeDontProceed) { |
+ MalwareIframeDontProceedTest(); |
+} |
- EXPECT_EQ(url, |
- browser()->tab_strip_model()->GetActiveWebContents()->GetURL()); |
+IN_PROC_BROWSER_TEST_F(SafeBrowsingInterstitialTestV2, MalwareIframeProceed) { |
+ MalwareIframeProceedTest(); |
+} |
+IN_PROC_BROWSER_TEST_F(SafeBrowsingInterstitialTestV3, MalwareIframeProceed) { |
+ MalwareIframeProceedTest(); |
} |
// http://crbug.com/273302 |
@@ -753,137 +1033,34 @@ IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageTest, MalwareIframeProceed) { |
#else |
#define MAYBE_MalwareIframeReportDetails MalwareIframeReportDetails |
#endif |
-IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageTest, |
- MAYBE_MalwareIframeReportDetails) { |
- scoped_refptr<content::MessageLoopRunner> malware_report_sent_runner( |
- new content::MessageLoopRunner); |
- SetReportSentCallback(malware_report_sent_runner->QuitClosure()); |
- |
- GURL url = SetupMalwareIframeWarningAndNavigate(); |
- |
- LOG(INFO) << "1"; |
- |
- // If the DOM details from renderer did not already return, wait for them. |
- details_factory_.get_details()->WaitForDOM(); |
- LOG(INFO) << "2"; |
- |
- EXPECT_TRUE(Click("check-report")); |
- LOG(INFO) << "3"; |
- |
- EXPECT_TRUE(ClickAndWaitForDetach("proceed")); |
- LOG(INFO) << "4"; |
- AssertNoInterstitial(true); // Assert the interstitial is gone |
- LOG(INFO) << "5"; |
- |
- ASSERT_TRUE(browser()->profile()->GetPrefs()->GetBoolean( |
- prefs::kSafeBrowsingReportingEnabled)); |
- LOG(INFO) << "6"; |
- |
- EXPECT_EQ(url, |
- browser()->tab_strip_model()->GetActiveWebContents()->GetURL()); |
- LOG(INFO) << "7"; |
- |
- malware_report_sent_runner->Run(); |
- std::string serialized = GetReportSent(); |
- safe_browsing::ClientMalwareReportRequest report; |
- ASSERT_TRUE(report.ParseFromString(serialized)); |
- // Verify the report is complete. |
- EXPECT_TRUE(report.complete()); |
- LOG(INFO) << "8"; |
+IN_PROC_BROWSER_TEST_F(SafeBrowsingInterstitialTestV2, |
+ MAYBE_MalwareIframeReportDetails) { |
+ MalwareIframeReportDetailsTest(); |
} |
- |
-// Verifies that the "proceed anyway" link isn't available when it is disabled |
-// by the corresponding policy. Also verifies that sending the "proceed" |
-// command anyway doesn't advance to the malware site. |
-IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageTest, ProceedDisabled) { |
-#if defined(OS_WIN) && defined(USE_ASH) |
- // Disable this test in Metro+Ash for now (http://crbug.com/262796). |
- if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) |
- return; |
-#endif |
- |
- // Simulate a policy disabling the "proceed anyway" link. |
- browser()->profile()->GetPrefs()->SetBoolean( |
- prefs::kSafeBrowsingProceedAnywayDisabled, true); |
- |
- SetupWarningAndNavigate(SB_THREAT_TYPE_URL_MALWARE); |
- |
- EXPECT_EQ(VISIBLE, GetVisibility("check-report")); |
- EXPECT_EQ(HIDDEN, GetVisibility("show-diagnostic-link")); |
- EXPECT_EQ(HIDDEN, GetVisibility("proceed")); |
- EXPECT_EQ(HIDDEN, GetVisibility("proceed-span")); |
- EXPECT_TRUE(Click("see-more-link")); |
- EXPECT_EQ(VISIBLE, GetVisibility("show-diagnostic-link")); |
- EXPECT_EQ(HIDDEN, GetVisibility("proceed")); |
- EXPECT_EQ(HIDDEN, GetVisibility("proceed-span")); |
- |
- // The "proceed" command should go back instead, if proceeding is disabled. |
- EXPECT_TRUE(ClickAndWaitForDetach("proceed")); |
- AssertNoInterstitial(true); |
- EXPECT_EQ(GURL(url::kAboutBlankURL), // Back to "about:blank" |
- browser()->tab_strip_model()->GetActiveWebContents()->GetURL()); |
+IN_PROC_BROWSER_TEST_F(SafeBrowsingInterstitialTestV3, |
+ MAYBE_MalwareIframeReportDetails) { |
+ MalwareIframeReportDetailsTest(); |
} |
-// Verifies that the reporting checkbox is hidden on non-HTTP pages. |
-// TODO(mattm): Should also verify that no report is sent, but there isn't a |
-// good way to do that in the current design. |
-IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageTest, ReportingDisabled) { |
-#if defined(OS_WIN) && defined(USE_ASH) |
- // Disable this test in Metro+Ash for now (http://crbug.com/262796). |
- if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) |
- return; |
-#endif |
- |
- browser()->profile()->GetPrefs()->SetBoolean( |
- prefs::kSafeBrowsingReportingEnabled, true); |
- |
- net::SpawnedTestServer https_server( |
- net::SpawnedTestServer::TYPE_HTTPS, net::SpawnedTestServer::kLocalhost, |
- base::FilePath(FILE_PATH_LITERAL("chrome/test/data"))); |
- ASSERT_TRUE(https_server.Start()); |
- GURL url = https_server.GetURL(kEmptyPage); |
- SetURLThreatType(url, SB_THREAT_TYPE_URL_MALWARE); |
- ui_test_utils::NavigateToURL(browser(), url); |
- ASSERT_TRUE(WaitForReady()); |
- |
- EXPECT_EQ(HIDDEN, GetVisibility("check-report")); |
- EXPECT_EQ(HIDDEN, GetVisibility("show-diagnostic-link")); |
- EXPECT_EQ(HIDDEN, GetVisibility("proceed")); |
- EXPECT_TRUE(Click("see-more-link")); |
- EXPECT_EQ(VISIBLE, GetVisibility("show-diagnostic-link")); |
- EXPECT_EQ(VISIBLE, GetVisibility("proceed")); |
- |
- EXPECT_TRUE(ClickAndWaitForDetach("back")); |
- AssertNoInterstitial(false); // Assert the interstitial is gone |
- EXPECT_EQ(GURL(url::kAboutBlankURL), // Back to "about:blank" |
- browser()->tab_strip_model()->GetActiveWebContents()->GetURL()); |
+IN_PROC_BROWSER_TEST_F(SafeBrowsingInterstitialTestV2, ProceedDisabled) { |
+ ProceedDisabledTest(); |
+} |
+IN_PROC_BROWSER_TEST_F(SafeBrowsingInterstitialTestV3, ProceedDisabled) { |
+ ProceedDisabledTest(); |
} |
-IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageTest, PhishingDontProceed) { |
-#if defined(OS_WIN) && defined(USE_ASH) |
- // Disable this test in Metro+Ash for now (http://crbug.com/262796). |
- if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) |
- return; |
-#endif |
+IN_PROC_BROWSER_TEST_F(SafeBrowsingInterstitialTestV2, ReportingDisabled) { |
+ ReportingDisabledTest(); |
+} |
+IN_PROC_BROWSER_TEST_F(SafeBrowsingInterstitialTestV3, ReportingDisabled) { |
+ ReportingDisabledTest(); |
+} |
- SetupWarningAndNavigate(SB_THREAT_TYPE_URL_PHISHING); |
- |
- EXPECT_EQ(HIDDEN, GetVisibility("malware-icon")); |
- EXPECT_EQ(HIDDEN, GetVisibility("subresource-icon")); |
- EXPECT_EQ(VISIBLE, GetVisibility("phishing-icon")); |
- EXPECT_EQ(HIDDEN, GetVisibility("check-report")); |
- EXPECT_EQ(HIDDEN, GetVisibility("show-diagnostic-link")); |
- EXPECT_EQ(HIDDEN, GetVisibility("report-error-link")); |
- EXPECT_EQ(HIDDEN, GetVisibility("proceed")); |
- EXPECT_TRUE(Click("see-more-link")); |
- EXPECT_EQ(HIDDEN, GetVisibility("show-diagnostic-link")); |
- EXPECT_EQ(VISIBLE, GetVisibility("report-error-link")); |
- EXPECT_EQ(VISIBLE, GetVisibility("proceed")); |
- |
- EXPECT_TRUE(ClickAndWaitForDetach("back")); |
- AssertNoInterstitial(false); // Assert the interstitial is gone |
- EXPECT_EQ(GURL(url::kAboutBlankURL), // We are back to "about:blank". |
- browser()->tab_strip_model()->GetActiveWebContents()->GetURL()); |
+IN_PROC_BROWSER_TEST_F(SafeBrowsingInterstitialTestV2, PhishingDontProceed) { |
+ PhishingDontProceedTest(); |
+} |
+IN_PROC_BROWSER_TEST_F(SafeBrowsingInterstitialTestV3, PhishingDontProceed) { |
+ PhishingDontProceedTest(); |
} |
// http://crbug.com/247763 |
@@ -893,30 +1070,18 @@ IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageTest, PhishingDontProceed) { |
#else |
#define MAYBE_PhishingProceed PhishingProceed |
#endif |
- |
-IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageTest, MAYBE_PhishingProceed) { |
- GURL url = SetupWarningAndNavigate(SB_THREAT_TYPE_URL_PHISHING); |
- LOG(INFO) << "1"; |
- |
- EXPECT_TRUE(ClickAndWaitForDetach("proceed")); |
- LOG(INFO) << "2"; |
- AssertNoInterstitial(true); // Assert the interstitial is gone |
- LOG(INFO) << "3"; |
- EXPECT_EQ(url, |
- browser()->tab_strip_model()->GetActiveWebContents()->GetURL()); |
- LOG(INFO) << "4"; |
+IN_PROC_BROWSER_TEST_F(SafeBrowsingInterstitialTestV2, MAYBE_PhishingProceed) { |
+ PhishingProceedTest(); |
+} |
+IN_PROC_BROWSER_TEST_F(SafeBrowsingInterstitialTestV3, MAYBE_PhishingProceed) { |
+ PhishingProceedTest(); |
} |
-IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageTest, PhishingReportError) { |
- SetupWarningAndNavigate(SB_THREAT_TYPE_URL_PHISHING); |
- |
- EXPECT_TRUE(ClickAndWaitForDetach("report-error-link")); |
- AssertNoInterstitial(false); // Assert the interstitial is gone |
- |
- // We are in the error reporting page. |
- EXPECT_EQ( |
- "/safebrowsing/report_error/", |
- browser()->tab_strip_model()->GetActiveWebContents()->GetURL().path()); |
+IN_PROC_BROWSER_TEST_F(SafeBrowsingInterstitialTestV2, PhishingReportError) { |
+ PhishingReportErrorTest(); |
+} |
+IN_PROC_BROWSER_TEST_F(SafeBrowsingInterstitialTestV3, PhishingReportError) { |
+ PhishingReportErrorTest(); |
} |
// See crbug.com/248447 |
@@ -926,19 +1091,11 @@ IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageTest, PhishingReportError) { |
#else |
#define MAYBE_PhishingLearnMore PhishingLearnMore |
#endif |
- |
-IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageTest, MAYBE_PhishingLearnMore) { |
- SetupWarningAndNavigate(SB_THREAT_TYPE_URL_PHISHING); |
- LOG(INFO) << "1"; |
- |
- EXPECT_TRUE(ClickAndWaitForDetach("learn-more-link")); |
- LOG(INFO) << "2"; |
- AssertNoInterstitial(false); // Assert the interstitial is gone |
- |
- LOG(INFO) << "3"; |
- // We are in the help page. |
- EXPECT_EQ( |
- "/transparencyreport/safebrowsing/", |
- browser()->tab_strip_model()->GetActiveWebContents()->GetURL().path()); |
- LOG(INFO) << "4"; |
+IN_PROC_BROWSER_TEST_F(SafeBrowsingInterstitialTestV2, |
+ MAYBE_PhishingLearnMore) { |
+ PhishingLearnMoreTest(); |
+} |
+IN_PROC_BROWSER_TEST_F(SafeBrowsingInterstitialTestV3, |
+ MAYBE_PhishingLearnMore) { |
+ PhishingLearnMoreTest(); |
} |