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 // TODO(mattm): remove / merge this file with | 10 // TODO(mattm): remove / merge this file with |
| (...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 495 | 495 |
| 496 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageV2Test, MalwareDontProceed) { | 496 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageV2Test, MalwareDontProceed) { |
| 497 GURL url = test_server()->GetURL(kEmptyPage); | 497 GURL url = test_server()->GetURL(kEmptyPage); |
| 498 AddURLResult(url, SafeBrowsingService::URL_MALWARE); | 498 AddURLResult(url, SafeBrowsingService::URL_MALWARE); |
| 499 | 499 |
| 500 ui_test_utils::NavigateToURL(browser(), url); | 500 ui_test_utils::NavigateToURL(browser(), url); |
| 501 ASSERT_TRUE(WaitForReady()); | 501 ASSERT_TRUE(WaitForReady()); |
| 502 | 502 |
| 503 EXPECT_EQ(VISIBLE, GetVisibility("malware-icon")); | 503 EXPECT_EQ(VISIBLE, GetVisibility("malware-icon")); |
| 504 EXPECT_EQ(HIDDEN, GetVisibility("subresource-icon")); | 504 EXPECT_EQ(HIDDEN, GetVisibility("subresource-icon")); |
| 505 EXPECT_EQ(HIDDEN, GetVisibility("phishing-icon")); | |
| 505 EXPECT_EQ(VISIBLE, GetVisibility("check-report")); | 506 EXPECT_EQ(VISIBLE, GetVisibility("check-report")); |
| 506 EXPECT_EQ(HIDDEN, GetVisibility("show-diagnostic-link")); | 507 EXPECT_EQ(HIDDEN, GetVisibility("show-diagnostic-link")); |
| 508 EXPECT_EQ(HIDDEN, GetVisibility("report-error-link")); | |
| 507 EXPECT_EQ(HIDDEN, GetVisibility("proceed")); | 509 EXPECT_EQ(HIDDEN, GetVisibility("proceed")); |
| 508 EXPECT_TRUE(Click("see-more-link")); | 510 EXPECT_TRUE(Click("see-more-link")); |
| 509 EXPECT_EQ(VISIBLE, GetVisibility("show-diagnostic-link")); | 511 EXPECT_EQ(VISIBLE, GetVisibility("show-diagnostic-link")); |
| 512 EXPECT_EQ(HIDDEN, GetVisibility("report-error-link")); | |
| 510 EXPECT_EQ(VISIBLE, GetVisibility("proceed")); | 513 EXPECT_EQ(VISIBLE, GetVisibility("proceed")); |
| 511 | 514 |
| 512 EXPECT_TRUE(ClickAndWaitForDetach("back")); | 515 EXPECT_TRUE(ClickAndWaitForDetach("back")); |
| 513 AssertNoInterstitial(false); // Assert the interstitial is gone | 516 AssertNoInterstitial(false); // Assert the interstitial is gone |
| 514 EXPECT_EQ( | 517 EXPECT_EQ( |
| 515 GURL(chrome::kAboutBlankURL), // Back to "about:blank" | 518 GURL(chrome::kAboutBlankURL), // Back to "about:blank" |
| 516 chrome::GetActiveWebContents(browser())->GetURL()); | 519 chrome::GetActiveWebContents(browser())->GetURL()); |
| 517 } | 520 } |
| 518 | 521 |
| 519 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageV2Test, MalwareProceed) { | 522 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageV2Test, MalwareProceed) { |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 549 MalwareIframeDontProceed) { | 552 MalwareIframeDontProceed) { |
| 550 GURL url = test_server()->GetURL(kMalwarePage); | 553 GURL url = test_server()->GetURL(kMalwarePage); |
| 551 GURL iframe_url = test_server()->GetURL(kMalwareIframe); | 554 GURL iframe_url = test_server()->GetURL(kMalwareIframe); |
| 552 AddURLResult(iframe_url, SafeBrowsingService::URL_MALWARE); | 555 AddURLResult(iframe_url, SafeBrowsingService::URL_MALWARE); |
| 553 | 556 |
| 554 ui_test_utils::NavigateToURL(browser(), url); | 557 ui_test_utils::NavigateToURL(browser(), url); |
| 555 ASSERT_TRUE(WaitForReady()); | 558 ASSERT_TRUE(WaitForReady()); |
| 556 | 559 |
| 557 EXPECT_EQ(HIDDEN, GetVisibility("malware-icon")); | 560 EXPECT_EQ(HIDDEN, GetVisibility("malware-icon")); |
| 558 EXPECT_EQ(VISIBLE, GetVisibility("subresource-icon")); | 561 EXPECT_EQ(VISIBLE, GetVisibility("subresource-icon")); |
| 562 EXPECT_EQ(HIDDEN, GetVisibility("phishing-icon")); | |
| 559 EXPECT_EQ(VISIBLE, GetVisibility("check-report")); | 563 EXPECT_EQ(VISIBLE, GetVisibility("check-report")); |
| 560 EXPECT_EQ(HIDDEN, GetVisibility("show-diagnostic-link")); | 564 EXPECT_EQ(HIDDEN, GetVisibility("show-diagnostic-link")); |
| 565 EXPECT_EQ(HIDDEN, GetVisibility("report-error-link")); | |
| 561 EXPECT_EQ(HIDDEN, GetVisibility("proceed")); | 566 EXPECT_EQ(HIDDEN, GetVisibility("proceed")); |
| 562 EXPECT_TRUE(Click("see-more-link")); | 567 EXPECT_TRUE(Click("see-more-link")); |
| 563 EXPECT_EQ(VISIBLE, GetVisibility("show-diagnostic-link")); | 568 EXPECT_EQ(VISIBLE, GetVisibility("show-diagnostic-link")); |
| 569 EXPECT_EQ(HIDDEN, GetVisibility("report-error-link")); | |
| 564 EXPECT_EQ(VISIBLE, GetVisibility("proceed")); | 570 EXPECT_EQ(VISIBLE, GetVisibility("proceed")); |
| 565 | 571 |
| 566 EXPECT_TRUE(ClickAndWaitForDetach("back")); | 572 EXPECT_TRUE(ClickAndWaitForDetach("back")); |
| 567 AssertNoInterstitial(false); // Assert the interstitial is gone | 573 AssertNoInterstitial(false); // Assert the interstitial is gone |
| 568 | 574 |
| 569 EXPECT_EQ( | 575 EXPECT_EQ( |
| 570 GURL(chrome::kAboutBlankURL), // Back to "about:blank" | 576 GURL(chrome::kAboutBlankURL), // Back to "about:blank" |
| 571 chrome::GetActiveWebContents(browser())->GetURL()); | 577 chrome::GetActiveWebContents(browser())->GetURL()); |
| 572 } | 578 } |
| 573 | 579 |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 663 EXPECT_TRUE(Click("see-more-link")); | 669 EXPECT_TRUE(Click("see-more-link")); |
| 664 EXPECT_EQ(VISIBLE, GetVisibility("show-diagnostic-link")); | 670 EXPECT_EQ(VISIBLE, GetVisibility("show-diagnostic-link")); |
| 665 EXPECT_EQ(VISIBLE, GetVisibility("proceed")); | 671 EXPECT_EQ(VISIBLE, GetVisibility("proceed")); |
| 666 | 672 |
| 667 EXPECT_TRUE(ClickAndWaitForDetach("back")); | 673 EXPECT_TRUE(ClickAndWaitForDetach("back")); |
| 668 AssertNoInterstitial(false); // Assert the interstitial is gone | 674 AssertNoInterstitial(false); // Assert the interstitial is gone |
| 669 EXPECT_EQ( | 675 EXPECT_EQ( |
| 670 GURL(chrome::kAboutBlankURL), // Back to "about:blank" | 676 GURL(chrome::kAboutBlankURL), // Back to "about:blank" |
| 671 chrome::GetActiveWebContents(browser())->GetURL()); | 677 chrome::GetActiveWebContents(browser())->GetURL()); |
| 672 } | 678 } |
| 679 | |
| 680 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageV2Test, PhishingDontProceed) { | |
| 681 GURL url = test_server()->GetURL(kEmptyPage); | |
| 682 AddURLResult(url, SafeBrowsingService::URL_PHISHING); | |
| 683 | |
| 684 ui_test_utils::NavigateToURL(browser(), url); | |
| 685 ASSERT_TRUE(WaitForReady()); | |
| 686 | |
| 687 EXPECT_EQ(HIDDEN, GetVisibility("malware-icon")); | |
| 688 EXPECT_EQ(HIDDEN, GetVisibility("subresource-icon")); | |
| 689 EXPECT_EQ(VISIBLE, GetVisibility("phishing-icon")); | |
| 690 EXPECT_EQ(HIDDEN, GetVisibility("check-report")); | |
| 691 EXPECT_EQ(HIDDEN, GetVisibility("show-diagnostic-link")); | |
| 692 EXPECT_EQ(HIDDEN, GetVisibility("report-error-link")); | |
| 693 EXPECT_EQ(HIDDEN, GetVisibility("proceed")); | |
| 694 EXPECT_TRUE(Click("see-more-link")); | |
| 695 EXPECT_EQ(HIDDEN, GetVisibility("show-diagnostic-link")); | |
| 696 EXPECT_EQ(VISIBLE, GetVisibility("report-error-link")); | |
| 697 EXPECT_EQ(VISIBLE, GetVisibility("proceed")); | |
| 698 | |
| 699 EXPECT_TRUE(ClickAndWaitForDetach("back")); | |
| 700 AssertNoInterstitial(false); // Assert the interstitial is gone | |
| 701 EXPECT_EQ( | |
| 702 GURL(chrome::kAboutBlankURL), // We are back to "about:blank". | |
| 703 chrome::GetActiveWebContents(browser())->GetURL()); | |
| 704 } | |
| 705 | |
| 706 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageV2Test, PhishingProceed) { | |
| 707 GURL url = test_server()->GetURL(kEmptyPage); | |
| 708 AddURLResult(url, SafeBrowsingService::URL_PHISHING); | |
| 709 | |
| 710 ui_test_utils::NavigateToURL(browser(), url); | |
| 711 ASSERT_TRUE(WaitForReady()); | |
|
Dan Beam
2012/09/13 04:54:26
maybe make a setup method here? this is the same c
mattm
2012/09/13 20:12:07
Done.
| |
| 712 | |
| 713 EXPECT_TRUE(ClickAndWaitForDetach("proceed")); | |
| 714 AssertNoInterstitial(true); // Assert the interstitial is gone | |
|
Dan Beam
2012/09/13 04:54:26
nit: why 4 \s?
mattm
2012/09/13 20:12:07
dunno, that's what all the other tests had. :p
fi
| |
| 715 EXPECT_EQ(url, chrome::GetActiveWebContents(browser())->GetURL()); | |
| 716 } | |
| 717 | |
| 718 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageV2Test, PhishingReportError) { | |
| 719 GURL url = test_server()->GetURL(kEmptyPage); | |
| 720 AddURLResult(url, SafeBrowsingService::URL_PHISHING); | |
| 721 | |
| 722 ui_test_utils::NavigateToURL(browser(), url); | |
| 723 ASSERT_TRUE(WaitForReady()); | |
| 724 | |
| 725 EXPECT_TRUE(ClickAndWaitForDetach("report-error-link")); | |
| 726 AssertNoInterstitial(false); // Assert the interstitial is gone | |
| 727 | |
| 728 // We are in the error reporting page. | |
| 729 EXPECT_EQ( | |
| 730 "/safebrowsing/report_error/", | |
| 731 chrome::GetActiveWebContents(browser())->GetURL().path()); | |
| 732 } | |
| 733 | |
| 734 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageV2Test, PhishingLearnMore) { | |
| 735 GURL url = test_server()->GetURL(kEmptyPage); | |
| 736 AddURLResult(url, SafeBrowsingService::URL_PHISHING); | |
| 737 | |
| 738 ui_test_utils::NavigateToURL(browser(), url); | |
| 739 ASSERT_TRUE(WaitForReady()); | |
| 740 | |
| 741 EXPECT_TRUE(ClickAndWaitForDetach("learn-more-link")); | |
| 742 AssertNoInterstitial(false); // Assert the interstitial is gone | |
| 743 | |
| 744 // We are in the help page. | |
| 745 EXPECT_EQ( | |
| 746 "/goodtoknow/online-safety/phishing/", | |
| 747 chrome::GetActiveWebContents(browser())->GetURL().path()); | |
| 748 } | |
| OLD | NEW |