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

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

Issue 10534062: TabContentsWrapper -> TabContents, part 16. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 6 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
« no previous file with comments | « chrome/browser/history/multipart_browsertest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/bind.h" 10 #include "base/bind.h"
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 // The client redirect appears as two page visits in the browser. 91 // The client redirect appears as two page visits in the browser.
92 ui_test_utils::NavigateToURLBlockUntilNavigationsComplete( 92 ui_test_utils::NavigateToURLBlockUntilNavigationsComplete(
93 browser(), first_url, 2); 93 browser(), first_url, 2);
94 94
95 std::vector<GURL> redirects = GetRedirects(first_url); 95 std::vector<GURL> redirects = GetRedirects(first_url);
96 96
97 ASSERT_EQ(1U, redirects.size()); 97 ASSERT_EQ(1U, redirects.size());
98 EXPECT_EQ(final_url.spec(), redirects[0].spec()); 98 EXPECT_EQ(final_url.spec(), redirects[0].spec());
99 99
100 // The address bar should display the final URL. 100 // The address bar should display the final URL.
101 EXPECT_EQ(final_url, browser()->GetSelectedWebContents()->GetURL()); 101 EXPECT_EQ(final_url, browser()->GetActiveWebContents()->GetURL());
102 102
103 // Navigate one more time. 103 // Navigate one more time.
104 ui_test_utils::NavigateToURLBlockUntilNavigationsComplete( 104 ui_test_utils::NavigateToURLBlockUntilNavigationsComplete(
105 browser(), first_url, 2); 105 browser(), first_url, 2);
106 106
107 // The address bar should still display the final URL. 107 // The address bar should still display the final URL.
108 EXPECT_EQ(final_url, browser()->GetSelectedWebContents()->GetURL()); 108 EXPECT_EQ(final_url, browser()->GetActiveWebContents()->GetURL());
109 } 109 }
110 110
111 // http://code.google.com/p/chromium/issues/detail?id=62772 111 // http://code.google.com/p/chromium/issues/detail?id=62772
112 IN_PROC_BROWSER_TEST_F(RedirectTest, ClientEmptyReferer) { 112 IN_PROC_BROWSER_TEST_F(RedirectTest, ClientEmptyReferer) {
113 ASSERT_TRUE(test_server()->Start()); 113 ASSERT_TRUE(test_server()->Start());
114 114
115 // Create the file contents, which will do a redirect to the 115 // Create the file contents, which will do a redirect to the
116 // test server. 116 // test server.
117 GURL final_url = test_server()->GetURL(std::string()); 117 GURL final_url = test_server()->GetURL(std::string());
118 ASSERT_TRUE(final_url.is_valid()); 118 ASSERT_TRUE(final_url.is_valid());
(...skipping 26 matching lines...) Expand all
145 EXPECT_EQ(final_url.spec(), redirects[0].spec()); 145 EXPECT_EQ(final_url.spec(), redirects[0].spec());
146 } 146 }
147 147
148 // Tests to make sure a location change when a pending redirect exists isn't 148 // Tests to make sure a location change when a pending redirect exists isn't
149 // flagged as a redirect. 149 // flagged as a redirect.
150 IN_PROC_BROWSER_TEST_F(RedirectTest, ClientCancelled) { 150 IN_PROC_BROWSER_TEST_F(RedirectTest, ClientCancelled) {
151 GURL first_url = ui_test_utils::GetTestUrl( 151 GURL first_url = ui_test_utils::GetTestUrl(
152 FilePath(), FilePath().AppendASCII("cancelled_redirect_test.html")); 152 FilePath(), FilePath().AppendASCII("cancelled_redirect_test.html"));
153 ui_test_utils::NavigateToURL(browser(), first_url); 153 ui_test_utils::NavigateToURL(browser(), first_url);
154 154
155 content::WebContents* web_contents = browser()->GetSelectedWebContents(); 155 content::WebContents* web_contents = browser()->GetActiveWebContents();
156 content::TestNavigationObserver navigation_observer( 156 content::TestNavigationObserver navigation_observer(
157 content::Source<content::NavigationController>( 157 content::Source<content::NavigationController>(
158 &web_contents->GetController())); 158 &web_contents->GetController()));
159 159
160 // Simulate a click to force to make a user-initiated location change; 160 // Simulate a click to force to make a user-initiated location change;
161 // otherwise, a non user-initiated in-page location change will be treated 161 // otherwise, a non user-initiated in-page location change will be treated
162 // as client redirect and the redirect will be recoreded, which can cause 162 // as client redirect and the redirect will be recoreded, which can cause
163 // this test failed. 163 // this test failed.
164 ui_test_utils::SimulateMouseClick(web_contents); 164 ui_test_utils::SimulateMouseClick(web_contents);
165 navigation_observer.Wait(); 165 navigation_observer.Wait();
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 ASSERT_TRUE(test_server()->Start()); 200 ASSERT_TRUE(test_server()->Start());
201 201
202 const std::string ref("reference"); 202 const std::string ref("reference");
203 203
204 GURL final_url = test_server()->GetURL(std::string()); 204 GURL final_url = test_server()->GetURL(std::string());
205 GURL initial_url = test_server()->GetURL( 205 GURL initial_url = test_server()->GetURL(
206 "server-redirect?" + final_url.spec() + "#" + ref); 206 "server-redirect?" + final_url.spec() + "#" + ref);
207 207
208 ui_test_utils::NavigateToURL(browser(), initial_url); 208 ui_test_utils::NavigateToURL(browser(), initial_url);
209 209
210 EXPECT_EQ(ref, browser()->GetSelectedWebContents()->GetURL().ref()); 210 EXPECT_EQ(ref, browser()->GetActiveWebContents()->GetURL().ref());
211 } 211 }
212 212
213 // Test that redirect from http:// to file:// : 213 // Test that redirect from http:// to file:// :
214 // A) does not crash the browser or confuse the redirect chain, see bug 1080873 214 // A) does not crash the browser or confuse the redirect chain, see bug 1080873
215 // B) does not take place. 215 // B) does not take place.
216 // 216 //
217 // Flaky on XP and Vista, http://crbug.com/69390. 217 // Flaky on XP and Vista, http://crbug.com/69390.
218 IN_PROC_BROWSER_TEST_F(RedirectTest, NoHttpToFile) { 218 IN_PROC_BROWSER_TEST_F(RedirectTest, NoHttpToFile) {
219 ASSERT_TRUE(test_server()->Start()); 219 ASSERT_TRUE(test_server()->Start());
220 GURL file_url = ui_test_utils::GetTestUrl( 220 GURL file_url = ui_test_utils::GetTestUrl(
221 FilePath(), FilePath().AppendASCII("http_to_file.html")); 221 FilePath(), FilePath().AppendASCII("http_to_file.html"));
222 222
223 GURL initial_url = test_server()->GetURL( 223 GURL initial_url = test_server()->GetURL(
224 "client-redirect?" + file_url.spec()); 224 "client-redirect?" + file_url.spec());
225 225
226 ui_test_utils::NavigateToURL(browser(), initial_url); 226 ui_test_utils::NavigateToURL(browser(), initial_url);
227 // We make sure the title doesn't match the title from the file, because the 227 // We make sure the title doesn't match the title from the file, because the
228 // nav should not have taken place. 228 // nav should not have taken place.
229 EXPECT_NE(ASCIIToUTF16("File!"), 229 EXPECT_NE(ASCIIToUTF16("File!"),
230 browser()->GetSelectedWebContents()->GetTitle()); 230 browser()->GetActiveWebContents()->GetTitle());
231 } 231 }
232 232
233 // Ensures that non-user initiated location changes (within page) are 233 // Ensures that non-user initiated location changes (within page) are
234 // flagged as client redirects. See bug 1139823. 234 // flagged as client redirects. See bug 1139823.
235 IN_PROC_BROWSER_TEST_F(RedirectTest, ClientFragments) { 235 IN_PROC_BROWSER_TEST_F(RedirectTest, ClientFragments) {
236 ASSERT_TRUE(test_server()->Start()); 236 ASSERT_TRUE(test_server()->Start());
237 GURL first_url = ui_test_utils::GetTestUrl( 237 GURL first_url = ui_test_utils::GetTestUrl(
238 FilePath(), FilePath().AppendASCII("ref_redirect.html")); 238 FilePath(), FilePath().AppendASCII("ref_redirect.html"));
239 ui_test_utils::NavigateToURL(browser(), first_url); 239 ui_test_utils::NavigateToURL(browser(), first_url);
240 std::vector<GURL> redirects = GetRedirects(first_url); 240 std::vector<GURL> redirects = GetRedirects(first_url);
(...skipping 17 matching lines...) Expand all
258 // which causes it to start a provisional load, and while it is waiting 258 // which causes it to start a provisional load, and while it is waiting
259 // for the response (which means it hasn't committed the load for the client 259 // for the response (which means it hasn't committed the load for the client
260 // redirect destination page yet), we issue a new navigation request. 260 // redirect destination page yet), we issue a new navigation request.
261 ASSERT_TRUE(test_server()->Start()); 261 ASSERT_TRUE(test_server()->Start());
262 262
263 GURL final_url = test_server()->GetURL("files/title2.html"); 263 GURL final_url = test_server()->GetURL("files/title2.html");
264 GURL slow = test_server()->GetURL("slow?60"); 264 GURL slow = test_server()->GetURL("slow?60");
265 GURL first_url = test_server()->GetURL( 265 GURL first_url = test_server()->GetURL(
266 "client-redirect?" + slow.spec()); 266 "client-redirect?" + slow.spec());
267 267
268 content::WebContents* web_contents = browser()->GetSelectedWebContents(); 268 content::WebContents* web_contents = browser()->GetActiveWebContents();
269 content::TestNavigationObserver observer( 269 content::TestNavigationObserver observer(
270 content::Source<content::NavigationController>( 270 content::Source<content::NavigationController>(
271 &web_contents->GetController()), 271 &web_contents->GetController()),
272 NULL, 2); 272 NULL, 2);
273 273
274 ui_test_utils::NavigateToURLWithDisposition( 274 ui_test_utils::NavigateToURLWithDisposition(
275 browser(), first_url, CURRENT_TAB, ui_test_utils::BROWSER_TEST_NONE); 275 browser(), first_url, CURRENT_TAB, ui_test_utils::BROWSER_TEST_NONE);
276 // We don't sleep here - the first navigation won't have been committed yet 276 // We don't sleep here - the first navigation won't have been committed yet
277 // because we told the server to wait a minute. This means the browser has 277 // because we told the server to wait a minute. This means the browser has
278 // started it's provisional load for the client redirect destination page but 278 // started it's provisional load for the client redirect destination page but
279 // hasn't completed. Our time is now! 279 // hasn't completed. Our time is now!
280 ui_test_utils::NavigateToURLWithDisposition( 280 ui_test_utils::NavigateToURLWithDisposition(
281 browser(), final_url, CURRENT_TAB, ui_test_utils::BROWSER_TEST_NONE); 281 browser(), final_url, CURRENT_TAB, ui_test_utils::BROWSER_TEST_NONE);
282 observer.Wait(); 282 observer.Wait();
283 283
284 // Check to make sure the navigation did in fact take place and we are 284 // Check to make sure the navigation did in fact take place and we are
285 // at the expected page. 285 // at the expected page.
286 EXPECT_EQ(ASCIIToUTF16("Title Of Awesomeness"), 286 EXPECT_EQ(ASCIIToUTF16("Title Of Awesomeness"),
287 browser()->GetSelectedWebContents()->GetTitle()); 287 browser()->GetActiveWebContents()->GetTitle());
288 288
289 bool final_navigation_not_redirect = true; 289 bool final_navigation_not_redirect = true;
290 std::vector<GURL> redirects = GetRedirects(first_url); 290 std::vector<GURL> redirects = GetRedirects(first_url);
291 // Check to make sure our request for files/title2.html doesn't get flagged 291 // Check to make sure our request for files/title2.html doesn't get flagged
292 // as a client redirect from the first (/client-redirect?) page. 292 // as a client redirect from the first (/client-redirect?) page.
293 for (std::vector<GURL>::iterator it = redirects.begin(); 293 for (std::vector<GURL>::iterator it = redirects.begin();
294 it != redirects.end(); ++it) { 294 it != redirects.end(); ++it) {
295 if (final_url.spec() == it->spec()) { 295 if (final_url.spec() == it->spec()) {
296 final_navigation_not_redirect = false; 296 final_navigation_not_redirect = false;
297 break; 297 break;
298 } 298 }
299 } 299 }
300 EXPECT_TRUE(final_navigation_not_redirect); 300 EXPECT_TRUE(final_navigation_not_redirect);
301 } 301 }
OLDNEW
« no previous file with comments | « chrome/browser/history/multipart_browsertest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698