summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser')
-rw-r--r--chrome/browser/browser_uitest.cc17
-rw-r--r--chrome/browser/renderer_host/resource_dispatcher_host_uitest.cc49
-rw-r--r--chrome/browser/session_history_uitest.cc15
-rw-r--r--chrome/browser/tab_contents/view_source_uitest.cc1
-rw-r--r--chrome/browser/unload_uitest.cc21
5 files changed, 25 insertions, 78 deletions
diff --git a/chrome/browser/browser_uitest.cc b/chrome/browser/browser_uitest.cc
index abfecd9..5ceb55f 100644
--- a/chrome/browser/browser_uitest.cc
+++ b/chrome/browser/browser_uitest.cc
@@ -222,20 +222,9 @@ TEST_F(VisibleBrowserTest, WindowOpenClose) {
FilePath test_file(test_data_directory_);
test_file = test_file.AppendASCII("window.close.html");
- NavigateToURL(net::FilePathToFileURL(test_file));
-
- int i;
- for (i = 0; i < 10; ++i) {
- PlatformThread::Sleep(action_max_timeout_ms() / 10);
- std::wstring title = GetActiveTabTitle();
- if (title == L"PASSED") {
- // Success, bail out.
- break;
- }
- }
-
- if (i == 10)
- FAIL() << "failed to get error page title";
+ NavigateToURLBlockUntilNavigationsComplete(
+ net::FilePathToFileURL(test_file), 2);
+ EXPECT_EQ(L"Title Of Awesomeness", GetActiveTabTitle());
}
class ShowModalDialogTest : public UITest {
diff --git a/chrome/browser/renderer_host/resource_dispatcher_host_uitest.cc b/chrome/browser/renderer_host/resource_dispatcher_host_uitest.cc
index 58f6591..469dba7 100644
--- a/chrome/browser/renderer_host/resource_dispatcher_host_uitest.cc
+++ b/chrome/browser/renderer_host/resource_dispatcher_host_uitest.cc
@@ -23,18 +23,11 @@ namespace {
class ResourceDispatcherTest : public UITest {
public:
void CheckTitleTest(const std::wstring& file,
- const std::wstring& expected_title) {
- NavigateToURL(URLRequestMockHTTPJob::GetMockUrl(
- FilePath::FromWStringHack(file)));
- const int kCheckDelayMs = 100;
- int max_wait_time = 5000;
- while (max_wait_time > 0) {
- max_wait_time -= kCheckDelayMs;
- PlatformThread::Sleep(kCheckDelayMs);
- if (expected_title == GetActiveTabTitle())
- break;
- }
-
+ const std::wstring& expected_title,
+ int expected_navigations) {
+ NavigateToURLBlockUntilNavigationsComplete(
+ URLRequestMockHTTPJob::GetMockUrl(FilePath::FromWStringHack(file)),
+ expected_navigations);
EXPECT_EQ(expected_title, GetActiveTabTitle());
}
@@ -46,25 +39,24 @@ class ResourceDispatcherTest : public UITest {
TEST_F(ResourceDispatcherTest, SniffHTMLWithNoContentType) {
CheckTitleTest(L"content-sniffer-test0.html",
- L"Content Sniffer Test 0");
+ L"Content Sniffer Test 0", 1);
}
TEST_F(ResourceDispatcherTest, RespectNoSniffDirective) {
- CheckTitleTest(L"nosniff-test.html", L"");
+ CheckTitleTest(L"nosniff-test.html", L"", 1);
}
TEST_F(ResourceDispatcherTest, DoNotSniffHTMLFromTextPlain) {
- CheckTitleTest(L"content-sniffer-test1.html", L"");
+ CheckTitleTest(L"content-sniffer-test1.html", L"", 1);
}
TEST_F(ResourceDispatcherTest, DoNotSniffHTMLFromImageGIF) {
- CheckTitleTest(L"content-sniffer-test2.html", L"");
+ CheckTitleTest(L"content-sniffer-test2.html", L"", 1);
}
TEST_F(ResourceDispatcherTest, SniffNoContentTypeNoData) {
CheckTitleTest(L"content-sniffer-test3.html",
- L"Content Sniffer Test 3");
- PlatformThread::Sleep(sleep_timeout_ms() * 2);
+ L"Content Sniffer Test 3", 1);
EXPECT_EQ(1, GetTabCount());
// Make sure the download shelf is not showing.
@@ -75,11 +67,11 @@ TEST_F(ResourceDispatcherTest, SniffNoContentTypeNoData) {
}
TEST_F(ResourceDispatcherTest, ContentDispositionEmpty) {
- CheckTitleTest(L"content-disposition-empty.html", L"success");
+ CheckTitleTest(L"content-disposition-empty.html", L"success", 1);
}
TEST_F(ResourceDispatcherTest, ContentDispositionInline) {
- CheckTitleTest(L"content-disposition-inline.html", L"success");
+ CheckTitleTest(L"content-disposition-inline.html", L"success", 1);
}
// Test for bug #1091358.
@@ -184,7 +176,7 @@ TEST_F(ResourceDispatcherTest, CrossSiteOnunloadCookie) {
// Navigate to a new cross-site page, to dispatch unload event and set the
// cookie.
CheckTitleTest(L"content-sniffer-test0.html",
- L"Content Sniffer Test 0");
+ L"Content Sniffer Test 0", 1);
// Check that the cookie was set.
std::string value_result;
@@ -229,7 +221,7 @@ TEST_F(ResourceDispatcherTest, CrossSiteAfterCrash) {
// Navigate to a new cross-site page. The browser should not wait around for
// the old renderer's on{before}unload handlers to run.
CheckTitleTest(L"content-sniffer-test0.html",
- L"Content Sniffer Test 0");
+ L"Content Sniffer Test 0", 1);
}
#endif // !defined(OS_MACOSX)
@@ -243,7 +235,7 @@ TEST_F(ResourceDispatcherTest, CrossSiteNavigationNonBuffered) {
// Start with an HTTP page.
CheckTitleTest(L"content-sniffer-test0.html",
- L"Content Sniffer Test 0");
+ L"Content Sniffer Test 0", 1);
// Now load a file:// page, which does not use the BufferedEventHandler.
// Make sure that the page loads and displays a title, and doesn't get stuck.
@@ -304,20 +296,15 @@ TEST_F(ResourceDispatcherTest, CrossSiteNavigationErrorPage) {
}
TEST_F(ResourceDispatcherTest, CrossOriginRedirectBlocked) {
- int before = automation()->GetFilteredInetHitCount();
- CheckTitleTest(L"cross-origin-redirect-blocked.html",
- L"done");
- int after = automation()->GetFilteredInetHitCount();
- //
// We expect the following URL requests from this test:
// 1- http://mock.http/cross-origin-redirect-blocked.html
// 2- http://mock.http/redirect-to-title2.html
// 3- http://mock.http/title2.html
//
// If the redirect in #2 were not blocked, we'd also see a request
- // for http://mock.http:4000/title2.html.
- //
- EXPECT_EQ(3, after - before);
+ // for http://mock.http:4000/title2.html, and the title would be different.
+ CheckTitleTest(L"cross-origin-redirect-blocked.html",
+ L"Title Of More Awesomeness", 2);
}
} // namespace
diff --git a/chrome/browser/session_history_uitest.cc b/chrome/browser/session_history_uitest.cc
index fe06d8b..d2bbc84 100644
--- a/chrome/browser/session_history_uitest.cc
+++ b/chrome/browser/session_history_uitest.cc
@@ -72,21 +72,6 @@ class SessionHistoryTest : public UITest {
return title;
}
- // Try 10 times to get the right tab title.
- wstring TestTabTitle(const wstring& value) {
- // Error pages load separately, but the UI automation system does not wait
- // for error pages to load before returning after a navigation request.
- // So, we need to sleep a little.
- const int kWaitForErrorPageMsec = 200;
-
- for (int i = 0; i < 10; ++i) {
- if (value.compare(GetTabTitle()) == 0)
- return value;
- PlatformThread::Sleep(kWaitForErrorPageMsec);
- }
- return GetTabTitle();
- }
-
GURL GetTabURL() {
GURL url;
EXPECT_TRUE(tab_->GetCurrentURL(&url));
diff --git a/chrome/browser/tab_contents/view_source_uitest.cc b/chrome/browser/tab_contents/view_source_uitest.cc
index 4ee078d..60af8d6 100644
--- a/chrome/browser/tab_contents/view_source_uitest.cc
+++ b/chrome/browser/tab_contents/view_source_uitest.cc
@@ -48,7 +48,6 @@ TEST_F(ViewSourceTest, DoesBrowserRenderInViewSource) {
scoped_refptr<TabProxy> tab(GetActiveTab());
ASSERT_TRUE(tab.get());
tab->NavigateToURL(url);
- PlatformThread::Sleep(sleep_timeout_ms());
// Try to retrieve the cookie that the page sets
// It should not be there (because we are in view-source mode
diff --git a/chrome/browser/unload_uitest.cc b/chrome/browser/unload_uitest.cc
index 86d0a82..2bbe357 100644
--- a/chrome/browser/unload_uitest.cc
+++ b/chrome/browser/unload_uitest.cc
@@ -103,32 +103,19 @@ class UnloadTest : public UITest {
}
}
- void CheckTitle(const std::wstring& expected_title) {
- const int kCheckDelayMs = 100;
- int max_wait_time = 5000;
- while (max_wait_time > 0) {
- max_wait_time -= kCheckDelayMs;
- PlatformThread::Sleep(kCheckDelayMs);
- if (expected_title == GetActiveTabTitle())
- break;
- }
-
- EXPECT_EQ(expected_title, GetActiveTabTitle());
- }
-
void NavigateToDataURL(const std::string& html_content,
const std::wstring& expected_title) {
NavigateToURL(GURL("data:text/html," + html_content));
- CheckTitle(expected_title);
+ EXPECT_EQ(expected_title, GetActiveTabTitle());
}
void NavigateToNolistenersFileTwice() {
NavigateToURL(URLRequestMockHTTPJob::GetMockUrl(
FilePath(FILE_PATH_LITERAL("title2.html"))));
- CheckTitle(L"Title Of Awesomeness");
+ EXPECT_EQ(L"Title Of Awesomeness", GetActiveTabTitle());
NavigateToURL(URLRequestMockHTTPJob::GetMockUrl(
FilePath(FILE_PATH_LITERAL("title2.html"))));
- CheckTitle(L"Title Of Awesomeness");
+ EXPECT_EQ(L"Title Of Awesomeness", GetActiveTabTitle());
}
// Navigates to a URL asynchronously, then again synchronously. The first
@@ -146,7 +133,7 @@ class UnloadTest : public UITest {
URLRequestMockHTTPJob::GetMockUrl(
FilePath(FILE_PATH_LITERAL("title2.html"))));
- CheckTitle(L"Title Of Awesomeness");
+ EXPECT_EQ(L"Title Of Awesomeness", GetActiveTabTitle());
}
void LoadUrlAndQuitBrowser(const std::string& html_content,