| OLD | NEW |
| 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 20 matching lines...) Expand all Loading... |
| 31 #include "content/public/test/test_navigation_observer.h" | 31 #include "content/public/test/test_navigation_observer.h" |
| 32 #include "net/base/filename_util.h" | 32 #include "net/base/filename_util.h" |
| 33 #include "net/test/spawned_test_server/spawned_test_server.h" | 33 #include "net/test/spawned_test_server/spawned_test_server.h" |
| 34 #include "ui/events/event_constants.h" | 34 #include "ui/events/event_constants.h" |
| 35 | 35 |
| 36 class RedirectTest : public InProcessBrowserTest { | 36 class RedirectTest : public InProcessBrowserTest { |
| 37 public: | 37 public: |
| 38 RedirectTest() {} | 38 RedirectTest() {} |
| 39 | 39 |
| 40 std::vector<GURL> GetRedirects(const GURL& url) { | 40 std::vector<GURL> GetRedirects(const GURL& url) { |
| 41 HistoryService* history_service = | 41 HistoryService* history_service = HistoryServiceFactory::GetForProfile( |
| 42 HistoryServiceFactory::GetForProfile(browser()->profile(), | 42 browser()->profile(), ServiceAccessType::EXPLICIT_ACCESS); |
| 43 Profile::EXPLICIT_ACCESS); | |
| 44 | 43 |
| 45 // Schedule a history query for redirects. The response will be sent | 44 // Schedule a history query for redirects. The response will be sent |
| 46 // asynchronously from the callback the history system uses to notify us | 45 // asynchronously from the callback the history system uses to notify us |
| 47 // that it's done: OnRedirectQueryComplete. | 46 // that it's done: OnRedirectQueryComplete. |
| 48 std::vector<GURL> rv; | 47 std::vector<GURL> rv; |
| 49 history_service->QueryRedirectsFrom( | 48 history_service->QueryRedirectsFrom( |
| 50 url, | 49 url, |
| 51 base::Bind(&RedirectTest::OnRedirectQueryComplete, | 50 base::Bind(&RedirectTest::OnRedirectQueryComplete, |
| 52 base::Unretained(this), | 51 base::Unretained(this), |
| 53 &rv), | 52 &rv), |
| (...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 298 // as a client redirect from the first (/client-redirect?) page. | 297 // as a client redirect from the first (/client-redirect?) page. |
| 299 for (std::vector<GURL>::iterator it = redirects.begin(); | 298 for (std::vector<GURL>::iterator it = redirects.begin(); |
| 300 it != redirects.end(); ++it) { | 299 it != redirects.end(); ++it) { |
| 301 if (final_url.spec() == it->spec()) { | 300 if (final_url.spec() == it->spec()) { |
| 302 final_navigation_not_redirect = false; | 301 final_navigation_not_redirect = false; |
| 303 break; | 302 break; |
| 304 } | 303 } |
| 305 } | 304 } |
| 306 EXPECT_TRUE(final_navigation_not_redirect); | 305 EXPECT_TRUE(final_navigation_not_redirect); |
| 307 } | 306 } |
| OLD | NEW |