Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(461)

Side by Side Diff: chrome/browser/safe_browsing/safe_browsing_blocking_page_test.cc

Issue 445493002: Delete the Safe Browsing V2 interstitial and Finch trial (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Removing binary files Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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 TestSafeBrowsingBlockingPageV2 : public SafeBrowsingBlockingPageV2 { 308 class TestSafeBrowsingBlockingPage : public SafeBrowsingBlockingPage {
309 public: 309 public:
310 TestSafeBrowsingBlockingPageV2(SafeBrowsingUIManager* manager, 310 TestSafeBrowsingBlockingPage(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 : SafeBrowsingBlockingPage(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 ~TestSafeBrowsingBlockingPageV2() { 319 virtual ~TestSafeBrowsingBlockingPage() {
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() {
330 LOG(INFO) << __FUNCTION__; 330 LOG(INFO) << __FUNCTION__;
331 wait_for_delete_ = true; 331 wait_for_delete_ = true;
332 content::RunMessageLoop(); 332 content::RunMessageLoop();
333 } 333 }
334 334
335 // InterstitialPageDelegate methods: 335 // InterstitialPageDelegate methods:
336 virtual void CommandReceived(const std::string& command) OVERRIDE { 336 virtual void CommandReceived(const std::string& command) OVERRIDE {
337 LOG(INFO) << __FUNCTION__ << " " << command; 337 LOG(INFO) << __FUNCTION__ << " " << command;
338 SafeBrowsingBlockingPageV2::CommandReceived(command); 338 SafeBrowsingBlockingPage::CommandReceived(command);
339 } 339 }
340 virtual void OnProceed() OVERRIDE { 340 virtual void OnProceed() OVERRIDE {
341 LOG(INFO) << __FUNCTION__; 341 LOG(INFO) << __FUNCTION__;
342 SafeBrowsingBlockingPageV2::OnProceed(); 342 SafeBrowsingBlockingPage::OnProceed();
343 } 343 }
344 virtual void OnDontProceed() OVERRIDE { 344 virtual void OnDontProceed() OVERRIDE {
345 LOG(INFO) << __FUNCTION__; 345 LOG(INFO) << __FUNCTION__;
346 SafeBrowsingBlockingPageV2::OnDontProceed(); 346 SafeBrowsingBlockingPage::OnDontProceed();
347 } 347 }
348 348
349 private: 349 private:
350 bool wait_for_delete_;
351 };
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_; 350 bool wait_for_delete_;
397 }; 351 };
398 352
399 class TestSafeBrowsingBlockingPageFactory 353 class TestSafeBrowsingBlockingPageFactory
400 : public SafeBrowsingBlockingPageFactory { 354 : public SafeBrowsingBlockingPageFactory {
401 public: 355 public:
402 TestSafeBrowsingBlockingPageFactory() : version_(2) { } 356 TestSafeBrowsingBlockingPageFactory() { }
403 virtual ~TestSafeBrowsingBlockingPageFactory() { } 357 virtual ~TestSafeBrowsingBlockingPageFactory() { }
404 358
405 virtual SafeBrowsingBlockingPage* CreateSafeBrowsingPage( 359 virtual SafeBrowsingBlockingPage* CreateSafeBrowsingPage(
406 SafeBrowsingUIManager* delegate, 360 SafeBrowsingUIManager* delegate,
407 WebContents* web_contents, 361 WebContents* web_contents,
408 const SafeBrowsingBlockingPage::UnsafeResourceList& unsafe_resources) 362 const SafeBrowsingBlockingPage::UnsafeResourceList& unsafe_resources)
409 OVERRIDE { 363 OVERRIDE {
410 if (version_ == 3) { 364 return new TestSafeBrowsingBlockingPage(delegate, web_contents,
411 return new TestSafeBrowsingBlockingPageV3(delegate, web_contents,
412 unsafe_resources);
413 }
414 return new TestSafeBrowsingBlockingPageV2(delegate, web_contents,
415 unsafe_resources); 365 unsafe_resources);
416 } 366 }
417
418 void SetTestVersion(int version) {
419 version_ = version;
420 }
421
422 private:
423 int version_;
424 }; 367 };
425 368
426 } // namespace 369 } // namespace
427 370
428 // Tests the safe browsing blocking page in a browser. 371 // Tests the safe browsing blocking page in a browser.
429 class SafeBrowsingBlockingPageBrowserTest 372 class SafeBrowsingBlockingPageBrowserTest
430 : public InProcessBrowserTest, 373 : public InProcessBrowserTest,
431 public testing::WithParamInterface<int> { 374 public testing::WithParamInterface<int> {
432 public: 375 public:
433 enum Visibility { 376 enum Visibility {
434 VISIBILITY_ERROR = -1, 377 VISIBILITY_ERROR = -1,
435 HIDDEN = 0, 378 HIDDEN = 0,
436 VISIBLE = 1 379 VISIBLE = 1
437 }; 380 };
438 381
439 SafeBrowsingBlockingPageBrowserTest() { 382 SafeBrowsingBlockingPageBrowserTest() {
440 } 383 }
441 384
442 virtual void SetUp() OVERRIDE { 385 virtual void SetUp() OVERRIDE {
443 SafeBrowsingService::RegisterFactory(&factory_); 386 SafeBrowsingService::RegisterFactory(&factory_);
444 SafeBrowsingBlockingPage::RegisterFactory(&blocking_page_factory_); 387 SafeBrowsingBlockingPage::RegisterFactory(&blocking_page_factory_);
445 blocking_page_factory_.SetTestVersion(GetParam());
446 MalwareDetails::RegisterFactory(&details_factory_); 388 MalwareDetails::RegisterFactory(&details_factory_);
447 InProcessBrowserTest::SetUp(); 389 InProcessBrowserTest::SetUp();
448 } 390 }
449 391
450 virtual void TearDown() OVERRIDE { 392 virtual void TearDown() OVERRIDE {
451 InProcessBrowserTest::TearDown(); 393 InProcessBrowserTest::TearDown();
452 SafeBrowsingBlockingPage::RegisterFactory(NULL); 394 SafeBrowsingBlockingPage::RegisterFactory(NULL);
453 SafeBrowsingService::RegisterFactory(NULL); 395 SafeBrowsingService::RegisterFactory(NULL);
454 MalwareDetails::RegisterFactory(NULL); 396 MalwareDetails::RegisterFactory(NULL);
455 } 397 }
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
525 ASSERT_TRUE(interstitial_page); 467 ASSERT_TRUE(interstitial_page);
526 interstitial_page->Proceed(); 468 interstitial_page->Proceed();
527 } 469 }
528 470
529 void AssertNoInterstitial(bool wait_for_delete) { 471 void AssertNoInterstitial(bool wait_for_delete) {
530 WebContents* contents = 472 WebContents* contents =
531 browser()->tab_strip_model()->GetActiveWebContents(); 473 browser()->tab_strip_model()->GetActiveWebContents();
532 474
533 if (contents->ShowingInterstitialPage() && wait_for_delete) { 475 if (contents->ShowingInterstitialPage() && wait_for_delete) {
534 // We'll get notified when the interstitial is deleted. 476 // We'll get notified when the interstitial is deleted.
535 if (GetParam() == 3) { 477 TestSafeBrowsingBlockingPage* page =
536 TestSafeBrowsingBlockingPageV3* page = 478 static_cast<TestSafeBrowsingBlockingPage*>(
537 static_cast<TestSafeBrowsingBlockingPageV3*>( 479 contents->GetInterstitialPage()->GetDelegateForTesting());
538 contents->GetInterstitialPage()->GetDelegateForTesting()); 480 page->WaitForDelete();
539 page->WaitForDelete();
540 } else {
541 TestSafeBrowsingBlockingPageV2* page =
542 static_cast<TestSafeBrowsingBlockingPageV2*>(
543 contents->GetInterstitialPage()->GetDelegateForTesting());
544 page->WaitForDelete();
545 }
546 } 481 }
547 482
548 // Can't use InterstitialPage::GetInterstitialPage() because that 483 // Can't use InterstitialPage::GetInterstitialPage() because that
549 // gets updated after the TestSafeBrowsingBlockingPage destructor 484 // gets updated after the TestSafeBrowsingBlockingPage destructor
550 ASSERT_FALSE(contents->ShowingInterstitialPage()); 485 ASSERT_FALSE(contents->ShowingInterstitialPage());
551 } 486 }
552 487
553 bool YesInterstitial() { 488 bool YesInterstitial() {
554 WebContents* contents = 489 WebContents* contents =
555 browser()->tab_strip_model()->GetActiveWebContents(); 490 browser()->tab_strip_model()->GetActiveWebContents();
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
693 protected: 628 protected:
694 TestMalwareDetailsFactory details_factory_; 629 TestMalwareDetailsFactory details_factory_;
695 630
696 private: 631 private:
697 TestSafeBrowsingServiceFactory factory_; 632 TestSafeBrowsingServiceFactory factory_;
698 TestSafeBrowsingBlockingPageFactory blocking_page_factory_; 633 TestSafeBrowsingBlockingPageFactory blocking_page_factory_;
699 634
700 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingBlockingPageBrowserTest); 635 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingBlockingPageBrowserTest);
701 }; 636 };
702 637
703 INSTANTIATE_TEST_CASE_P(SafeBrowsingInterstitialVersions,
704 SafeBrowsingBlockingPageBrowserTest,
705 testing::Values(2, 3));
706
707 // TODO(linux_aura) http://crbug.com/163931 638 // TODO(linux_aura) http://crbug.com/163931
708 // TODO(win_aura) http://crbug.com/154081 639 // TODO(win_aura) http://crbug.com/154081
709 #if defined(USE_AURA) && !defined(OS_CHROMEOS) 640 #if defined(USE_AURA) && !defined(OS_CHROMEOS)
710 #define MAYBE_MalwareRedirectInIFrameCanceled DISABLED_MalwareRedirectInIFrameCa nceled 641 #define MAYBE_MalwareRedirectInIFrameCanceled DISABLED_MalwareRedirectInIFrameCa nceled
711 #else 642 #else
712 #define MAYBE_MalwareRedirectInIFrameCanceled MalwareRedirectInIFrameCanceled 643 #define MAYBE_MalwareRedirectInIFrameCanceled MalwareRedirectInIFrameCanceled
713 #endif 644 #endif
714 IN_PROC_BROWSER_TEST_P(SafeBrowsingBlockingPageBrowserTest, 645 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageBrowserTest,
715 MAYBE_MalwareRedirectInIFrameCanceled) { 646 MAYBE_MalwareRedirectInIFrameCanceled) {
716 // 1. Test the case that redirect is a subresource. 647 // 1. Test the case that redirect is a subresource.
717 MalwareRedirectCancelAndProceed("openWinIFrame"); 648 MalwareRedirectCancelAndProceed("openWinIFrame");
718 // If the redirect was from subresource but canceled, "proceed" will continue 649 // If the redirect was from subresource but canceled, "proceed" will continue
719 // with the rest of resources. 650 // with the rest of resources.
720 AssertNoInterstitial(true); 651 AssertNoInterstitial(true);
721 } 652 }
722 653
723 IN_PROC_BROWSER_TEST_P(SafeBrowsingBlockingPageBrowserTest, 654 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageBrowserTest,
724 MalwareRedirectCanceled) { 655 MalwareRedirectCanceled) {
725 // 2. Test the case that redirect is the only resource. 656 // 2. Test the case that redirect is the only resource.
726 MalwareRedirectCancelAndProceed("openWin"); 657 MalwareRedirectCancelAndProceed("openWin");
727 // Clicking proceed won't do anything if the main request is cancelled 658 // Clicking proceed won't do anything if the main request is cancelled
728 // already. See crbug.com/76460. 659 // already. See crbug.com/76460.
729 EXPECT_TRUE(YesInterstitial()); 660 EXPECT_TRUE(YesInterstitial());
730 } 661 }
731 662
732 IN_PROC_BROWSER_TEST_P(SafeBrowsingBlockingPageBrowserTest, 663 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageBrowserTest,
733 MalwareDontProceed) { 664 MalwareDontProceed) {
734 #if defined(OS_WIN) && defined(USE_ASH) 665 #if defined(OS_WIN) && defined(USE_ASH)
735 // Disable this test in Metro+Ash for now (http://crbug.com/262796). 666 // Disable this test in Metro+Ash for now (http://crbug.com/262796).
736 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) 667 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests))
737 return; 668 return;
738 #endif 669 #endif
739 670
740 SetupWarningAndNavigate(SB_THREAT_TYPE_URL_MALWARE); 671 SetupWarningAndNavigate(SB_THREAT_TYPE_URL_MALWARE);
741 672
742 if (GetParam() == 2) { 673 EXPECT_EQ(VISIBLE, GetVisibility("primary-button"));
743 EXPECT_EQ(VISIBLE, GetVisibility("malware-icon")); 674 EXPECT_EQ(HIDDEN, GetVisibility("details"));
744 EXPECT_EQ(HIDDEN, GetVisibility("subresource-icon")); 675 EXPECT_EQ(HIDDEN, GetVisibility("proceed-link"));
745 EXPECT_EQ(HIDDEN, GetVisibility("phishing-icon")); 676 EXPECT_EQ(HIDDEN, GetVisibility("error-code"));
746 EXPECT_EQ(VISIBLE, GetVisibility("check-report")); 677 EXPECT_TRUE(Click("details-button"));
747 EXPECT_EQ(HIDDEN, GetVisibility("show-diagnostic-link")); 678 EXPECT_EQ(VISIBLE, GetVisibility("details"));
748 EXPECT_EQ(HIDDEN, GetVisibility("report-error-link")); 679 EXPECT_EQ(VISIBLE, GetVisibility("proceed-link"));
749 EXPECT_EQ(HIDDEN, GetVisibility("proceed")); 680 EXPECT_EQ(HIDDEN, GetVisibility("error-code"));
750 EXPECT_TRUE(Click("see-more-link")); 681 EXPECT_TRUE(ClickAndWaitForDetach("primary-button"));
751 EXPECT_EQ(VISIBLE, GetVisibility("show-diagnostic-link"));
752 EXPECT_EQ(HIDDEN, GetVisibility("report-error-link"));
753 EXPECT_EQ(VISIBLE, GetVisibility("proceed"));
754 EXPECT_TRUE(ClickAndWaitForDetach("back"));
755 } else {
756 EXPECT_EQ(VISIBLE, GetVisibility("primary-button"));
757 EXPECT_EQ(HIDDEN, GetVisibility("details"));
758 EXPECT_EQ(HIDDEN, GetVisibility("proceed-link"));
759 EXPECT_EQ(HIDDEN, GetVisibility("error-code"));
760 EXPECT_TRUE(Click("details-button"));
761 EXPECT_EQ(VISIBLE, GetVisibility("details"));
762 EXPECT_EQ(VISIBLE, GetVisibility("proceed-link"));
763 EXPECT_EQ(HIDDEN, GetVisibility("error-code"));
764 EXPECT_TRUE(ClickAndWaitForDetach("primary-button"));
765 }
766 682
767 AssertNoInterstitial(false); // Assert the interstitial is gone 683 AssertNoInterstitial(false); // Assert the interstitial is gone
768 EXPECT_EQ(GURL(url::kAboutBlankURL), // Back to "about:blank" 684 EXPECT_EQ(GURL(url::kAboutBlankURL), // Back to "about:blank"
769 browser()->tab_strip_model()->GetActiveWebContents()->GetURL()); 685 browser()->tab_strip_model()->GetActiveWebContents()->GetURL());
770 } 686 }
771 687
772 IN_PROC_BROWSER_TEST_P(SafeBrowsingBlockingPageBrowserTest, MalwareProceed) { 688 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageBrowserTest, MalwareProceed) {
773 GURL url = SetupWarningAndNavigate(SB_THREAT_TYPE_URL_MALWARE); 689 GURL url = SetupWarningAndNavigate(SB_THREAT_TYPE_URL_MALWARE);
774 690
775 if (GetParam() == 2) 691 EXPECT_TRUE(ClickAndWaitForDetach("proceed-link"));
776 EXPECT_TRUE(ClickAndWaitForDetach("proceed"));
777 else
778 EXPECT_TRUE(ClickAndWaitForDetach("proceed-link"));
779 AssertNoInterstitial(true); // Assert the interstitial is gone. 692 AssertNoInterstitial(true); // Assert the interstitial is gone.
780 EXPECT_EQ(url, 693 EXPECT_EQ(url,
781 browser()->tab_strip_model()->GetActiveWebContents()->GetURL()); 694 browser()->tab_strip_model()->GetActiveWebContents()->GetURL());
782 } 695 }
783 696
784 IN_PROC_BROWSER_TEST_P(SafeBrowsingBlockingPageBrowserTest, 697 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageBrowserTest,
785 MalwareLearnMoreV2) {
786 if (GetParam() == 3) return; // Don't have this link in V3.
787 SetupWarningAndNavigate(SB_THREAT_TYPE_URL_MALWARE);
788
789 EXPECT_TRUE(ClickAndWaitForDetach("learn-more-link"));
790 AssertNoInterstitial(false); // Assert the interstitial is gone
791
792 // We are in the help page.
793 EXPECT_EQ(
794 "/transparencyreport/safebrowsing/",
795 browser()->tab_strip_model()->GetActiveWebContents()->GetURL().path());
796 }
797
798 IN_PROC_BROWSER_TEST_P(SafeBrowsingBlockingPageBrowserTest,
799 MalwareIframeDontProceed) { 698 MalwareIframeDontProceed) {
800 #if defined(OS_WIN) && defined(USE_ASH) 699 #if defined(OS_WIN) && defined(USE_ASH)
801 // Disable this test in Metro+Ash for now (http://crbug.com/262796). 700 // Disable this test in Metro+Ash for now (http://crbug.com/262796).
802 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) 701 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests))
803 return; 702 return;
804 #endif 703 #endif
805 704
806 SetupMalwareIframeWarningAndNavigate(); 705 SetupMalwareIframeWarningAndNavigate();
807 706
808 if (GetParam() == 2) { 707 EXPECT_EQ(VISIBLE, GetVisibility("primary-button"));
809 EXPECT_EQ(HIDDEN, GetVisibility("malware-icon")); 708 EXPECT_EQ(HIDDEN, GetVisibility("details"));
810 EXPECT_EQ(VISIBLE, GetVisibility("subresource-icon")); 709 EXPECT_EQ(HIDDEN, GetVisibility("proceed-link"));
811 EXPECT_EQ(HIDDEN, GetVisibility("phishing-icon")); 710 EXPECT_EQ(HIDDEN, GetVisibility("error-code"));
812 EXPECT_EQ(VISIBLE, GetVisibility("check-report")); 711 EXPECT_TRUE(Click("details-button"));
813 EXPECT_EQ(HIDDEN, GetVisibility("show-diagnostic-link")); 712 EXPECT_EQ(VISIBLE, GetVisibility("details"));
814 EXPECT_EQ(HIDDEN, GetVisibility("report-error-link")); 713 EXPECT_EQ(VISIBLE, GetVisibility("proceed-link"));
815 EXPECT_EQ(HIDDEN, GetVisibility("proceed")); 714 EXPECT_EQ(HIDDEN, GetVisibility("error-code"));
816 EXPECT_TRUE(Click("see-more-link")); 715 EXPECT_TRUE(ClickAndWaitForDetach("primary-button"));
817 EXPECT_EQ(VISIBLE, GetVisibility("show-diagnostic-link"));
818 EXPECT_EQ(HIDDEN, GetVisibility("report-error-link"));
819 EXPECT_EQ(VISIBLE, GetVisibility("proceed"));
820 EXPECT_TRUE(ClickAndWaitForDetach("back"));
821 } else {
822 EXPECT_EQ(VISIBLE, GetVisibility("primary-button"));
823 EXPECT_EQ(HIDDEN, GetVisibility("details"));
824 EXPECT_EQ(HIDDEN, GetVisibility("proceed-link"));
825 EXPECT_EQ(HIDDEN, GetVisibility("error-code"));
826 EXPECT_TRUE(Click("details-button"));
827 EXPECT_EQ(VISIBLE, GetVisibility("details"));
828 EXPECT_EQ(VISIBLE, GetVisibility("proceed-link"));
829 EXPECT_EQ(HIDDEN, GetVisibility("error-code"));
830 EXPECT_TRUE(ClickAndWaitForDetach("primary-button"));
831 }
832 716
833 AssertNoInterstitial(false); // Assert the interstitial is gone 717 AssertNoInterstitial(false); // Assert the interstitial is gone
834 718
835 EXPECT_EQ(GURL(url::kAboutBlankURL), // Back to "about:blank" 719 EXPECT_EQ(GURL(url::kAboutBlankURL), // Back to "about:blank"
836 browser()->tab_strip_model()->GetActiveWebContents()->GetURL()); 720 browser()->tab_strip_model()->GetActiveWebContents()->GetURL());
837 } 721 }
838 722
839 IN_PROC_BROWSER_TEST_P(SafeBrowsingBlockingPageBrowserTest, 723 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageBrowserTest,
840 MalwareIframeProceed) { 724 MalwareIframeProceed) {
841 GURL url = SetupMalwareIframeWarningAndNavigate(); 725 GURL url = SetupMalwareIframeWarningAndNavigate();
842 726
843 if (GetParam() == 2) 727 EXPECT_TRUE(ClickAndWaitForDetach("proceed-link"));
844 EXPECT_TRUE(ClickAndWaitForDetach("proceed"));
845 else
846 EXPECT_TRUE(ClickAndWaitForDetach("proceed-link"));
847 AssertNoInterstitial(true); // Assert the interstitial is gone 728 AssertNoInterstitial(true); // Assert the interstitial is gone
848 729
849 EXPECT_EQ(url, 730 EXPECT_EQ(url,
850 browser()->tab_strip_model()->GetActiveWebContents()->GetURL()); 731 browser()->tab_strip_model()->GetActiveWebContents()->GetURL());
851 } 732 }
852 733
853 // http://crbug.com/273302 734 // TODO(felt): Needs to be re-enabled: http://crbug.com/273302
854 #if defined(OS_WIN) 735 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageBrowserTest,
855 // Temporarily re-enabled to get some logs. 736 DISABLED_MalwareIframeReportDetails) {
856 #define MAYBE_MalwareIframeReportDetails MalwareIframeReportDetails
857 #else
858 #define MAYBE_MalwareIframeReportDetails MalwareIframeReportDetails
859 #endif
860 IN_PROC_BROWSER_TEST_P(SafeBrowsingBlockingPageBrowserTest,
861 MAYBE_MalwareIframeReportDetails) {
862 // TODO(felt): Enable for V3 when the checkbox is added.
863 if (GetParam() == 3) return;
864
865 scoped_refptr<content::MessageLoopRunner> malware_report_sent_runner( 737 scoped_refptr<content::MessageLoopRunner> malware_report_sent_runner(
866 new content::MessageLoopRunner); 738 new content::MessageLoopRunner);
867 SetReportSentCallback(malware_report_sent_runner->QuitClosure()); 739 SetReportSentCallback(malware_report_sent_runner->QuitClosure());
868 740
869 GURL url = SetupMalwareIframeWarningAndNavigate(); 741 GURL url = SetupMalwareIframeWarningAndNavigate();
870 742
871 LOG(INFO) << "1"; 743 LOG(INFO) << "1";
872 744
873 // If the DOM details from renderer did not already return, wait for them. 745 // If the DOM details from renderer did not already return, wait for them.
874 details_factory_.get_details()->WaitForDOM(); 746 details_factory_.get_details()->WaitForDOM();
(...skipping 20 matching lines...) Expand all
895 safe_browsing::ClientMalwareReportRequest report; 767 safe_browsing::ClientMalwareReportRequest report;
896 ASSERT_TRUE(report.ParseFromString(serialized)); 768 ASSERT_TRUE(report.ParseFromString(serialized));
897 // Verify the report is complete. 769 // Verify the report is complete.
898 EXPECT_TRUE(report.complete()); 770 EXPECT_TRUE(report.complete());
899 LOG(INFO) << "8"; 771 LOG(INFO) << "8";
900 } 772 }
901 773
902 // Verifies that the "proceed anyway" link isn't available when it is disabled 774 // Verifies that the "proceed anyway" link isn't available when it is disabled
903 // by the corresponding policy. Also verifies that sending the "proceed" 775 // by the corresponding policy. Also verifies that sending the "proceed"
904 // command anyway doesn't advance to the malware site. 776 // command anyway doesn't advance to the malware site.
905 IN_PROC_BROWSER_TEST_P(SafeBrowsingBlockingPageBrowserTest, ProceedDisabled) { 777 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageBrowserTest, ProceedDisabled) {
906 #if defined(OS_WIN) && defined(USE_ASH) 778 #if defined(OS_WIN) && defined(USE_ASH)
907 // Disable this test in Metro+Ash for now (http://crbug.com/262796). 779 // Disable this test in Metro+Ash for now (http://crbug.com/262796).
908 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) 780 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests))
909 return; 781 return;
910 #endif 782 #endif
911 if (GetParam() == 3) return;
912 783
913 // Simulate a policy disabling the "proceed anyway" link. 784 // Simulate a policy disabling the "proceed anyway" link.
914 browser()->profile()->GetPrefs()->SetBoolean( 785 browser()->profile()->GetPrefs()->SetBoolean(
915 prefs::kSafeBrowsingProceedAnywayDisabled, true); 786 prefs::kSafeBrowsingProceedAnywayDisabled, true);
916 787
917 SetupWarningAndNavigate(SB_THREAT_TYPE_URL_MALWARE); 788 SetupWarningAndNavigate(SB_THREAT_TYPE_URL_MALWARE);
918 789
919 if (GetParam() == 2) { 790 EXPECT_EQ(VISIBLE, GetVisibility("primary-button"));
920 EXPECT_EQ(VISIBLE, GetVisibility("check-report")); 791 EXPECT_EQ(HIDDEN, GetVisibility("details"));
921 EXPECT_EQ(HIDDEN, GetVisibility("show-diagnostic-link")); 792 EXPECT_EQ(HIDDEN, GetVisibility("proceed-link"));
922 EXPECT_EQ(HIDDEN, GetVisibility("proceed")); 793 EXPECT_EQ(HIDDEN, GetVisibility("final-paragraph"));
923 EXPECT_EQ(HIDDEN, GetVisibility("proceed-span")); 794 EXPECT_TRUE(Click("details-button"));
924 EXPECT_TRUE(Click("see-more-link")); 795 EXPECT_EQ(HIDDEN, GetVisibility("proceed-link"));
925 EXPECT_EQ(VISIBLE, GetVisibility("show-diagnostic-link")); 796 EXPECT_EQ(HIDDEN, GetVisibility("final-paragraph"));
926 EXPECT_EQ(HIDDEN, GetVisibility("proceed")); 797 SendCommand("proceed");
927 EXPECT_EQ(HIDDEN, GetVisibility("proceed-span"));
928 EXPECT_TRUE(ClickAndWaitForDetach("proceed"));
929 } else {
930 EXPECT_EQ(VISIBLE, GetVisibility("primary-button"));
931 EXPECT_EQ(HIDDEN, GetVisibility("details"));
932 EXPECT_EQ(HIDDEN, GetVisibility("proceed-link"));
933 EXPECT_EQ(HIDDEN, GetVisibility("final-paragraph"));
934 EXPECT_TRUE(Click("details-button"));
935 EXPECT_EQ(HIDDEN, GetVisibility("proceed-link"));
936 EXPECT_EQ(HIDDEN, GetVisibility("final-paragraph"));
937 SendCommand("proceed");
938 }
939 798
940 // The "proceed" command should go back instead, if proceeding is disabled. 799 // The "proceed" command should go back instead, if proceeding is disabled.
941 AssertNoInterstitial(true); 800 AssertNoInterstitial(true);
942 EXPECT_EQ(GURL(url::kAboutBlankURL), // Back to "about:blank" 801 EXPECT_EQ(GURL(url::kAboutBlankURL), // Back to "about:blank"
943 browser()->tab_strip_model()->GetActiveWebContents()->GetURL()); 802 browser()->tab_strip_model()->GetActiveWebContents()->GetURL());
944 } 803 }
945 804
805 // TODO(felt): Needs to be re-enabled: http://crbug.com/273302
946 // Verifies that the reporting checkbox is hidden on non-HTTP pages. 806 // Verifies that the reporting checkbox is hidden on non-HTTP pages.
947 // TODO(mattm): Should also verify that no report is sent, but there isn't a 807 // TODO(mattm): Should also verify that no report is sent, but there isn't a
948 // good way to do that in the current design. 808 // good way to do that in the current design.
949 IN_PROC_BROWSER_TEST_P(SafeBrowsingBlockingPageBrowserTest, ReportingDisabled) { 809 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageBrowserTest,
810 DISABLED_ReportingDisabled) {
950 #if defined(OS_WIN) && defined(USE_ASH) 811 #if defined(OS_WIN) && defined(USE_ASH)
951 // Disable this test in Metro+Ash for now (http://crbug.com/262796). 812 // Disable this test in Metro+Ash for now (http://crbug.com/262796).
952 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) 813 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests))
953 return; 814 return;
954 #endif 815 #endif
955 // TODO(felt): Enable for V3 when the checkbox is added.
956 if (GetParam() == 3) return;
957 816
958 browser()->profile()->GetPrefs()->SetBoolean( 817 browser()->profile()->GetPrefs()->SetBoolean(
959 prefs::kSafeBrowsingExtendedReportingEnabled, true); 818 prefs::kSafeBrowsingExtendedReportingEnabled, true);
960 819
961 net::SpawnedTestServer https_server( 820 net::SpawnedTestServer https_server(
962 net::SpawnedTestServer::TYPE_HTTPS, net::SpawnedTestServer::kLocalhost, 821 net::SpawnedTestServer::TYPE_HTTPS, net::SpawnedTestServer::kLocalhost,
963 base::FilePath(FILE_PATH_LITERAL("chrome/test/data"))); 822 base::FilePath(FILE_PATH_LITERAL("chrome/test/data")));
964 ASSERT_TRUE(https_server.Start()); 823 ASSERT_TRUE(https_server.Start());
965 GURL url = https_server.GetURL(kEmptyPage); 824 GURL url = https_server.GetURL(kEmptyPage);
966 SetURLThreatType(url, SB_THREAT_TYPE_URL_MALWARE); 825 SetURLThreatType(url, SB_THREAT_TYPE_URL_MALWARE);
967 ui_test_utils::NavigateToURL(browser(), url); 826 ui_test_utils::NavigateToURL(browser(), url);
968 ASSERT_TRUE(WaitForReady()); 827 ASSERT_TRUE(WaitForReady());
969 828
970 EXPECT_EQ(HIDDEN, GetVisibility("check-report")); 829 EXPECT_EQ(HIDDEN, GetVisibility("check-report"));
971 EXPECT_EQ(HIDDEN, GetVisibility("show-diagnostic-link")); 830 EXPECT_EQ(HIDDEN, GetVisibility("show-diagnostic-link"));
972 EXPECT_EQ(HIDDEN, GetVisibility("proceed")); 831 EXPECT_EQ(HIDDEN, GetVisibility("proceed"));
973 EXPECT_TRUE(Click("see-more-link")); 832 EXPECT_TRUE(Click("see-more-link"));
974 EXPECT_EQ(VISIBLE, GetVisibility("show-diagnostic-link")); 833 EXPECT_EQ(VISIBLE, GetVisibility("show-diagnostic-link"));
975 EXPECT_EQ(VISIBLE, GetVisibility("proceed")); 834 EXPECT_EQ(VISIBLE, GetVisibility("proceed"));
976 835
977 EXPECT_TRUE(ClickAndWaitForDetach("back")); 836 EXPECT_TRUE(ClickAndWaitForDetach("back"));
978 AssertNoInterstitial(false); // Assert the interstitial is gone 837 AssertNoInterstitial(false); // Assert the interstitial is gone
979 EXPECT_EQ(GURL(url::kAboutBlankURL), // Back to "about:blank" 838 EXPECT_EQ(GURL(url::kAboutBlankURL), // Back to "about:blank"
980 browser()->tab_strip_model()->GetActiveWebContents()->GetURL()); 839 browser()->tab_strip_model()->GetActiveWebContents()->GetURL());
981 } 840 }
982 841
983 IN_PROC_BROWSER_TEST_P(SafeBrowsingBlockingPageBrowserTest, 842 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageBrowserTest,
984 PhishingDontProceed) { 843 PhishingDontProceed) {
985 #if defined(OS_WIN) && defined(USE_ASH) 844 #if defined(OS_WIN) && defined(USE_ASH)
986 // Disable this test in Metro+Ash for now (http://crbug.com/262796). 845 // Disable this test in Metro+Ash for now (http://crbug.com/262796).
987 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) 846 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests))
988 return; 847 return;
989 #endif 848 #endif
990 849
991 SetupWarningAndNavigate(SB_THREAT_TYPE_URL_PHISHING); 850 SetupWarningAndNavigate(SB_THREAT_TYPE_URL_PHISHING);
992 851
993 if (GetParam() == 2) { 852 EXPECT_EQ(VISIBLE, GetVisibility("primary-button"));
994 EXPECT_EQ(HIDDEN, GetVisibility("malware-icon")); 853 EXPECT_EQ(HIDDEN, GetVisibility("details"));
995 EXPECT_EQ(HIDDEN, GetVisibility("subresource-icon")); 854 EXPECT_EQ(HIDDEN, GetVisibility("proceed-link"));
996 EXPECT_EQ(VISIBLE, GetVisibility("phishing-icon")); 855 EXPECT_EQ(HIDDEN, GetVisibility("error-code"));
997 EXPECT_EQ(HIDDEN, GetVisibility("check-report")); 856 EXPECT_TRUE(Click("details-button"));
998 EXPECT_EQ(HIDDEN, GetVisibility("show-diagnostic-link")); 857 EXPECT_EQ(VISIBLE, GetVisibility("details"));
999 EXPECT_EQ(HIDDEN, GetVisibility("report-error-link")); 858 EXPECT_EQ(VISIBLE, GetVisibility("proceed-link"));
1000 EXPECT_EQ(HIDDEN, GetVisibility("proceed")); 859 EXPECT_EQ(HIDDEN, GetVisibility("error-code"));
1001 EXPECT_TRUE(Click("see-more-link")); 860 EXPECT_TRUE(ClickAndWaitForDetach("primary-button"));
1002 EXPECT_EQ(HIDDEN, GetVisibility("show-diagnostic-link"));
1003 EXPECT_EQ(VISIBLE, GetVisibility("report-error-link"));
1004 EXPECT_EQ(VISIBLE, GetVisibility("proceed"));
1005 EXPECT_TRUE(ClickAndWaitForDetach("back"));
1006 } else {
1007 EXPECT_EQ(VISIBLE, GetVisibility("primary-button"));
1008 EXPECT_EQ(HIDDEN, GetVisibility("details"));
1009 EXPECT_EQ(HIDDEN, GetVisibility("proceed-link"));
1010 EXPECT_EQ(HIDDEN, GetVisibility("error-code"));
1011 EXPECT_TRUE(Click("details-button"));
1012 EXPECT_EQ(VISIBLE, GetVisibility("details"));
1013 EXPECT_EQ(VISIBLE, GetVisibility("proceed-link"));
1014 EXPECT_EQ(HIDDEN, GetVisibility("error-code"));
1015 EXPECT_TRUE(ClickAndWaitForDetach("primary-button"));
1016 }
1017 861
1018 AssertNoInterstitial(false); // Assert the interstitial is gone 862 AssertNoInterstitial(false); // Assert the interstitial is gone
1019 EXPECT_EQ(GURL(url::kAboutBlankURL), // We are back to "about:blank". 863 EXPECT_EQ(GURL(url::kAboutBlankURL), // We are back to "about:blank".
1020 browser()->tab_strip_model()->GetActiveWebContents()->GetURL()); 864 browser()->tab_strip_model()->GetActiveWebContents()->GetURL());
1021 } 865 }
1022 866
1023 // http://crbug.com/247763 867 // http://crbug.com/247763
1024 #if defined(OS_WIN) 868 #if defined(OS_WIN)
1025 // Temporarily re-enabled to get some logs. 869 // Temporarily re-enabled to get some logs.
1026 #define MAYBE_PhishingProceed PhishingProceed 870 #define MAYBE_PhishingProceed PhishingProceed
1027 #else 871 #else
1028 #define MAYBE_PhishingProceed PhishingProceed 872 #define MAYBE_PhishingProceed PhishingProceed
1029 #endif 873 #endif
1030 IN_PROC_BROWSER_TEST_P(SafeBrowsingBlockingPageBrowserTest, 874 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageBrowserTest,
1031 MAYBE_PhishingProceed) { 875 MAYBE_PhishingProceed) {
1032 GURL url = SetupWarningAndNavigate(SB_THREAT_TYPE_URL_PHISHING); 876 GURL url = SetupWarningAndNavigate(SB_THREAT_TYPE_URL_PHISHING);
1033 LOG(INFO) << "1"; 877 LOG(INFO) << "1";
1034 878
1035 if (GetParam() == 2) 879 EXPECT_TRUE(ClickAndWaitForDetach("proceed-link"));
1036 EXPECT_TRUE(ClickAndWaitForDetach("proceed"));
1037 else
1038 EXPECT_TRUE(ClickAndWaitForDetach("proceed-link"));
1039 LOG(INFO) << "2"; 880 LOG(INFO) << "2";
1040 AssertNoInterstitial(true); // Assert the interstitial is gone 881 AssertNoInterstitial(true); // Assert the interstitial is gone
1041 LOG(INFO) << "3"; 882 LOG(INFO) << "3";
1042 EXPECT_EQ(url, 883 EXPECT_EQ(url,
1043 browser()->tab_strip_model()->GetActiveWebContents()->GetURL()); 884 browser()->tab_strip_model()->GetActiveWebContents()->GetURL());
1044 LOG(INFO) << "4"; 885 LOG(INFO) << "4";
1045 } 886 }
1046 887
1047 IN_PROC_BROWSER_TEST_P(SafeBrowsingBlockingPageBrowserTest,
1048 PhishingReportErrorV2) {
1049 if (GetParam() == 3) return; // Not supported in V3.
1050 SetupWarningAndNavigate(SB_THREAT_TYPE_URL_PHISHING);
1051
1052 EXPECT_TRUE(ClickAndWaitForDetach("report-error-link"));
1053 AssertNoInterstitial(false); // Assert the interstitial is gone
1054
1055 // We are in the error reporting page.
1056 EXPECT_EQ(
1057 "/safebrowsing/report_error/",
1058 browser()->tab_strip_model()->GetActiveWebContents()->GetURL().path());
1059 }
1060
1061 // See crbug.com/248447 888 // See crbug.com/248447
1062 #if defined(OS_WIN) 889 #if defined(OS_WIN)
1063 // Temporarily re-enabled to get some logs. 890 // Temporarily re-enabled to get some logs.
1064 #define MAYBE_PhishingLearnMore PhishingLearnMore 891 #define MAYBE_PhishingLearnMore PhishingLearnMore
1065 #else 892 #else
1066 #define MAYBE_PhishingLearnMore PhishingLearnMore 893 #define MAYBE_PhishingLearnMore PhishingLearnMore
1067 #endif 894 #endif
1068 895
1069 IN_PROC_BROWSER_TEST_P(SafeBrowsingBlockingPageBrowserTest, 896 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageBrowserTest,
1070 MAYBE_PhishingLearnMore) { 897 MAYBE_PhishingLearnMore) {
1071 SetupWarningAndNavigate(SB_THREAT_TYPE_URL_PHISHING); 898 SetupWarningAndNavigate(SB_THREAT_TYPE_URL_PHISHING);
1072 LOG(INFO) << "1"; 899 LOG(INFO) << "1";
1073 900
1074 if (GetParam() == 2) 901 EXPECT_TRUE(ClickAndWaitForDetach("help-link"));
1075 EXPECT_TRUE(ClickAndWaitForDetach("learn-more-link"));
1076 else
1077 EXPECT_TRUE(ClickAndWaitForDetach("help-link"));
1078 LOG(INFO) << "2"; 902 LOG(INFO) << "2";
1079 AssertNoInterstitial(false); // Assert the interstitial is gone 903 AssertNoInterstitial(false); // Assert the interstitial is gone
1080 904
1081 LOG(INFO) << "3"; 905 LOG(INFO) << "3";
1082 // We are in the help page. 906 // We are in the help page.
1083 EXPECT_EQ( 907 EXPECT_EQ(
1084 "/transparencyreport/safebrowsing/", 908 "/transparencyreport/safebrowsing/",
1085 browser()->tab_strip_model()->GetActiveWebContents()->GetURL().path()); 909 browser()->tab_strip_model()->GetActiveWebContents()->GetURL().path());
1086 LOG(INFO) << "4"; 910 LOG(INFO) << "4";
1087 } 911 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698