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

Side by Side Diff: chrome/browser/net/dns_probe_browsertest.cc

Issue 137623011: Switch to using the new Link Doctor API. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Add missing file, fix test Created 6 years, 10 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 <set> 5 #include <set>
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/path_service.h" 10 #include "base/path_service.h"
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 return delayed_probes_.size(); 103 return delayed_probes_.size();
104 } 104 }
105 105
106 private: 106 private:
107 std::vector<ProbeCallback> delayed_probes_; 107 std::vector<ProbeCallback> delayed_probes_;
108 }; 108 };
109 109
110 FilePath GetMockLinkDoctorFilePath() { 110 FilePath GetMockLinkDoctorFilePath() {
111 FilePath root_http; 111 FilePath root_http;
112 PathService::Get(chrome::DIR_TEST_DATA, &root_http); 112 PathService::Get(chrome::DIR_TEST_DATA, &root_http);
113 return root_http.AppendASCII("mock-link-doctor.html"); 113 return root_http.AppendASCII("mock-link-doctor.json");
114 } 114 }
115 115
116 // A request that can be delayed until Resume() is called. Can also run a 116 // A request that can be delayed until Resume() is called. Can also run a
117 // callback if destroyed without being resumed. Resume can be called either 117 // callback if destroyed without being resumed. Resume can be called either
118 // before or after a the request is started. 118 // before or after a the request is started.
119 class DelayableRequest { 119 class DelayableRequest {
120 public: 120 public:
121 // Called by a DelayableRequest if it was set to be delayed, and has been 121 // Called by a DelayableRequest if it was set to be delayed, and has been
122 // destroyed without Undelay being called. 122 // destroyed without Undelay being called.
123 typedef base::Callback<void(DelayableRequest* request)> DestructionCallback; 123 typedef base::Callback<void(DelayableRequest* request)> DestructionCallback;
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after
454 void NavigateToDnsError(int num_navigations); 454 void NavigateToDnsError(int num_navigations);
455 void NavigateToOtherError(int num_navigations); 455 void NavigateToOtherError(int num_navigations);
456 456
457 void StartDelayedProbes(int expected_delayed_probe_count); 457 void StartDelayedProbes(int expected_delayed_probe_count);
458 DnsProbeStatus WaitForSentStatus(); 458 DnsProbeStatus WaitForSentStatus();
459 int pending_status_count() const { return dns_probe_status_queue_.size(); } 459 int pending_status_count() const { return dns_probe_status_queue_.size(); }
460 460
461 std::string Title(); 461 std::string Title();
462 bool PageContains(const std::string& expected); 462 bool PageContains(const std::string& expected);
463 463
464 // Checks that the local error page is being displayed, without Link Doctor
465 // suggestions, and with the specified status text. The status text should be
466 // either a network error or DNS probe status.
467 void ExpectDisplayingLocalErrorPage(const std::string& status_text);
468
469 // Checks that an error page with suggestions retrieved from the mock Link
470 // Doctor result is being displayed, with the specified status text.
471 // The status text should be either a network error or DNS probe status.
472 void ExpectDisplayingLinkDoctor(const std::string& status_text);
473
464 private: 474 private:
465 void OnDnsProbeStatusSent(DnsProbeStatus dns_probe_status); 475 void OnDnsProbeStatusSent(DnsProbeStatus dns_probe_status);
466 476
467 DnsProbeBrowserTestIOThreadHelper* helper_; 477 DnsProbeBrowserTestIOThreadHelper* helper_;
468 478
469 // Browser that methods apply to. 479 // Browser that methods apply to.
470 Browser* active_browser_; 480 Browser* active_browser_;
471 // Helper that current has its DnsProbeStatus messages monitored. 481 // Helper that current has its DnsProbeStatus messages monitored.
472 NetErrorTabHelper* monitored_tab_helper_; 482 NetErrorTabHelper* monitored_tab_helper_;
473 483
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
631 bool rv = content::ExecuteScriptAndExtractString( 641 bool rv = content::ExecuteScriptAndExtractString(
632 active_browser_->tab_strip_model()->GetActiveWebContents(), 642 active_browser_->tab_strip_model()->GetActiveWebContents(),
633 "domAutomationController.send(document.body.textContent);", 643 "domAutomationController.send(document.body.textContent);",
634 &text_content); 644 &text_content);
635 if (!rv) 645 if (!rv)
636 return false; 646 return false;
637 647
638 return text_content.find(expected) != std::string::npos; 648 return text_content.find(expected) != std::string::npos;
639 } 649 }
640 650
651 void DnsProbeBrowserTest::ExpectDisplayingLocalErrorPage(
652 const std::string& status_text) {
653 EXPECT_FALSE(PageContains("http://correction1/"));
654 EXPECT_FALSE(PageContains("http://correction2/"));
655 EXPECT_TRUE(PageContains(status_text));
656 }
657
658 void DnsProbeBrowserTest::ExpectDisplayingLinkDoctor(
659 const std::string& status_text) {
660 EXPECT_TRUE(PageContains("http://correction1/"));
661 EXPECT_TRUE(PageContains("http://correction2/"));
662 EXPECT_TRUE(PageContains(status_text));
663 }
664
641 void DnsProbeBrowserTest::OnDnsProbeStatusSent( 665 void DnsProbeBrowserTest::OnDnsProbeStatusSent(
642 DnsProbeStatus dns_probe_status) { 666 DnsProbeStatus dns_probe_status) {
643 dns_probe_status_queue_.push_back(dns_probe_status); 667 dns_probe_status_queue_.push_back(dns_probe_status);
644 if (awaiting_dns_probe_status_) 668 if (awaiting_dns_probe_status_)
645 MessageLoop::current()->Quit(); 669 MessageLoop::current()->Quit();
646 } 670 }
647 671
648 // Make sure probes don't break non-DNS error pages when Link Doctor loads. 672 // Make sure probes don't break non-DNS error pages when Link Doctor loads.
649 IN_PROC_BROWSER_TEST_F(DnsProbeBrowserTest, OtherErrorWithWorkingLinkDoctor) { 673 IN_PROC_BROWSER_TEST_F(DnsProbeBrowserTest, OtherErrorWithWorkingLinkDoctor) {
650 SetLinkDoctorBroken(false); 674 SetLinkDoctorBroken(false);
651 675
652 NavigateToOtherError(2); 676 NavigateToOtherError(2);
653 EXPECT_EQ("Mock Link Doctor", Title()); 677 ExpectDisplayingLinkDoctor("ERR_CONNECTION_REFUSED");
654 } 678 }
655 679
656 // Make sure probes don't break non-DNS error pages when Link Doctor doesn't 680 // Make sure probes don't break non-DNS error pages when Link Doctor doesn't
657 // load. 681 // load.
658 IN_PROC_BROWSER_TEST_F(DnsProbeBrowserTest, OtherErrorWithBrokenLinkDoctor) { 682 IN_PROC_BROWSER_TEST_F(DnsProbeBrowserTest, OtherErrorWithBrokenLinkDoctor) {
659 SetLinkDoctorBroken(true); 683 SetLinkDoctorBroken(true);
660 684
661 NavigateToOtherError(2); 685 NavigateToOtherError(2);
662 EXPECT_TRUE(PageContains("CONNECTION_REFUSED")); 686 ExpectDisplayingLocalErrorPage("ERR_CONNECTION_REFUSED");
663 } 687 }
664 688
665 // Make sure probes don't break DNS error pages when Link doctor loads. 689 // Make sure probes don't break DNS error pages when Link Doctor loads.
666 IN_PROC_BROWSER_TEST_F(DnsProbeBrowserTest, 690 IN_PROC_BROWSER_TEST_F(DnsProbeBrowserTest,
667 NxdomainProbeResultWithWorkingLinkDoctor) { 691 NxdomainProbeResultWithWorkingLinkDoctor) {
668 SetLinkDoctorBroken(false); 692 SetLinkDoctorBroken(false);
669 SetMockDnsClientRules(MockDnsClientRule::OK, MockDnsClientRule::OK); 693 SetMockDnsClientRules(MockDnsClientRule::OK, MockDnsClientRule::OK);
670 694
671 NavigateToDnsError(2); 695 NavigateToDnsError(2);
672 EXPECT_EQ("Mock Link Doctor", Title()); 696 ExpectDisplayingLinkDoctor("ERR_NAME_NOT_RESOLVED");
673 697
674 // One status for committing a blank page before the Link Doctor, and one for 698 // One status for committing a blank page before the Link Doctor, and one for
675 // when the Link Doctor is committed. 699 // when the Link Doctor is committed.
676 EXPECT_EQ(chrome_common_net::DNS_PROBE_STARTED, WaitForSentStatus()); 700 EXPECT_EQ(chrome_common_net::DNS_PROBE_STARTED, WaitForSentStatus());
677 EXPECT_EQ(chrome_common_net::DNS_PROBE_STARTED, WaitForSentStatus()); 701 EXPECT_EQ(chrome_common_net::DNS_PROBE_STARTED, WaitForSentStatus());
678 EXPECT_EQ(0, pending_status_count()); 702 EXPECT_EQ(0, pending_status_count());
679 EXPECT_EQ("Mock Link Doctor", Title()); 703 ExpectDisplayingLinkDoctor("ERR_NAME_NOT_RESOLVED");
680 704
681 StartDelayedProbes(1); 705 StartDelayedProbes(1);
682 706
683 EXPECT_EQ(chrome_common_net::DNS_PROBE_FINISHED_NXDOMAIN, 707 EXPECT_EQ(chrome_common_net::DNS_PROBE_FINISHED_NXDOMAIN,
684 WaitForSentStatus()); 708 WaitForSentStatus());
685 EXPECT_EQ(0, pending_status_count()); 709 EXPECT_EQ(0, pending_status_count());
686 EXPECT_EQ("Mock Link Doctor", Title()); 710 ExpectDisplayingLinkDoctor("ERR_NAME_NOT_RESOLVED");
687 } 711 }
688 712
689 // Make sure probes don't break Link Doctor when probes complete before the 713 // Make sure probes don't break Link Doctor when probes complete before the
690 // Link Doctor loads. 714 // Link Doctor loads.
691 IN_PROC_BROWSER_TEST_F(DnsProbeBrowserTest, 715 IN_PROC_BROWSER_TEST_F(DnsProbeBrowserTest,
692 NxdomainProbeResultWithWorkingSlowLinkDoctor) { 716 NxdomainProbeResultWithWorkingSlowLinkDoctor) {
693 SetLinkDoctorBroken(false); 717 SetLinkDoctorBroken(false);
694 SetLinkDoctorDelayRequests(true); 718 SetLinkDoctorDelayRequests(true);
695 SetMockDnsClientRules(MockDnsClientRule::OK, MockDnsClientRule::OK); 719 SetMockDnsClientRules(MockDnsClientRule::OK, MockDnsClientRule::OK);
696 720
(...skipping 12 matching lines...) Expand all
709 WaitForSentStatus()); 733 WaitForSentStatus());
710 EXPECT_EQ(0, pending_status_count()); 734 EXPECT_EQ(0, pending_status_count());
711 EXPECT_EQ("", Title()); 735 EXPECT_EQ("", Title());
712 736
713 content::TestNavigationObserver observer( 737 content::TestNavigationObserver observer(
714 browser()->tab_strip_model()->GetActiveWebContents(), 1); 738 browser()->tab_strip_model()->GetActiveWebContents(), 1);
715 // The Link Doctor page finishes loading. 739 // The Link Doctor page finishes loading.
716 SetLinkDoctorDelayRequests(false); 740 SetLinkDoctorDelayRequests(false);
717 // Wait for it to commit. 741 // Wait for it to commit.
718 observer.Wait(); 742 observer.Wait();
719 EXPECT_EQ("Mock Link Doctor", Title()); 743 ExpectDisplayingLinkDoctor("ERR_NAME_NOT_RESOLVED");
720 744
721 // Committing the Link Doctor page should trigger sending the probe result 745 // Committing the Link Doctor page should trigger sending the probe result
722 // again. 746 // again.
723 EXPECT_EQ(chrome_common_net::DNS_PROBE_FINISHED_NXDOMAIN, 747 EXPECT_EQ(chrome_common_net::DNS_PROBE_FINISHED_NXDOMAIN,
724 WaitForSentStatus()); 748 WaitForSentStatus());
725 EXPECT_EQ("Mock Link Doctor", Title()); 749 ExpectDisplayingLinkDoctor("ERR_NAME_NOT_RESOLVED");
726 } 750 }
727 751
728 // Make sure probes update DNS error page properly when they're supposed to. 752 // Make sure probes update DNS error page properly when they're supposed to.
729 IN_PROC_BROWSER_TEST_F(DnsProbeBrowserTest, 753 IN_PROC_BROWSER_TEST_F(DnsProbeBrowserTest,
730 NoInternetProbeResultWithBrokenLinkDoctor) { 754 NoInternetProbeResultWithBrokenLinkDoctor) {
731 SetLinkDoctorBroken(true); 755 SetLinkDoctorBroken(true);
732 SetMockDnsClientRules(MockDnsClientRule::TIMEOUT, 756 SetMockDnsClientRules(MockDnsClientRule::TIMEOUT,
733 MockDnsClientRule::TIMEOUT); 757 MockDnsClientRule::TIMEOUT);
734 758
735 NavigateToDnsError(2); 759 NavigateToDnsError(2);
736 760
737 EXPECT_EQ(chrome_common_net::DNS_PROBE_STARTED, WaitForSentStatus()); 761 EXPECT_EQ(chrome_common_net::DNS_PROBE_STARTED, WaitForSentStatus());
738 EXPECT_EQ(chrome_common_net::DNS_PROBE_STARTED, WaitForSentStatus()); 762 EXPECT_EQ(chrome_common_net::DNS_PROBE_STARTED, WaitForSentStatus());
739 763
740 // PageContains runs the RunLoop, so make sure nothing hairy happens. 764 // Checking the page runs the RunLoop, so make sure nothing hairy happens.
741 EXPECT_EQ(0, pending_status_count()); 765 EXPECT_EQ(0, pending_status_count());
742 EXPECT_TRUE(PageContains("DNS_PROBE_STARTED")); 766 ExpectDisplayingLocalErrorPage("DNS_PROBE_STARTED");
743 EXPECT_EQ(0, pending_status_count()); 767 EXPECT_EQ(0, pending_status_count());
744 768
745 StartDelayedProbes(1); 769 StartDelayedProbes(1);
746 770
747 EXPECT_EQ(chrome_common_net::DNS_PROBE_FINISHED_NO_INTERNET, 771 EXPECT_EQ(chrome_common_net::DNS_PROBE_FINISHED_NO_INTERNET,
748 WaitForSentStatus()); 772 WaitForSentStatus());
749 773
750 // PageContains runs the RunLoop, so make sure nothing hairy happens. 774 // Checking the page runs the RunLoop, so make sure nothing hairy happens.
751 EXPECT_EQ(0, pending_status_count()); 775 EXPECT_EQ(0, pending_status_count());
752 EXPECT_TRUE(PageContains("DNS_PROBE_FINISHED_NO_INTERNET")); 776 ExpectDisplayingLocalErrorPage("DNS_PROBE_FINISHED_NO_INTERNET");
753 } 777 }
754 778
755 // Make sure probes don't break Link Doctor when probes complete before the 779 // Make sure probes don't break Link Doctor when probes complete before the
756 // Link Doctor request returns an error. 780 // Link Doctor request returns an error.
757 IN_PROC_BROWSER_TEST_F(DnsProbeBrowserTest, 781 IN_PROC_BROWSER_TEST_F(DnsProbeBrowserTest,
758 NoInternetProbeResultWithSlowBrokenLinkDoctor) { 782 NoInternetProbeResultWithSlowBrokenLinkDoctor) {
759 SetLinkDoctorBroken(true); 783 SetLinkDoctorBroken(true);
760 SetLinkDoctorDelayRequests(true); 784 SetLinkDoctorDelayRequests(true);
761 SetMockDnsClientRules(MockDnsClientRule::TIMEOUT, 785 SetMockDnsClientRules(MockDnsClientRule::TIMEOUT,
762 MockDnsClientRule::TIMEOUT); 786 MockDnsClientRule::TIMEOUT);
(...skipping 18 matching lines...) Expand all
781 browser()->tab_strip_model()->GetActiveWebContents(), 1); 805 browser()->tab_strip_model()->GetActiveWebContents(), 1);
782 // The Link Doctor request fails. 806 // The Link Doctor request fails.
783 SetLinkDoctorDelayRequests(false); 807 SetLinkDoctorDelayRequests(false);
784 // Wait for the DNS error page to load instead. 808 // Wait for the DNS error page to load instead.
785 observer.Wait(); 809 observer.Wait();
786 // The page committing should result in sending the probe results again. 810 // The page committing should result in sending the probe results again.
787 EXPECT_EQ(chrome_common_net::DNS_PROBE_FINISHED_NO_INTERNET, 811 EXPECT_EQ(chrome_common_net::DNS_PROBE_FINISHED_NO_INTERNET,
788 WaitForSentStatus()); 812 WaitForSentStatus());
789 813
790 EXPECT_EQ(0, pending_status_count()); 814 EXPECT_EQ(0, pending_status_count());
791 EXPECT_TRUE(PageContains("DNS_PROBE_FINISHED_NO_INTERNET")); 815 ExpectDisplayingLocalErrorPage("DNS_PROBE_FINISHED_NO_INTERNET");
792 } 816 }
793 817
794 // Double-check to make sure sync failures don't explode. 818 // Double-check to make sure sync failures don't explode.
795 IN_PROC_BROWSER_TEST_F(DnsProbeBrowserTest, SyncFailureWithBrokenLinkDoctor) { 819 IN_PROC_BROWSER_TEST_F(DnsProbeBrowserTest, SyncFailureWithBrokenLinkDoctor) {
796 SetLinkDoctorBroken(true); 820 SetLinkDoctorBroken(true);
797 SetMockDnsClientRules(MockDnsClientRule::FAIL, MockDnsClientRule::FAIL); 821 SetMockDnsClientRules(MockDnsClientRule::FAIL, MockDnsClientRule::FAIL);
798 822
799 NavigateToDnsError(2); 823 NavigateToDnsError(2);
800 824
801 EXPECT_EQ(chrome_common_net::DNS_PROBE_STARTED, WaitForSentStatus()); 825 EXPECT_EQ(chrome_common_net::DNS_PROBE_STARTED, WaitForSentStatus());
802 EXPECT_EQ(chrome_common_net::DNS_PROBE_STARTED, WaitForSentStatus()); 826 EXPECT_EQ(chrome_common_net::DNS_PROBE_STARTED, WaitForSentStatus());
803 827
804 // PageContains runs the RunLoop, so make sure nothing hairy happens. 828 // Checking the page runs the RunLoop, so make sure nothing hairy happens.
805 EXPECT_EQ(0, pending_status_count()); 829 EXPECT_EQ(0, pending_status_count());
806 EXPECT_TRUE(PageContains("DNS_PROBE_STARTED")); 830 ExpectDisplayingLocalErrorPage("DNS_PROBE_STARTED");
807 EXPECT_EQ(0, pending_status_count()); 831 EXPECT_EQ(0, pending_status_count());
808 832
809 StartDelayedProbes(1); 833 StartDelayedProbes(1);
810 834
811 EXPECT_EQ(chrome_common_net::DNS_PROBE_FINISHED_INCONCLUSIVE, 835 EXPECT_EQ(chrome_common_net::DNS_PROBE_FINISHED_INCONCLUSIVE,
812 WaitForSentStatus()); 836 WaitForSentStatus());
813 837
814 // PageContains runs the RunLoop, so make sure nothing hairy happens. 838 // Checking the page runs the RunLoop, so make sure nothing hairy happens.
815 EXPECT_EQ(0, pending_status_count()); 839 EXPECT_EQ(0, pending_status_count());
816 EXPECT_TRUE(PageContains("NAME_NOT_RESOLVED")); 840 ExpectDisplayingLocalErrorPage("ERR_NAME_NOT_RESOLVED");
817 EXPECT_EQ(0, pending_status_count()); 841 EXPECT_EQ(0, pending_status_count());
818 } 842 }
819 843
820 // Test that pressing the stop button cancels loading the Link Doctor page. 844 // Test that pressing the stop button cancels loading the Link Doctor page.
821 // TODO(mmenke): Add a test for the cross process navigation case. 845 // TODO(mmenke): Add a test for the cross process navigation case.
822 // TODO(mmenke): This test could flakily pass due to the timeout on downloading 846 // TODO(mmenke): This test could flakily pass due to the timeout on downloading
823 // the Link Doctor page. Disable that timeout for browser tests. 847 // the Link Doctor page. Disable that timeout for browser tests.
824 IN_PROC_BROWSER_TEST_F(DnsProbeBrowserTest, LinkDoctorLoadStopped) { 848 IN_PROC_BROWSER_TEST_F(DnsProbeBrowserTest, LinkDoctorLoadStopped) {
825 SetLinkDoctorDelayRequests(true); 849 SetLinkDoctorDelayRequests(true);
826 SetLinkDoctorBroken(true); 850 SetLinkDoctorBroken(true);
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
896 browser()->profile()->GetPrefs()->SetBoolean( 920 browser()->profile()->GetPrefs()->SetBoolean(
897 prefs::kAlternateErrorPagesEnabled, false); 921 prefs::kAlternateErrorPagesEnabled, false);
898 922
899 SetLinkDoctorBroken(true); 923 SetLinkDoctorBroken(true);
900 SetMockDnsClientRules(MockDnsClientRule::TIMEOUT, MockDnsClientRule::TIMEOUT); 924 SetMockDnsClientRules(MockDnsClientRule::TIMEOUT, MockDnsClientRule::TIMEOUT);
901 925
902 NavigateToDnsError(1); 926 NavigateToDnsError(1);
903 927
904 EXPECT_EQ(chrome_common_net::DNS_PROBE_NOT_RUN, WaitForSentStatus()); 928 EXPECT_EQ(chrome_common_net::DNS_PROBE_NOT_RUN, WaitForSentStatus());
905 929
906 // PageContains runs the RunLoop, so make sure nothing hairy happens. 930 // Checking the page runs the RunLoop, so make sure nothing hairy happens.
907 EXPECT_EQ(0, pending_status_count()); 931 EXPECT_EQ(0, pending_status_count());
908 EXPECT_TRUE(PageContains("NAME_NOT_RESOLVED")); 932 ExpectDisplayingLocalErrorPage("ERR_NAME_NOT_RESOLVED");
909 } 933 }
910 934
911 // Test the case that Link Doctor is disabled, but DNS probes are enabled. This 935 // Test the case that Link Doctor is disabled, but DNS probes are enabled. This
912 // is the case with Chromium builds. 936 // is the case with Chromium builds.
913 IN_PROC_BROWSER_TEST_F(DnsProbeBrowserTest, LinkDoctorDisabled) { 937 IN_PROC_BROWSER_TEST_F(DnsProbeBrowserTest, LinkDoctorDisabled) {
914 // Disable Link Doctor. 938 // Disable Link Doctor.
915 browser()->profile()->GetPrefs()->SetBoolean( 939 browser()->profile()->GetPrefs()->SetBoolean(
916 prefs::kAlternateErrorPagesEnabled, false); 940 prefs::kAlternateErrorPagesEnabled, false);
917 // Requests to the Link Doctor should work if any are made, so the test fails 941 // Requests to the Link Doctor should work if any are made, so the test fails
918 // if that happens unexpectedly. 942 // if that happens unexpectedly.
919 SetLinkDoctorBroken(false); 943 SetLinkDoctorBroken(false);
920 // Normally disabling the LinkDoctor disables DNS probes, so force DNS probes 944 // Normally disabling the LinkDoctor disables DNS probes, so force DNS probes
921 // to be enabled. 945 // to be enabled.
922 NetErrorTabHelper::set_state_for_testing( 946 NetErrorTabHelper::set_state_for_testing(
923 NetErrorTabHelper::TESTING_FORCE_ENABLED); 947 NetErrorTabHelper::TESTING_FORCE_ENABLED);
924 948
925 SetMockDnsClientRules(MockDnsClientRule::FAIL, MockDnsClientRule::FAIL); 949 SetMockDnsClientRules(MockDnsClientRule::FAIL, MockDnsClientRule::FAIL);
926 950
927 // Just one commit and one sent status, since the Link Doctor is disabled. 951 // Just one commit and one sent status, since the Link Doctor is disabled.
928 NavigateToDnsError(1); 952 NavigateToDnsError(1);
929 EXPECT_EQ(chrome_common_net::DNS_PROBE_STARTED, WaitForSentStatus()); 953 EXPECT_EQ(chrome_common_net::DNS_PROBE_STARTED, WaitForSentStatus());
930 954
931 // PageContains runs the RunLoop, so make sure nothing hairy happens. 955 // Checking the page runs the RunLoop, so make sure nothing hairy happens.
932 EXPECT_EQ(0, pending_status_count()); 956 EXPECT_EQ(0, pending_status_count());
933 EXPECT_TRUE(PageContains("DNS_PROBE_STARTED")); 957 ExpectDisplayingLocalErrorPage("DNS_PROBE_STARTED");
934 EXPECT_EQ(0, pending_status_count()); 958 EXPECT_EQ(0, pending_status_count());
935 959
936 StartDelayedProbes(1); 960 StartDelayedProbes(1);
937 961
938 EXPECT_EQ(chrome_common_net::DNS_PROBE_FINISHED_INCONCLUSIVE, 962 EXPECT_EQ(chrome_common_net::DNS_PROBE_FINISHED_INCONCLUSIVE,
939 WaitForSentStatus()); 963 WaitForSentStatus());
940 EXPECT_EQ(0, pending_status_count()); 964 EXPECT_EQ(0, pending_status_count());
941 EXPECT_TRUE(PageContains("NAME_NOT_RESOLVED")); 965 ExpectDisplayingLocalErrorPage("ERR_NAME_NOT_RESOLVED");
942 } 966 }
943 967
944 // Test incognito mode. Link Doctor should be disabled, but DNS probes are 968 // Test incognito mode. Link Doctor should be disabled, but DNS probes are
945 // still enabled. 969 // still enabled.
946 IN_PROC_BROWSER_TEST_F(DnsProbeBrowserTest, Incognito) { 970 IN_PROC_BROWSER_TEST_F(DnsProbeBrowserTest, Incognito) {
947 // Requests to the Link Doctor should work if any are made, so the test will 971 // Requests to the Link Doctor should work if any are made, so the test will
948 // fail if one is requested unexpectedly. 972 // fail if one is requested unexpectedly.
949 SetLinkDoctorBroken(false); 973 SetLinkDoctorBroken(false);
950 974
951 Browser* incognito = CreateIncognitoBrowser(); 975 Browser* incognito = CreateIncognitoBrowser();
952 SetActiveBrowser(incognito); 976 SetActiveBrowser(incognito);
953 977
954 SetMockDnsClientRules(MockDnsClientRule::FAIL, MockDnsClientRule::FAIL); 978 SetMockDnsClientRules(MockDnsClientRule::FAIL, MockDnsClientRule::FAIL);
955 979
956 // Just one commit and one sent status, since the Link Doctor is disabled. 980 // Just one commit and one sent status, since the Link Doctor is disabled.
957 NavigateToDnsError(1); 981 NavigateToDnsError(1);
958 EXPECT_EQ(chrome_common_net::DNS_PROBE_STARTED, WaitForSentStatus()); 982 EXPECT_EQ(chrome_common_net::DNS_PROBE_STARTED, WaitForSentStatus());
959 983
960 // PageContains runs the RunLoop, so make sure nothing hairy happens. 984 // Checking the page runs the RunLoop, so make sure nothing hairy happens.
961 EXPECT_EQ(0, pending_status_count()); 985 EXPECT_EQ(0, pending_status_count());
962 EXPECT_TRUE(PageContains("DNS_PROBE_STARTED")); 986 ExpectDisplayingLocalErrorPage("DNS_PROBE_STARTED");
963 EXPECT_EQ(0, pending_status_count()); 987 EXPECT_EQ(0, pending_status_count());
964 988
965 StartDelayedProbes(1); 989 StartDelayedProbes(1);
966 990
967 EXPECT_EQ(chrome_common_net::DNS_PROBE_FINISHED_INCONCLUSIVE, 991 EXPECT_EQ(chrome_common_net::DNS_PROBE_FINISHED_INCONCLUSIVE,
968 WaitForSentStatus()); 992 WaitForSentStatus());
969 EXPECT_EQ(0, pending_status_count()); 993 EXPECT_EQ(0, pending_status_count());
970 EXPECT_TRUE(PageContains("NAME_NOT_RESOLVED")); 994 ExpectDisplayingLocalErrorPage("ERR_NAME_NOT_RESOLVED");
971 } 995 }
972 996
973 } // namespace 997 } // namespace
974 998
975 } // namespace chrome_browser_net 999 } // namespace chrome_browser_net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698