diff options
author | nsylvain@chromium.org <nsylvain@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-12-30 23:29:54 +0000 |
---|---|---|
committer | nsylvain@chromium.org <nsylvain@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-12-30 23:29:54 +0000 |
commit | 5d9c52a60b5e91819c2664572a6e0ef343a3ea28 (patch) | |
tree | 30406e4c144cf8d036a4ef1e4dabebcc1b6a8e05 /chrome/browser/history | |
parent | 997c8ca739b3f79ff76adbbf421c7056af8ccdcb (diff) | |
download | chromium_src-5d9c52a60b5e91819c2664572a6e0ef343a3ea28.zip chromium_src-5d9c52a60b5e91819c2664572a6e0ef343a3ea28.tar.gz chromium_src-5d9c52a60b5e91819c2664572a6e0ef343a3ea28.tar.bz2 |
Revert 7508.7509 and 7510
Review URL: http://codereview.chromium.org/17030
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@7514 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/history')
-rw-r--r-- | chrome/browser/history/redirect_uitest.cc | 128 |
1 files changed, 55 insertions, 73 deletions
diff --git a/chrome/browser/history/redirect_uitest.cc b/chrome/browser/history/redirect_uitest.cc index 4002500..272c59a 100644 --- a/chrome/browser/history/redirect_uitest.cc +++ b/chrome/browser/history/redirect_uitest.cc @@ -30,12 +30,10 @@ class RedirectTest : public UITest { // Tests a single server redirect TEST_F(RedirectTest, Server) { - scoped_refptr<HTTPTestServer> server = - HTTPTestServer::CreateServer(kDocRoot); - ASSERT_TRUE(NULL != server.get()); + TestServer server(kDocRoot); - GURL final_url = server->TestServerPageW(std::wstring()); - GURL first_url = server->TestServerPageW( + GURL final_url = server.TestServerPageW(std::wstring()); + GURL first_url = server.TestServerPageW( std::wstring(L"server-redirect?") + UTF8ToWide(final_url.spec())); NavigateToURL(first_url); @@ -52,12 +50,10 @@ TEST_F(RedirectTest, Server) { // Tests a single client redirect. TEST_F(RedirectTest, Client) { - scoped_refptr<HTTPTestServer> server = - HTTPTestServer::CreateServer(kDocRoot); - ASSERT_TRUE(NULL != server.get()); + TestServer server(kDocRoot); - GURL final_url = server->TestServerPageW(std::wstring()); - GURL first_url = server->TestServerPageW( + GURL final_url = server.TestServerPageW(std::wstring()); + GURL first_url = server.TestServerPageW( std::wstring(L"client-redirect?") + UTF8ToWide(final_url.spec())); // We need the sleep for the client redirects, because it appears as two @@ -76,32 +72,30 @@ TEST_F(RedirectTest, Client) { } TEST_F(RedirectTest, ClientEmptyReferer) { - scoped_refptr<HTTPTestServer> server = - HTTPTestServer::CreateServer(kDocRoot); - ASSERT_TRUE(NULL != server.get()); - - GURL final_url = server->TestServerPageW(std::wstring()); - std::wstring test_file = test_data_directory_; - file_util::AppendToPath(&test_file, L"file_client_redirect.html"); - GURL first_url = net::FilePathToFileURL(test_file); - - NavigateToURL(first_url); - std::vector<GURL> redirects; - // We need the sleeps for the client redirects, because it appears as two - // page visits in the browser. And note for this test the browser actually - // loads the html file on disk, rather than just getting a response from - // the TestServer. - for (int i = 0; i < 10; ++i) { - Sleep(kWaitForActionMaxMsec / 10); - scoped_ptr<TabProxy> tab_proxy(GetActiveTab()); - ASSERT_TRUE(tab_proxy.get()); - ASSERT_TRUE(tab_proxy->GetRedirectsFrom(first_url, &redirects)); - if (!redirects.empty()) - break; - } + TestServer server(kDocRoot); + + GURL final_url = server.TestServerPageW(std::wstring()); + std::wstring test_file = test_data_directory_; + file_util::AppendToPath(&test_file, L"file_client_redirect.html"); + GURL first_url = net::FilePathToFileURL(test_file); + + NavigateToURL(first_url); + std::vector<GURL> redirects; + // We need the sleeps for the client redirects, because it appears as two + // page visits in the browser. And note for this test the browser actually + // loads the html file on disk, rather than just getting a response from + // the TestServer. + for (int i = 0; i < 10; ++i) { + Sleep(kWaitForActionMaxMsec / 10); + scoped_ptr<TabProxy> tab_proxy(GetActiveTab()); + ASSERT_TRUE(tab_proxy.get()); + ASSERT_TRUE(tab_proxy->GetRedirectsFrom(first_url, &redirects)); + if (!redirects.empty()) + break; + } - EXPECT_EQ(1, redirects.size()); - EXPECT_EQ(final_url.spec(), redirects[0].spec()); + EXPECT_EQ(1, redirects.size()); + EXPECT_EQ(final_url.spec(), redirects[0].spec()); } // Tests to make sure a location change when a pending redirect exists isn't @@ -142,16 +136,14 @@ TEST_F(RedirectTest, ClientCancelled) { // TODO(creis): This is disabled temporarily while I figure out why it is // failing. TEST_F(RedirectTest, DISABLED_ClientServerServer) { - scoped_refptr<HTTPTestServer> server = - HTTPTestServer::CreateServer(kDocRoot); - ASSERT_TRUE(NULL != server.get()); + TestServer server(kDocRoot); - GURL final_url = server->TestServerPageW(std::wstring()); - GURL next_to_last = server->TestServerPageW( + GURL final_url = server.TestServerPageW(std::wstring()); + GURL next_to_last = server.TestServerPageW( std::wstring(L"server-redirect?") + UTF8ToWide(final_url.spec())); - GURL second_url = server->TestServerPageW( + GURL second_url = server.TestServerPageW( std::wstring(L"server-redirect?") + UTF8ToWide(next_to_last.spec())); - GURL first_url = server->TestServerPageW( + GURL first_url = server.TestServerPageW( std::wstring(L"client-redirect?") + UTF8ToWide(second_url.spec())); std::vector<GURL> redirects; @@ -176,14 +168,12 @@ TEST_F(RedirectTest, DISABLED_ClientServerServer) { // Tests that the "#reference" gets preserved across server redirects. TEST_F(RedirectTest, ServerReference) { - scoped_refptr<HTTPTestServer> server = - HTTPTestServer::CreateServer(kDocRoot); - ASSERT_TRUE(NULL != server.get()); + TestServer server(kDocRoot); const std::string ref("reference"); - GURL final_url = server->TestServerPageW(std::wstring()); - GURL initial_url = server->TestServerPageW( + GURL final_url = server.TestServerPageW(std::wstring()); + GURL initial_url = server.TestServerPageW( std::wstring(L"server-redirect?") + UTF8ToWide(final_url.spec()) + L"#" + UTF8ToWide(ref)); @@ -197,14 +187,12 @@ TEST_F(RedirectTest, ServerReference) { // A) does not crash the browser or confuse the redirect chain, see bug 1080873 // B) does not take place. TEST_F(RedirectTest, NoHttpToFile) { - scoped_refptr<HTTPTestServer> server = - HTTPTestServer::CreateServer(kDocRoot); - ASSERT_TRUE(NULL != server.get()); + TestServer server(kDocRoot); std::wstring test_file = test_data_directory_; file_util::AppendToPath(&test_file, L"http_to_file.html"); GURL file_url = net::FilePathToFileURL(test_file); - GURL initial_url = server->TestServerPageW( + GURL initial_url = server.TestServerPageW( std::wstring(L"client-redirect?") + UTF8ToWide(file_url.spec())); NavigateToURL(initial_url); @@ -220,10 +208,7 @@ TEST_F(RedirectTest, NoHttpToFile) { // Ensures that non-user initiated location changes (within page) are // flagged as client redirects. See bug 1139823. TEST_F(RedirectTest, ClientFragments) { - scoped_refptr<HTTPTestServer> server = - HTTPTestServer::CreateServer(kDocRoot); - ASSERT_TRUE(NULL != server.get()); - + TestServer server(kDocRoot); std::wstring test_file = test_data_directory_; file_util::AppendToPath(&test_file, L"ref_redirect.html"); GURL first_url = net::FilePathToFileURL(test_file); @@ -244,27 +229,24 @@ TEST_F(RedirectTest, ClientFragments) { } // TODO(timsteele): This is disabled because our current testserver can't -// handle multiple requests in parallel, making it hang on the first request -// to /slow?60. It's unable to serve our second request for files/title2.html -// until /slow? completes, which doesn't give the desired behavior. We could -// alternatively load the second page from disk, but we would need to start -// the browser for this testcase with --process-per-tab, and I don't think -// we can do this at test-case-level granularity at the moment. -TEST_F(RedirectTest, - DISABLED_ClientCancelledByNewNavigationAfterProvisionalLoad) { +// handle multiple requests in parallel, making it hang on the first request to +// /slow?60. It's unable to serve our second request for files/title2.html until +// /slow? completes, which doesn't give the desired behavior. We could +// alternatively load the second page from disk, but we would need to start the +// browser for this testcase with --process-per-tab, and I don't think we can do +// this at test-case-level granularity at the moment. +TEST_F(RedirectTest, DISABLED_ClientCancelledByNewNavigationAfterProvisionalLoad) { // We want to initiate a second navigation after the provisional load for // the client redirect destination has started, but before this load is // committed. To achieve this, we tell the browser to load a slow page, // which causes it to start a provisional load, and while it is waiting // for the response (which means it hasn't committed the load for the client // redirect destination page yet), we issue a new navigation request. - scoped_refptr<HTTPTestServer> server = - HTTPTestServer::CreateServer(kDocRoot); - ASSERT_TRUE(NULL != server.get()); - - GURL final_url = server->TestServerPageW(std::wstring(L"files/title2.html")); - GURL slow = server->TestServerPageW(std::wstring(L"slow?60")); - GURL first_url = server->TestServerPageW( + TestServer server(kDocRoot); + + GURL final_url = server.TestServerPageW(std::wstring(L"files/title2.html")); + GURL slow = server.TestServerPageW(std::wstring(L"slow?60")); + GURL first_url = server.TestServerPageW( std::wstring(L"client-redirect?") + UTF8ToWide(slow.spec())); std::vector<GURL> redirects; @@ -274,7 +256,7 @@ TEST_F(RedirectTest, // started it's provisional load for the client redirect destination page but // hasn't completed. Our time is now! NavigateToURL(final_url); - + std::wstring tab_title; std::wstring final_url_title = L"Title Of Awesomeness"; // Wait till the final page has been loaded. @@ -289,9 +271,9 @@ TEST_F(RedirectTest, } } - // Check to make sure the navigation did in fact take place and we are + // Check to make sure the navigation did in fact take place and we are // at the expected page. - EXPECT_EQ(final_url_title, tab_title); + EXPECT_EQ(final_url_title, tab_title); bool final_navigation_not_redirect = true; // Check to make sure our request for files/title2.html doesn't get flagged |