Chromium Code Reviews| 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 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 298 | 298 |
| 299 FakeMalwareDetails* get_details() { | 299 FakeMalwareDetails* get_details() { |
| 300 return details_; | 300 return details_; |
| 301 } | 301 } |
| 302 | 302 |
| 303 private: | 303 private: |
| 304 FakeMalwareDetails* details_; | 304 FakeMalwareDetails* details_; |
| 305 }; | 305 }; |
| 306 | 306 |
| 307 // A SafeBrowingBlockingPage class that lets us wait until it's hidden. | 307 // A SafeBrowingBlockingPage class that lets us wait until it's hidden. |
| 308 class TestSafeBrowsingBlockingPage : public SafeBrowsingBlockingPageV2 { | 308 class TestSafeBrowsingBlockingPageV2 : public SafeBrowsingBlockingPageV2 { |
| 309 public: | 309 public: |
| 310 TestSafeBrowsingBlockingPage(SafeBrowsingUIManager* manager, | 310 TestSafeBrowsingBlockingPageV2(SafeBrowsingUIManager* manager, |
| 311 WebContents* web_contents, | 311 WebContents* web_contents, |
| 312 const UnsafeResourceList& unsafe_resources) | 312 const UnsafeResourceList& unsafe_resources) |
| 313 : SafeBrowsingBlockingPageV2(manager, web_contents, unsafe_resources), | 313 : SafeBrowsingBlockingPageV2(manager, web_contents, unsafe_resources), |
| 314 wait_for_delete_(false) { | 314 wait_for_delete_(false) { |
| 315 // Don't wait the whole 3 seconds for the browser test. | 315 // Don't wait the whole 3 seconds for the browser test. |
| 316 malware_details_proceed_delay_ms_ = 100; | 316 malware_details_proceed_delay_ms_ = 100; |
| 317 } | 317 } |
| 318 | 318 |
| 319 virtual ~TestSafeBrowsingBlockingPage() { | 319 virtual ~TestSafeBrowsingBlockingPageV2() { |
| 320 LOG(INFO) << __FUNCTION__; | 320 LOG(INFO) << __FUNCTION__; |
| 321 if (!wait_for_delete_) | 321 if (!wait_for_delete_) |
| 322 return; | 322 return; |
| 323 | 323 |
| 324 // Notify that we are gone | 324 // Notify that we are gone |
| 325 base::MessageLoopForUI::current()->Quit(); | 325 base::MessageLoopForUI::current()->Quit(); |
| 326 wait_for_delete_ = false; | 326 wait_for_delete_ = false; |
| 327 } | 327 } |
| 328 | 328 |
| 329 void WaitForDelete() { | 329 void WaitForDelete() { |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 343 } | 343 } |
| 344 virtual void OnDontProceed() OVERRIDE { | 344 virtual void OnDontProceed() OVERRIDE { |
| 345 LOG(INFO) << __FUNCTION__; | 345 LOG(INFO) << __FUNCTION__; |
| 346 SafeBrowsingBlockingPageV2::OnDontProceed(); | 346 SafeBrowsingBlockingPageV2::OnDontProceed(); |
| 347 } | 347 } |
| 348 | 348 |
| 349 private: | 349 private: |
| 350 bool wait_for_delete_; | 350 bool wait_for_delete_; |
| 351 }; | 351 }; |
| 352 | 352 |
| 353 // A SafeBrowingBlockingPage class that lets us wait until it's hidden. | |
| 354 class TestSafeBrowsingBlockingPageV3 : public SafeBrowsingBlockingPageV3 { | |
| 355 public: | |
| 356 TestSafeBrowsingBlockingPageV3(SafeBrowsingUIManager* manager, | |
| 357 WebContents* web_contents, | |
| 358 const UnsafeResourceList& unsafe_resources) | |
| 359 : SafeBrowsingBlockingPageV3(manager, web_contents, unsafe_resources), | |
| 360 wait_for_delete_(false) { | |
| 361 // Don't wait the whole 3 seconds for the browser test. | |
| 362 malware_details_proceed_delay_ms_ = 100; | |
| 363 } | |
| 364 | |
| 365 virtual ~TestSafeBrowsingBlockingPageV3() { | |
| 366 LOG(INFO) << __FUNCTION__; | |
| 367 if (!wait_for_delete_) | |
| 368 return; | |
| 369 | |
| 370 // Notify that we are gone | |
| 371 base::MessageLoopForUI::current()->Quit(); | |
| 372 wait_for_delete_ = false; | |
| 373 } | |
| 374 | |
| 375 void WaitForDelete() { | |
| 376 LOG(INFO) << __FUNCTION__; | |
| 377 wait_for_delete_ = true; | |
| 378 content::RunMessageLoop(); | |
| 379 } | |
| 380 | |
| 381 // InterstitialPageDelegate methods: | |
| 382 virtual void CommandReceived(const std::string& command) OVERRIDE { | |
| 383 LOG(INFO) << __FUNCTION__ << " " << command; | |
| 384 SafeBrowsingBlockingPageV3::CommandReceived(command); | |
| 385 } | |
| 386 virtual void OnProceed() OVERRIDE { | |
| 387 LOG(INFO) << __FUNCTION__; | |
| 388 SafeBrowsingBlockingPageV3::OnProceed(); | |
| 389 } | |
| 390 virtual void OnDontProceed() OVERRIDE { | |
| 391 LOG(INFO) << __FUNCTION__; | |
| 392 SafeBrowsingBlockingPageV3::OnDontProceed(); | |
| 393 } | |
| 394 | |
| 395 private: | |
| 396 bool wait_for_delete_; | |
| 397 }; | |
| 398 | |
| 399 template <class TestSBInterstitialPage> | |
| 353 class TestSafeBrowsingBlockingPageFactory | 400 class TestSafeBrowsingBlockingPageFactory |
| 354 : public SafeBrowsingBlockingPageFactory { | 401 : public SafeBrowsingBlockingPageFactory { |
| 355 public: | 402 public: |
| 356 TestSafeBrowsingBlockingPageFactory() { } | 403 TestSafeBrowsingBlockingPageFactory() { } |
| 357 virtual ~TestSafeBrowsingBlockingPageFactory() { } | 404 virtual ~TestSafeBrowsingBlockingPageFactory() { } |
| 358 | 405 |
| 359 virtual SafeBrowsingBlockingPage* CreateSafeBrowsingPage( | 406 virtual SafeBrowsingBlockingPage* CreateSafeBrowsingPage( |
| 360 SafeBrowsingUIManager* delegate, | 407 SafeBrowsingUIManager* delegate, |
| 361 WebContents* web_contents, | 408 WebContents* web_contents, |
| 362 const SafeBrowsingBlockingPage::UnsafeResourceList& unsafe_resources) | 409 const SafeBrowsingBlockingPage::UnsafeResourceList& unsafe_resources) |
| 363 OVERRIDE { | 410 OVERRIDE { |
| 364 return new TestSafeBrowsingBlockingPage(delegate, web_contents, | 411 return new TestSBInterstitialPage(delegate, web_contents, unsafe_resources); |
| 365 unsafe_resources); | |
| 366 } | 412 } |
| 367 }; | 413 }; |
| 368 | 414 |
| 369 } // namespace | 415 } // namespace |
| 370 | 416 |
| 371 // Tests the safe browsing blocking page in a browser. | 417 // Tests the safe browsing blocking page in a browser. |
| 372 class SafeBrowsingBlockingPageTest : public InProcessBrowserTest { | 418 template <class TestSBInterstitialPage> |
| 419 class SafeBrowsingBlockingPageBrowserTest : public InProcessBrowserTest { | |
| 373 public: | 420 public: |
| 374 enum Visibility { | 421 enum Visibility { |
| 375 VISIBILITY_ERROR = -1, | 422 VISIBILITY_ERROR = -1, |
| 376 HIDDEN = 0, | 423 HIDDEN = 0, |
| 377 VISIBLE = 1, | 424 VISIBLE = 1, |
| 378 }; | 425 }; |
| 379 | 426 |
| 380 SafeBrowsingBlockingPageTest() { | 427 SafeBrowsingBlockingPageBrowserTest() { |
| 381 } | 428 } |
| 382 | 429 |
| 383 virtual void SetUp() OVERRIDE { | 430 virtual void SetUp() OVERRIDE { |
| 384 SafeBrowsingService::RegisterFactory(&factory_); | 431 SafeBrowsingService::RegisterFactory(&factory_); |
| 385 SafeBrowsingBlockingPage::RegisterFactory(&blocking_page_factory_); | 432 SafeBrowsingBlockingPage::RegisterFactory(&blocking_page_factory_); |
| 386 MalwareDetails::RegisterFactory(&details_factory_); | 433 MalwareDetails::RegisterFactory(&details_factory_); |
| 387 InProcessBrowserTest::SetUp(); | 434 InProcessBrowserTest::SetUp(); |
| 388 } | 435 } |
| 389 | 436 |
| 390 virtual void TearDown() OVERRIDE { | 437 virtual void TearDown() OVERRIDE { |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 465 ASSERT_TRUE(interstitial_page); | 512 ASSERT_TRUE(interstitial_page); |
| 466 interstitial_page->Proceed(); | 513 interstitial_page->Proceed(); |
| 467 } | 514 } |
| 468 | 515 |
| 469 void AssertNoInterstitial(bool wait_for_delete) { | 516 void AssertNoInterstitial(bool wait_for_delete) { |
| 470 WebContents* contents = | 517 WebContents* contents = |
| 471 browser()->tab_strip_model()->GetActiveWebContents(); | 518 browser()->tab_strip_model()->GetActiveWebContents(); |
| 472 | 519 |
| 473 if (contents->ShowingInterstitialPage() && wait_for_delete) { | 520 if (contents->ShowingInterstitialPage() && wait_for_delete) { |
| 474 // We'll get notified when the interstitial is deleted. | 521 // We'll get notified when the interstitial is deleted. |
| 475 TestSafeBrowsingBlockingPage* page = | 522 TestSafeBrowsingBlockingPageV2* page = |
| 476 static_cast<TestSafeBrowsingBlockingPage*>( | 523 static_cast<TestSafeBrowsingBlockingPageV2*>( |
| 477 contents->GetInterstitialPage()->GetDelegateForTesting()); | 524 contents->GetInterstitialPage()->GetDelegateForTesting()); |
| 478 page->WaitForDelete(); | 525 page->WaitForDelete(); |
| 479 } | 526 } |
| 480 | 527 |
| 481 // Can't use InterstitialPage::GetInterstitialPage() because that | 528 // Can't use InterstitialPage::GetInterstitialPage() because that |
| 482 // gets updated after the TestSafeBrowsingBlockingPage destructor | 529 // gets updated after the TestSafeBrowsingBlockingPage destructor |
| 483 ASSERT_FALSE(contents->ShowingInterstitialPage()); | 530 ASSERT_FALSE(contents->ShowingInterstitialPage()); |
| 484 } | 531 } |
| 485 | 532 |
| 486 bool YesInterstitial() { | 533 bool YesInterstitial() { |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 616 InterstitialObserver observer( | 663 InterstitialObserver observer( |
| 617 browser()->tab_strip_model()->GetActiveWebContents(), | 664 browser()->tab_strip_model()->GetActiveWebContents(), |
| 618 base::Closure(), | 665 base::Closure(), |
| 619 loop_runner->QuitClosure()); | 666 loop_runner->QuitClosure()); |
| 620 if (!Click(node_id)) | 667 if (!Click(node_id)) |
| 621 return false; | 668 return false; |
| 622 loop_runner->Run(); | 669 loop_runner->Run(); |
| 623 return true; | 670 return true; |
| 624 } | 671 } |
| 625 | 672 |
| 673 // 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.
| |
| 674 | |
| 675 void MalwareRedirectInIFrameCanceledTest() { | |
| 676 // 1. Test the case that redirect is a subresource. | |
| 677 MalwareRedirectCancelAndProceed("openWinIFrame"); | |
| 678 // If the redirect was from subresource but canceled, "proceed" will | |
| 679 // continue with the rest of resources. | |
| 680 AssertNoInterstitial(true); | |
| 681 } | |
| 682 | |
| 683 void MalwareRedirectCanceledTest() { | |
| 684 // 2. Test the case that redirect is the only resource. | |
| 685 MalwareRedirectCancelAndProceed("openWin"); | |
| 686 // Clicking proceed won't do anything if the main request is cancelled | |
| 687 // already. See crbug.com/76460. | |
| 688 EXPECT_TRUE(YesInterstitial()); | |
| 689 } | |
| 690 | |
| 691 void MalwareDontProceedTest() { | |
| 692 #if defined(OS_WIN) && defined(USE_ASH) | |
| 693 // Disable this test in Metro+Ash for now (http://crbug.com/262796). | |
| 694 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) | |
| 695 return; | |
| 696 #endif | |
| 697 | |
| 698 SetupWarningAndNavigate(SB_THREAT_TYPE_URL_MALWARE); | |
| 699 | |
| 700 EXPECT_EQ(VISIBLE, GetVisibility("malware-icon")); | |
| 701 EXPECT_EQ(HIDDEN, GetVisibility("subresource-icon")); | |
| 702 EXPECT_EQ(HIDDEN, GetVisibility("phishing-icon")); | |
| 703 EXPECT_EQ(VISIBLE, GetVisibility("check-report")); | |
| 704 EXPECT_EQ(HIDDEN, GetVisibility("show-diagnostic-link")); | |
| 705 EXPECT_EQ(HIDDEN, GetVisibility("report-error-link")); | |
| 706 EXPECT_EQ(HIDDEN, GetVisibility("proceed")); | |
| 707 EXPECT_TRUE(Click("see-more-link")); | |
| 708 EXPECT_EQ(VISIBLE, GetVisibility("show-diagnostic-link")); | |
| 709 EXPECT_EQ(HIDDEN, GetVisibility("report-error-link")); | |
| 710 EXPECT_EQ(VISIBLE, GetVisibility("proceed")); | |
| 711 | |
| 712 EXPECT_TRUE(ClickAndWaitForDetach("back")); | |
| 713 AssertNoInterstitial(false); // Assert the interstitial is gone | |
| 714 EXPECT_EQ(GURL(url::kAboutBlankURL), // Back to "about:blank" | |
| 715 browser()->tab_strip_model()->GetActiveWebContents()->GetURL()); | |
| 716 } | |
| 717 | |
| 718 void MalwareProceedTest() { | |
| 719 GURL url = SetupWarningAndNavigate(SB_THREAT_TYPE_URL_MALWARE); | |
| 720 | |
| 721 EXPECT_TRUE(ClickAndWaitForDetach("proceed")); | |
| 722 AssertNoInterstitial(true); // Assert the interstitial is gone. | |
| 723 EXPECT_EQ(url, | |
| 724 browser()->tab_strip_model()->GetActiveWebContents()->GetURL()); | |
| 725 } | |
| 726 | |
| 727 void MalwareLearnMoreTest() { | |
| 728 SetupWarningAndNavigate(SB_THREAT_TYPE_URL_MALWARE); | |
| 729 | |
| 730 EXPECT_TRUE(ClickAndWaitForDetach("learn-more-link")); | |
| 731 AssertNoInterstitial(false); // Assert the interstitial is gone | |
| 732 | |
| 733 // We are in the help page. | |
| 734 EXPECT_EQ( | |
| 735 "/transparencyreport/safebrowsing/", | |
| 736 browser()->tab_strip_model()->GetActiveWebContents()->GetURL().path()); | |
| 737 } | |
| 738 | |
| 739 void MalwareIframeDontProceedTest() { | |
| 740 #if defined(OS_WIN) && defined(USE_ASH) | |
| 741 // Disable this test in Metro+Ash for now (http://crbug.com/262796). | |
| 742 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) | |
| 743 return; | |
| 744 #endif | |
| 745 | |
| 746 SetupMalwareIframeWarningAndNavigate(); | |
| 747 | |
| 748 EXPECT_EQ(HIDDEN, GetVisibility("malware-icon")); | |
| 749 EXPECT_EQ(VISIBLE, GetVisibility("subresource-icon")); | |
| 750 EXPECT_EQ(HIDDEN, GetVisibility("phishing-icon")); | |
| 751 EXPECT_EQ(VISIBLE, GetVisibility("check-report")); | |
| 752 EXPECT_EQ(HIDDEN, GetVisibility("show-diagnostic-link")); | |
| 753 EXPECT_EQ(HIDDEN, GetVisibility("report-error-link")); | |
| 754 EXPECT_EQ(HIDDEN, GetVisibility("proceed")); | |
| 755 EXPECT_TRUE(Click("see-more-link")); | |
| 756 EXPECT_EQ(VISIBLE, GetVisibility("show-diagnostic-link")); | |
| 757 EXPECT_EQ(HIDDEN, GetVisibility("report-error-link")); | |
| 758 EXPECT_EQ(VISIBLE, GetVisibility("proceed")); | |
| 759 | |
| 760 EXPECT_TRUE(ClickAndWaitForDetach("back")); | |
| 761 AssertNoInterstitial(false); // Assert the interstitial is gone | |
| 762 | |
| 763 EXPECT_EQ(GURL(url::kAboutBlankURL), // Back to "about:blank" | |
| 764 browser()->tab_strip_model()->GetActiveWebContents()->GetURL()); | |
| 765 } | |
| 766 | |
| 767 void MalwareIframeProceedTest() { | |
| 768 GURL url = SetupMalwareIframeWarningAndNavigate(); | |
| 769 | |
| 770 EXPECT_TRUE(ClickAndWaitForDetach("proceed")); | |
| 771 AssertNoInterstitial(true); // Assert the interstitial is gone | |
| 772 | |
| 773 EXPECT_EQ(url, | |
| 774 browser()->tab_strip_model()->GetActiveWebContents()->GetURL()); | |
| 775 } | |
| 776 | |
| 777 void MalwareIframeReportDetailsTest() { | |
| 778 scoped_refptr<content::MessageLoopRunner> malware_report_sent_runner( | |
| 779 new content::MessageLoopRunner); | |
| 780 SetReportSentCallback(malware_report_sent_runner->QuitClosure()); | |
| 781 | |
| 782 GURL url = SetupMalwareIframeWarningAndNavigate(); | |
| 783 | |
| 784 LOG(INFO) << "1"; | |
| 785 | |
| 786 // If the DOM details from renderer did not already return, wait for them. | |
| 787 details_factory_.get_details()->WaitForDOM(); | |
| 788 LOG(INFO) << "2"; | |
| 789 | |
| 790 EXPECT_TRUE(Click("check-report")); | |
| 791 LOG(INFO) << "3"; | |
| 792 | |
| 793 EXPECT_TRUE(ClickAndWaitForDetach("proceed")); | |
| 794 LOG(INFO) << "4"; | |
| 795 AssertNoInterstitial(true); // Assert the interstitial is gone | |
| 796 LOG(INFO) << "5"; | |
| 797 | |
| 798 ASSERT_TRUE(browser()->profile()->GetPrefs()->GetBoolean( | |
| 799 prefs::kSafeBrowsingReportingEnabled)); | |
| 800 LOG(INFO) << "6"; | |
| 801 | |
| 802 EXPECT_EQ(url, | |
| 803 browser()->tab_strip_model()->GetActiveWebContents()->GetURL()); | |
| 804 LOG(INFO) << "7"; | |
| 805 | |
| 806 malware_report_sent_runner->Run(); | |
| 807 std::string serialized = GetReportSent(); | |
| 808 safe_browsing::ClientMalwareReportRequest report; | |
| 809 ASSERT_TRUE(report.ParseFromString(serialized)); | |
| 810 // Verify the report is complete. | |
| 811 EXPECT_TRUE(report.complete()); | |
| 812 LOG(INFO) << "8"; | |
| 813 } | |
| 814 | |
| 815 // Verifies that the "proceed anyway" link isn't available when it is disabled | |
| 816 // by the corresponding policy. Also verifies that sending the "proceed" | |
| 817 // command anyway doesn't advance to the malware site. | |
| 818 void ProceedDisabledTest() { | |
| 819 #if defined(OS_WIN) && defined(USE_ASH) | |
| 820 // Disable this test in Metro+Ash for now (http://crbug.com/262796). | |
| 821 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) | |
| 822 return; | |
| 823 #endif | |
| 824 | |
| 825 // Simulate a policy disabling the "proceed anyway" link. | |
| 826 browser()->profile()->GetPrefs()->SetBoolean( | |
| 827 prefs::kSafeBrowsingProceedAnywayDisabled, true); | |
| 828 | |
| 829 SetupWarningAndNavigate(SB_THREAT_TYPE_URL_MALWARE); | |
| 830 | |
| 831 EXPECT_EQ(VISIBLE, GetVisibility("check-report")); | |
| 832 EXPECT_EQ(HIDDEN, GetVisibility("show-diagnostic-link")); | |
| 833 EXPECT_EQ(HIDDEN, GetVisibility("proceed")); | |
| 834 EXPECT_EQ(HIDDEN, GetVisibility("proceed-span")); | |
| 835 EXPECT_TRUE(Click("see-more-link")); | |
| 836 EXPECT_EQ(VISIBLE, GetVisibility("show-diagnostic-link")); | |
| 837 EXPECT_EQ(HIDDEN, GetVisibility("proceed")); | |
| 838 EXPECT_EQ(HIDDEN, GetVisibility("proceed-span")); | |
| 839 | |
| 840 // The "proceed" command should go back instead, if proceeding is disabled. | |
| 841 EXPECT_TRUE(ClickAndWaitForDetach("proceed")); | |
| 842 AssertNoInterstitial(true); | |
| 843 EXPECT_EQ(GURL(url::kAboutBlankURL), // Back to "about:blank" | |
| 844 browser()->tab_strip_model()->GetActiveWebContents()->GetURL()); | |
| 845 } | |
| 846 | |
| 847 // Verifies that the reporting checkbox is hidden on non-HTTP pages. | |
| 848 // TODO(mattm): Should also verify that no report is sent, but there isn't a | |
| 849 // good way to do that in the current design. | |
| 850 void ReportingDisabledTest() { | |
| 851 #if defined(OS_WIN) && defined(USE_ASH) | |
| 852 // Disable this test in Metro+Ash for now (http://crbug.com/262796). | |
| 853 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) | |
| 854 return; | |
| 855 #endif | |
| 856 | |
| 857 browser()->profile()->GetPrefs()->SetBoolean( | |
| 858 prefs::kSafeBrowsingReportingEnabled, true); | |
| 859 | |
| 860 net::SpawnedTestServer https_server( | |
| 861 net::SpawnedTestServer::TYPE_HTTPS, net::SpawnedTestServer::kLocalhost, | |
| 862 base::FilePath(FILE_PATH_LITERAL("chrome/test/data"))); | |
| 863 ASSERT_TRUE(https_server.Start()); | |
| 864 GURL url = https_server.GetURL(kEmptyPage); | |
| 865 SetURLThreatType(url, SB_THREAT_TYPE_URL_MALWARE); | |
| 866 ui_test_utils::NavigateToURL(browser(), url); | |
| 867 ASSERT_TRUE(WaitForReady()); | |
| 868 | |
| 869 EXPECT_EQ(HIDDEN, GetVisibility("check-report")); | |
| 870 EXPECT_EQ(HIDDEN, GetVisibility("show-diagnostic-link")); | |
| 871 EXPECT_EQ(HIDDEN, GetVisibility("proceed")); | |
| 872 EXPECT_TRUE(Click("see-more-link")); | |
| 873 EXPECT_EQ(VISIBLE, GetVisibility("show-diagnostic-link")); | |
| 874 EXPECT_EQ(VISIBLE, GetVisibility("proceed")); | |
| 875 | |
| 876 EXPECT_TRUE(ClickAndWaitForDetach("back")); | |
| 877 AssertNoInterstitial(false); // Assert the interstitial is gone | |
| 878 EXPECT_EQ(GURL(url::kAboutBlankURL), // Back to "about:blank" | |
| 879 browser()->tab_strip_model()->GetActiveWebContents()->GetURL()); | |
| 880 } | |
| 881 | |
| 882 void PhishingDontProceedTest() { | |
| 883 #if defined(OS_WIN) && defined(USE_ASH) | |
| 884 // Disable this test in Metro+Ash for now (http://crbug.com/262796). | |
| 885 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) | |
| 886 return; | |
| 887 #endif | |
| 888 | |
| 889 SetupWarningAndNavigate(SB_THREAT_TYPE_URL_PHISHING); | |
| 890 | |
| 891 EXPECT_EQ(HIDDEN, GetVisibility("malware-icon")); | |
| 892 EXPECT_EQ(HIDDEN, GetVisibility("subresource-icon")); | |
| 893 EXPECT_EQ(VISIBLE, GetVisibility("phishing-icon")); | |
| 894 EXPECT_EQ(HIDDEN, GetVisibility("check-report")); | |
| 895 EXPECT_EQ(HIDDEN, GetVisibility("show-diagnostic-link")); | |
| 896 EXPECT_EQ(HIDDEN, GetVisibility("report-error-link")); | |
| 897 EXPECT_EQ(HIDDEN, GetVisibility("proceed")); | |
| 898 EXPECT_TRUE(Click("see-more-link")); | |
| 899 EXPECT_EQ(HIDDEN, GetVisibility("show-diagnostic-link")); | |
| 900 EXPECT_EQ(VISIBLE, GetVisibility("report-error-link")); | |
| 901 EXPECT_EQ(VISIBLE, GetVisibility("proceed")); | |
| 902 | |
| 903 EXPECT_TRUE(ClickAndWaitForDetach("back")); | |
| 904 AssertNoInterstitial(false); // Assert the interstitial is gone | |
| 905 EXPECT_EQ(GURL(url::kAboutBlankURL), // We are back to "about:blank". | |
| 906 browser()->tab_strip_model()->GetActiveWebContents()->GetURL()); | |
| 907 } | |
| 908 | |
| 909 void PhishingProceedTest() { | |
| 910 GURL url = SetupWarningAndNavigate(SB_THREAT_TYPE_URL_PHISHING); | |
| 911 LOG(INFO) << "1"; | |
| 912 | |
| 913 EXPECT_TRUE(ClickAndWaitForDetach("proceed")); | |
| 914 LOG(INFO) << "2"; | |
| 915 AssertNoInterstitial(true); // Assert the interstitial is gone | |
| 916 LOG(INFO) << "3"; | |
| 917 EXPECT_EQ(url, | |
| 918 browser()->tab_strip_model()->GetActiveWebContents()->GetURL()); | |
| 919 LOG(INFO) << "4"; | |
| 920 } | |
| 921 | |
| 922 void PhishingReportErrorTest() { | |
| 923 SetupWarningAndNavigate(SB_THREAT_TYPE_URL_PHISHING); | |
| 924 | |
| 925 EXPECT_TRUE(ClickAndWaitForDetach("report-error-link")); | |
| 926 AssertNoInterstitial(false); // Assert the interstitial is gone | |
| 927 | |
| 928 // We are in the error reporting page. | |
| 929 EXPECT_EQ( | |
| 930 "/safebrowsing/report_error/", | |
| 931 browser()->tab_strip_model()->GetActiveWebContents()->GetURL().path()); | |
| 932 } | |
| 933 | |
| 934 void PhishingLearnMoreTest() { | |
| 935 SetupWarningAndNavigate(SB_THREAT_TYPE_URL_PHISHING); | |
| 936 LOG(INFO) << "1"; | |
| 937 | |
| 938 EXPECT_TRUE(ClickAndWaitForDetach("learn-more-link")); | |
| 939 LOG(INFO) << "2"; | |
| 940 AssertNoInterstitial(false); // Assert the interstitial is gone | |
| 941 | |
| 942 LOG(INFO) << "3"; | |
| 943 // We are in the help page. | |
| 944 EXPECT_EQ( | |
| 945 "/transparencyreport/safebrowsing/", | |
| 946 browser()->tab_strip_model()->GetActiveWebContents()->GetURL().path()); | |
| 947 LOG(INFO) << "4"; | |
| 948 } | |
| 949 | |
| 626 protected: | 950 protected: |
| 627 TestMalwareDetailsFactory details_factory_; | 951 TestMalwareDetailsFactory details_factory_; |
| 628 | 952 |
| 629 private: | 953 private: |
| 630 TestSafeBrowsingServiceFactory factory_; | 954 TestSafeBrowsingServiceFactory factory_; |
| 631 TestSafeBrowsingBlockingPageFactory blocking_page_factory_; | 955 TestSafeBrowsingBlockingPageFactory<TestSBInterstitialPage> |
| 632 | 956 blocking_page_factory_; |
| 633 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingBlockingPageTest); | 957 |
| 958 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingBlockingPageBrowserTest); | |
| 634 }; | 959 }; |
| 635 | 960 |
| 961 typedef SafeBrowsingBlockingPageBrowserTest<TestSafeBrowsingBlockingPageV2> | |
| 962 SafeBrowsingInterstitialTestV2; | |
| 963 typedef SafeBrowsingBlockingPageBrowserTest<TestSafeBrowsingBlockingPageV3> | |
| 964 SafeBrowsingInterstitialTestV3; | |
| 965 | |
| 636 // TODO(linux_aura) http://crbug.com/163931 | 966 // TODO(linux_aura) http://crbug.com/163931 |
| 637 // TODO(win_aura) http://crbug.com/154081 | 967 // TODO(win_aura) http://crbug.com/154081 |
| 638 #if defined(USE_AURA) && !defined(OS_CHROMEOS) | 968 #if defined(USE_AURA) && !defined(OS_CHROMEOS) |
| 639 #define MAYBE_MalwareRedirectInIFrameCanceled DISABLED_MalwareRedirectInIFrameCa nceled | 969 #define MAYBE_MalwareRedirectInIFrameCanceled DISABLED_MalwareRedirectInIFrameCa nceled |
| 640 #else | 970 #else |
| 641 #define MAYBE_MalwareRedirectInIFrameCanceled MalwareRedirectInIFrameCanceled | 971 #define MAYBE_MalwareRedirectInIFrameCanceled MalwareRedirectInIFrameCanceled |
| 642 #endif | 972 #endif |
| 643 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageTest, | 973 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.
| |
| 644 MAYBE_MalwareRedirectInIFrameCanceled) { | 974 MAYBE_MalwareRedirectInIFrameCanceled) { |
| 645 // 1. Test the case that redirect is a subresource. | 975 MalwareRedirectInIFrameCanceledTest(); |
| 646 MalwareRedirectCancelAndProceed("openWinIFrame"); | 976 } |
| 647 // If the redirect was from subresource but canceled, "proceed" will continue | 977 IN_PROC_BROWSER_TEST_F(SafeBrowsingInterstitialTestV3, |
| 648 // with the rest of resources. | 978 MAYBE_MalwareRedirectInIFrameCanceled) { |
| 649 AssertNoInterstitial(true); | 979 MalwareRedirectInIFrameCanceledTest(); |
| 650 } | 980 } |
| 651 | 981 |
| 652 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageTest, | 982 |
| 653 MalwareRedirectCanceled) { | 983 IN_PROC_BROWSER_TEST_F(SafeBrowsingInterstitialTestV2, |
| 654 // 2. Test the case that redirect is the only resource. | 984 MalwareRedirectCanceled) { |
| 655 MalwareRedirectCancelAndProceed("openWin"); | 985 MalwareRedirectCanceledTest(); |
| 656 // Clicking proceed won't do anything if the main request is cancelled | 986 } |
| 657 // already. See crbug.com/76460. | 987 IN_PROC_BROWSER_TEST_F(SafeBrowsingInterstitialTestV3, |
| 658 EXPECT_TRUE(YesInterstitial()); | 988 MalwareRedirectCanceled) { |
| 989 MalwareRedirectCanceledTest(); | |
| 659 } | 990 } |
| 660 | 991 |
| 661 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageTest, MalwareDontProceed) { | 992 IN_PROC_BROWSER_TEST_F(SafeBrowsingInterstitialTestV2, MalwareDontProceed) { |
| 662 #if defined(OS_WIN) && defined(USE_ASH) | 993 MalwareDontProceedTest(); |
| 663 // Disable this test in Metro+Ash for now (http://crbug.com/262796). | 994 } |
| 664 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) | 995 IN_PROC_BROWSER_TEST_F(SafeBrowsingInterstitialTestV3, MalwareDontProceed) { |
| 665 return; | 996 MalwareDontProceedTest(); |
| 666 #endif | |
| 667 | |
| 668 SetupWarningAndNavigate(SB_THREAT_TYPE_URL_MALWARE); | |
| 669 | |
| 670 EXPECT_EQ(VISIBLE, GetVisibility("malware-icon")); | |
| 671 EXPECT_EQ(HIDDEN, GetVisibility("subresource-icon")); | |
| 672 EXPECT_EQ(HIDDEN, GetVisibility("phishing-icon")); | |
| 673 EXPECT_EQ(VISIBLE, GetVisibility("check-report")); | |
| 674 EXPECT_EQ(HIDDEN, GetVisibility("show-diagnostic-link")); | |
| 675 EXPECT_EQ(HIDDEN, GetVisibility("report-error-link")); | |
| 676 EXPECT_EQ(HIDDEN, GetVisibility("proceed")); | |
| 677 EXPECT_TRUE(Click("see-more-link")); | |
| 678 EXPECT_EQ(VISIBLE, GetVisibility("show-diagnostic-link")); | |
| 679 EXPECT_EQ(HIDDEN, GetVisibility("report-error-link")); | |
| 680 EXPECT_EQ(VISIBLE, GetVisibility("proceed")); | |
| 681 | |
| 682 EXPECT_TRUE(ClickAndWaitForDetach("back")); | |
| 683 AssertNoInterstitial(false); // Assert the interstitial is gone | |
| 684 EXPECT_EQ(GURL(url::kAboutBlankURL), // Back to "about:blank" | |
| 685 browser()->tab_strip_model()->GetActiveWebContents()->GetURL()); | |
| 686 } | 997 } |
| 687 | 998 |
| 688 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageTest, MalwareProceed) { | 999 IN_PROC_BROWSER_TEST_F(SafeBrowsingInterstitialTestV2, MalwareProceed) { |
| 689 GURL url = SetupWarningAndNavigate(SB_THREAT_TYPE_URL_MALWARE); | 1000 MalwareProceedTest(); |
| 690 | 1001 } |
| 691 EXPECT_TRUE(ClickAndWaitForDetach("proceed")); | 1002 IN_PROC_BROWSER_TEST_F(SafeBrowsingInterstitialTestV3, MalwareProceed) { |
| 692 AssertNoInterstitial(true); // Assert the interstitial is gone. | 1003 MalwareProceedTest(); |
| 693 EXPECT_EQ(url, | |
| 694 browser()->tab_strip_model()->GetActiveWebContents()->GetURL()); | |
| 695 } | 1004 } |
| 696 | 1005 |
| 697 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageTest, | 1006 IN_PROC_BROWSER_TEST_F(SafeBrowsingInterstitialTestV2, MalwareLearnMore) { |
| 698 MalwareLearnMore) { | 1007 MalwareLearnMoreTest(); |
| 699 SetupWarningAndNavigate(SB_THREAT_TYPE_URL_MALWARE); | 1008 } |
| 700 | 1009 IN_PROC_BROWSER_TEST_F(SafeBrowsingInterstitialTestV3, MalwareLearnMore) { |
| 701 EXPECT_TRUE(ClickAndWaitForDetach("learn-more-link")); | 1010 MalwareLearnMoreTest(); |
| 702 AssertNoInterstitial(false); // Assert the interstitial is gone | |
| 703 | |
| 704 // We are in the help page. | |
| 705 EXPECT_EQ( | |
| 706 "/transparencyreport/safebrowsing/", | |
| 707 browser()->tab_strip_model()->GetActiveWebContents()->GetURL().path()); | |
| 708 } | 1011 } |
| 709 | 1012 |
| 710 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageTest, | 1013 IN_PROC_BROWSER_TEST_F(SafeBrowsingInterstitialTestV2, |
| 711 MalwareIframeDontProceed) { | 1014 MalwareIframeDontProceed) { |
| 712 #if defined(OS_WIN) && defined(USE_ASH) | 1015 MalwareIframeDontProceedTest(); |
| 713 // Disable this test in Metro+Ash for now (http://crbug.com/262796). | 1016 } |
| 714 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) | 1017 IN_PROC_BROWSER_TEST_F(SafeBrowsingInterstitialTestV3, |
| 715 return; | 1018 MalwareIframeDontProceed) { |
| 716 #endif | 1019 MalwareIframeDontProceedTest(); |
| 717 | |
| 718 SetupMalwareIframeWarningAndNavigate(); | |
| 719 | |
| 720 EXPECT_EQ(HIDDEN, GetVisibility("malware-icon")); | |
| 721 EXPECT_EQ(VISIBLE, GetVisibility("subresource-icon")); | |
| 722 EXPECT_EQ(HIDDEN, GetVisibility("phishing-icon")); | |
| 723 EXPECT_EQ(VISIBLE, GetVisibility("check-report")); | |
| 724 EXPECT_EQ(HIDDEN, GetVisibility("show-diagnostic-link")); | |
| 725 EXPECT_EQ(HIDDEN, GetVisibility("report-error-link")); | |
| 726 EXPECT_EQ(HIDDEN, GetVisibility("proceed")); | |
| 727 EXPECT_TRUE(Click("see-more-link")); | |
| 728 EXPECT_EQ(VISIBLE, GetVisibility("show-diagnostic-link")); | |
| 729 EXPECT_EQ(HIDDEN, GetVisibility("report-error-link")); | |
| 730 EXPECT_EQ(VISIBLE, GetVisibility("proceed")); | |
| 731 | |
| 732 EXPECT_TRUE(ClickAndWaitForDetach("back")); | |
| 733 AssertNoInterstitial(false); // Assert the interstitial is gone | |
| 734 | |
| 735 EXPECT_EQ(GURL(url::kAboutBlankURL), // Back to "about:blank" | |
| 736 browser()->tab_strip_model()->GetActiveWebContents()->GetURL()); | |
| 737 } | 1020 } |
| 738 | 1021 |
| 739 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageTest, MalwareIframeProceed) { | 1022 IN_PROC_BROWSER_TEST_F(SafeBrowsingInterstitialTestV2, MalwareIframeProceed) { |
| 740 GURL url = SetupMalwareIframeWarningAndNavigate(); | 1023 MalwareIframeProceedTest(); |
| 741 | 1024 } |
| 742 EXPECT_TRUE(ClickAndWaitForDetach("proceed")); | 1025 IN_PROC_BROWSER_TEST_F(SafeBrowsingInterstitialTestV3, MalwareIframeProceed) { |
| 743 AssertNoInterstitial(true); // Assert the interstitial is gone | 1026 MalwareIframeProceedTest(); |
| 744 | |
| 745 EXPECT_EQ(url, | |
| 746 browser()->tab_strip_model()->GetActiveWebContents()->GetURL()); | |
| 747 } | 1027 } |
| 748 | 1028 |
| 749 // http://crbug.com/273302 | 1029 // http://crbug.com/273302 |
| 750 #if defined(OS_WIN) | 1030 #if defined(OS_WIN) |
| 751 // Temporarily re-enabled to get some logs. | 1031 // Temporarily re-enabled to get some logs. |
| 752 #define MAYBE_MalwareIframeReportDetails MalwareIframeReportDetails | 1032 #define MAYBE_MalwareIframeReportDetails MalwareIframeReportDetails |
| 753 #else | 1033 #else |
| 754 #define MAYBE_MalwareIframeReportDetails MalwareIframeReportDetails | 1034 #define MAYBE_MalwareIframeReportDetails MalwareIframeReportDetails |
| 755 #endif | 1035 #endif |
| 756 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageTest, | 1036 IN_PROC_BROWSER_TEST_F(SafeBrowsingInterstitialTestV2, |
| 757 MAYBE_MalwareIframeReportDetails) { | 1037 MAYBE_MalwareIframeReportDetails) { |
| 758 scoped_refptr<content::MessageLoopRunner> malware_report_sent_runner( | 1038 MalwareIframeReportDetailsTest(); |
| 759 new content::MessageLoopRunner); | 1039 } |
| 760 SetReportSentCallback(malware_report_sent_runner->QuitClosure()); | 1040 IN_PROC_BROWSER_TEST_F(SafeBrowsingInterstitialTestV3, |
| 761 | 1041 MAYBE_MalwareIframeReportDetails) { |
| 762 GURL url = SetupMalwareIframeWarningAndNavigate(); | 1042 MalwareIframeReportDetailsTest(); |
| 763 | |
| 764 LOG(INFO) << "1"; | |
| 765 | |
| 766 // If the DOM details from renderer did not already return, wait for them. | |
| 767 details_factory_.get_details()->WaitForDOM(); | |
| 768 LOG(INFO) << "2"; | |
| 769 | |
| 770 EXPECT_TRUE(Click("check-report")); | |
| 771 LOG(INFO) << "3"; | |
| 772 | |
| 773 EXPECT_TRUE(ClickAndWaitForDetach("proceed")); | |
| 774 LOG(INFO) << "4"; | |
| 775 AssertNoInterstitial(true); // Assert the interstitial is gone | |
| 776 LOG(INFO) << "5"; | |
| 777 | |
| 778 ASSERT_TRUE(browser()->profile()->GetPrefs()->GetBoolean( | |
| 779 prefs::kSafeBrowsingReportingEnabled)); | |
| 780 LOG(INFO) << "6"; | |
| 781 | |
| 782 EXPECT_EQ(url, | |
| 783 browser()->tab_strip_model()->GetActiveWebContents()->GetURL()); | |
| 784 LOG(INFO) << "7"; | |
| 785 | |
| 786 malware_report_sent_runner->Run(); | |
| 787 std::string serialized = GetReportSent(); | |
| 788 safe_browsing::ClientMalwareReportRequest report; | |
| 789 ASSERT_TRUE(report.ParseFromString(serialized)); | |
| 790 // Verify the report is complete. | |
| 791 EXPECT_TRUE(report.complete()); | |
| 792 LOG(INFO) << "8"; | |
| 793 } | 1043 } |
| 794 | 1044 |
| 795 // Verifies that the "proceed anyway" link isn't available when it is disabled | 1045 IN_PROC_BROWSER_TEST_F(SafeBrowsingInterstitialTestV2, ProceedDisabled) { |
| 796 // by the corresponding policy. Also verifies that sending the "proceed" | 1046 ProceedDisabledTest(); |
| 797 // command anyway doesn't advance to the malware site. | 1047 } |
| 798 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageTest, ProceedDisabled) { | 1048 IN_PROC_BROWSER_TEST_F(SafeBrowsingInterstitialTestV3, ProceedDisabled) { |
| 799 #if defined(OS_WIN) && defined(USE_ASH) | 1049 ProceedDisabledTest(); |
| 800 // Disable this test in Metro+Ash for now (http://crbug.com/262796). | |
| 801 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) | |
| 802 return; | |
| 803 #endif | |
| 804 | |
| 805 // Simulate a policy disabling the "proceed anyway" link. | |
| 806 browser()->profile()->GetPrefs()->SetBoolean( | |
| 807 prefs::kSafeBrowsingProceedAnywayDisabled, true); | |
| 808 | |
| 809 SetupWarningAndNavigate(SB_THREAT_TYPE_URL_MALWARE); | |
| 810 | |
| 811 EXPECT_EQ(VISIBLE, GetVisibility("check-report")); | |
| 812 EXPECT_EQ(HIDDEN, GetVisibility("show-diagnostic-link")); | |
| 813 EXPECT_EQ(HIDDEN, GetVisibility("proceed")); | |
| 814 EXPECT_EQ(HIDDEN, GetVisibility("proceed-span")); | |
| 815 EXPECT_TRUE(Click("see-more-link")); | |
| 816 EXPECT_EQ(VISIBLE, GetVisibility("show-diagnostic-link")); | |
| 817 EXPECT_EQ(HIDDEN, GetVisibility("proceed")); | |
| 818 EXPECT_EQ(HIDDEN, GetVisibility("proceed-span")); | |
| 819 | |
| 820 // The "proceed" command should go back instead, if proceeding is disabled. | |
| 821 EXPECT_TRUE(ClickAndWaitForDetach("proceed")); | |
| 822 AssertNoInterstitial(true); | |
| 823 EXPECT_EQ(GURL(url::kAboutBlankURL), // Back to "about:blank" | |
| 824 browser()->tab_strip_model()->GetActiveWebContents()->GetURL()); | |
| 825 } | 1050 } |
| 826 | 1051 |
| 827 // Verifies that the reporting checkbox is hidden on non-HTTP pages. | 1052 IN_PROC_BROWSER_TEST_F(SafeBrowsingInterstitialTestV2, ReportingDisabled) { |
| 828 // TODO(mattm): Should also verify that no report is sent, but there isn't a | 1053 ReportingDisabledTest(); |
| 829 // good way to do that in the current design. | 1054 } |
| 830 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageTest, ReportingDisabled) { | 1055 IN_PROC_BROWSER_TEST_F(SafeBrowsingInterstitialTestV3, ReportingDisabled) { |
| 831 #if defined(OS_WIN) && defined(USE_ASH) | 1056 ReportingDisabledTest(); |
| 832 // Disable this test in Metro+Ash for now (http://crbug.com/262796). | |
| 833 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) | |
| 834 return; | |
| 835 #endif | |
| 836 | |
| 837 browser()->profile()->GetPrefs()->SetBoolean( | |
| 838 prefs::kSafeBrowsingReportingEnabled, true); | |
| 839 | |
| 840 net::SpawnedTestServer https_server( | |
| 841 net::SpawnedTestServer::TYPE_HTTPS, net::SpawnedTestServer::kLocalhost, | |
| 842 base::FilePath(FILE_PATH_LITERAL("chrome/test/data"))); | |
| 843 ASSERT_TRUE(https_server.Start()); | |
| 844 GURL url = https_server.GetURL(kEmptyPage); | |
| 845 SetURLThreatType(url, SB_THREAT_TYPE_URL_MALWARE); | |
| 846 ui_test_utils::NavigateToURL(browser(), url); | |
| 847 ASSERT_TRUE(WaitForReady()); | |
| 848 | |
| 849 EXPECT_EQ(HIDDEN, GetVisibility("check-report")); | |
| 850 EXPECT_EQ(HIDDEN, GetVisibility("show-diagnostic-link")); | |
| 851 EXPECT_EQ(HIDDEN, GetVisibility("proceed")); | |
| 852 EXPECT_TRUE(Click("see-more-link")); | |
| 853 EXPECT_EQ(VISIBLE, GetVisibility("show-diagnostic-link")); | |
| 854 EXPECT_EQ(VISIBLE, GetVisibility("proceed")); | |
| 855 | |
| 856 EXPECT_TRUE(ClickAndWaitForDetach("back")); | |
| 857 AssertNoInterstitial(false); // Assert the interstitial is gone | |
| 858 EXPECT_EQ(GURL(url::kAboutBlankURL), // Back to "about:blank" | |
| 859 browser()->tab_strip_model()->GetActiveWebContents()->GetURL()); | |
| 860 } | 1057 } |
| 861 | 1058 |
| 862 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageTest, PhishingDontProceed) { | 1059 IN_PROC_BROWSER_TEST_F(SafeBrowsingInterstitialTestV2, PhishingDontProceed) { |
| 863 #if defined(OS_WIN) && defined(USE_ASH) | 1060 PhishingDontProceedTest(); |
| 864 // Disable this test in Metro+Ash for now (http://crbug.com/262796). | 1061 } |
| 865 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) | 1062 IN_PROC_BROWSER_TEST_F(SafeBrowsingInterstitialTestV3, PhishingDontProceed) { |
| 866 return; | 1063 PhishingDontProceedTest(); |
| 867 #endif | |
| 868 | |
| 869 SetupWarningAndNavigate(SB_THREAT_TYPE_URL_PHISHING); | |
| 870 | |
| 871 EXPECT_EQ(HIDDEN, GetVisibility("malware-icon")); | |
| 872 EXPECT_EQ(HIDDEN, GetVisibility("subresource-icon")); | |
| 873 EXPECT_EQ(VISIBLE, GetVisibility("phishing-icon")); | |
| 874 EXPECT_EQ(HIDDEN, GetVisibility("check-report")); | |
| 875 EXPECT_EQ(HIDDEN, GetVisibility("show-diagnostic-link")); | |
| 876 EXPECT_EQ(HIDDEN, GetVisibility("report-error-link")); | |
| 877 EXPECT_EQ(HIDDEN, GetVisibility("proceed")); | |
| 878 EXPECT_TRUE(Click("see-more-link")); | |
| 879 EXPECT_EQ(HIDDEN, GetVisibility("show-diagnostic-link")); | |
| 880 EXPECT_EQ(VISIBLE, GetVisibility("report-error-link")); | |
| 881 EXPECT_EQ(VISIBLE, GetVisibility("proceed")); | |
| 882 | |
| 883 EXPECT_TRUE(ClickAndWaitForDetach("back")); | |
| 884 AssertNoInterstitial(false); // Assert the interstitial is gone | |
| 885 EXPECT_EQ(GURL(url::kAboutBlankURL), // We are back to "about:blank". | |
| 886 browser()->tab_strip_model()->GetActiveWebContents()->GetURL()); | |
| 887 } | 1064 } |
| 888 | 1065 |
| 889 // http://crbug.com/247763 | 1066 // http://crbug.com/247763 |
| 890 #if defined(OS_WIN) | 1067 #if defined(OS_WIN) |
| 891 // Temporarily re-enabled to get some logs. | 1068 // Temporarily re-enabled to get some logs. |
| 892 #define MAYBE_PhishingProceed PhishingProceed | 1069 #define MAYBE_PhishingProceed PhishingProceed |
| 893 #else | 1070 #else |
| 894 #define MAYBE_PhishingProceed PhishingProceed | 1071 #define MAYBE_PhishingProceed PhishingProceed |
| 895 #endif | 1072 #endif |
| 896 | 1073 IN_PROC_BROWSER_TEST_F(SafeBrowsingInterstitialTestV2, MAYBE_PhishingProceed) { |
| 897 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageTest, MAYBE_PhishingProceed) { | 1074 PhishingProceedTest(); |
| 898 GURL url = SetupWarningAndNavigate(SB_THREAT_TYPE_URL_PHISHING); | 1075 } |
| 899 LOG(INFO) << "1"; | 1076 IN_PROC_BROWSER_TEST_F(SafeBrowsingInterstitialTestV3, MAYBE_PhishingProceed) { |
| 900 | 1077 PhishingProceedTest(); |
| 901 EXPECT_TRUE(ClickAndWaitForDetach("proceed")); | |
| 902 LOG(INFO) << "2"; | |
| 903 AssertNoInterstitial(true); // Assert the interstitial is gone | |
| 904 LOG(INFO) << "3"; | |
| 905 EXPECT_EQ(url, | |
| 906 browser()->tab_strip_model()->GetActiveWebContents()->GetURL()); | |
| 907 LOG(INFO) << "4"; | |
| 908 } | 1078 } |
| 909 | 1079 |
| 910 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageTest, PhishingReportError) { | 1080 IN_PROC_BROWSER_TEST_F(SafeBrowsingInterstitialTestV2, PhishingReportError) { |
| 911 SetupWarningAndNavigate(SB_THREAT_TYPE_URL_PHISHING); | 1081 PhishingReportErrorTest(); |
| 912 | 1082 } |
| 913 EXPECT_TRUE(ClickAndWaitForDetach("report-error-link")); | 1083 IN_PROC_BROWSER_TEST_F(SafeBrowsingInterstitialTestV3, PhishingReportError) { |
| 914 AssertNoInterstitial(false); // Assert the interstitial is gone | 1084 PhishingReportErrorTest(); |
| 915 | |
| 916 // We are in the error reporting page. | |
| 917 EXPECT_EQ( | |
| 918 "/safebrowsing/report_error/", | |
| 919 browser()->tab_strip_model()->GetActiveWebContents()->GetURL().path()); | |
| 920 } | 1085 } |
| 921 | 1086 |
| 922 // See crbug.com/248447 | 1087 // See crbug.com/248447 |
| 923 #if defined(OS_WIN) | 1088 #if defined(OS_WIN) |
| 924 // Temporarily re-enabled to get some logs. | 1089 // Temporarily re-enabled to get some logs. |
| 925 #define MAYBE_PhishingLearnMore PhishingLearnMore | 1090 #define MAYBE_PhishingLearnMore PhishingLearnMore |
| 926 #else | 1091 #else |
| 927 #define MAYBE_PhishingLearnMore PhishingLearnMore | 1092 #define MAYBE_PhishingLearnMore PhishingLearnMore |
| 928 #endif | 1093 #endif |
| 929 | 1094 IN_PROC_BROWSER_TEST_F(SafeBrowsingInterstitialTestV2, |
| 930 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageTest, MAYBE_PhishingLearnMore) { | 1095 MAYBE_PhishingLearnMore) { |
| 931 SetupWarningAndNavigate(SB_THREAT_TYPE_URL_PHISHING); | 1096 PhishingLearnMoreTest(); |
| 932 LOG(INFO) << "1"; | |
| 933 | |
| 934 EXPECT_TRUE(ClickAndWaitForDetach("learn-more-link")); | |
| 935 LOG(INFO) << "2"; | |
| 936 AssertNoInterstitial(false); // Assert the interstitial is gone | |
| 937 | |
| 938 LOG(INFO) << "3"; | |
| 939 // We are in the help page. | |
| 940 EXPECT_EQ( | |
| 941 "/transparencyreport/safebrowsing/", | |
| 942 browser()->tab_strip_model()->GetActiveWebContents()->GetURL().path()); | |
| 943 LOG(INFO) << "4"; | |
| 944 } | 1097 } |
| 1098 IN_PROC_BROWSER_TEST_F(SafeBrowsingInterstitialTestV3, | |
| 1099 MAYBE_PhishingLearnMore) { | |
| 1100 PhishingLearnMoreTest(); | |
| 1101 } | |
| OLD | NEW |