summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/errorpage_browsertest.cc48
-rw-r--r--chrome/browser/errorpage_uitest.cc33
-rw-r--r--chrome/browser/google_util.cc3
-rw-r--r--chrome/browser/google_util.h2
-rw-r--r--chrome/browser/net/url_request_mock_link_doctor_job.cc40
-rw-r--r--chrome/browser/net/url_request_mock_link_doctor_job.h23
-rw-r--r--chrome/browser/net/url_request_mock_util.cc2
-rw-r--r--chrome/browser/tab_contents/tab_contents.cc6
-rw-r--r--chrome/chrome.gyp2
-rw-r--r--chrome/test/data/mock-link-doctor.html4
-rw-r--r--chrome/test/data/mock-link-doctor.html.mock-http-headers2
-rw-r--r--chrome/test/in_process_browser_test.cc3
12 files changed, 116 insertions, 52 deletions
diff --git a/chrome/browser/errorpage_browsertest.cc b/chrome/browser/errorpage_browsertest.cc
index 338c521..2a5a195 100644
--- a/chrome/browser/errorpage_browsertest.cc
+++ b/chrome/browser/errorpage_browsertest.cc
@@ -14,17 +14,6 @@
namespace {
class ErrorPageBrowserTest : public InProcessBrowserTest {
- protected:
- // We're generally not sure what the title will be exactly (it comes from
- // external source, and may be localized etc), but it will alway contain the
- // hostname, so we check for that.
- // For a proper way to do that http://crbug.com/18365 has been filed.
- void AssertCurrentTabTitleContains(const std::string& text) {
- string16 title;
- EXPECT_TRUE(ui_test_utils::GetCurrentTabTitle(browser(), &title));
- EXPECT_NE(string16::npos, title.find(ASCIIToUTF16(text))) <<
- "could not find \"" << text << "\" in \"" << title << "\"";
- }
};
using ui_test_utils::NavigateToURL;
@@ -35,23 +24,27 @@ using ui_test_utils::NavigateToURLBlockUntilNavigationsComplete;
IN_PROC_BROWSER_TEST_F(ErrorPageBrowserTest, DNSError_Basic) {
GURL test_url(URLRequestFailedDnsJob::kTestUrl);
+ string16 title;
+
NavigateToURLBlockUntilNavigationsComplete(browser(), test_url, 2);
- AssertCurrentTabTitleContains(test_url.host());
+ EXPECT_TRUE(ui_test_utils::GetCurrentTabTitle(browser(), &title));
+ EXPECT_EQ(ASCIIToUTF16("Mock Link Doctor"), title);
}
// Test that a DNS error occuring in the main frame does not result in an
// additional session history entry.
IN_PROC_BROWSER_TEST_F(ErrorPageBrowserTest, DNSError_GoBack1) {
GURL test_url(URLRequestFailedDnsJob::kTestUrl);
+ string16 title;
NavigateToURL(browser(), URLRequestMockHTTPJob::GetMockUrl(L"title2.html"));
NavigateToURLBlockUntilNavigationsComplete(browser(), test_url, 2);
- AssertCurrentTabTitleContains(test_url.host());
+ EXPECT_TRUE(ui_test_utils::GetCurrentTabTitle(browser(), &title));
+ EXPECT_EQ(ASCIIToUTF16("Mock Link Doctor"), title);
browser()->GoBack(CURRENT_TAB);
ASSERT_TRUE(ui_test_utils::WaitForNavigationInCurrentTab(browser()));
- string16 title;
ASSERT_TRUE(ui_test_utils::GetCurrentTabTitle(browser(), &title));
EXPECT_EQ(ASCIIToUTF16("Title Of Awesomeness"), title);
}
@@ -60,20 +53,22 @@ IN_PROC_BROWSER_TEST_F(ErrorPageBrowserTest, DNSError_GoBack1) {
// additional session history entry.
IN_PROC_BROWSER_TEST_F(ErrorPageBrowserTest, DNSError_GoBack2) {
GURL test_url(URLRequestFailedDnsJob::kTestUrl);
+ string16 title;
NavigateToURL(browser(), URLRequestMockHTTPJob::GetMockUrl(L"title2.html"));
NavigateToURLBlockUntilNavigationsComplete(browser(), test_url, 2);
- AssertCurrentTabTitleContains(test_url.host());
+ EXPECT_TRUE(ui_test_utils::GetCurrentTabTitle(browser(), &title));
+ EXPECT_EQ(ASCIIToUTF16("Mock Link Doctor"), title);
NavigateToURL(browser(), URLRequestMockHTTPJob::GetMockUrl(L"title3.html"));
browser()->GoBack(CURRENT_TAB);
ASSERT_TRUE(ui_test_utils::WaitForNavigationsInCurrentTab(browser(), 2));
- AssertCurrentTabTitleContains(test_url.host());
+ EXPECT_TRUE(ui_test_utils::GetCurrentTabTitle(browser(), &title));
+ EXPECT_EQ(ASCIIToUTF16("Mock Link Doctor"), title);
browser()->GoBack(CURRENT_TAB);
ASSERT_TRUE(ui_test_utils::WaitForNavigationInCurrentTab(browser()));
- string16 title;
ASSERT_TRUE(ui_test_utils::GetCurrentTabTitle(browser(), &title));
EXPECT_EQ(ASCIIToUTF16("Title Of Awesomeness"), title);
}
@@ -82,49 +77,54 @@ IN_PROC_BROWSER_TEST_F(ErrorPageBrowserTest, DNSError_GoBack2) {
// additional session history entry.
IN_PROC_BROWSER_TEST_F(ErrorPageBrowserTest, DNSError_GoBackAndForward1) {
GURL test_url(URLRequestFailedDnsJob::kTestUrl);
+ string16 title;
NavigateToURL(browser(), URLRequestMockHTTPJob::GetMockUrl(L"title2.html"));
NavigateToURLBlockUntilNavigationsComplete(browser(), test_url, 2);
- AssertCurrentTabTitleContains(test_url.host());
+ EXPECT_TRUE(ui_test_utils::GetCurrentTabTitle(browser(), &title));
+ EXPECT_EQ(ASCIIToUTF16("Mock Link Doctor"), title);
NavigateToURL(browser(), URLRequestMockHTTPJob::GetMockUrl(L"title3.html"));
browser()->GoBack(CURRENT_TAB);
ASSERT_TRUE(ui_test_utils::WaitForNavigationsInCurrentTab(browser(), 2));
- AssertCurrentTabTitleContains(test_url.host());
+ EXPECT_TRUE(ui_test_utils::GetCurrentTabTitle(browser(), &title));
+ EXPECT_EQ(ASCIIToUTF16("Mock Link Doctor"), title);
browser()->GoBack(CURRENT_TAB);
ASSERT_TRUE(ui_test_utils::WaitForNavigationInCurrentTab(browser()));
browser()->GoForward(CURRENT_TAB);
ASSERT_TRUE(ui_test_utils::WaitForNavigationsInCurrentTab(browser(), 2));
- AssertCurrentTabTitleContains(test_url.host());
}
// Test that a DNS error occuring in the main frame does not result in an
// additional session history entry.
IN_PROC_BROWSER_TEST_F(ErrorPageBrowserTest, DNSError_GoBackAndForward2) {
GURL test_url(URLRequestFailedDnsJob::kTestUrl);
+ string16 title;
NavigateToURL(browser(), URLRequestMockHTTPJob::GetMockUrl(L"title3.html"));
NavigateToURLBlockUntilNavigationsComplete(browser(), test_url, 2);
- AssertCurrentTabTitleContains(test_url.host());
+ EXPECT_TRUE(ui_test_utils::GetCurrentTabTitle(browser(), &title));
+ EXPECT_EQ(ASCIIToUTF16("Mock Link Doctor"), title);
NavigateToURL(browser(), URLRequestMockHTTPJob::GetMockUrl(L"title2.html"));
browser()->GoBack(CURRENT_TAB);
ASSERT_TRUE(ui_test_utils::WaitForNavigationsInCurrentTab(browser(), 2));
- AssertCurrentTabTitleContains(test_url.host());
+ EXPECT_TRUE(ui_test_utils::GetCurrentTabTitle(browser(), &title));
+ EXPECT_EQ(ASCIIToUTF16("Mock Link Doctor"), title);
browser()->GoBack(CURRENT_TAB);
ASSERT_TRUE(ui_test_utils::WaitForNavigationInCurrentTab(browser()));
browser()->GoForward(CURRENT_TAB);
ASSERT_TRUE(ui_test_utils::WaitForNavigationsInCurrentTab(browser(), 2));
- AssertCurrentTabTitleContains(test_url.host());
+ EXPECT_TRUE(ui_test_utils::GetCurrentTabTitle(browser(), &title));
+ EXPECT_EQ(ASCIIToUTF16("Mock Link Doctor"), title);
browser()->GoForward(CURRENT_TAB);
ASSERT_TRUE(ui_test_utils::WaitForNavigationInCurrentTab(browser()));
- string16 title;
ASSERT_TRUE(ui_test_utils::GetCurrentTabTitle(browser(), &title));
EXPECT_EQ(ASCIIToUTF16("Title Of Awesomeness"), title);
}
diff --git a/chrome/browser/errorpage_uitest.cc b/chrome/browser/errorpage_uitest.cc
index 8a4c3a0..7480157 100644
--- a/chrome/browser/errorpage_uitest.cc
+++ b/chrome/browser/errorpage_uitest.cc
@@ -19,15 +19,6 @@ class ErrorPageTest : public UITest {
}
return false;
}
- bool WaitForTitleContaining(const std::string& title_substring) {
- for (int i = 0; i < 100; ++i) {
- std::wstring title = GetActiveTabTitle();
- if (title.find(UTF8ToWide(title_substring)) != std::wstring::npos)
- return true;
- PlatformThread::Sleep(sleep_timeout_ms() / 10);
- }
- return false;
- }
};
TEST_F(ErrorPageTest, DNSError_Basic) {
@@ -35,7 +26,7 @@ TEST_F(ErrorPageTest, DNSError_Basic) {
NavigateToURLBlockUntilNavigationsComplete(test_url, 2);
- EXPECT_TRUE(WaitForTitleContaining(test_url.host()));
+ EXPECT_TRUE(WaitForTitleMatching(L"Mock Link Doctor"));
}
// Flaky, see http://crbug.com/19361 and http://crbug.com/19395.
@@ -46,7 +37,7 @@ TEST_F(ErrorPageTest, DISABLED_DNSError_GoBack1) {
NavigateToURL(URLRequestMockHTTPJob::GetMockUrl(L"title2.html"));
NavigateToURL(test_url);
- EXPECT_TRUE(WaitForTitleContaining(test_url.host()));
+ EXPECT_TRUE(WaitForTitleMatching(L"Mock Link Doctor"));
GetActiveTab()->GoBack();
@@ -61,11 +52,11 @@ TEST_F(ErrorPageTest, DISABLED_DNSError_GoBack2) {
NavigateToURL(URLRequestMockHTTPJob::GetMockUrl(L"title2.html"));
NavigateToURL(test_url);
- EXPECT_TRUE(WaitForTitleContaining(test_url.host()));
+ EXPECT_TRUE(WaitForTitleMatching(L"Mock Link Doctor"));
NavigateToURL(URLRequestMockHTTPJob::GetMockUrl(L"title3.html"));
GetActiveTab()->GoBack();
- EXPECT_TRUE(WaitForTitleContaining(test_url.host()));
+ EXPECT_TRUE(WaitForTitleMatching(L"Mock Link Doctor"));
GetActiveTab()->GoBack();
EXPECT_TRUE(WaitForTitleMatching(L"Title Of Awesomeness"));
@@ -80,15 +71,15 @@ TEST_F(ErrorPageTest, DISABLED_DNSError_GoBack2AndForward) {
NavigateToURL(URLRequestMockHTTPJob::GetMockUrl(L"title2.html"));
NavigateToURL(test_url);
- EXPECT_TRUE(WaitForTitleContaining(test_url.host()));
+ EXPECT_TRUE(WaitForTitleMatching(L"Mock Link Doctor"));
NavigateToURL(URLRequestMockHTTPJob::GetMockUrl(L"title3.html"));
GetActiveTab()->GoBack();
- EXPECT_TRUE(WaitForTitleContaining(test_url.host()));
+ EXPECT_TRUE(WaitForTitleMatching(L"Mock Link Doctor"));
GetActiveTab()->GoBack();
GetActiveTab()->GoForward();
- EXPECT_TRUE(WaitForTitleContaining(test_url.host()));
+ EXPECT_TRUE(WaitForTitleMatching(L"Mock Link Doctor"));
}
// Flaky, see http://crbug.com/19361 and http://crbug.com/19395.
@@ -100,14 +91,14 @@ TEST_F(ErrorPageTest, DISABLED_DNSError_GoBack2Forward2) {
NavigateToURL(URLRequestMockHTTPJob::GetMockUrl(L"title3.html"));
NavigateToURL(test_url);
- EXPECT_TRUE(WaitForTitleContaining(test_url.host()));
+ EXPECT_TRUE(WaitForTitleMatching(L"Mock Link Doctor"));
NavigateToURL(URLRequestMockHTTPJob::GetMockUrl(L"title2.html"));
GetActiveTab()->GoBack();
- EXPECT_TRUE(WaitForTitleContaining(test_url.host()));
+ EXPECT_TRUE(WaitForTitleMatching(L"Mock Link Doctor"));
GetActiveTab()->GoBack();
GetActiveTab()->GoForward();
- EXPECT_TRUE(WaitForTitleContaining(test_url.host()));
+ EXPECT_TRUE(WaitForTitleMatching(L"Mock Link Doctor"));
GetActiveTab()->GoForward();
EXPECT_TRUE(WaitForTitleMatching(L"Title Of Awesomeness"));
@@ -161,13 +152,13 @@ TEST_F(ErrorPageTest, Page404) {
NavigateToURL(URLRequestMockHTTPJob::GetMockUrl(L"title2.html"));
NavigateToURL(URLRequestMockHTTPJob::GetMockUrl(L"page404.html"));
- EXPECT_TRUE(WaitForTitleContaining("page404.html"));
+ EXPECT_TRUE(WaitForTitleMatching(L"Mock Link Doctor"));
}
TEST_F(ErrorPageTest, Page404_GoBack) {
NavigateToURL(URLRequestMockHTTPJob::GetMockUrl(L"title2.html"));
NavigateToURL(URLRequestMockHTTPJob::GetMockUrl(L"page404.html"));
- EXPECT_TRUE(WaitForTitleContaining("page404.html"));
+ EXPECT_TRUE(WaitForTitleMatching(L"Mock Link Doctor"));
GetActiveTab()->GoBack();
diff --git a/chrome/browser/google_util.cc b/chrome/browser/google_util.cc
index 0949d2f..9cb5e22 100644
--- a/chrome/browser/google_util.cc
+++ b/chrome/browser/google_util.cc
@@ -31,6 +31,9 @@ GURL AppendParam(const GURL& url,
namespace google_util {
+const char kLinkDoctorBaseURL[] =
+ "http://linkhelp.clients.google.com/tbproxy/lh/fixurl";
+
GURL AppendGoogleLocaleParam(const GURL& url) {
return AppendParam(url, "hl",
g_browser_process->GetApplicationLocale());
diff --git a/chrome/browser/google_util.h b/chrome/browser/google_util.h
index d24ae89..a4f99e3 100644
--- a/chrome/browser/google_util.h
+++ b/chrome/browser/google_util.h
@@ -11,6 +11,8 @@ class GURL;
namespace google_util {
+extern const char kLinkDoctorBaseURL[];
+
// Adds the Google locale string to the URL (e.g., hl=en-US). This does not
// check to see if the param already exists.
GURL AppendGoogleLocaleParam(const GURL& url);
diff --git a/chrome/browser/net/url_request_mock_link_doctor_job.cc b/chrome/browser/net/url_request_mock_link_doctor_job.cc
new file mode 100644
index 0000000..88ef438
--- /dev/null
+++ b/chrome/browser/net/url_request_mock_link_doctor_job.cc
@@ -0,0 +1,40 @@
+// Copyright (c) 2009 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 "chrome/browser/net/url_request_mock_link_doctor_job.h"
+
+#include "base/path_service.h"
+#include "chrome/browser/google_util.h"
+#include "chrome/common/chrome_paths.h"
+#include "googleurl/src/gurl.h"
+#include "net/url_request/url_request_filter.h"
+
+namespace {
+
+FilePath GetMockFilePath() {
+ FilePath test_dir;
+ bool success = PathService::Get(chrome::DIR_TEST_DATA, &test_dir);
+ DCHECK(success);
+ return test_dir.AppendASCII("mock-link-doctor.html");
+}
+
+} // namespace
+
+/* static */
+URLRequestJob* URLRequestMockLinkDoctorJob::Factory(URLRequest* request,
+ const std::string& scheme) {
+ return new URLRequestMockLinkDoctorJob(request);
+}
+
+/* static */
+void URLRequestMockLinkDoctorJob::AddUrlHandler() {
+ URLRequestFilter* filter = URLRequestFilter::GetInstance();
+ filter->AddHostnameHandler("http",
+ GURL(google_util::kLinkDoctorBaseURL).host(),
+ URLRequestMockLinkDoctorJob::Factory);
+}
+
+URLRequestMockLinkDoctorJob::URLRequestMockLinkDoctorJob(URLRequest* request)
+ : URLRequestMockHTTPJob(request, GetMockFilePath()) {
+}
diff --git a/chrome/browser/net/url_request_mock_link_doctor_job.h b/chrome/browser/net/url_request_mock_link_doctor_job.h
new file mode 100644
index 0000000..74fd00e
--- /dev/null
+++ b/chrome/browser/net/url_request_mock_link_doctor_job.h
@@ -0,0 +1,23 @@
+// Copyright (c) 2009 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.
+//
+// A URLRequestJob class that substitutes LinkDoctor requests.
+
+#ifndef CHROME_BROWSER_NET_URL_REQUEST_MOCK_LINK_DOCTOR_JOB_H_
+#define CHROME_BROWSER_NET_URL_REQUEST_MOCK_LINK_DOCTOR_JOB_H_
+
+#include "chrome/browser/net/url_request_mock_http_job.h"
+
+class URLRequestMockLinkDoctorJob : public URLRequestMockHTTPJob {
+ public:
+ URLRequestMockLinkDoctorJob(URLRequest* request);
+ virtual ~URLRequestMockLinkDoctorJob() { }
+
+ static URLRequest::ProtocolFactory Factory;
+
+ // Adds the testing URLs to the URLRequestFilter.
+ static void AddUrlHandler();
+};
+
+# endif // CHROME_BROWSER_NET_URL_REQUEST_MOCK_LINK_DOCTOR_JOB_H_
diff --git a/chrome/browser/net/url_request_mock_util.cc b/chrome/browser/net/url_request_mock_util.cc
index 9a559b1..680ed1d 100644
--- a/chrome/browser/net/url_request_mock_util.cc
+++ b/chrome/browser/net/url_request_mock_util.cc
@@ -10,6 +10,7 @@
#include "chrome/browser/chrome_thread.h"
#include "chrome/browser/net/url_request_failed_dns_job.h"
#include "chrome/browser/net/url_request_mock_http_job.h"
+#include "chrome/browser/net/url_request_mock_link_doctor_job.h"
#include "chrome/browser/net/url_request_slow_download_job.h"
#include "chrome/browser/net/url_request_slow_http_job.h"
#include "chrome/common/chrome_paths.h"
@@ -26,6 +27,7 @@ void SetUrlRequestMocksEnabled(bool enabled) {
URLRequestFilter::GetInstance()->ClearHandlers();
URLRequestFailedDnsJob::AddUrlHandler();
+ URLRequestMockLinkDoctorJob::AddUrlHandler();
URLRequestSlowDownloadJob::AddUrlHandler();
std::wstring root_http;
diff --git a/chrome/browser/tab_contents/tab_contents.cc b/chrome/browser/tab_contents/tab_contents.cc
index 18880c1..7056fe5 100644
--- a/chrome/browser/tab_contents/tab_contents.cc
+++ b/chrome/browser/tab_contents/tab_contents.cc
@@ -141,9 +141,6 @@ const float kMaxHeightFactor = 0.6;
// contents.
const int kJavascriptMessageExpectedDelay = 1000;
-const char kLinkDoctorBaseURL[] =
- "http://linkhelp.clients.google.com/tbproxy/lh/fixurl";
-
// The list of prefs we want to observe.
const wchar_t* kPrefsToObserve[] = {
prefs::kAlternateErrorPagesEnabled,
@@ -2259,7 +2256,8 @@ GURL TabContents::GetAlternateErrorPageURL() const {
PrefService* prefs = profile()->GetPrefs();
DCHECK(prefs);
if (prefs->GetBoolean(prefs::kAlternateErrorPagesEnabled)) {
- url = google_util::AppendGoogleLocaleParam(GURL(kLinkDoctorBaseURL));
+ url = google_util::AppendGoogleLocaleParam(
+ GURL(google_util::kLinkDoctorBaseURL));
url = google_util::AppendGoogleTLDParam(url);
}
return url;
diff --git a/chrome/chrome.gyp b/chrome/chrome.gyp
index 2432058..cc11e89 100644
--- a/chrome/chrome.gyp
+++ b/chrome/chrome.gyp
@@ -1449,6 +1449,8 @@
# are currently used by production code in automation_provider.cc.
'browser/net/url_request_mock_http_job.cc',
'browser/net/url_request_mock_http_job.h',
+ 'browser/net/url_request_mock_link_doctor_job.cc',
+ 'browser/net/url_request_mock_link_doctor_job.h',
'browser/net/url_request_mock_util.cc',
'browser/net/url_request_mock_util.h',
'browser/net/url_request_slow_download_job.cc',
diff --git a/chrome/test/data/mock-link-doctor.html b/chrome/test/data/mock-link-doctor.html
new file mode 100644
index 0000000..e1e12a3
--- /dev/null
+++ b/chrome/test/data/mock-link-doctor.html
@@ -0,0 +1,4 @@
+<html>
+<head><title>Mock Link Doctor</title></head>
+<body></body>
+</html>
diff --git a/chrome/test/data/mock-link-doctor.html.mock-http-headers b/chrome/test/data/mock-link-doctor.html.mock-http-headers
new file mode 100644
index 0000000..57fae25
--- /dev/null
+++ b/chrome/test/data/mock-link-doctor.html.mock-http-headers
@@ -0,0 +1,2 @@
+HTTP/1.0 200 OK
+Content-type: text/html
diff --git a/chrome/test/in_process_browser_test.cc b/chrome/test/in_process_browser_test.cc
index 0c58c55..629525b 100644
--- a/chrome/test/in_process_browser_test.cc
+++ b/chrome/test/in_process_browser_test.cc
@@ -246,9 +246,6 @@ void InProcessBrowserTest::ConfigureHostResolverProc(
// TODO(phajdan.jr): remove, http://crbug.com/2635
host_resolver_proc->AllowDirectLookup("*.google.com");
- // TODO(phajdan.jr): remove, http://crbug.com/18365
- host_resolver_proc->AllowDirectLookup("*.gstatic.com");
-
// See http://en.wikipedia.org/wiki/Web_Proxy_Autodiscovery_Protocol
// We don't want the test code to use it.
host_resolver_proc->AddSimulatedFailure("wpad");