Index: chrome/browser/net/dns_probe_browsertest.cc |
diff --git a/chrome/browser/net/dns_probe_browsertest.cc b/chrome/browser/net/dns_probe_browsertest.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..0ec34f7c93fbe3755f246ebaf849831c5d6c0a88 |
--- /dev/null |
+++ b/chrome/browser/net/dns_probe_browsertest.cc |
@@ -0,0 +1,513 @@ |
+// Copyright (c) 2013 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "base/bind.h" |
+#include "base/memory/scoped_ptr.h" |
+#include "base/message_loop.h" |
+#include "base/path_service.h" |
+#include "base/threading/thread_restrictions.h" |
+#include "chrome/browser/browser_process.h" |
+#include "chrome/browser/google/google_util.h" |
+#include "chrome/browser/io_thread.h" |
+#include "chrome/browser/net/dns_probe_test_util.h" |
+#include "chrome/browser/net/net_error_tab_helper.h" |
+#include "chrome/browser/net/url_request_mock_util.h" |
+#include "chrome/browser/ui/browser.h" |
+#include "chrome/browser/ui/tabs/tab_strip_model.h" |
+#include "chrome/common/chrome_paths.h" |
+#include "chrome/common/net/net_error_info.h" |
+#include "chrome/test/base/in_process_browser_test.h" |
+#include "chrome/test/base/ui_test_utils.h" |
+#include "content/public/browser/browser_thread.h" |
+#include "content/public/browser/web_contents.h" |
+#include "content/public/test/browser_test_utils.h" |
+#include "content/test/net/url_request_failed_job.h" |
+#include "content/test/net/url_request_mock_http_job.h" |
+#include "net/base/net_errors.h" |
+#include "net/dns/dns_test_util.h" |
+#include "net/url_request/url_request_filter.h" |
+#include "net/url_request/url_request_job.h" |
+#include "net/url_request/url_request_job_factory.h" |
+ |
+using base::Bind; |
+using base::Callback; |
+using base::Closure; |
+using base::ConstRef; |
+using base::FilePath; |
+using base::MessageLoop; |
+using base::Unretained; |
+using chrome_common_net::DnsProbeStatus; |
+using content::BrowserThread; |
+using content::URLRequestFailedJob; |
+using content::URLRequestMockHTTPJob; |
+using content::WebContents; |
+using google_util::LinkDoctorBaseURL; |
+using net::MockDnsClientRule; |
+using net::NetworkDelegate; |
+using net::URLRequest; |
+using net::URLRequestFilter; |
+using net::URLRequestJob; |
+using net::URLRequestJobFactory; |
+using ui_test_utils::NavigateToURL; |
+using ui_test_utils::NavigateToURLBlockUntilNavigationsComplete; |
+ |
+namespace chrome_browser_net { |
+ |
+namespace { |
+ |
+class DelayingDnsProbeService : public DnsProbeService { |
mmenke
2013/06/28 18:06:19
Think this is worth a comment (Both what it does a
Deprecated (see juliatuttle)
2013/07/01 17:39:55
Done.
|
+ public: |
+ DelayingDnsProbeService() : DnsProbeService() {} |
mmenke
2013/06/28 18:06:19
nit: " : DnsProbeService()" not needed.
Deprecated (see juliatuttle)
2013/07/01 17:39:55
Done.
|
+ |
+ virtual void ProbeDns(const ProbeCallback& callback) OVERRIDE { |
+ DnsProbeService::ProbeDns(Bind( |
+ &DelayingDnsProbeService::WouldCallCallback, |
+ Unretained(this), |
+ callback)); |
+ } |
+ |
+ void WouldCallCallback(const ProbeCallback& callback, |
+ DnsProbeStatus result) { |
+ delayed_callbacks_.push_back(Bind(callback, result)); |
+ } |
+ |
+ void CallDelayedCallbacks() { |
mmenke
2013/06/28 18:06:19
BUG: We could have an async call to CallCallbacks
Deprecated (see juliatuttle)
2013/07/01 17:39:55
Done.
|
+ std::vector<Closure> callbacks; |
+ callbacks.swap(delayed_callbacks_); |
+ |
+ for (std::vector<Closure>::const_iterator i = callbacks.begin(); |
+ i != callbacks.end(); ++i) { |
+ i->Run(); |
+ } |
+ } |
+ |
+ int delayed_callback_count() const { return delayed_callbacks_.size(); } |
+ |
+ private: |
+ std::vector<Closure> delayed_callbacks_; |
+}; |
+ |
+FilePath GetMockLinkDoctorFilePath() { |
+ FilePath root_http; |
+ PathService::Get(chrome::DIR_TEST_DATA, &root_http); |
+ return root_http.AppendASCII("mock-link-doctor.html"); |
+} |
+ |
+class BrokenLinkDoctorProtocolHandler |
+ : public URLRequestJobFactory::ProtocolHandler { |
+ public: |
+ explicit BrokenLinkDoctorProtocolHandler( |
+ const FilePath& mock_link_doctor_file_path) |
+ : mock_link_doctor_file_path_(mock_link_doctor_file_path), |
+ net_error_(net::OK) {} |
+ |
+ virtual ~BrokenLinkDoctorProtocolHandler() {} |
+ |
+ virtual URLRequestJob* MaybeCreateJob( |
+ URLRequest* request, NetworkDelegate* network_delegate) const OVERRIDE { |
+ if (net_error_ != net::OK) { |
+ return new URLRequestFailedJob(request, network_delegate, net_error_); |
+ } else { |
+ return new URLRequestMockHTTPJob( |
+ request, network_delegate, mock_link_doctor_file_path_); |
+ } |
+ } |
+ |
+ void set_net_error(int net_error) { net_error_ = net_error; } |
+ |
+ private: |
+ const FilePath mock_link_doctor_file_path_; |
+ int net_error_; |
+}; |
+ |
+class DnsProbeBrowserTestIOThreadHelper { |
+ public: |
+ DnsProbeBrowserTestIOThreadHelper(); |
+ |
+ void SetUpOnIOThread(IOThread* io_thread); |
+ void CleanUpOnIOThreadAndDeleteHelper(); |
+ |
+ void SetMockDnsClientRules(MockDnsClientRule::Result system_good_result, |
+ MockDnsClientRule::Result public_good_result); |
+ void SetLinkDoctorNetError(int link_doctor_net_error); |
+ void CallDelayedProbeCallbacks(int expected_delayed_callback_count); |
+ |
+ private: |
+ IOThread* io_thread_; |
+ DnsProbeService* original_dns_probe_service_; |
+ DelayingDnsProbeService* delaying_dns_probe_service_; |
+ BrokenLinkDoctorProtocolHandler* protocol_handler_; |
+ FilePath mock_link_doctor_file_path_; |
+}; |
+ |
+DnsProbeBrowserTestIOThreadHelper::DnsProbeBrowserTestIOThreadHelper() |
+ : io_thread_(NULL), |
+ original_dns_probe_service_(NULL), |
+ delaying_dns_probe_service_(NULL), |
+ protocol_handler_(NULL), |
+ mock_link_doctor_file_path_(GetMockLinkDoctorFilePath()) {} |
+ |
+void DnsProbeBrowserTestIOThreadHelper::SetUpOnIOThread(IOThread* io_thread) { |
+ CHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
+ CHECK(io_thread); |
+ CHECK(!io_thread_); |
+ CHECK(!original_dns_probe_service_); |
+ CHECK(!delaying_dns_probe_service_); |
+ CHECK(!protocol_handler_); |
+ |
+ io_thread_ = io_thread; |
+ |
+ delaying_dns_probe_service_ = new DelayingDnsProbeService(); |
+ |
+ IOThread::Globals* globals = io_thread_->globals(); |
+ original_dns_probe_service_ = globals->dns_probe_service.release(); |
+ globals->dns_probe_service.reset(delaying_dns_probe_service_); |
+ |
+ URLRequestFailedJob::AddUrlHandler(); |
+ |
+ scoped_ptr<URLRequestJobFactory::ProtocolHandler> protocol_handler( |
+ new BrokenLinkDoctorProtocolHandler(mock_link_doctor_file_path_)); |
+ protocol_handler_ = |
+ static_cast<BrokenLinkDoctorProtocolHandler*>(protocol_handler.get()); |
+ const GURL link_doctor_base_url = LinkDoctorBaseURL(); |
+ const std::string link_doctor_host = link_doctor_base_url.host(); |
+ URLRequestFilter::GetInstance()->AddHostnameProtocolHandler( |
+ "http", link_doctor_host, protocol_handler.Pass()); |
+ |
mmenke
2013/06/28 18:06:19
nit: Remove blank line.
Deprecated (see juliatuttle)
2013/07/01 17:39:55
Done.
|
+} |
+ |
+void DnsProbeBrowserTestIOThreadHelper::CleanUpOnIOThreadAndDeleteHelper() { |
+ CHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
+ |
+ URLRequestFilter::GetInstance()->ClearHandlers(); |
+ |
+ DnsProbeService* delaying_dns_probe_service; |
+ |
+ IOThread::Globals* globals = io_thread_->globals(); |
mmenke
2013/06/28 18:06:19
optional: Feels safest to me to just always keep
Deprecated (see juliatuttle)
2013/07/01 17:39:55
Done.
|
+ delaying_dns_probe_service = globals->dns_probe_service.release(); |
+ globals->dns_probe_service.reset(original_dns_probe_service_); |
+ |
+ CHECK_EQ(delaying_dns_probe_service_, delaying_dns_probe_service); |
+ delete delaying_dns_probe_service_; |
+ |
+ delete this; |
+} |
+ |
+void DnsProbeBrowserTestIOThreadHelper::SetMockDnsClientRules( |
+ MockDnsClientRule::Result system_result, |
+ MockDnsClientRule::Result public_result) { |
mmenke
2013/06/28 18:06:19
CHECK(BrowserThread::CurrentlyOn(BrowserThread::IO
Deprecated (see juliatuttle)
2013/07/01 17:39:55
Done.
|
+ DnsProbeService* service = io_thread_->globals()->dns_probe_service.get(); |
+ service->SetSystemClientForTesting( |
+ CreateMockDnsClientForProbes(system_result)); |
+ service->SetPublicClientForTesting( |
+ CreateMockDnsClientForProbes(public_result)); |
+} |
+ |
+void DnsProbeBrowserTestIOThreadHelper::SetLinkDoctorNetError( |
+ int link_doctor_net_error) { |
mmenke
2013/06/28 18:06:19
CHECK(BrowserThread::CurrentlyOn(BrowserThread::IO
Deprecated (see juliatuttle)
2013/07/01 17:39:55
Done.
|
+ protocol_handler_->set_net_error(link_doctor_net_error); |
+} |
+ |
+void DnsProbeBrowserTestIOThreadHelper::CallDelayedProbeCallbacks( |
+ int expected_delayed_callback_count) { |
mmenke
2013/06/28 18:06:19
CHECK(BrowserThread::CurrentlyOn(BrowserThread::IO
Deprecated (see juliatuttle)
2013/07/01 17:39:55
Done.
|
+ CHECK(delaying_dns_probe_service_); |
+ |
+ if (expected_delayed_callback_count >= 0) { |
mmenke
2013/06/28 18:06:19
nit: Is this needed?
Deprecated (see juliatuttle)
2013/07/01 17:39:55
Done.
|
+ int actual_delayed_callback_count = |
+ delaying_dns_probe_service_->delayed_callback_count(); |
+ EXPECT_EQ(expected_delayed_callback_count, actual_delayed_callback_count); |
+ } |
+ |
+ delaying_dns_probe_service_->CallDelayedCallbacks(); |
+} |
+ |
+class DnsProbeBrowserTest : public InProcessBrowserTest { |
+ public: |
+ DnsProbeBrowserTest(); |
+ |
+ virtual void SetUpOnMainThread() OVERRIDE; |
+ virtual void CleanUpOnMainThread() OVERRIDE; |
+ |
+ protected: |
+ void SetLinkDoctorBroken(bool broken); |
+ void SetMockDnsClientRules(MockDnsClientRule::Result system_result, |
+ MockDnsClientRule::Result public_result); |
+ void NavigateToDnsError(); |
+ void NavigateToOtherError(); |
+ |
+ void CallDelayedProbeCallbacks(int expected_delayed_callback_count); |
+ DnsProbeStatus WaitForSentStatus(); |
+ int dns_probe_status_count() const { return dns_probe_status_count_; } |
+ |
+ bool TitleIs(const std::string& expected); |
+ bool PageContains(const std::string& expected); |
+ |
+ private: |
+ void OnDnsProbeStatusSent(DnsProbeStatus dns_probe_status); |
+ |
+ DnsProbeBrowserTestIOThreadHelper* helper_; |
+ |
+ bool awaiting_dns_probe_status_; |
+ int dns_probe_status_count_; |
+ std::list<DnsProbeStatus> dns_probe_statuses_; |
+}; |
+ |
+DnsProbeBrowserTest::DnsProbeBrowserTest() |
+ : helper_(new DnsProbeBrowserTestIOThreadHelper()), |
+ awaiting_dns_probe_status_(false), |
+ dns_probe_status_count_(0) { |
+} |
+ |
+void DnsProbeBrowserTest::SetUpOnMainThread() { |
+ NetErrorTabHelper::set_state_for_testing( |
+ NetErrorTabHelper::TESTING_FORCE_ENABLED); |
+ |
+ CHECK(helper_); |
mmenke
2013/06/28 18:06:19
optional: This seems like overkill, since we neve
Deprecated (see juliatuttle)
2013/07/01 17:39:55
Done.
|
+ BrowserThread::PostTask( |
+ BrowserThread::IO, FROM_HERE, |
+ Bind(&DnsProbeBrowserTestIOThreadHelper::SetUpOnIOThread, |
+ Unretained(helper_), |
+ g_browser_process->io_thread())); |
+ |
+ NetErrorTabHelper* tab_helper = NetErrorTabHelper::FromWebContents( |
+ browser()->tab_strip_model()->GetActiveWebContents()); |
+ tab_helper->set_dns_probe_status_snoop_callback_for_testing(Bind( |
+ &DnsProbeBrowserTest::OnDnsProbeStatusSent, |
+ Unretained(this))); |
+} |
+ |
+void DnsProbeBrowserTest::CleanUpOnMainThread() { |
+ CHECK(helper_); |
+ BrowserThread::PostTask( |
+ BrowserThread::IO, FROM_HERE, |
+ Bind(&DnsProbeBrowserTestIOThreadHelper::CleanUpOnIOThreadAndDeleteHelper, |
+ Unretained(helper_))); |
+ |
+ NetErrorTabHelper::set_state_for_testing( |
+ NetErrorTabHelper::TESTING_DEFAULT); |
+} |
+ |
+void DnsProbeBrowserTest::SetLinkDoctorBroken(bool broken) { |
+ int net_error = broken ? net::ERR_NAME_NOT_RESOLVED : net::OK; |
+ |
+ BrowserThread::PostTask( |
+ BrowserThread::IO, FROM_HERE, |
+ Bind(&DnsProbeBrowserTestIOThreadHelper::SetLinkDoctorNetError, |
+ Unretained(helper_), |
+ net_error)); |
+} |
+ |
+// These two functions wait for two navigations because Link Doctor loads two |
+// pages: a blank page, so the user stops seeing the previous page, and then |
+// either the Link Doctor page or a regular error page. We want to wait for |
+// the error page, so we wait for both loads to finish. |
+ |
+void DnsProbeBrowserTest::NavigateToDnsError() { |
+ NavigateToURLBlockUntilNavigationsComplete( |
+ browser(), |
+ URLRequestFailedJob::GetMockHttpUrl(net::ERR_NAME_NOT_RESOLVED), |
+ 2); |
+} |
+ |
+void DnsProbeBrowserTest::NavigateToOtherError() { |
+ NavigateToURLBlockUntilNavigationsComplete( |
+ browser(), |
+ URLRequestFailedJob::GetMockHttpUrl(net::ERR_CONNECTION_REFUSED), |
+ 2); |
+} |
mmenke
2013/06/28 18:06:19
Hmm...Worth the effort of a test with link doctor
Deprecated (see juliatuttle)
2013/07/01 17:39:55
Not in this CL, but sure.
|
+ |
+void DnsProbeBrowserTest::SetMockDnsClientRules( |
+ MockDnsClientRule::Result system_result, |
+ MockDnsClientRule::Result public_result) { |
+ BrowserThread::PostTask( |
+ BrowserThread::IO, FROM_HERE, |
+ Bind(&DnsProbeBrowserTestIOThreadHelper::SetMockDnsClientRules, |
+ Unretained(helper_), |
+ system_result, |
+ public_result)); |
+} |
+ |
+void DnsProbeBrowserTest::CallDelayedProbeCallbacks( |
+ int expected_delayed_callback_count) { |
+ BrowserThread::PostTask( |
+ BrowserThread::IO, FROM_HERE, |
+ Bind(&DnsProbeBrowserTestIOThreadHelper::CallDelayedProbeCallbacks, |
+ Unretained(helper_), |
+ expected_delayed_callback_count)); |
+} |
+ |
+DnsProbeStatus DnsProbeBrowserTest::WaitForSentStatus() { |
+ CHECK(!awaiting_dns_probe_status_); |
+ while (dns_probe_statuses_.empty()) { |
+ awaiting_dns_probe_status_ = true; |
+ MessageLoop::current()->Run(); |
mmenke
2013/06/28 18:06:19
RunLoop is now "right" way of doing this.
I belie
Deprecated (see juliatuttle)
2013/07/01 17:39:55
I think I am doing something wrong; I tried sticki
mmenke
2013/07/01 18:11:44
Sorry, I thought I'd told you, I'm taking a week o
|
+ awaiting_dns_probe_status_ = false; |
+ } |
+ |
+ CHECK(!dns_probe_statuses_.empty()); |
+ DnsProbeStatus status = dns_probe_statuses_.front(); |
+ dns_probe_statuses_.pop_front(); |
+ return status; |
+} |
+ |
+// Check title by roundtripping to renderer, to make sure any probe results |
+// sent before this have been applied. |
+bool DnsProbeBrowserTest::TitleIs(const std::string& expected) { |
mmenke
2013/06/28 18:06:19
Suggest making this return the title instead of a
Deprecated (see juliatuttle)
2013/07/01 17:39:55
Done.
|
+ std::string title; |
+ |
+ WebContents* contents = |
+ browser()->tab_strip_model()->GetActiveWebContents(); |
+ |
+ bool rv = content::ExecuteScriptAndExtractString( |
+ contents, |
+ "domAutomationController.send(document.title);", |
+ &title); |
+ if (!rv) |
+ return false; |
+ |
+ return title == expected; |
+} |
+ |
+// Check text by roundtripping to renderer, to make sure any probe results |
+// sent before this have been applied. |
+bool DnsProbeBrowserTest::PageContains(const std::string& expected) { |
+ std::string text_content; |
+ |
+ bool rv = content::ExecuteScriptAndExtractString( |
+ browser()->tab_strip_model()->GetActiveWebContents(), |
+ "domAutomationController.send(document.body.textContent);", |
+ &text_content); |
+ if (!rv) |
+ return false; |
+ |
+ return text_content.find(expected) != std::string::npos; |
+} |
+ |
+void DnsProbeBrowserTest::OnDnsProbeStatusSent( |
+ DnsProbeStatus dns_probe_status) { |
+ dns_probe_statuses_.push_back(dns_probe_status); |
+ |
+ dns_probe_status_count_++; |
+ if (awaiting_dns_probe_status_) |
+ MessageLoop::current()->Quit(); |
+} |
+ |
+IN_PROC_BROWSER_TEST_F(DnsProbeBrowserTest, OtherErrorWithLinkDoctor) { |
+ SetLinkDoctorBroken(false); |
+ |
+ NavigateToOtherError(); |
+ EXPECT_TRUE(TitleIs("Mock Link Doctor")); |
+ |
+ EXPECT_EQ(0, dns_probe_status_count()); |
mmenke
2013/06/28 18:06:19
Should we do something like "CallDelayedProbeCallb
Deprecated (see juliatuttle)
2013/07/01 17:39:55
Done.
|
+} |
+ |
+IN_PROC_BROWSER_TEST_F(DnsProbeBrowserTest, OtherErrorWithoutLinkDoctor) { |
mmenke
2013/06/28 18:06:19
Do we care about an error page that doesn't try to
Deprecated (see juliatuttle)
2013/07/01 17:39:55
This is mostly here to ensure that GetErrorStringF
|
+ SetLinkDoctorBroken(true); |
+ |
+ NavigateToOtherError(); |
+ EXPECT_TRUE(PageContains("CONNECTION_REFUSED")); |
+ |
+ EXPECT_EQ(0, dns_probe_status_count()); |
+} |
+ |
+IN_PROC_BROWSER_TEST_F(DnsProbeBrowserTest, NxdomainWithLinkDoctor) { |
mmenke
2013/06/28 18:06:19
Suggest a comment describing what this particular
Deprecated (see juliatuttle)
2013/07/01 17:39:55
Done.
|
+ SetLinkDoctorBroken(false); |
+ SetMockDnsClientRules(MockDnsClientRule::OK, MockDnsClientRule::OK); |
+ |
+ NavigateToDnsError(); |
+ EXPECT_TRUE(TitleIs("Mock Link Doctor")); |
mmenke
2013/06/28 18:06:19
We run probes and send messages here, think we sho
Deprecated (see juliatuttle)
2013/07/01 17:39:55
Done.
|
+} |
+ |
+IN_PROC_BROWSER_TEST_F(DnsProbeBrowserTest, NoInternetWithoutLinkDoctor) { |
+ SetLinkDoctorBroken(true); |
+ SetMockDnsClientRules(MockDnsClientRule::TIMEOUT, |
+ MockDnsClientRule::TIMEOUT); |
+ |
+ NavigateToDnsError(); |
+ |
+ EXPECT_EQ(chrome_common_net::DNS_PROBE_STARTED, WaitForSentStatus()); |
+ EXPECT_EQ(chrome_common_net::DNS_PROBE_STARTED, WaitForSentStatus()); |
+ |
+ // PageContains runs the RunLoop, so make sure nothing hairy happens. |
+ EXPECT_EQ(2, dns_probe_status_count()); |
+ EXPECT_TRUE(PageContains("DNS_PROBE_STARTED")); |
+ EXPECT_EQ(2, dns_probe_status_count()); |
+ |
+ CallDelayedProbeCallbacks(1); |
+ |
+ EXPECT_EQ(chrome_common_net::DNS_PROBE_FINISHED_NO_INTERNET, |
+ WaitForSentStatus()); |
+ |
+ // PageContains runs the RunLoop, so make sure nothing hairy happens. |
+ EXPECT_EQ(3, dns_probe_status_count()); |
+ EXPECT_TRUE(PageContains("DNS_PROBE_FINISHED_NO_INTERNET")); |
+ EXPECT_EQ(3, dns_probe_status_count()); |
+} |
+ |
+IN_PROC_BROWSER_TEST_F(DnsProbeBrowserTest, SyncFailureWithoutLinkDoctor) { |
+ SetLinkDoctorBroken(true); |
+ SetMockDnsClientRules(MockDnsClientRule::FAIL_SYNC, |
+ MockDnsClientRule::FAIL_SYNC); |
+ |
+ NavigateToDnsError(); |
+ |
+ EXPECT_EQ(chrome_common_net::DNS_PROBE_STARTED, WaitForSentStatus()); |
+ EXPECT_EQ(chrome_common_net::DNS_PROBE_STARTED, WaitForSentStatus()); |
+ |
+ // PageContains runs the RunLoop, so make sure nothing hairy happens. |
+ EXPECT_EQ(2, dns_probe_status_count()); |
+ EXPECT_TRUE(PageContains("DNS_PROBE_STARTED")); |
+ EXPECT_EQ(2, dns_probe_status_count()); |
+ |
+ CallDelayedProbeCallbacks(1); |
+ |
+ EXPECT_EQ(chrome_common_net::DNS_PROBE_FINISHED_UNKNOWN, |
+ WaitForSentStatus()); |
+ |
+ // PageContains runs the RunLoop, so make sure nothing hairy happens. |
+ EXPECT_EQ(3, dns_probe_status_count()); |
+ EXPECT_TRUE(PageContains("NAME_NOT_RESOLVED")); |
+ EXPECT_EQ(3, dns_probe_status_count()); |
+} |
+ |
+IN_PROC_BROWSER_TEST_F(DnsProbeBrowserTest, NoProbeInSubframe) { |
+ SetLinkDoctorBroken(false); |
+ |
+ const FilePath::CharType kIframeDnsErrorHtmlName[] = |
+ FILE_PATH_LITERAL("iframe_dns_error.html"); |
+ |
+ NavigateToURL( |
+ browser(), |
+ URLRequestMockHTTPJob::GetMockUrl(FilePath(kIframeDnsErrorHtmlName))); |
+ |
+ // By the time NavigateToURL returns, the browser will have seen the failed |
+ // provisional load. If a probe was started (or considered but not run), |
+ // then the NetErrorTabHelper would have sent a NetErrorInfo message. Thus, |
+ // if one hasn't been sent by now, the NetErrorTabHelper has not (and won't) |
+ // start a probe for this DNS error. |
+ EXPECT_EQ(0, dns_probe_status_count()); |
+} |
+ |
+IN_PROC_BROWSER_TEST_F(DnsProbeBrowserTest, ProbesDisabled) { |
+ NetErrorTabHelper::set_state_for_testing( |
+ NetErrorTabHelper::TESTING_FORCE_DISABLED); |
+ |
+ SetLinkDoctorBroken(true); |
+ SetMockDnsClientRules(MockDnsClientRule::TIMEOUT, |
+ MockDnsClientRule::TIMEOUT); |
+ |
+ NavigateToDnsError(); |
+ |
+ EXPECT_EQ(chrome_common_net::DNS_PROBE_NOT_RUN, WaitForSentStatus()); |
+ EXPECT_EQ(chrome_common_net::DNS_PROBE_NOT_RUN, WaitForSentStatus()); |
+ |
+ // PageContains runs the RunLoop, so make sure nothing hairy happens. |
+ EXPECT_EQ(2, dns_probe_status_count()); |
+ EXPECT_TRUE(PageContains("NAME_NOT_RESOLVED")); |
+ EXPECT_EQ(2, dns_probe_status_count()); |
+} |
+ |
+} // namespace |
+ |
+} // namespace chrome_browser_net |