| Index: chrome/browser/history/redirect_uitest.cc
|
| ===================================================================
|
| --- chrome/browser/history/redirect_uitest.cc (revision 7513)
|
| +++ chrome/browser/history/redirect_uitest.cc (working copy)
|
| @@ -30,12 +30,10 @@
|
|
|
| // 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 @@
|
|
|
| // 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, ClientEmptyReferer) {
|
| - scoped_refptr<HTTPTestServer> server =
|
| - HTTPTestServer::CreateServer(kDocRoot);
|
| - ASSERT_TRUE(NULL != server.get());
|
| + 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);
|
| + 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;
|
| - }
|
| + 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 @@
|
| // 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 @@
|
|
|
| // 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 @@
|
| // 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 @@
|
| // 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 @@
|
| }
|
|
|
| // 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 @@
|
| // 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 @@
|
| }
|
| }
|
|
|
| - // 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
|
|
|