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

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

Issue 61403004: Re-enable ClientSideDetectionHostTest.* now that crbug.com/313141 is fixed. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 1 month 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 | « no previous file | 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 #include "base/files/file_path.h" 5 #include "base/files/file_path.h"
6 #include "base/memory/ref_counted.h" 6 #include "base/memory/ref_counted.h"
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "base/run_loop.h" 8 #include "base/run_loop.h"
9 #include "base/strings/stringprintf.h" 9 #include "base/strings/stringprintf.h"
10 #include "base/synchronization/waitable_event.h" 10 #include "base/synchronization/waitable_event.h"
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 } 322 }
323 323
324 protected: 324 protected:
325 scoped_ptr<ClientSideDetectionHost> csd_host_; 325 scoped_ptr<ClientSideDetectionHost> csd_host_;
326 scoped_ptr<StrictMock<MockClientSideDetectionService> > csd_service_; 326 scoped_ptr<StrictMock<MockClientSideDetectionService> > csd_service_;
327 scoped_refptr<StrictMock<MockSafeBrowsingUIManager> > ui_manager_; 327 scoped_refptr<StrictMock<MockSafeBrowsingUIManager> > ui_manager_;
328 scoped_refptr<StrictMock<MockSafeBrowsingDatabaseManager> > database_manager_; 328 scoped_refptr<StrictMock<MockSafeBrowsingDatabaseManager> > database_manager_;
329 MockTestingProfile* mock_profile_; // We don't own this object 329 MockTestingProfile* mock_profile_; // We don't own this object
330 }; 330 };
331 331
332 #if defined(OS_WIN)
333 // Crashes on Blink canary bots: http://crbug.com/299149
334 TEST_F(ClientSideDetectionHostTest,
335 DISABLED_OnPhishingDetectionDoneInvalidVerdict) {
336 #else
337 TEST_F(ClientSideDetectionHostTest, OnPhishingDetectionDoneInvalidVerdict) { 332 TEST_F(ClientSideDetectionHostTest, OnPhishingDetectionDoneInvalidVerdict) {
338 #endif
339 // Case 0: renderer sends an invalid verdict string that we're unable to 333 // Case 0: renderer sends an invalid verdict string that we're unable to
340 // parse. 334 // parse.
341 MockBrowserFeatureExtractor* mock_extractor = 335 MockBrowserFeatureExtractor* mock_extractor =
342 new StrictMock<MockBrowserFeatureExtractor>( 336 new StrictMock<MockBrowserFeatureExtractor>(
343 web_contents(), 337 web_contents(),
344 csd_host_.get()); 338 csd_host_.get());
345 SetFeatureExtractor(mock_extractor); // The host class takes ownership. 339 SetFeatureExtractor(mock_extractor); // The host class takes ownership.
346 EXPECT_CALL(*mock_extractor, ExtractFeatures(_, _, _)).Times(0); 340 EXPECT_CALL(*mock_extractor, ExtractFeatures(_, _, _)).Times(0);
347 OnPhishingDetectionDone("Invalid Protocol Buffer"); 341 OnPhishingDetectionDone("Invalid Protocol Buffer");
348 EXPECT_TRUE(Mock::VerifyAndClear(mock_extractor)); 342 EXPECT_TRUE(Mock::VerifyAndClear(mock_extractor));
349 } 343 }
350 344
351 #if defined(OS_WIN)
352 // Fails on Blink canary bots: http://crbug.com/299149
353 TEST_F(ClientSideDetectionHostTest,
354 DISABLED_OnPhishingDetectionDoneNotPhishing) {
355 #else
356 TEST_F(ClientSideDetectionHostTest, OnPhishingDetectionDoneNotPhishing) { 345 TEST_F(ClientSideDetectionHostTest, OnPhishingDetectionDoneNotPhishing) {
357 #endif
358 // Case 1: client thinks the page is phishing. The server does not agree. 346 // Case 1: client thinks the page is phishing. The server does not agree.
359 // No interstitial is shown. 347 // No interstitial is shown.
360 MockBrowserFeatureExtractor* mock_extractor = 348 MockBrowserFeatureExtractor* mock_extractor =
361 new StrictMock<MockBrowserFeatureExtractor>( 349 new StrictMock<MockBrowserFeatureExtractor>(
362 web_contents(), 350 web_contents(),
363 csd_host_.get()); 351 csd_host_.get());
364 SetFeatureExtractor(mock_extractor); // The host class takes ownership. 352 SetFeatureExtractor(mock_extractor); // The host class takes ownership.
365 353
366 ClientSideDetectionService::ClientReportPhishingRequestCallback cb; 354 ClientSideDetectionService::ClientReportPhishingRequestCallback cb;
367 ClientPhishingRequest verdict; 355 ClientPhishingRequest verdict;
(...skipping 16 matching lines...) Expand all
384 EXPECT_TRUE(Mock::VerifyAndClear(csd_host_.get())); 372 EXPECT_TRUE(Mock::VerifyAndClear(csd_host_.get()));
385 ASSERT_FALSE(cb.is_null()); 373 ASSERT_FALSE(cb.is_null());
386 374
387 // Make sure DoDisplayBlockingPage is not going to be called. 375 // Make sure DoDisplayBlockingPage is not going to be called.
388 EXPECT_CALL(*ui_manager_.get(), DoDisplayBlockingPage(_)).Times(0); 376 EXPECT_CALL(*ui_manager_.get(), DoDisplayBlockingPage(_)).Times(0);
389 cb.Run(GURL(verdict.url()), false); 377 cb.Run(GURL(verdict.url()), false);
390 base::RunLoop().RunUntilIdle(); 378 base::RunLoop().RunUntilIdle();
391 EXPECT_TRUE(Mock::VerifyAndClear(ui_manager_.get())); 379 EXPECT_TRUE(Mock::VerifyAndClear(ui_manager_.get()));
392 } 380 }
393 381
394 #if defined(OS_WIN)
395 // Fails on Blink canary bots: http://crbug.com/299149
396 TEST_F(ClientSideDetectionHostTest, DISABLED_OnPhishingDetectionDoneDisabled) {
397 #else
398 TEST_F(ClientSideDetectionHostTest, OnPhishingDetectionDoneDisabled) { 382 TEST_F(ClientSideDetectionHostTest, OnPhishingDetectionDoneDisabled) {
399 #endif
400 // Case 2: client thinks the page is phishing and so does the server but 383 // Case 2: client thinks the page is phishing and so does the server but
401 // showing the interstitial is disabled => no interstitial is shown. 384 // showing the interstitial is disabled => no interstitial is shown.
402 MockBrowserFeatureExtractor* mock_extractor = 385 MockBrowserFeatureExtractor* mock_extractor =
403 new StrictMock<MockBrowserFeatureExtractor>( 386 new StrictMock<MockBrowserFeatureExtractor>(
404 web_contents(), 387 web_contents(),
405 csd_host_.get()); 388 csd_host_.get());
406 SetFeatureExtractor(mock_extractor); // The host class takes ownership. 389 SetFeatureExtractor(mock_extractor); // The host class takes ownership.
407 390
408 ClientSideDetectionService::ClientReportPhishingRequestCallback cb; 391 ClientSideDetectionService::ClientReportPhishingRequestCallback cb;
409 ClientPhishingRequest verdict; 392 ClientPhishingRequest verdict;
(...skipping 20 matching lines...) Expand all
430 EXPECT_TRUE(Mock::VerifyAndClear(csd_host_.get())); 413 EXPECT_TRUE(Mock::VerifyAndClear(csd_host_.get()));
431 ASSERT_FALSE(cb.is_null()); 414 ASSERT_FALSE(cb.is_null());
432 415
433 // Make sure DoDisplayBlockingPage is not going to be called. 416 // Make sure DoDisplayBlockingPage is not going to be called.
434 EXPECT_CALL(*ui_manager_.get(), DoDisplayBlockingPage(_)).Times(0); 417 EXPECT_CALL(*ui_manager_.get(), DoDisplayBlockingPage(_)).Times(0);
435 cb.Run(GURL(verdict.url()), false); 418 cb.Run(GURL(verdict.url()), false);
436 base::RunLoop().RunUntilIdle(); 419 base::RunLoop().RunUntilIdle();
437 EXPECT_TRUE(Mock::VerifyAndClear(ui_manager_.get())); 420 EXPECT_TRUE(Mock::VerifyAndClear(ui_manager_.get()));
438 } 421 }
439 422
440 #if defined(OS_WIN)
441 // Fails on Blink canary bots: http://crbug.com/299149
442 TEST_F(ClientSideDetectionHostTest,
443 DISABLED_OnPhishingDetectionDoneShowInterstitial) {
444 #else
445 TEST_F(ClientSideDetectionHostTest, OnPhishingDetectionDoneShowInterstitial) { 423 TEST_F(ClientSideDetectionHostTest, OnPhishingDetectionDoneShowInterstitial) {
446 #endif
447 // Case 3: client thinks the page is phishing and so does the server. 424 // Case 3: client thinks the page is phishing and so does the server.
448 // We show an interstitial. 425 // We show an interstitial.
449 MockBrowserFeatureExtractor* mock_extractor = 426 MockBrowserFeatureExtractor* mock_extractor =
450 new StrictMock<MockBrowserFeatureExtractor>( 427 new StrictMock<MockBrowserFeatureExtractor>(
451 web_contents(), 428 web_contents(),
452 csd_host_.get()); 429 csd_host_.get());
453 SetFeatureExtractor(mock_extractor); // The host class takes ownership. 430 SetFeatureExtractor(mock_extractor); // The host class takes ownership.
454 431
455 ClientSideDetectionService::ClientReportPhishingRequestCallback cb; 432 ClientSideDetectionService::ClientReportPhishingRequestCallback cb;
456 GURL phishing_url("http://phishingurl.com/"); 433 GURL phishing_url("http://phishingurl.com/");
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
493 resource.render_view_id); 470 resource.render_view_id);
494 471
495 // Make sure the client object will be deleted. 472 // Make sure the client object will be deleted.
496 BrowserThread::PostTask( 473 BrowserThread::PostTask(
497 BrowserThread::IO, 474 BrowserThread::IO,
498 FROM_HERE, 475 FROM_HERE,
499 base::Bind(&MockSafeBrowsingUIManager::InvokeOnBlockingPageComplete, 476 base::Bind(&MockSafeBrowsingUIManager::InvokeOnBlockingPageComplete,
500 ui_manager_, resource.callback)); 477 ui_manager_, resource.callback));
501 } 478 }
502 479
503 #if defined(OS_WIN)
504 // Fails on Blink canary bots: http://crbug.com/299149
505 TEST_F(ClientSideDetectionHostTest,
506 DISABLED_OnPhishingDetectionDoneMultiplePings) {
507 #else
508 TEST_F(ClientSideDetectionHostTest, OnPhishingDetectionDoneMultiplePings) { 480 TEST_F(ClientSideDetectionHostTest, OnPhishingDetectionDoneMultiplePings) {
509 #endif
510 // Case 4 & 5: client thinks a page is phishing then navigates to 481 // Case 4 & 5: client thinks a page is phishing then navigates to
511 // another page which is also considered phishing by the client 482 // another page which is also considered phishing by the client
512 // before the server responds with a verdict. After a while the 483 // before the server responds with a verdict. After a while the
513 // server responds for both requests with a phishing verdict. Only 484 // server responds for both requests with a phishing verdict. Only
514 // a single interstitial is shown for the second URL. 485 // a single interstitial is shown for the second URL.
515 MockBrowserFeatureExtractor* mock_extractor = 486 MockBrowserFeatureExtractor* mock_extractor =
516 new StrictMock<MockBrowserFeatureExtractor>( 487 new StrictMock<MockBrowserFeatureExtractor>(
517 web_contents(), 488 web_contents(),
518 csd_host_.get()); 489 csd_host_.get());
519 SetFeatureExtractor(mock_extractor); // The host class takes ownership. 490 SetFeatureExtractor(mock_extractor); // The host class takes ownership.
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
594 resource.render_view_id); 565 resource.render_view_id);
595 566
596 // Make sure the client object will be deleted. 567 // Make sure the client object will be deleted.
597 BrowserThread::PostTask( 568 BrowserThread::PostTask(
598 BrowserThread::IO, 569 BrowserThread::IO,
599 FROM_HERE, 570 FROM_HERE,
600 base::Bind(&MockSafeBrowsingUIManager::InvokeOnBlockingPageComplete, 571 base::Bind(&MockSafeBrowsingUIManager::InvokeOnBlockingPageComplete,
601 ui_manager_, resource.callback)); 572 ui_manager_, resource.callback));
602 } 573 }
603 574
604 #if defined(OS_WIN)
605 // Fails on Blink canary bots: http://crbug.com/299149
606 TEST_F(ClientSideDetectionHostTest,
607 DISABLED_OnPhishingDetectionDoneVerdictNotPhishing) {
608 #else
609 TEST_F(ClientSideDetectionHostTest, 575 TEST_F(ClientSideDetectionHostTest,
610 OnPhishingDetectionDoneVerdictNotPhishing) { 576 OnPhishingDetectionDoneVerdictNotPhishing) {
611 #endif
612 // Case 6: renderer sends a verdict string that isn't phishing. 577 // Case 6: renderer sends a verdict string that isn't phishing.
613 MockBrowserFeatureExtractor* mock_extractor = 578 MockBrowserFeatureExtractor* mock_extractor =
614 new StrictMock<MockBrowserFeatureExtractor>( 579 new StrictMock<MockBrowserFeatureExtractor>(
615 web_contents(), 580 web_contents(),
616 csd_host_.get()); 581 csd_host_.get());
617 SetFeatureExtractor(mock_extractor); // The host class takes ownership. 582 SetFeatureExtractor(mock_extractor); // The host class takes ownership.
618 583
619 ClientPhishingRequest verdict; 584 ClientPhishingRequest verdict;
620 verdict.set_url("http://not-phishing.com/"); 585 verdict.set_url("http://not-phishing.com/");
621 verdict.set_client_score(0.1f); 586 verdict.set_client_score(0.1f);
622 verdict.set_is_phishing(false); 587 verdict.set_is_phishing(false);
623 588
624 ClientMalwareRequest malware_verdict; 589 ClientMalwareRequest malware_verdict;
625 malware_verdict.set_url(verdict.url()); 590 malware_verdict.set_url(verdict.url());
626 591
627 EXPECT_CALL(*mock_extractor, ExtractFeatures(_, _, _)).Times(0); 592 EXPECT_CALL(*mock_extractor, ExtractFeatures(_, _, _)).Times(0);
628 EXPECT_CALL(*mock_extractor, ExtractMalwareFeatures(_, _, _)) 593 EXPECT_CALL(*mock_extractor, ExtractMalwareFeatures(_, _, _))
629 .WillOnce(InvokeMalwareCallback(&malware_verdict)); 594 .WillOnce(InvokeMalwareCallback(&malware_verdict));
630 OnPhishingDetectionDone(verdict.SerializeAsString()); 595 OnPhishingDetectionDone(verdict.SerializeAsString());
631 EXPECT_TRUE(Mock::VerifyAndClear(mock_extractor)); 596 EXPECT_TRUE(Mock::VerifyAndClear(mock_extractor));
632 } 597 }
633 598
634 #if defined(OS_WIN)
635 // Fails on Blink canary bots: http://crbug.com/299149
636 TEST_F(ClientSideDetectionHostTest,
637 DISABLED_OnPhishingDetectionDoneVerdictNotPhishingButSBMatch) {
638 #else
639 TEST_F(ClientSideDetectionHostTest, 599 TEST_F(ClientSideDetectionHostTest,
640 OnPhishingDetectionDoneVerdictNotPhishingButSBMatch) { 600 OnPhishingDetectionDoneVerdictNotPhishingButSBMatch) {
641 #endif
642 // Case 7: renderer sends a verdict string that isn't phishing but the URL 601 // Case 7: renderer sends a verdict string that isn't phishing but the URL
643 // was on the regular phishing or malware lists. 602 // was on the regular phishing or malware lists.
644 GURL url("http://not-phishing.com/"); 603 GURL url("http://not-phishing.com/");
645 ClientPhishingRequest verdict; 604 ClientPhishingRequest verdict;
646 verdict.set_url(url.spec()); 605 verdict.set_url(url.spec());
647 verdict.set_client_score(0.1f); 606 verdict.set_client_score(0.1f);
648 verdict.set_is_phishing(false); 607 verdict.set_is_phishing(false);
649 608
650 // First we have to navigate to the URL to set the unique page ID. 609 // First we have to navigate to the URL to set the unique page ID.
651 ExpectPreClassificationChecks(url, &kFalse, &kFalse, &kFalse, &kFalse, 610 ExpectPreClassificationChecks(url, &kFalse, &kFalse, &kFalse, &kFalse,
652 &kFalse, &kFalse); 611 &kFalse, &kFalse);
653 NavigateAndCommit(url); 612 NavigateAndCommit(url);
654 WaitAndCheckPreClassificationChecks(); 613 WaitAndCheckPreClassificationChecks();
655 SetUnsafeResourceToCurrent(); 614 SetUnsafeResourceToCurrent();
656 615
657 EXPECT_CALL(*csd_service_, 616 EXPECT_CALL(*csd_service_,
658 SendClientReportPhishingRequest( 617 SendClientReportPhishingRequest(
659 Pointee(PartiallyEqualVerdict(verdict)), CallbackIsNull())) 618 Pointee(PartiallyEqualVerdict(verdict)), CallbackIsNull()))
660 .WillOnce(DoAll(DeleteArg<0>(), QuitUIMessageLoop())); 619 .WillOnce(DoAll(DeleteArg<0>(), QuitUIMessageLoop()));
661 std::vector<GURL> redirect_chain; 620 std::vector<GURL> redirect_chain;
662 redirect_chain.push_back(url); 621 redirect_chain.push_back(url);
663 SetRedirectChain(redirect_chain); 622 SetRedirectChain(redirect_chain);
664 OnPhishingDetectionDone(verdict.SerializeAsString()); 623 OnPhishingDetectionDone(verdict.SerializeAsString());
665 base::MessageLoop::current()->Run(); 624 base::MessageLoop::current()->Run();
666 EXPECT_TRUE(Mock::VerifyAndClear(csd_host_.get())); 625 EXPECT_TRUE(Mock::VerifyAndClear(csd_host_.get()));
667 } 626 }
668 627
669 #if defined(OS_WIN)
670 // Crashes on Blink canary bots: http://crbug.com/299149
671 TEST_F(ClientSideDetectionHostTest, DISABLED_UpdateIPUrlMap) {
672 #else
673 TEST_F(ClientSideDetectionHostTest, UpdateIPUrlMap) { 628 TEST_F(ClientSideDetectionHostTest, UpdateIPUrlMap) {
674 #endif
675 BrowseInfo* browse_info = GetBrowseInfo(); 629 BrowseInfo* browse_info = GetBrowseInfo();
676 630
677 // Empty IP or host are skipped 631 // Empty IP or host are skipped
678 UpdateIPUrlMap("250.10.10.10", std::string()); 632 UpdateIPUrlMap("250.10.10.10", std::string());
679 ASSERT_EQ(0U, browse_info->ips.size()); 633 ASSERT_EQ(0U, browse_info->ips.size());
680 UpdateIPUrlMap(std::string(), "http://google.com/a"); 634 UpdateIPUrlMap(std::string(), "http://google.com/a");
681 ASSERT_EQ(0U, browse_info->ips.size()); 635 ASSERT_EQ(0U, browse_info->ips.size());
682 UpdateIPUrlMap(std::string(), std::string()); 636 UpdateIPUrlMap(std::string(), std::string());
683 ASSERT_EQ(0U, browse_info->ips.size()); 637 ASSERT_EQ(0U, browse_info->ips.size());
684 638
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
717 671
718 // Add url to existing IPs succeed 672 // Add url to existing IPs succeed
719 UpdateIPUrlMap("100.100.100.256", "more.com/"); 673 UpdateIPUrlMap("100.100.100.256", "more.com/");
720 ASSERT_EQ(2U, browse_info->ips["100.100.100.256"].size()); 674 ASSERT_EQ(2U, browse_info->ips["100.100.100.256"].size());
721 expected_urls.clear(); 675 expected_urls.clear();
722 expected_urls.insert("test.com/"); 676 expected_urls.insert("test.com/");
723 expected_urls.insert("more.com/"); 677 expected_urls.insert("more.com/");
724 EXPECT_EQ(expected_urls, browse_info->ips["100.100.100.256"]); 678 EXPECT_EQ(expected_urls, browse_info->ips["100.100.100.256"]);
725 } 679 }
726 680
727 #if defined(OS_WIN)
728 // Crashes on Blink canary bots: http://crbug.com/299149
729 TEST_F(ClientSideDetectionHostTest,
730 DISABLED_OnPhishingDetectionDoneVerdictNotPhishingNotMalwareIP) {
731 #else
732 TEST_F(ClientSideDetectionHostTest, 681 TEST_F(ClientSideDetectionHostTest,
733 OnPhishingDetectionDoneVerdictNotPhishingNotMalwareIP) { 682 OnPhishingDetectionDoneVerdictNotPhishingNotMalwareIP) {
734 #endif
735 // Case 7: renderer sends a verdict string that isn't phishing and not matches 683 // Case 7: renderer sends a verdict string that isn't phishing and not matches
736 // malware bad IP list 684 // malware bad IP list
737 MockBrowserFeatureExtractor* mock_extractor = 685 MockBrowserFeatureExtractor* mock_extractor =
738 new StrictMock<MockBrowserFeatureExtractor>( 686 new StrictMock<MockBrowserFeatureExtractor>(
739 web_contents(), 687 web_contents(),
740 csd_host_.get()); 688 csd_host_.get());
741 SetFeatureExtractor(mock_extractor); // The host class takes ownership. 689 SetFeatureExtractor(mock_extractor); // The host class takes ownership.
742 690
743 ClientPhishingRequest verdict; 691 ClientPhishingRequest verdict;
744 verdict.set_url("http://not-phishing.com/"); 692 verdict.set_url("http://not-phishing.com/");
745 verdict.set_client_score(0.1f); 693 verdict.set_client_score(0.1f);
746 verdict.set_is_phishing(false); 694 verdict.set_is_phishing(false);
747 695
748 ClientMalwareRequest malware_verdict; 696 ClientMalwareRequest malware_verdict;
749 malware_verdict.set_url(verdict.url()); 697 malware_verdict.set_url(verdict.url());
750 698
751 // That is a special case. If there were no IP matches or if feature 699 // That is a special case. If there were no IP matches or if feature
752 // extraction failed the callback will delete the malware_verdict. 700 // extraction failed the callback will delete the malware_verdict.
753 EXPECT_CALL(*mock_extractor, ExtractMalwareFeatures(_, _, _)) 701 EXPECT_CALL(*mock_extractor, ExtractMalwareFeatures(_, _, _))
754 .WillOnce(InvokeMalwareCallback(&malware_verdict)); 702 .WillOnce(InvokeMalwareCallback(&malware_verdict));
755 EXPECT_CALL(*csd_service_, 703 EXPECT_CALL(*csd_service_,
756 SendClientReportMalwareRequest(_, _)).Times(0); 704 SendClientReportMalwareRequest(_, _)).Times(0);
757 EXPECT_CALL(*mock_extractor, ExtractFeatures(_, _, _)).Times(0); 705 EXPECT_CALL(*mock_extractor, ExtractFeatures(_, _, _)).Times(0);
758 706
759 OnPhishingDetectionDone(verdict.SerializeAsString()); 707 OnPhishingDetectionDone(verdict.SerializeAsString());
760 EXPECT_TRUE(Mock::VerifyAndClear(mock_extractor)); 708 EXPECT_TRUE(Mock::VerifyAndClear(mock_extractor));
761 } 709 }
762 710
763 #if defined(OS_WIN)
764 // Crashes on Blink canary bots: http://crbug.com/299149
765 TEST_F(ClientSideDetectionHostTest,
766 DISABLED_OnPhishingDetectionDoneVerdictNotPhishingButMalwareIP) {
767 #else
768 TEST_F(ClientSideDetectionHostTest, 711 TEST_F(ClientSideDetectionHostTest,
769 OnPhishingDetectionDoneVerdictNotPhishingButMalwareIP) { 712 OnPhishingDetectionDoneVerdictNotPhishingButMalwareIP) {
770 #endif
771 // Case 8: renderer sends a verdict string that isn't phishing but matches 713 // Case 8: renderer sends a verdict string that isn't phishing but matches
772 // malware bad IP list 714 // malware bad IP list
773 MockBrowserFeatureExtractor* mock_extractor = 715 MockBrowserFeatureExtractor* mock_extractor =
774 new StrictMock<MockBrowserFeatureExtractor>( 716 new StrictMock<MockBrowserFeatureExtractor>(
775 web_contents(), 717 web_contents(),
776 csd_host_.get()); 718 csd_host_.get());
777 SetFeatureExtractor(mock_extractor); // The host class takes ownership. 719 SetFeatureExtractor(mock_extractor); // The host class takes ownership.
778 720
779 ClientPhishingRequest verdict; 721 ClientPhishingRequest verdict;
780 verdict.set_url("http://not-phishing.com/"); 722 verdict.set_url("http://not-phishing.com/");
(...skipping 12 matching lines...) Expand all
793 EXPECT_CALL(*csd_service_, 735 EXPECT_CALL(*csd_service_,
794 SendClientReportMalwareRequest( 736 SendClientReportMalwareRequest(
795 Pointee(PartiallyEqualMalwareVerdict(malware_verdict)), _)) 737 Pointee(PartiallyEqualMalwareVerdict(malware_verdict)), _))
796 .WillOnce(DeleteArg<0>()); 738 .WillOnce(DeleteArg<0>());
797 EXPECT_CALL(*mock_extractor, ExtractFeatures(_, _, _)).Times(0); 739 EXPECT_CALL(*mock_extractor, ExtractFeatures(_, _, _)).Times(0);
798 740
799 OnPhishingDetectionDone(verdict.SerializeAsString()); 741 OnPhishingDetectionDone(verdict.SerializeAsString());
800 EXPECT_TRUE(Mock::VerifyAndClear(mock_extractor)); 742 EXPECT_TRUE(Mock::VerifyAndClear(mock_extractor));
801 } 743 }
802 744
803 #if defined(OS_WIN)
804 // Crashes on Blink canary bots: http://crbug.com/299149
805 TEST_F(ClientSideDetectionHostTest,
806 DISABLED_OnPhishingDetectionDoneVerdictPhishingAndMalwareIP) {
807 #else
808 TEST_F(ClientSideDetectionHostTest, 745 TEST_F(ClientSideDetectionHostTest,
809 OnPhishingDetectionDoneVerdictPhishingAndMalwareIP) { 746 OnPhishingDetectionDoneVerdictPhishingAndMalwareIP) {
810 #endif
811 // Case 9: renderer sends a verdict string that is phishing and matches 747 // Case 9: renderer sends a verdict string that is phishing and matches
812 // malware bad IP list 748 // malware bad IP list
813 MockBrowserFeatureExtractor* mock_extractor = 749 MockBrowserFeatureExtractor* mock_extractor =
814 new StrictMock<MockBrowserFeatureExtractor>( 750 new StrictMock<MockBrowserFeatureExtractor>(
815 web_contents(), 751 web_contents(),
816 csd_host_.get()); 752 csd_host_.get());
817 SetFeatureExtractor(mock_extractor); // The host class takes ownership. 753 SetFeatureExtractor(mock_extractor); // The host class takes ownership.
818 754
819 ClientSideDetectionService::ClientReportPhishingRequestCallback cb; 755 ClientSideDetectionService::ClientReportPhishingRequestCallback cb;
820 ClientPhishingRequest verdict; 756 ClientPhishingRequest verdict;
(...skipping 23 matching lines...) Expand all
844 SendClientReportPhishingRequest( 780 SendClientReportPhishingRequest(
845 Pointee(PartiallyEqualVerdict(verdict)), _)) 781 Pointee(PartiallyEqualVerdict(verdict)), _))
846 .WillOnce(SaveArg<1>(&cb)); 782 .WillOnce(SaveArg<1>(&cb));
847 OnPhishingDetectionDone(verdict.SerializeAsString()); 783 OnPhishingDetectionDone(verdict.SerializeAsString());
848 EXPECT_TRUE(Mock::VerifyAndClear(mock_extractor)); 784 EXPECT_TRUE(Mock::VerifyAndClear(mock_extractor));
849 EXPECT_TRUE(Mock::VerifyAndClear(csd_host_.get())); 785 EXPECT_TRUE(Mock::VerifyAndClear(csd_host_.get()));
850 EXPECT_TRUE(Mock::VerifyAndClear(csd_service_.get())); 786 EXPECT_TRUE(Mock::VerifyAndClear(csd_service_.get()));
851 ASSERT_FALSE(cb.is_null()); 787 ASSERT_FALSE(cb.is_null());
852 } 788 }
853 789
854 #if defined(OS_WIN)
855 // Crashes on Blink canary bots: http://crbug.com/299149
856 TEST_F(ClientSideDetectionHostTest,
857 DISABLED_OnPhishingDetectionDoneShowMalwareInterstitial) {
858 #else
859 TEST_F(ClientSideDetectionHostTest, 790 TEST_F(ClientSideDetectionHostTest,
860 OnPhishingDetectionDoneShowMalwareInterstitial) { 791 OnPhishingDetectionDoneShowMalwareInterstitial) {
861 #endif
862 // Case 10: client thinks the page match malware IP and so does the server. 792 // Case 10: client thinks the page match malware IP and so does the server.
863 // We show an sub-resource malware interstitial. 793 // We show an sub-resource malware interstitial.
864 MockBrowserFeatureExtractor* mock_extractor = 794 MockBrowserFeatureExtractor* mock_extractor =
865 new StrictMock<MockBrowserFeatureExtractor>( 795 new StrictMock<MockBrowserFeatureExtractor>(
866 web_contents(), 796 web_contents(),
867 csd_host_.get()); 797 csd_host_.get());
868 SetFeatureExtractor(mock_extractor); // The host class takes ownership. 798 SetFeatureExtractor(mock_extractor); // The host class takes ownership.
869 799
870 ClientPhishingRequest verdict; 800 ClientPhishingRequest verdict;
871 verdict.set_url("http://not-phishing.com/"); 801 verdict.set_url("http://not-phishing.com/");
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
910 resource.render_view_id); 840 resource.render_view_id);
911 841
912 // Make sure the client object will be deleted. 842 // Make sure the client object will be deleted.
913 BrowserThread::PostTask( 843 BrowserThread::PostTask(
914 BrowserThread::IO, 844 BrowserThread::IO,
915 FROM_HERE, 845 FROM_HERE,
916 base::Bind(&MockSafeBrowsingUIManager::InvokeOnBlockingPageComplete, 846 base::Bind(&MockSafeBrowsingUIManager::InvokeOnBlockingPageComplete,
917 ui_manager_, resource.callback)); 847 ui_manager_, resource.callback));
918 } 848 }
919 849
920 #if defined(OS_WIN)
921 // Crashes on Blink canary bots: http://crbug.com/299149
922 TEST_F(ClientSideDetectionHostTest,
923 DISABLED_NavigationCancelsShouldClassifyUrl) {
924 #else
925 TEST_F(ClientSideDetectionHostTest, NavigationCancelsShouldClassifyUrl) { 850 TEST_F(ClientSideDetectionHostTest, NavigationCancelsShouldClassifyUrl) {
926 #endif
927 // Test that canceling pending should classify requests works as expected. 851 // Test that canceling pending should classify requests works as expected.
928 852
929 GURL first_url("http://first.phishy.url.com"); 853 GURL first_url("http://first.phishy.url.com");
930 GURL second_url("http://second.url.com/"); 854 GURL second_url("http://second.url.com/");
931 // The first few checks are done synchronously so check that they have been 855 // The first few checks are done synchronously so check that they have been
932 // done for the first URL, while the second URL has all the checks done. We 856 // done for the first URL, while the second URL has all the checks done. We
933 // need to manually set up the IsPrivateIPAddress mock since if the same mock 857 // need to manually set up the IsPrivateIPAddress mock since if the same mock
934 // expectation is specified twice, gmock will only use the last instance of 858 // expectation is specified twice, gmock will only use the last instance of
935 // it, meaning the first will never be matched. 859 // it, meaning the first will never be matched.
936 EXPECT_CALL(*csd_service_, IsPrivateIPAddress(_)) 860 EXPECT_CALL(*csd_service_, IsPrivateIPAddress(_))
937 .WillOnce(Return(false)) 861 .WillOnce(Return(false))
938 .WillOnce(Return(false)); 862 .WillOnce(Return(false));
939 ExpectPreClassificationChecks(first_url, NULL, &kFalse, &kFalse, NULL, 863 ExpectPreClassificationChecks(first_url, NULL, &kFalse, &kFalse, NULL,
940 NULL, NULL); 864 NULL, NULL);
941 ExpectPreClassificationChecks(second_url, NULL, &kFalse, &kFalse, &kFalse, 865 ExpectPreClassificationChecks(second_url, NULL, &kFalse, &kFalse, &kFalse,
942 &kFalse, &kFalse); 866 &kFalse, &kFalse);
943 867
944 NavigateAndCommit(first_url); 868 NavigateAndCommit(first_url);
945 // Don't flush the message loop, as we want to navigate to a different 869 // Don't flush the message loop, as we want to navigate to a different
946 // url before the final pre-classification checks are run. 870 // url before the final pre-classification checks are run.
947 NavigateAndCommit(second_url); 871 NavigateAndCommit(second_url);
948 WaitAndCheckPreClassificationChecks(); 872 WaitAndCheckPreClassificationChecks();
949 } 873 }
950 874
951 #if defined(OS_WIN)
952 // Crashes on Blink canary bots: http://crbug.com/299149
953 TEST_F(ClientSideDetectionHostTest, DISABLED_ShouldClassifyUrl) {
954 #else
955 TEST_F(ClientSideDetectionHostTest, ShouldClassifyUrl) { 875 TEST_F(ClientSideDetectionHostTest, ShouldClassifyUrl) {
956 #endif
957 // Navigate the tab to a page. We should see a StartPhishingDetection IPC. 876 // Navigate the tab to a page. We should see a StartPhishingDetection IPC.
958 GURL url("http://host.com/"); 877 GURL url("http://host.com/");
959 ExpectPreClassificationChecks(url, &kFalse, &kFalse, &kFalse, &kFalse, 878 ExpectPreClassificationChecks(url, &kFalse, &kFalse, &kFalse, &kFalse,
960 &kFalse, &kFalse); 879 &kFalse, &kFalse);
961 NavigateAndCommit(url); 880 NavigateAndCommit(url);
962 WaitAndCheckPreClassificationChecks(); 881 WaitAndCheckPreClassificationChecks();
963 882
964 const IPC::Message* msg = process()->sink().GetFirstMessageMatching( 883 const IPC::Message* msg = process()->sink().GetFirstMessageMatching(
965 SafeBrowsingMsg_StartPhishingDetection::ID); 884 SafeBrowsingMsg_StartPhishingDetection::ID);
966 ASSERT_TRUE(msg); 885 ASSERT_TRUE(msg);
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
1099 EXPECT_TRUE(Mock::VerifyAndClear(csd_host_.get())); 1018 EXPECT_TRUE(Mock::VerifyAndClear(csd_host_.get()));
1100 EXPECT_TRUE(Mock::VerifyAndClear(ui_manager_.get())); 1019 EXPECT_TRUE(Mock::VerifyAndClear(ui_manager_.get()));
1101 EXPECT_EQ(url, resource.url); 1020 EXPECT_EQ(url, resource.url);
1102 EXPECT_EQ(url, resource.original_url); 1021 EXPECT_EQ(url, resource.original_url);
1103 resource.callback.Reset(); 1022 resource.callback.Reset();
1104 msg = process()->sink().GetFirstMessageMatching( 1023 msg = process()->sink().GetFirstMessageMatching(
1105 SafeBrowsingMsg_StartPhishingDetection::ID); 1024 SafeBrowsingMsg_StartPhishingDetection::ID);
1106 ASSERT_FALSE(msg); 1025 ASSERT_FALSE(msg);
1107 } 1026 }
1108 } // namespace safe_browsing 1027 } // namespace safe_browsing
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698