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

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

Issue 10928173: Safe Browsing phishing interstitial redesign. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 8 years, 3 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
« no previous file with comments | « chrome/browser/safe_browsing/safe_browsing_blocking_page.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 // TODO(mattm): remove / merge this file with 10 // TODO(mattm): remove / merge this file with
(...skipping 24 matching lines...) Expand all
35 #include "content/public/browser/web_contents_view.h" 35 #include "content/public/browser/web_contents_view.h"
36 #include "content/public/test/test_browser_thread.h" 36 #include "content/public/test/test_browser_thread.h"
37 37
38 using content::BrowserThread; 38 using content::BrowserThread;
39 using content::InterstitialPage; 39 using content::InterstitialPage;
40 using content::NavigationController; 40 using content::NavigationController;
41 using content::WebContents; 41 using content::WebContents;
42 42
43 namespace { 43 namespace {
44 44
45 const char kEmptyPage[] = "files/empty.html";
46 const char kMalwarePage[] = "files/safe_browsing/malware.html";
47 const char kMalwareIframe[] = "files/safe_browsing/malware_iframe.html";
48
45 // A SafeBrowingService class that allows us to inject the malicious URLs. 49 // A SafeBrowingService class that allows us to inject the malicious URLs.
46 class FakeSafeBrowsingService : public SafeBrowsingService { 50 class FakeSafeBrowsingService : public SafeBrowsingService {
47 public: 51 public:
48 FakeSafeBrowsingService() {} 52 FakeSafeBrowsingService() {}
49 53
50 // Called on the IO thread to check if the given url is safe or not. If we 54 // Called on the IO thread to check if the given url is safe or not. If we
51 // can synchronously determine that the url is safe, CheckUrl returns true. 55 // can synchronously determine that the url is safe, CheckUrl returns true.
52 // Otherwise it returns false, and "client" is called asynchronously with the 56 // Otherwise it returns false, and "client" is called asynchronously with the
53 // result when it is ready. 57 // result when it is ready.
54 // Overrides SafeBrowsingService::CheckBrowseUrl. 58 // Overrides SafeBrowsingService::CheckBrowseUrl.
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 void AddURLResult(const GURL& url, 271 void AddURLResult(const GURL& url,
268 SafeBrowsingService::UrlCheckResult checkresult) { 272 SafeBrowsingService::UrlCheckResult checkresult) {
269 FakeSafeBrowsingService* service = 273 FakeSafeBrowsingService* service =
270 static_cast<FakeSafeBrowsingService*>( 274 static_cast<FakeSafeBrowsingService*>(
271 g_browser_process->safe_browsing_service()); 275 g_browser_process->safe_browsing_service());
272 276
273 ASSERT_TRUE(service); 277 ASSERT_TRUE(service);
274 service->AddURLResult(url, checkresult); 278 service->AddURLResult(url, checkresult);
275 } 279 }
276 280
281 // Adds a safebrowsing result of type |check_result| to the fake safebrowsing
282 // service, navigates to that page, and returns the url.
283 GURL SetupWarningAndNavigate(
284 SafeBrowsingService::UrlCheckResult check_result) {
285 GURL url = test_server()->GetURL(kEmptyPage);
286 AddURLResult(url, check_result);
287
288 ui_test_utils::NavigateToURL(browser(), url);
289 EXPECT_TRUE(WaitForReady());
290 return url;
291 }
292
293 // Adds a safebrowsing malware result to the fake safebrowsing service,
294 // navigates to a page with an iframe containing the malware site, and
295 // returns the url of the parent page.
296 GURL SetupMalwareIframeWarningAndNavigate() {
297 GURL url = test_server()->GetURL(kMalwarePage);
298 GURL iframe_url = test_server()->GetURL(kMalwareIframe);
299 AddURLResult(iframe_url, SafeBrowsingService::URL_MALWARE);
300
301 ui_test_utils::NavigateToURL(browser(), url);
302 EXPECT_TRUE(WaitForReady());
303 return url;
304 }
305
277 void SendCommand(const std::string& command) { 306 void SendCommand(const std::string& command) {
278 WebContents* contents = chrome::GetActiveWebContents(browser()); 307 WebContents* contents = chrome::GetActiveWebContents(browser());
279 // We use InterstitialPage::GetInterstitialPage(tab) instead of 308 // We use InterstitialPage::GetInterstitialPage(tab) instead of
280 // tab->GetInterstitialPage() because the tab doesn't have a pointer 309 // tab->GetInterstitialPage() because the tab doesn't have a pointer
281 // to its interstital page until it gets a command from the renderer 310 // to its interstital page until it gets a command from the renderer
282 // that it has indeed displayed it -- and this sometimes happens after 311 // that it has indeed displayed it -- and this sometimes happens after
283 // NavigateToURL returns. 312 // NavigateToURL returns.
284 SafeBrowsingBlockingPage* interstitial_page = 313 SafeBrowsingBlockingPage* interstitial_page =
285 static_cast<SafeBrowsingBlockingPage*>( 314 static_cast<SafeBrowsingBlockingPage*>(
286 InterstitialPage::GetInterstitialPage(contents)-> 315 InterstitialPage::GetInterstitialPage(contents)->
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
461 protected: 490 protected:
462 TestMalwareDetailsFactory details_factory_; 491 TestMalwareDetailsFactory details_factory_;
463 492
464 private: 493 private:
465 TestSafeBrowsingServiceFactory factory_; 494 TestSafeBrowsingServiceFactory factory_;
466 TestSafeBrowsingBlockingPageFactory blocking_page_factory_; 495 TestSafeBrowsingBlockingPageFactory blocking_page_factory_;
467 496
468 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingBlockingPageV2Test); 497 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingBlockingPageV2Test);
469 }; 498 };
470 499
471 const char kEmptyPage[] = "files/empty.html";
472 const char kMalwarePage[] = "files/safe_browsing/malware.html";
473 const char kMalwareIframe[] = "files/safe_browsing/malware_iframe.html";
474
475 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageV2Test, 500 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageV2Test,
476 MalwareRedirectInIFrameCanceled) { 501 MalwareRedirectInIFrameCanceled) {
477 // 1. Test the case that redirect is a subresource. 502 // 1. Test the case that redirect is a subresource.
478 MalwareRedirectCancelAndProceed("openWinIFrame"); 503 MalwareRedirectCancelAndProceed("openWinIFrame");
479 // If the redirect was from subresource but canceled, "proceed" will continue 504 // If the redirect was from subresource but canceled, "proceed" will continue
480 // with the rest of resources. 505 // with the rest of resources.
481 AssertNoInterstitial(true); 506 AssertNoInterstitial(true);
482 } 507 }
483 508
484 // Observed to peridically fail on the ChromeOS tests due to a real 509 // Observed to peridically fail on the ChromeOS tests due to a real
485 // use-after-free bug reported by ASan. 510 // use-after-free bug reported by ASan.
486 // See crbug.com/145482 511 // See crbug.com/145482
487 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageV2Test, 512 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageV2Test,
488 DISABLED_MalwareRedirectCanceled) { 513 DISABLED_MalwareRedirectCanceled) {
489 // 2. Test the case that redirect is the only resource. 514 // 2. Test the case that redirect is the only resource.
490 MalwareRedirectCancelAndProceed("openWin"); 515 MalwareRedirectCancelAndProceed("openWin");
491 // Clicking proceed won't do anything if the main request is cancelled 516 // Clicking proceed won't do anything if the main request is cancelled
492 // already. See crbug.com/76460. 517 // already. See crbug.com/76460.
493 EXPECT_TRUE(YesInterstitial()); 518 EXPECT_TRUE(YesInterstitial());
494 } 519 }
495 520
496 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageV2Test, MalwareDontProceed) { 521 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageV2Test, MalwareDontProceed) {
497 GURL url = test_server()->GetURL(kEmptyPage); 522 SetupWarningAndNavigate(SafeBrowsingService::URL_MALWARE);
498 AddURLResult(url, SafeBrowsingService::URL_MALWARE);
499
500 ui_test_utils::NavigateToURL(browser(), url);
501 ASSERT_TRUE(WaitForReady());
502 523
503 EXPECT_EQ(VISIBLE, GetVisibility("malware-icon")); 524 EXPECT_EQ(VISIBLE, GetVisibility("malware-icon"));
504 EXPECT_EQ(HIDDEN, GetVisibility("subresource-icon")); 525 EXPECT_EQ(HIDDEN, GetVisibility("subresource-icon"));
526 EXPECT_EQ(HIDDEN, GetVisibility("phishing-icon"));
505 EXPECT_EQ(VISIBLE, GetVisibility("check-report")); 527 EXPECT_EQ(VISIBLE, GetVisibility("check-report"));
506 EXPECT_EQ(HIDDEN, GetVisibility("show-diagnostic-link")); 528 EXPECT_EQ(HIDDEN, GetVisibility("show-diagnostic-link"));
529 EXPECT_EQ(HIDDEN, GetVisibility("report-error-link"));
507 EXPECT_EQ(HIDDEN, GetVisibility("proceed")); 530 EXPECT_EQ(HIDDEN, GetVisibility("proceed"));
508 EXPECT_TRUE(Click("see-more-link")); 531 EXPECT_TRUE(Click("see-more-link"));
509 EXPECT_EQ(VISIBLE, GetVisibility("show-diagnostic-link")); 532 EXPECT_EQ(VISIBLE, GetVisibility("show-diagnostic-link"));
533 EXPECT_EQ(HIDDEN, GetVisibility("report-error-link"));
510 EXPECT_EQ(VISIBLE, GetVisibility("proceed")); 534 EXPECT_EQ(VISIBLE, GetVisibility("proceed"));
511 535
512 EXPECT_TRUE(ClickAndWaitForDetach("back")); 536 EXPECT_TRUE(ClickAndWaitForDetach("back"));
513 AssertNoInterstitial(false); // Assert the interstitial is gone 537 AssertNoInterstitial(false); // Assert the interstitial is gone
514 EXPECT_EQ( 538 EXPECT_EQ(
515 GURL(chrome::kAboutBlankURL), // Back to "about:blank" 539 GURL(chrome::kAboutBlankURL), // Back to "about:blank"
516 chrome::GetActiveWebContents(browser())->GetURL()); 540 chrome::GetActiveWebContents(browser())->GetURL());
517 } 541 }
518 542
519 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageV2Test, MalwareProceed) { 543 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageV2Test, MalwareProceed) {
520 GURL url = test_server()->GetURL(kEmptyPage); 544 GURL url = SetupWarningAndNavigate(SafeBrowsingService::URL_MALWARE);
521 AddURLResult(url, SafeBrowsingService::URL_MALWARE);
522
523 ui_test_utils::NavigateToURL(browser(), url);
524 ASSERT_TRUE(WaitForReady());
525 545
526 EXPECT_TRUE(ClickAndWaitForDetach("proceed")); 546 EXPECT_TRUE(ClickAndWaitForDetach("proceed"));
527 AssertNoInterstitial(true); // Assert the interstitial is gone. 547 AssertNoInterstitial(true); // Assert the interstitial is gone.
528 EXPECT_EQ(url, chrome::GetActiveWebContents(browser())->GetURL()); 548 EXPECT_EQ(url, chrome::GetActiveWebContents(browser())->GetURL());
529 } 549 }
530 550
531 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageV2Test, 551 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageV2Test,
532 MalwareLearnMore) { 552 MalwareLearnMore) {
533 GURL url = test_server()->GetURL(kEmptyPage); 553 SetupWarningAndNavigate(SafeBrowsingService::URL_MALWARE);
534 AddURLResult(url, SafeBrowsingService::URL_MALWARE);
535
536 ui_test_utils::NavigateToURL(browser(), url);
537 ASSERT_TRUE(WaitForReady());
538 554
539 EXPECT_TRUE(ClickAndWaitForDetach("learn-more-link")); 555 EXPECT_TRUE(ClickAndWaitForDetach("learn-more-link"));
540 AssertNoInterstitial(false); // Assert the interstitial is gone 556 AssertNoInterstitial(false); // Assert the interstitial is gone
541 557
542 // We are in the help page. 558 // We are in the help page.
543 EXPECT_EQ( 559 EXPECT_EQ(
544 "/goodtoknow/online-safety/malware/", 560 "/goodtoknow/online-safety/malware/",
545 chrome::GetActiveWebContents(browser())->GetURL().path()); 561 chrome::GetActiveWebContents(browser())->GetURL().path());
546 } 562 }
547 563
548 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageV2Test, 564 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageV2Test,
549 MalwareIframeDontProceed) { 565 MalwareIframeDontProceed) {
550 GURL url = test_server()->GetURL(kMalwarePage); 566 SetupMalwareIframeWarningAndNavigate();
551 GURL iframe_url = test_server()->GetURL(kMalwareIframe);
552 AddURLResult(iframe_url, SafeBrowsingService::URL_MALWARE);
553
554 ui_test_utils::NavigateToURL(browser(), url);
555 ASSERT_TRUE(WaitForReady());
556 567
557 EXPECT_EQ(HIDDEN, GetVisibility("malware-icon")); 568 EXPECT_EQ(HIDDEN, GetVisibility("malware-icon"));
558 EXPECT_EQ(VISIBLE, GetVisibility("subresource-icon")); 569 EXPECT_EQ(VISIBLE, GetVisibility("subresource-icon"));
570 EXPECT_EQ(HIDDEN, GetVisibility("phishing-icon"));
559 EXPECT_EQ(VISIBLE, GetVisibility("check-report")); 571 EXPECT_EQ(VISIBLE, GetVisibility("check-report"));
560 EXPECT_EQ(HIDDEN, GetVisibility("show-diagnostic-link")); 572 EXPECT_EQ(HIDDEN, GetVisibility("show-diagnostic-link"));
573 EXPECT_EQ(HIDDEN, GetVisibility("report-error-link"));
561 EXPECT_EQ(HIDDEN, GetVisibility("proceed")); 574 EXPECT_EQ(HIDDEN, GetVisibility("proceed"));
562 EXPECT_TRUE(Click("see-more-link")); 575 EXPECT_TRUE(Click("see-more-link"));
563 EXPECT_EQ(VISIBLE, GetVisibility("show-diagnostic-link")); 576 EXPECT_EQ(VISIBLE, GetVisibility("show-diagnostic-link"));
577 EXPECT_EQ(HIDDEN, GetVisibility("report-error-link"));
564 EXPECT_EQ(VISIBLE, GetVisibility("proceed")); 578 EXPECT_EQ(VISIBLE, GetVisibility("proceed"));
565 579
566 EXPECT_TRUE(ClickAndWaitForDetach("back")); 580 EXPECT_TRUE(ClickAndWaitForDetach("back"));
567 AssertNoInterstitial(false); // Assert the interstitial is gone 581 AssertNoInterstitial(false); // Assert the interstitial is gone
568 582
569 EXPECT_EQ( 583 EXPECT_EQ(
570 GURL(chrome::kAboutBlankURL), // Back to "about:blank" 584 GURL(chrome::kAboutBlankURL), // Back to "about:blank"
571 chrome::GetActiveWebContents(browser())->GetURL()); 585 chrome::GetActiveWebContents(browser())->GetURL());
572 } 586 }
573 587
574 // Crashy, http://crbug.com/68834. 588 // Crashy, http://crbug.com/68834.
575 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageV2Test, 589 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageV2Test,
576 DISABLED_MalwareIframeProceed) { 590 DISABLED_MalwareIframeProceed) {
577 GURL url = test_server()->GetURL(kMalwarePage); 591 GURL url = SetupMalwareIframeWarningAndNavigate();
578 GURL iframe_url = test_server()->GetURL(kMalwareIframe);
579 AddURLResult(iframe_url, SafeBrowsingService::URL_MALWARE);
580
581 ui_test_utils::NavigateToURL(browser(), url);
582 ASSERT_TRUE(WaitForReady());
583 592
584 EXPECT_TRUE(ClickAndWaitForDetach("proceed")); 593 EXPECT_TRUE(ClickAndWaitForDetach("proceed"));
585 AssertNoInterstitial(true); // Assert the interstitial is gone 594 AssertNoInterstitial(true); // Assert the interstitial is gone
586 595
587 EXPECT_EQ(url, chrome::GetActiveWebContents(browser())->GetURL()); 596 EXPECT_EQ(url, chrome::GetActiveWebContents(browser())->GetURL());
588 } 597 }
589 598
590 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageV2Test, 599 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageV2Test,
591 MalwareIframeReportDetails) { 600 MalwareIframeReportDetails) {
592 GURL url = test_server()->GetURL(kMalwarePage); 601 GURL url = SetupMalwareIframeWarningAndNavigate();
593 GURL iframe_url = test_server()->GetURL(kMalwareIframe);
594 AddURLResult(iframe_url, SafeBrowsingService::URL_MALWARE);
595
596 ui_test_utils::NavigateToURL(browser(), url);
597 ASSERT_TRUE(WaitForReady());
598 602
599 // If the DOM details from renderer did not already return, wait for them. 603 // If the DOM details from renderer did not already return, wait for them.
600 details_factory_.get_details()->WaitForDOM(); 604 details_factory_.get_details()->WaitForDOM();
601 605
602 EXPECT_TRUE(Click("check-report")); 606 EXPECT_TRUE(Click("check-report"));
603 607
604 EXPECT_TRUE(ClickAndWaitForDetach("proceed")); 608 EXPECT_TRUE(ClickAndWaitForDetach("proceed"));
605 AssertNoInterstitial(true); // Assert the interstitial is gone 609 AssertNoInterstitial(true); // Assert the interstitial is gone
606 610
607 EXPECT_TRUE(browser()->profile()->GetPrefs()->GetBoolean( 611 EXPECT_TRUE(browser()->profile()->GetPrefs()->GetBoolean(
608 prefs::kSafeBrowsingReportingEnabled)); 612 prefs::kSafeBrowsingReportingEnabled));
609 613
610 EXPECT_EQ(url, chrome::GetActiveWebContents(browser())->GetURL()); 614 EXPECT_EQ(url, chrome::GetActiveWebContents(browser())->GetURL());
611 AssertReportSent(); 615 AssertReportSent();
612 } 616 }
613 617
614 // Verifies that the "proceed anyway" link isn't available when it is disabled 618 // Verifies that the "proceed anyway" link isn't available when it is disabled
615 // by the corresponding policy. Also verifies that sending the "proceed" 619 // by the corresponding policy. Also verifies that sending the "proceed"
616 // command anyway doesn't advance to the malware site. 620 // command anyway doesn't advance to the malware site.
617 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageV2Test, ProceedDisabled) { 621 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageV2Test, ProceedDisabled) {
618 // Simulate a policy disabling the "proceed anyway" link. 622 // Simulate a policy disabling the "proceed anyway" link.
619 browser()->profile()->GetPrefs()->SetBoolean( 623 browser()->profile()->GetPrefs()->SetBoolean(
620 prefs::kSafeBrowsingProceedAnywayDisabled, true); 624 prefs::kSafeBrowsingProceedAnywayDisabled, true);
621 625
622 GURL url = test_server()->GetURL(kEmptyPage); 626 SetupWarningAndNavigate(SafeBrowsingService::URL_MALWARE);
623 AddURLResult(url, SafeBrowsingService::URL_MALWARE);
624 ui_test_utils::NavigateToURL(browser(), url);
625 ASSERT_TRUE(WaitForReady());
626 627
627 EXPECT_EQ(VISIBLE, GetVisibility("check-report")); 628 EXPECT_EQ(VISIBLE, GetVisibility("check-report"));
628 EXPECT_EQ(HIDDEN, GetVisibility("show-diagnostic-link")); 629 EXPECT_EQ(HIDDEN, GetVisibility("show-diagnostic-link"));
629 EXPECT_EQ(HIDDEN, GetVisibility("proceed")); 630 EXPECT_EQ(HIDDEN, GetVisibility("proceed"));
630 EXPECT_EQ(HIDDEN, GetVisibility("proceed-span")); 631 EXPECT_EQ(HIDDEN, GetVisibility("proceed-span"));
631 EXPECT_TRUE(Click("see-more-link")); 632 EXPECT_TRUE(Click("see-more-link"));
632 EXPECT_EQ(VISIBLE, GetVisibility("show-diagnostic-link")); 633 EXPECT_EQ(VISIBLE, GetVisibility("show-diagnostic-link"));
633 EXPECT_EQ(HIDDEN, GetVisibility("proceed")); 634 EXPECT_EQ(HIDDEN, GetVisibility("proceed"));
634 EXPECT_EQ(HIDDEN, GetVisibility("proceed-span")); 635 EXPECT_EQ(HIDDEN, GetVisibility("proceed-span"));
635 636
636 // The "proceed" command should go back instead, if proceeding is disabled. 637 // The "proceed" command should go back instead, if proceeding is disabled.
637 EXPECT_TRUE(ClickAndWaitForDetach("proceed")); 638 EXPECT_TRUE(ClickAndWaitForDetach("proceed"));
638 AssertNoInterstitial(true); 639 AssertNoInterstitial(true);
639 EXPECT_EQ( 640 EXPECT_EQ(
640 GURL(chrome::kAboutBlankURL), // Back to "about:blank" 641 GURL(chrome::kAboutBlankURL), // Back to "about:blank"
641 chrome::GetActiveWebContents(browser())->GetURL()); 642 chrome::GetActiveWebContents(browser())->GetURL());
642 } 643 }
643 644
644 // Verifies that the reporting checkbox is hidden on non-HTTP pages. 645 // Verifies that the reporting checkbox is hidden on non-HTTP pages.
645 // TODO(mattm): Should also verify that no report is sent, but there isn't a 646 // TODO(mattm): Should also verify that no report is sent, but there isn't a
646 // good way to do that in the current design. 647 // good way to do that in the current design.
647 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageV2Test, ReportingDisabled) { 648 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageV2Test, ReportingDisabled) {
648 browser()->profile()->GetPrefs()->SetBoolean( 649 browser()->profile()->GetPrefs()->SetBoolean(
649 prefs::kSafeBrowsingReportingEnabled, true); 650 prefs::kSafeBrowsingReportingEnabled, true);
650 651
651 net::TestServer https_server(net::TestServer::TYPE_HTTPS, 652 net::TestServer https_server(net::TestServer::TYPE_HTTPS,
652 net::TestServer::kLocalhost, 653 net::TestServer::kLocalhost,
653 FilePath(FILE_PATH_LITERAL("chrome/test/data"))); 654 FilePath(FILE_PATH_LITERAL("chrome/test/data")));
654 ASSERT_TRUE(https_server.Start()); 655 ASSERT_TRUE(https_server.Start());
655 GURL url = https_server.GetURL(kEmptyPage); 656 GURL url = https_server.GetURL(kEmptyPage);
656 AddURLResult(url, SafeBrowsingService::URL_MALWARE); 657 AddURLResult(url, SafeBrowsingService::URL_MALWARE);
657 ui_test_utils::NavigateToURL(browser(), url); 658 ui_test_utils::NavigateToURL(browser(), url);
658 ASSERT_TRUE(WaitForReady()); 659 ASSERT_TRUE(WaitForReady());
659 660
660 EXPECT_EQ(HIDDEN, GetVisibility("check-report")); 661 EXPECT_EQ(HIDDEN, GetVisibility("check-report"));
661 EXPECT_EQ(HIDDEN, GetVisibility("show-diagnostic-link")); 662 EXPECT_EQ(HIDDEN, GetVisibility("show-diagnostic-link"));
662 EXPECT_EQ(HIDDEN, GetVisibility("proceed")); 663 EXPECT_EQ(HIDDEN, GetVisibility("proceed"));
663 EXPECT_TRUE(Click("see-more-link")); 664 EXPECT_TRUE(Click("see-more-link"));
664 EXPECT_EQ(VISIBLE, GetVisibility("show-diagnostic-link")); 665 EXPECT_EQ(VISIBLE, GetVisibility("show-diagnostic-link"));
665 EXPECT_EQ(VISIBLE, GetVisibility("proceed")); 666 EXPECT_EQ(VISIBLE, GetVisibility("proceed"));
666 667
667 EXPECT_TRUE(ClickAndWaitForDetach("back")); 668 EXPECT_TRUE(ClickAndWaitForDetach("back"));
668 AssertNoInterstitial(false); // Assert the interstitial is gone 669 AssertNoInterstitial(false); // Assert the interstitial is gone
669 EXPECT_EQ( 670 EXPECT_EQ(
670 GURL(chrome::kAboutBlankURL), // Back to "about:blank" 671 GURL(chrome::kAboutBlankURL), // Back to "about:blank"
671 chrome::GetActiveWebContents(browser())->GetURL()); 672 chrome::GetActiveWebContents(browser())->GetURL());
672 } 673 }
674
675 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageV2Test, PhishingDontProceed) {
676 SetupWarningAndNavigate(SafeBrowsingService::URL_PHISHING);
677
678 EXPECT_EQ(HIDDEN, GetVisibility("malware-icon"));
679 EXPECT_EQ(HIDDEN, GetVisibility("subresource-icon"));
680 EXPECT_EQ(VISIBLE, GetVisibility("phishing-icon"));
681 EXPECT_EQ(HIDDEN, GetVisibility("check-report"));
682 EXPECT_EQ(HIDDEN, GetVisibility("show-diagnostic-link"));
683 EXPECT_EQ(HIDDEN, GetVisibility("report-error-link"));
684 EXPECT_EQ(HIDDEN, GetVisibility("proceed"));
685 EXPECT_TRUE(Click("see-more-link"));
686 EXPECT_EQ(HIDDEN, GetVisibility("show-diagnostic-link"));
687 EXPECT_EQ(VISIBLE, GetVisibility("report-error-link"));
688 EXPECT_EQ(VISIBLE, GetVisibility("proceed"));
689
690 EXPECT_TRUE(ClickAndWaitForDetach("back"));
691 AssertNoInterstitial(false); // Assert the interstitial is gone
692 EXPECT_EQ(
693 GURL(chrome::kAboutBlankURL), // We are back to "about:blank".
694 chrome::GetActiveWebContents(browser())->GetURL());
695 }
696
697 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageV2Test, PhishingProceed) {
698 GURL url = SetupWarningAndNavigate(SafeBrowsingService::URL_PHISHING);
699
700 EXPECT_TRUE(ClickAndWaitForDetach("proceed"));
701 AssertNoInterstitial(true); // Assert the interstitial is gone
702 EXPECT_EQ(url, chrome::GetActiveWebContents(browser())->GetURL());
703 }
704
705 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageV2Test, PhishingReportError) {
706 SetupWarningAndNavigate(SafeBrowsingService::URL_PHISHING);
707
708 EXPECT_TRUE(ClickAndWaitForDetach("report-error-link"));
709 AssertNoInterstitial(false); // Assert the interstitial is gone
710
711 // We are in the error reporting page.
712 EXPECT_EQ(
713 "/safebrowsing/report_error/",
714 chrome::GetActiveWebContents(browser())->GetURL().path());
715 }
716
717 IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageV2Test, PhishingLearnMore) {
718 SetupWarningAndNavigate(SafeBrowsingService::URL_PHISHING);
719
720 EXPECT_TRUE(ClickAndWaitForDetach("learn-more-link"));
721 AssertNoInterstitial(false); // Assert the interstitial is gone
722
723 // We are in the help page.
724 EXPECT_EQ(
725 "/goodtoknow/online-safety/phishing/",
726 chrome::GetActiveWebContents(browser())->GetURL().path());
727 }
OLDNEW
« no previous file with comments | « chrome/browser/safe_browsing/safe_browsing_blocking_page.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698