Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(113)

Side by Side Diff: chrome/browser/history/redirect_uitest.cc

Issue 3136019: Fix a few test failures when landing http://trac.webkit.org/changeset/57178.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Navigates the browser to server and client redirect pages and makes sure 5 // Navigates the browser to server and client redirect pages and makes sure
6 // that the correct redirects are reflected in the history database. Errors 6 // that the correct redirects are reflected in the history database. Errors
7 // here might indicate that WebKit changed the calls our glue layer gets in 7 // here might indicate that WebKit changed the calls our glue layer gets in
8 // the case of redirects. It may also mean problems with the history system. 8 // the case of redirects. It may also mean problems with the history system.
9 9
10 #include "base/file_util.h" 10 #include "base/file_util.h"
11 #include "base/platform_thread.h" 11 #include "base/platform_thread.h"
12 #include "base/scoped_ptr.h" 12 #include "base/scoped_ptr.h"
13 #include "base/string_util.h" 13 #include "base/string_util.h"
14 #include "base/string16.h" 14 #include "base/string16.h"
15 #include "base/utf_string_conversions.h" 15 #include "base/utf_string_conversions.h"
16 #include "chrome/browser/view_ids.h"
17 #include "chrome/test/automation/browser_proxy.h"
16 #include "chrome/test/automation/tab_proxy.h" 18 #include "chrome/test/automation/tab_proxy.h"
19 #include "chrome/test/automation/window_proxy.h"
17 #include "chrome/test/ui/ui_test.h" 20 #include "chrome/test/ui/ui_test.h"
18 #include "net/base/net_util.h" 21 #include "net/base/net_util.h"
19 #include "net/test/test_server.h" 22 #include "net/test/test_server.h"
23 #include "views/event.h"
20 24
21 namespace { 25 namespace {
22 26
23 class RedirectTest : public UITest { 27 class RedirectTest : public UITest {
24 public: 28 public:
25 RedirectTest() 29 RedirectTest()
26 : test_server_(net::TestServer::TYPE_HTTP, 30 : test_server_(net::TestServer::TYPE_HTTP,
27 FilePath(FILE_PATH_LITERAL("chrome/test/data"))) { 31 FilePath(FILE_PATH_LITERAL("chrome/test/data"))) {
28 } 32 }
29 33
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 std::vector<GURL> redirects; 102 std::vector<GURL> redirects;
99 scoped_refptr<TabProxy> tab_proxy(GetActiveTab()); 103 scoped_refptr<TabProxy> tab_proxy(GetActiveTab());
100 ASSERT_TRUE(tab_proxy.get()); 104 ASSERT_TRUE(tab_proxy.get());
101 ASSERT_TRUE(tab_proxy->GetRedirectsFrom(first_url, &redirects)); 105 ASSERT_TRUE(tab_proxy->GetRedirectsFrom(first_url, &redirects));
102 ASSERT_EQ(1U, redirects.size()); 106 ASSERT_EQ(1U, redirects.size());
103 EXPECT_EQ(final_url.spec(), redirects[0].spec()); 107 EXPECT_EQ(final_url.spec(), redirects[0].spec());
104 } 108 }
105 109
106 // Tests to make sure a location change when a pending redirect exists isn't 110 // Tests to make sure a location change when a pending redirect exists isn't
107 // flagged as a redirect. 111 // flagged as a redirect.
112 #if defined(OS_WIN) || defined(OS_LINUX)
113 // SimulateOSClick is broken on the Mac: http://crbug.com/45162
108 TEST_F(RedirectTest, ClientCancelled) { 114 TEST_F(RedirectTest, ClientCancelled) {
109 FilePath first_path(test_data_directory_); 115 FilePath first_path(test_data_directory_);
110 first_path = first_path.AppendASCII("cancelled_redirect_test.html"); 116 first_path = first_path.AppendASCII("cancelled_redirect_test.html");
111 ASSERT_TRUE(file_util::AbsolutePath(&first_path)); 117 ASSERT_TRUE(file_util::AbsolutePath(&first_path));
112 GURL first_url = net::FilePathToFileURL(first_path); 118 GURL first_url = net::FilePathToFileURL(first_path);
113 119
114 NavigateToURLBlockUntilNavigationsComplete(first_url, 1); 120 NavigateToURLBlockUntilNavigationsComplete(first_url, 1);
115 121
116 NavigateToURL(GURL("javascript:click()")); // User initiated location change. 122 scoped_refptr<BrowserProxy> browser = automation()->GetBrowserWindow(0);
117 123 ASSERT_TRUE(browser.get());
124 scoped_refptr<WindowProxy> window = browser->GetWindow();
125 ASSERT_TRUE(window.get());
118 scoped_refptr<TabProxy> tab_proxy(GetActiveTab()); 126 scoped_refptr<TabProxy> tab_proxy(GetActiveTab());
119 ASSERT_TRUE(tab_proxy.get()); 127 ASSERT_TRUE(tab_proxy.get());
128 int64 last_nav_time = 0;
129 EXPECT_TRUE(tab_proxy->GetLastNavigationTime(&last_nav_time));
130 // Simulate a click to force to make a user-initiated location change;
131 // otherwise, a non user-initiated in-page location change will be treated
132 // as client redirect and the redirect will be recoreded, which can cause
133 // this test failed.
134 gfx::Rect tab_view_bounds;
135 ASSERT_TRUE(browser->BringToFront());
136 ASSERT_TRUE(window->GetViewBounds(VIEW_ID_TAB_CONTAINER, &tab_view_bounds,
137 true));
138 ASSERT_TRUE(
139 window->SimulateOSClick(tab_view_bounds.CenterPoint(),
140 views::Event::EF_LEFT_BUTTON_DOWN));
141 EXPECT_TRUE(tab_proxy->WaitForNavigation(last_nav_time));
120 142
121 std::vector<GURL> redirects; 143 std::vector<GURL> redirects;
122 ASSERT_TRUE(tab_proxy->GetRedirectsFrom(first_url, &redirects)); 144 ASSERT_TRUE(tab_proxy->GetRedirectsFrom(first_url, &redirects));
123 145
124 // There should be no redirects from first_url, because the anchor location 146 // There should be no redirects from first_url, because the anchor location
125 // change that occurs should not be flagged as a redirect and the meta-refresh 147 // change that occurs should not be flagged as a redirect and the meta-refresh
126 // won't have fired yet. 148 // won't have fired yet.
127 ASSERT_EQ(0U, redirects.size()); 149 ASSERT_EQ(0U, redirects.size());
128 GURL current_url; 150 GURL current_url;
129 ASSERT_TRUE(tab_proxy->GetCurrentURL(&current_url)); 151 ASSERT_TRUE(tab_proxy->GetCurrentURL(&current_url));
130 152
131 // Need to test final path and ref separately since constructing a file url 153 // Need to test final path and ref separately since constructing a file url
132 // containing an anchor using FilePathToFileURL will escape the anchor as 154 // containing an anchor using FilePathToFileURL will escape the anchor as
133 // %23, but in current_url the anchor will be '#'. 155 // %23, but in current_url the anchor will be '#'.
134 std::string final_ref = "myanchor"; 156 std::string final_ref = "myanchor";
135 FilePath current_path; 157 FilePath current_path;
136 ASSERT_TRUE(net::FileURLToFilePath(current_url, &current_path)); 158 ASSERT_TRUE(net::FileURLToFilePath(current_url, &current_path));
137 ASSERT_TRUE(file_util::AbsolutePath(&current_path)); 159 ASSERT_TRUE(file_util::AbsolutePath(&current_path));
138 // Path should remain unchanged. 160 // Path should remain unchanged.
139 EXPECT_EQ(StringToLowerASCII(first_path.value()), 161 EXPECT_EQ(StringToLowerASCII(first_path.value()),
140 StringToLowerASCII(current_path.value())); 162 StringToLowerASCII(current_path.value()));
141 EXPECT_EQ(final_ref, current_url.ref()); 163 EXPECT_EQ(final_ref, current_url.ref());
142 } 164 }
165 #endif
143 166
144 // Tests a client->server->server redirect 167 // Tests a client->server->server redirect
145 TEST_F(RedirectTest, ClientServerServer) { 168 TEST_F(RedirectTest, ClientServerServer) {
146 ASSERT_TRUE(test_server_.Start()); 169 ASSERT_TRUE(test_server_.Start());
147 170
148 GURL final_url = test_server_.GetURL(std::string()); 171 GURL final_url = test_server_.GetURL(std::string());
149 GURL next_to_last = test_server_.GetURL( 172 GURL next_to_last = test_server_.GetURL(
150 "server-redirect?" + final_url.spec()); 173 "server-redirect?" + final_url.spec());
151 GURL second_url = test_server_.GetURL( 174 GURL second_url = test_server_.GetURL(
152 "server-redirect?" + next_to_last.spec()); 175 "server-redirect?" + next_to_last.spec());
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 it != redirects.end(); ++it) { 309 it != redirects.end(); ++it) {
287 if (final_url.spec() == it->spec()) { 310 if (final_url.spec() == it->spec()) {
288 final_navigation_not_redirect = false; 311 final_navigation_not_redirect = false;
289 break; 312 break;
290 } 313 }
291 } 314 }
292 EXPECT_TRUE(final_navigation_not_redirect); 315 EXPECT_TRUE(final_navigation_not_redirect);
293 } 316 }
294 317
295 } // namespace 318 } // namespace
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_browsertests_misc.cc ('k') | chrome/test/data/cancelled_redirect_test.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698